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

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

parent ac20081f
...@@ -155,13 +155,14 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ ...@@ -155,13 +155,14 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY); Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch"); StopWatch stopWatch = new StopWatch("stopwatch");
log.info("计算天数区间:{}", compare); 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++) { for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i); DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr()); log.info("记录日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法"); stopWatch.start("执行本地方法");
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) { if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData(); List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> { sitePduList.stream().forEach(site -> {
......
...@@ -157,13 +157,13 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -157,13 +157,13 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY); Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch"); StopWatch stopWatch = new StopWatch("stopwatch");
log.info("计算天数区间:{}", compare); 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++) { for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i); DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr()); log.info("记录日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法"); stopWatch.start("执行本地方法");
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) { if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData(); List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> { sitePduList.stream().forEach(site -> {
......
...@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil; ...@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateUtil;
import com.mortals.framework.annotation.UnAuth; import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.service.ICacheService; import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.ThreadPool;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService; import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
...@@ -61,6 +62,8 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic ...@@ -61,6 +62,8 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
@Autowired @Autowired
private ISiteFeign siteFeign; private ISiteFeign siteFeign;
@Autowired
private StatService statService;
public StatController() { public StatController() {
...@@ -82,19 +85,23 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic ...@@ -82,19 +85,23 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
String busiDesc = "查询" + this.getModuleDesc(); String busiDesc = "查询" + this.getModuleDesc();
int code = 1; int code = 1;
try { try {
Runnable runnable = new Runnable() {
@Override
public void run() {
//天数区间分段计算 //天数区间分段计算
DateTime attendStart = DateUtil.parseDate(query.getCreateTimeStart()); DateTime attendStart = DateUtil.parseDate(query.getCreateTimeStart());
DateTime attendEnd = DateUtil.parseDate(query.getCreateTimeEnd()); DateTime attendEnd = DateUtil.parseDate(query.getCreateTimeEnd());
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY); Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
StopWatch stopWatch = new StopWatch("stopwatch"); StopWatch stopWatch = new StopWatch("stopwatch");
log.info("计算天数区间:{}", compare); 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++) { for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i); DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr()); log.info("记录日期:{}", curDate.toDateStr());
stopWatch.start("执行本地方法"); stopWatch.start("执行本地方法");
SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) { if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData(); List<SitePdu> sitePduList = resp.getData().getData();
sitePduList.stream().forEach(site -> { sitePduList.stream().forEach(site -> {
...@@ -108,13 +115,18 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic ...@@ -108,13 +115,18 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
statEntity.setMonth(curDate.month() + 1); statEntity.setMonth(curDate.month() + 1);
statEntity.setDay(curDate.dayOfMonth()); statEntity.setDay(curDate.dayOfMonth());
//设置年月日 //设置年月日
this.service.updateSiteStat(statEntity, context); statService.updateSiteStat(statEntity, context);
}); });
} }
stopWatch.stop(); stopWatch.stop();
log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis()); log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
} }
}
};
ThreadPool.getInstance().execute(runnable);
model.put("message_info", busiDesc + "成功"); model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】"); this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) { } 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