添加每日汇总测试接口
parent
82a9da64aa
commit
358081e37e
@ -0,0 +1,28 @@
|
|||||||
|
package com.glxp.api.controller;
|
||||||
|
|
||||||
|
import com.glxp.api.common.res.BaseResponse;
|
||||||
|
import com.glxp.api.common.util.ResultVOUtils;
|
||||||
|
import com.glxp.api.req.sync.BasicExportStatusRequest;
|
||||||
|
import com.glxp.api.task.TestStatOrderService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
public class TestController {
|
||||||
|
@Resource
|
||||||
|
TestStatOrderService statOrderService;
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/test/stat/order")
|
||||||
|
public BaseResponse getStatus(BasicExportStatusRequest basicExportStatusRequest) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
statOrderService.starGen(start);
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
return ResultVOUtils.success("生成成功!" + start + "=====" + end + "\n-------" + (start - end));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,88 @@
|
|||||||
|
package com.glxp.api.task;
|
||||||
|
|
||||||
|
import com.glxp.api.service.inout.IoStatDayService;
|
||||||
|
import com.glxp.api.service.inout.IoStatMonthService;
|
||||||
|
import com.glxp.api.service.inout.IoStatQuarterService;
|
||||||
|
import com.glxp.api.service.inout.IoStatYearService;
|
||||||
|
import com.glxp.api.util.MsDateUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class TestStatOrderService {
|
||||||
|
@Resource
|
||||||
|
private IoStatDayService statDayService;
|
||||||
|
@Resource
|
||||||
|
private IoStatMonthService statMonthService;
|
||||||
|
@Resource
|
||||||
|
private IoStatQuarterService statQuarterService;
|
||||||
|
@Resource
|
||||||
|
private IoStatYearService statYearService;
|
||||||
|
|
||||||
|
|
||||||
|
public void starGen(Long starTime) {
|
||||||
|
if (starTime == null) {
|
||||||
|
starTime = 1684252800000L;
|
||||||
|
}
|
||||||
|
Long oneDay = 1000 * 60 * 60 * 24L;//One Day TimeStamp
|
||||||
|
Long endTime = new Date().getTime();
|
||||||
|
while (starTime <= endTime) {
|
||||||
|
Date today = new Date(starTime);
|
||||||
|
genStat(today);
|
||||||
|
starTime += oneDay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void genStat(Date today) {
|
||||||
|
if (MsDateUtil.isYearStart(today)) {
|
||||||
|
//年初第一天,依次生成 日 -> 月 -> 季度 -> 年度 汇总数据
|
||||||
|
log.info("开始生成每日物资出入库汇总数据");
|
||||||
|
statDayService.statData(today);
|
||||||
|
log.info("每日物资出入库数据汇总生成结束");
|
||||||
|
|
||||||
|
log.info("本日为月初,生成月度物资出入库汇总数据");
|
||||||
|
statMonthService.statData(today);
|
||||||
|
log.info("月度物资出入库汇总数据生成结束");
|
||||||
|
|
||||||
|
log.info("本日为季初,生成季度物资出入库汇总数据");
|
||||||
|
statQuarterService.statData(today);
|
||||||
|
log.info("季度物资出入库汇总数据生成结束");
|
||||||
|
|
||||||
|
log.info("本日为年初,生成年度物资出入库汇总数据");
|
||||||
|
statYearService.statData(today);
|
||||||
|
log.info("年度物资出入库汇总数据生成结束");
|
||||||
|
} else if (MsDateUtil.isQuarterStart(today)) {
|
||||||
|
//季度第一天,依次生成 日 -> 月 -> 季度 汇总数据
|
||||||
|
log.info("开始生成每日物资出入库汇总数据");
|
||||||
|
statDayService.statData(today);
|
||||||
|
log.info("每日物资出入库数据汇总生成结束");
|
||||||
|
|
||||||
|
log.info("本日为月初,生成月度物资出入库汇总数据");
|
||||||
|
statMonthService.statData(today);
|
||||||
|
log.info("月度物资出入库汇总数据生成结束");
|
||||||
|
|
||||||
|
log.info("本日为季初,生成季度物资出入库汇总数据");
|
||||||
|
statQuarterService.statData(today);
|
||||||
|
log.info("季度物资出入库汇总数据生成结束");
|
||||||
|
} else if (MsDateUtil.isMonthStart(today)) {
|
||||||
|
//月度第一天,依次生成 日 -> 月 汇总数据
|
||||||
|
log.info("开始生成每日物资出入库汇总数据");
|
||||||
|
statDayService.statData(today);
|
||||||
|
log.info("每日物资出入库数据汇总生成结束");
|
||||||
|
|
||||||
|
log.info("本日为月初,生成月度物资出入库汇总数据");
|
||||||
|
statMonthService.statData(today);
|
||||||
|
log.info("月度物资出入库汇总数据生成结束");
|
||||||
|
} else {
|
||||||
|
//生成日汇总数据
|
||||||
|
log.info("开始生成每日物资出入库汇总数据");
|
||||||
|
statDayService.statData(today);
|
||||||
|
log.info("每日物资出入库数据汇总生成结束");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue