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

修改同步统计只统计开通的站点

parent 9a883119
...@@ -75,7 +75,31 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -75,7 +75,31 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
} }
private void updateSiteCache() { private void updateSiteCache() {
SitePdu sitePdu = new SitePdu();
AccessQuery accessQuery = new AccessQuery();
accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery);
for (AccessEntity accessEntity : accessEntities) {
SitePdu site = new SitePdu();
site.setId(accessEntity.getSiteId());
site.setSiteName(accessEntity.getSiteName());
site.setSiteCode(accessEntity.getSiteCode());
site.setAreaCode(accessEntity.getAreaCode());
updatePjSectionCache(site);
updatePjWindowCache(site);
updatePjHallNameCache(site);
updatePhQueueBusniessCache(site);
updatePhQueueSectionNameCache(site);
updatePhQueueWindowsCache(site);
updatePhQueueHallNameCache(site);
}
/* SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1); sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu); Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
if (resp.getCode() == 1) { if (resp.getCode() == 1) {
...@@ -90,7 +114,7 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -90,7 +114,7 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
updatePhQueueWindowsCache(site); updatePhQueueWindowsCache(site);
updatePhQueueHallNameCache(site); updatePhQueueHallNameCache(site);
} }
} }*/
} }
private void updatePhQueueBusniessCache(SitePdu site) { private void updatePhQueueBusniessCache(SitePdu site) {
......
...@@ -185,55 +185,33 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ ...@@ -185,55 +185,33 @@ 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 = new StopWatch();
log.info("计算天数区间:{}", compare); log.info("计算天数区间:{}", compare);
SitePdu sitePdu = new SitePdu();
AccessQuery accessQuery = new AccessQuery();
accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery);
for (AccessEntity accessEntity : accessEntities) {
SitePdu site = new SitePdu();
site.setId(accessEntity.getSiteId());
site.setSiteName(accessEntity.getSiteName());
site.setSiteCode(accessEntity.getSiteCode());
site.setAreaCode(accessEntity.getAreaCode());
updateSitePhStat(attendStart, compare, stopWatch, site, context);
}
/* SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1); sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu); Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
log.info("site resp:{}", JSON.toJSONString(resp)); log.info("site resp:{}", JSON.toJSONString(resp));
if (resp.getCode() == 1) { if (resp.getCode() == 1) {
List<SitePdu> sitePduList = resp.getData().getData(); List<SitePdu> sitePduList = resp.getData().getData();
for (SitePdu site : sitePduList) { for (SitePdu site : sitePduList) {
log.info("统计站点:{}", site.getSiteName()); updateSitePhStat(attendStart, compare, stopWatch, site, context);
stopWatch.start("站点排号统计开始");
AccessStatLogEntity statLogEntity = new AccessStatLogEntity();
statLogEntity.initAttrValue();
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.排队机.getValue());
statLogEntity.setCreateUserId(1L);
statLogEntity.setCreateTime(new Date());
statLogEntity.setSiteId(site.getId());
statLogEntity.setSiteCode(site.getSiteCode());
statLogEntity.setSiteName(site.getSiteName());
AccessQuery accessQuery = new AccessQuery();
accessQuery.setSiteId(site.getId() == null ? 0L : site.getId());
AccessEntity accessEntity = accessService.selectOne(accessQuery);
if (!ObjectUtils.isEmpty(accessEntity)) {
statLogEntity.setAccessId(accessEntity.getId());
}
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
PhQueueStatEntity sitestatEntity = new PhQueueStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setSiteId(site.getId());
sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setSiteCode(site.getSiteCode());
sitestatEntity.setYear(curDate.year());
sitestatEntity.setMonth(curDate.month() + 1);
sitestatEntity.setDay(curDate.dayOfMonth());
//设置年月日
phQueueStatService.updateSitePhStat(sitestatEntity, context);
}
stopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(stopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, context);
} }
//log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis()); //log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
} }*/
} }
}; };
...@@ -254,6 +232,48 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ ...@@ -254,6 +232,48 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
} }
private void updateSitePhStat(DateTime attendStart, Long compare, StopWatch stopWatch, SitePdu site, Context context) {
log.info("统计站点:{}", site.getSiteName());
stopWatch.start("站点排号统计开始");
AccessStatLogEntity statLogEntity = new AccessStatLogEntity();
statLogEntity.initAttrValue();
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.排队机.getValue());
statLogEntity.setCreateUserId(1L);
statLogEntity.setCreateTime(new Date());
statLogEntity.setSiteId(site.getId());
statLogEntity.setSiteCode(site.getSiteCode());
statLogEntity.setSiteName(site.getSiteName());
AccessQuery accessQuery = new AccessQuery();
accessQuery.setSiteId(site.getId() == null ? 0L : site.getId());
AccessEntity accessEntity = accessService.selectOne(accessQuery);
if (!ObjectUtils.isEmpty(accessEntity)) {
statLogEntity.setAccessId(accessEntity.getId());
}
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
PhQueueStatEntity sitestatEntity = new PhQueueStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setSiteId(site.getId());
sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setSiteCode(site.getSiteCode());
sitestatEntity.setYear(curDate.year());
sitestatEntity.setMonth(curDate.month() + 1);
sitestatEntity.setDay(curDate.dayOfMonth());
//设置年月日
phQueueStatService.updateSitePhStat(sitestatEntity, context);
}
stopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(stopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, context);
}
public static void main(String[] args) throws InterruptedException { public static void main(String[] args) throws InterruptedException {
StopWatch stopWatch = new StopWatch("stopwatch"); StopWatch stopWatch = new StopWatch("stopwatch");
......
...@@ -186,54 +186,31 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -186,54 +186,31 @@ 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();
AccessQuery accessQuery = new AccessQuery();
accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery);
for (AccessEntity accessEntity : accessEntities) {
SitePdu site = new SitePdu();
site.setId(accessEntity.getSiteId());
site.setSiteName(accessEntity.getSiteName());
site.setSiteCode(accessEntity.getSiteCode());
site.setAreaCode(accessEntity.getAreaCode());
updateSitePjStat(attendStart, compare, stopWatch, site, context);
}
/* SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1); sitePdu.setSize(-1);
Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu); Rest<RespData<List<SitePdu>>> resp = siteFeign.list(sitePdu);
List<SitePdu> sitePduList = resp.getData().getData(); List<SitePdu> sitePduList = resp.getData().getData();
log.info("site resp:{}", JSON.toJSONString(resp)); log.info("site resp:{}", JSON.toJSONString(resp));
if (resp.getCode() == 1) { if (resp.getCode() == 1) {
for (SitePdu site : sitePduList) { for (SitePdu site : sitePduList) {
stopWatch.start("站点评价统计开始"); updateSitePjStat(attendStart, compare, stopWatch, site, context);
AccessStatLogEntity statLogEntity = new AccessStatLogEntity();
statLogEntity.initAttrValue();
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.排队机.getValue());
statLogEntity.setCreateUserId(1L);
statLogEntity.setCreateTime(new Date());
statLogEntity.setSiteId(site.getId());
statLogEntity.setSiteCode(site.getSiteCode());
statLogEntity.setSiteName(site.getSiteName());
AccessQuery accessQuery = new AccessQuery();
accessQuery.setSiteId(site.getId() == null ? 0L : site.getId());
AccessEntity accessEntity = accessService.selectOne(accessQuery);
if (!ObjectUtils.isEmpty(accessEntity)) {
statLogEntity.setAccessId(accessEntity.getId());
}
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
PjEvaluateStatEntity sitestatEntity = new PjEvaluateStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setSiteId(site.getId());
sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setSiteCode(site.getSiteCode());
sitestatEntity.setYear(curDate.year());
sitestatEntity.setMonth(curDate.month() + 1);
sitestatEntity.setDay(curDate.dayOfMonth());
//设置年月日
pjEvaluateStatService.updateSitePjStat(sitestatEntity, context);
}
stopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(stopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, context);
} }
//log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis()); //log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
} }*/
} }
}; };
ThreadPool.getInstance().execute(runnable); ThreadPool.getInstance().execute(runnable);
...@@ -252,5 +229,46 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -252,5 +229,46 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
} }
private void updateSitePjStat(DateTime attendStart, Long compare, StopWatch stopWatch, SitePdu site, Context context) {
stopWatch.start("站点评价统计开始");
AccessStatLogEntity statLogEntity = new AccessStatLogEntity();
statLogEntity.initAttrValue();
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.排队机.getValue());
statLogEntity.setCreateUserId(1L);
statLogEntity.setCreateTime(new Date());
statLogEntity.setSiteId(site.getId());
statLogEntity.setSiteCode(site.getSiteCode());
statLogEntity.setSiteName(site.getSiteName());
AccessQuery accessQuery = new AccessQuery();
accessQuery.setSiteId(site.getId() == null ? 0L : site.getId());
AccessEntity accessEntity = accessService.selectOne(accessQuery);
if (!ObjectUtils.isEmpty(accessEntity)) {
statLogEntity.setAccessId(accessEntity.getId());
}
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
log.info("记录日期:{}", curDate.toDateStr());
PjEvaluateStatEntity sitestatEntity = new PjEvaluateStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setSiteId(site.getId());
sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setSiteCode(site.getSiteCode());
sitestatEntity.setYear(curDate.year());
sitestatEntity.setMonth(curDate.month() + 1);
sitestatEntity.setDay(curDate.dayOfMonth());
//设置年月日
pjEvaluateStatService.updateSitePjStat(sitestatEntity, context);
}
stopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(stopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, context);
}
} }
\ No newline at end of file
...@@ -47,7 +47,7 @@ POST {{baseUrl}}/pj/evaluate/stat/stat ...@@ -47,7 +47,7 @@ POST {{baseUrl}}/pj/evaluate/stat/stat
Content-Type: application/json Content-Type: application/json
{ {
"pjTimeStart": "2024-06-01", "pjTimeStart": "2023-01-01",
"pjTimeEnd": "2024-07-26" "pjTimeEnd": "2024-07-26"
} }
...@@ -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": "2024-06-01", "taketimeStart": "2023-01-01",
"taketimeEnd": "2024-07-26" "taketimeEnd": "2024-07-26"
} }
......
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