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

添加统计子站点

parent 6ed66f98
...@@ -77,27 +77,150 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -77,27 +77,150 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
updateSiteCache(); updateSiteCache();
} }
private void updateSiteCache() { private void statByDate() {
List<SitePdu> sitePduList = getStatSiteList();
for (SitePdu site : sitePduList) {
if (ObjectUtils.isEmpty(site.getId())) continue;
StopWatch allStopWatch = new StopWatch("allStopWatch");
StopWatch pjqStopWatch = new StopWatch("pjqStopWatch");
StopWatch pdjStopWatch = new StopWatch("pdjStopWatch");
allStopWatch.start();
AccessStatLogEntity statLogAllEntity = new AccessStatLogEntity();
statLogAllEntity.initAttrValue();
statLogAllEntity.setCreateUserId(1L);
statLogAllEntity.setCreateTime(new Date());
statLogAllEntity.setSiteId(site.getId());
statLogAllEntity.setSiteCode(site.getSiteCode());
statLogAllEntity.setSiteName(site.getSiteName());
statLogAllEntity.setStatStartTime(new Date());
statLogAllEntity.setType(AccessTypeEnum.全部.getValue());
pjqStopWatch.start();
AccessStatLogEntity statLogEntity = new AccessStatLogEntity();
statLogEntity.initAttrValue();
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());
}
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.评价器.getValue());
int range = 4;
for (int i = 0; i < range; i++) {
DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
int year = beforeDate.year();
int month = beforeDate.month() + 1;
int day = beforeDate.dayOfMonth();
PjEvaluateStatEntity sitestatEntity = new PjEvaluateStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setSiteId(site.getId());
sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setSiteCode(site.getSiteCode());
sitestatEntity.setYear(year);
sitestatEntity.setMonth(month);
sitestatEntity.setDay(day);
//设置年月日
pjEvaluateStatService.updateSitePjStat(sitestatEntity, null);
}
pjqStopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(pjqStopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, null);
pdjStopWatch.start();
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.排队机.getValue());
for (int i = 0; i < range; i++) {
DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
int year = beforeDate.year();
int month = beforeDate.month() + 1;
int day = beforeDate.dayOfMonth();
//设置排号
PhQueueStatEntity phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(site.getId());
phQueueStatEntity.setSiteName(site.getSiteName());
phQueueStatEntity.setSiteCode(site.getSiteCode());
phQueueStatEntity.setYear(year);
phQueueStatEntity.setMonth(month);
phQueueStatEntity.setDay(day);
phQueueStatService.updateSitePhStat(phQueueStatEntity, null);
}
pdjStopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(pjqStopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, null);
for (int i = 0; i < range; i++) {
DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
int year = beforeDate.year();
int month = beforeDate.month() + 1;
int day = beforeDate.dayOfMonth();
StatEntity statEntity = new StatEntity();
statEntity.initAttrValue();
statEntity.setSiteId(site.getId());
statEntity.setSiteName(site.getSiteName());
statEntity.setSiteCode(site.getSiteCode());
statEntity.setYear(year);
statEntity.setMonth(month);
statEntity.setDay(day);
//设置年月日
statService.updateSiteStat(statEntity, null);
}
allStopWatch.stop();
statLogAllEntity.setStatEndTime(new Date());
statLogAllEntity.setDuration(pjqStopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogAllEntity, null);
}
}
private List<SitePdu> getStatSiteList() {
AccessQuery accessQuery = new AccessQuery(); AccessQuery accessQuery = new AccessQuery();
accessQuery.setTagNotList(Arrays.asList("")); accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery); List<AccessEntity> accessEntities = accessService.find(accessQuery);
int total=0; List<SitePdu> sitePduList = new ArrayList<>();
List<SitePdu> sitePduList=new ArrayList<>();
for (AccessEntity accessEntity : accessEntities) { for (AccessEntity accessEntity : accessEntities) {
SitePdu sitePdu = new SitePdu(); SitePdu sitePdu = new SitePdu();
sitePdu.setId(accessEntity.getId()); sitePdu.setId(accessEntity.getId());
Rest<List<SitePdu>> sitesRest = siteFeign.getFlatSitesBySiteId(sitePdu); Rest<List<SitePdu>> sitesRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if(YesNoEnum.YES.getValue()==sitesRest.getCode()){ if (YesNoEnum.YES.getValue() == sitesRest.getCode()) {
sitePduList.addAll(sitesRest.getData()); sitePduList.addAll(sitesRest.getData());
} }
} }
if(!ObjectUtils.isEmpty(sitePduList)){ if (!ObjectUtils.isEmpty(sitePduList)) {
sitePduList=sitePduList.stream().collect( sitePduList = sitePduList.stream().collect(
collectingAndThen( collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(SitePdu::getId))), ArrayList::new)); toCollection(() -> new TreeSet<>(Comparator.comparing(SitePdu::getId))), ArrayList::new));
}
return sitePduList;
}
private void updateSiteCache() {
List<SitePdu> sitePduList = getStatSiteList();
for (SitePdu site : sitePduList) { for (SitePdu site : sitePduList) {
updatePjSectionCache(site); updatePjSectionCache(site);
updatePjWindowCache(site); updatePjWindowCache(site);
...@@ -109,8 +232,8 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -109,8 +232,8 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
updatePhQueueHallNameCache(site); updatePhQueueHallNameCache(site);
} }
total=sitePduList.size(); int total = sitePduList.size();
}
...@@ -151,8 +274,8 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -151,8 +274,8 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
}*/ }*/
cacheService.set(RedisKey.KEY_SITE_STAT_COUNT_CHCHE,total); cacheService.set(RedisKey.KEY_SITE_STAT_COUNT_CHCHE, total);
cacheService.set(RedisKey.KEY_SITE_STAT_TIME_CHCHE,DateUtil.formatDateTime(new Date())); cacheService.set(RedisKey.KEY_SITE_STAT_TIME_CHCHE, DateUtil.formatDateTime(new Date()));
...@@ -266,128 +389,6 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -266,128 +389,6 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
} }
} }
private void statByDate() {
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();
for (SitePdu site : sitePduList) {
if (ObjectUtils.isEmpty(site.getId())) continue;
StopWatch allStopWatch = new StopWatch("allStopWatch");
StopWatch pjqStopWatch = new StopWatch("pjqStopWatch");
StopWatch pdjStopWatch = new StopWatch("pdjStopWatch");
allStopWatch.start();
AccessStatLogEntity statLogAllEntity = new AccessStatLogEntity();
statLogAllEntity.initAttrValue();
statLogAllEntity.setCreateUserId(1L);
statLogAllEntity.setCreateTime(new Date());
statLogAllEntity.setSiteId(site.getId());
statLogAllEntity.setSiteCode(site.getSiteCode());
statLogAllEntity.setSiteName(site.getSiteName());
statLogAllEntity.setStatStartTime(new Date());
statLogAllEntity.setType(AccessTypeEnum.全部.getValue());
pjqStopWatch.start();
AccessStatLogEntity statLogEntity = new AccessStatLogEntity();
statLogEntity.initAttrValue();
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());
}
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.评价器.getValue());
int range = 4;
for (int i = 0; i < range; i++) {
DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
int year = beforeDate.year();
int month = beforeDate.month() + 1;
int day = beforeDate.dayOfMonth();
PjEvaluateStatEntity sitestatEntity = new PjEvaluateStatEntity();
sitestatEntity.initAttrValue();
sitestatEntity.setSiteId(site.getId());
sitestatEntity.setSiteName(site.getSiteName());
sitestatEntity.setSiteCode(site.getSiteCode());
sitestatEntity.setYear(year);
sitestatEntity.setMonth(month);
sitestatEntity.setDay(day);
//设置年月日
pjEvaluateStatService.updateSitePjStat(sitestatEntity, null);
}
pjqStopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(pjqStopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, null);
pdjStopWatch.start();
statLogEntity.setStatStartTime(new Date());
statLogEntity.setType(AccessTypeEnum.排队机.getValue());
for (int i = 0; i < range; i++) {
DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
int year = beforeDate.year();
int month = beforeDate.month() + 1;
int day = beforeDate.dayOfMonth();
//设置排号
PhQueueStatEntity phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(site.getId());
phQueueStatEntity.setSiteName(site.getSiteName());
phQueueStatEntity.setSiteCode(site.getSiteCode());
phQueueStatEntity.setYear(year);
phQueueStatEntity.setMonth(month);
phQueueStatEntity.setDay(day);
phQueueStatService.updateSitePhStat(phQueueStatEntity, null);
}
pdjStopWatch.stop();
statLogEntity.setStatEndTime(new Date());
statLogEntity.setDuration(pjqStopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogEntity, null);
for (int i = 0; i < range; i++) {
DateTime beforeDate = DateUtil.offsetDay(new Date(), -i);
int year = beforeDate.year();
int month = beforeDate.month() + 1;
int day = beforeDate.dayOfMonth();
StatEntity statEntity = new StatEntity();
statEntity.initAttrValue();
statEntity.setSiteId(site.getId());
statEntity.setSiteName(site.getSiteName());
statEntity.setSiteCode(site.getSiteCode());
statEntity.setYear(year);
statEntity.setMonth(month);
statEntity.setDay(day);
//设置年月日
statService.updateSiteStat(statEntity, null);
}
allStopWatch.stop();
statLogAllEntity.setStatEndTime(new Date());
statLogAllEntity.setDuration(pjqStopWatch.getLastTaskTimeMillis());
accessStatLogService.save(statLogAllEntity, null);
}
}
}
@Override @Override
public void stopTask(ITask task) throws AppException { public void stopTask(ITask task) throws AppException {
......
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