Commit ac20081f authored by 赵啸非's avatar 赵啸非

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

parent eeedb39b
...@@ -7,6 +7,7 @@ import com.mortals.framework.annotation.UnAuth; ...@@ -7,6 +7,7 @@ import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
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.code.GroupListEnum; import com.mortals.xhx.common.code.GroupListEnum;
...@@ -48,6 +49,8 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ ...@@ -48,6 +49,8 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
@Autowired @Autowired
private ISiteFeign siteFeign; private ISiteFeign siteFeign;
@Autowired
private PhQueueStatService phQueueStatService;
public PhQueueStatController() { public PhQueueStatController() {
super.setModuleDesc("排队叫号汇总统计"); super.setModuleDesc("排队叫号汇总统计");
...@@ -142,39 +145,48 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ ...@@ -142,39 +145,48 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
String busiDesc = "查询" + this.getModuleDesc(); String busiDesc = "查询" + this.getModuleDesc();
int code = 1; int code = 1;
try { try {
//天数区间分段计算
DateTime attendStart = DateUtil.parseDate(phQueueQuery.getTaketimeStart()); Runnable runnable = new Runnable() {
DateTime attendEnd = DateUtil.parseDate(phQueueQuery.getTaketimeEnd()); @Override
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY); public void run() {
StopWatch stopWatch = new StopWatch("stopwatch"); //天数区间分段计算
log.info("计算天数区间:{}", compare); DateTime attendStart = DateUtil.parseDate(phQueueQuery.getTaketimeStart());
for (int i = 0; i <= compare.intValue(); i++) { DateTime attendEnd = DateUtil.parseDate(phQueueQuery.getTaketimeEnd());
DateTime curDate = DateUtil.offsetDay(attendStart, i); Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
log.info("记录日期:{}", curDate.toDateStr()); StopWatch stopWatch = new StopWatch("stopwatch");
stopWatch.start("执行本地方法"); log.info("计算天数区间:{}", compare);
SitePdu sitePdu = new SitePdu(); for (int i = 0; i <= compare.intValue(); i++) {
sitePdu.setSize(-1); DateTime curDate = DateUtil.offsetDay(attendStart, i);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu); log.info("记录日期:{}", curDate.toDateStr());
if (resp.getCode() == 1) { stopWatch.start("执行本地方法");
List<SitePdu> sitePduList = resp.getData().getData(); SitePdu sitePdu = new SitePdu();
sitePduList.stream().forEach(site -> { sitePdu.setSize(-1);
PhQueueStatEntity sitestatEntity = new PhQueueStatEntity(); Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
sitestatEntity.initAttrValue(); if (resp.getCode() == 1) {
sitestatEntity.setSiteId(site.getId()); List<SitePdu> sitePduList = resp.getData().getData();
sitestatEntity.setSiteName(site.getSiteName()); sitePduList.stream().forEach(site -> {
sitestatEntity.setSiteCode(site.getSiteCode()); PhQueueStatEntity sitestatEntity = new PhQueueStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setYear(curDate.year()); sitestatEntity.setSiteId(site.getId());
sitestatEntity.setMonth(curDate.month() + 1); sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setDay(curDate.dayOfMonth()); sitestatEntity.setSiteCode(site.getSiteCode());
//设置年月日
this.service.updateSitePhStat(sitestatEntity, context); sitestatEntity.setYear(curDate.year());
}); sitestatEntity.setMonth(curDate.month() + 1);
sitestatEntity.setDay(curDate.dayOfMonth());
//设置年月日
phQueueStatService.updateSitePhStat(sitestatEntity, 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 + "成功"); model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】"); this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) { } catch (Exception e) {
......
...@@ -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.exception.AppException; import com.mortals.framework.exception.AppException;
import com.mortals.framework.util.ThreadPool;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.pdu.RespData; import com.mortals.xhx.common.pdu.RespData;
import com.mortals.xhx.common.pdu.site.SitePdu; import com.mortals.xhx.common.pdu.site.SitePdu;
...@@ -44,6 +45,8 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -44,6 +45,8 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
@Autowired @Autowired
private ISiteFeign siteFeign; private ISiteFeign siteFeign;
@Autowired
private PjEvaluateStatService pjEvaluateStatService;
public PjEvaluateStatController() { public PjEvaluateStatController() {
super.setModuleDesc("评价汇总统计"); super.setModuleDesc("评价汇总统计");
...@@ -144,39 +147,49 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -144,39 +147,49 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
String busiDesc = "查询" + this.getModuleDesc(); String busiDesc = "查询" + this.getModuleDesc();
int code = 1; int code = 1;
try { try {
//天数区间分段计算
DateTime attendStart = DateUtil.parseDate(pjEvaluateQuery.getPjTimeStart()); Runnable runnable = new Runnable() {
DateTime attendEnd = DateUtil.parseDate(pjEvaluateQuery.getPjTimeEnd()); @Override
Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY); public void run() {
StopWatch stopWatch = new StopWatch("stopwatch"); //天数区间分段计算
log.info("计算天数区间:{}", compare); DateTime attendStart = DateUtil.parseDate(pjEvaluateQuery.getPjTimeStart());
for (int i = 0; i <= compare.intValue(); i++) { DateTime attendEnd = DateUtil.parseDate(pjEvaluateQuery.getPjTimeEnd());
DateTime curDate = DateUtil.offsetDay(attendStart, i); Long compare = DateUtil.between(attendEnd, attendStart, DateUnit.DAY);
log.info("记录日期:{}", curDate.toDateStr()); StopWatch stopWatch = new StopWatch("stopwatch");
stopWatch.start("执行本地方法"); log.info("计算天数区间:{}", compare);
SitePdu sitePdu = new SitePdu(); for (int i = 0; i <= compare.intValue(); i++) {
sitePdu.setSize(-1); DateTime curDate = DateUtil.offsetDay(attendStart, i);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu); log.info("记录日期:{}", curDate.toDateStr());
if (resp.getCode() == 1) { stopWatch.start("执行本地方法");
List<SitePdu> sitePduList = resp.getData().getData(); SitePdu sitePdu = new SitePdu();
sitePduList.stream().forEach(site -> { sitePdu.setSize(-1);
PjEvaluateStatEntity sitestatEntity = new PjEvaluateStatEntity(); Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
sitestatEntity.initAttrValue(); if (resp.getCode() == 1) {
sitestatEntity.setSiteId(site.getId()); List<SitePdu> sitePduList = resp.getData().getData();
sitestatEntity.setSiteName(site.getSiteName()); sitePduList.stream().forEach(site -> {
sitestatEntity.setSiteCode(site.getSiteCode()); PjEvaluateStatEntity sitestatEntity = new PjEvaluateStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setYear(curDate.year()); sitestatEntity.setSiteId(site.getId());
sitestatEntity.setMonth(curDate.month() + 1); sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setDay(curDate.dayOfMonth()); sitestatEntity.setSiteCode(site.getSiteCode());
//设置年月日
this.service.updateSitePjStat(sitestatEntity, context); sitestatEntity.setYear(curDate.year());
}); sitestatEntity.setMonth(curDate.month() + 1);
sitestatEntity.setDay(curDate.dayOfMonth());
//设置年月日
pjEvaluateStatService.updateSitePjStat(sitestatEntity, 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 + "成功"); model.put("message_info", busiDesc + "成功");
this.recordSysLog(this.request, busiDesc + " 【成功】"); this.recordSysLog(this.request, busiDesc + " 【成功】");
} catch (Exception e) { } catch (Exception e) {
......
...@@ -56,7 +56,7 @@ POST {{baseUrl}}/ph/queue/stat/stat ...@@ -56,7 +56,7 @@ POST {{baseUrl}}/ph/queue/stat/stat
Content-Type: application/json Content-Type: application/json
{ {
"taketimeStart": "2023-01-01", "taketimeStart": "2024-06-01",
"taketimeEnd": "2024-07-10" "taketimeEnd": "2024-07-10"
} }
......
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