Commit 323ccb21 authored by 赵啸非's avatar 赵啸非

添加首页统计模块 统计近一周

parent ac20081f
......@@ -155,13 +155,14 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch");
log.info("计算天数区间:{}", compare);
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法");
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> {
......
......@@ -157,13 +157,13 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch");
log.info("计算天数区间:{}", compare);
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法");
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> {
......
......@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.ThreadPool;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.pdu.RespData;
......@@ -61,6 +62,8 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
@Autowired
private ISiteFeign siteFeign;
@Autowired
private StatService statService;
public StatController() {
......@@ -82,39 +85,48 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
String busiDesc = "查询" + this.getModuleDesc();
int code = 1;
try {
//天数区间分段计算
DateTime attendStart = DateUtil.parseDate(query.getCreateTimeStart());
DateTime attendEnd = DateUtil.parseDate(query.getCreateTimeEnd());
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch");
log.info("计算天数区间:{}", compare);
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法");
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> {
StatEntity statEntity = new StatEntity();
statEntity.initAttrValue();
statEntity.setSiteId(site.getId());
statEntity.setSiteName(site.getSiteName());
statEntity.setSiteCode(site.getSiteCode());
statEntity.setYear(curDate.year());
statEntity.setMonth(curDate.month() + 1);
statEntity.setDay(curDate.dayOfMonth());
//设置年月日
this.service.updateSiteStat(statEntity, context);
});
Runnable runnable = new Runnable() {
@Override
public void run() {
//天数区间分段计算
DateTime attendStart = DateUtil.parseDate(query.getCreateTimeStart());
DateTime attendEnd = DateUtil.parseDate(query.getCreateTimeEnd());
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch");
log.info("计算天数区间:{}", compare);
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法");
if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> {
StatEntity statEntity = new StatEntity();
statEntity.initAttrValue();
statEntity.setSiteId(site.getId());
statEntity.setSiteName(site.getSiteName());
statEntity.setSiteCode(site.getSiteCode());
statEntity.setYear(curDate.year());
statEntity.setMonth(curDate.month() + 1);
statEntity.setDay(curDate.dayOfMonth());
//设置年月日
statService.updateSiteStat(statEntity, context);
});
}
stopWatch.stop();
log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
}
}
};
ThreadPool.getInstance().execute(runnable);
stopWatch.stop();
log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
}
model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment