Commit 6ed66f98 authored by 赵啸非's avatar 赵啸非

添加统计子站点

parent 5cb52c0d
...@@ -33,9 +33,11 @@ import org.springframework.stereotype.Service; ...@@ -33,9 +33,11 @@ import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
import java.util.Arrays; import java.util.*;
import java.util.Date; import java.util.stream.Collectors;
import java.util.List;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;
/** /**
* 站点评价统计任务 * 站点评价统计任务
...@@ -82,8 +84,37 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -82,8 +84,37 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
List<AccessEntity> accessEntities = accessService.find(accessQuery); List<AccessEntity> accessEntities = accessService.find(accessQuery);
int total=0; int total=0;
List<SitePdu> sitePduList=new ArrayList<>();
for (AccessEntity accessEntity : accessEntities) { for (AccessEntity accessEntity : accessEntities) {
SitePdu sitePdu = new SitePdu();
sitePdu.setId(accessEntity.getId());
Rest<List<SitePdu>> sitesRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if(YesNoEnum.YES.getValue()==sitesRest.getCode()){
sitePduList.addAll(sitesRest.getData());
}
}
if(!ObjectUtils.isEmpty(sitePduList)){
sitePduList=sitePduList.stream().collect(
collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(SitePdu::getId))), ArrayList::new));
for (SitePdu site : sitePduList) {
updatePjSectionCache(site);
updatePjWindowCache(site);
updatePjHallNameCache(site);
updatePhQueueBusniessCache(site);
updatePhQueueSectionNameCache(site);
updatePhQueueWindowsCache(site);
updatePhQueueHallNameCache(site);
}
total=sitePduList.size();
}
/* for (AccessEntity accessEntity : accessEntities) {
SitePdu sitePdu = new SitePdu(); SitePdu sitePdu = new SitePdu();
sitePdu.setId(accessEntity.getId()); sitePdu.setId(accessEntity.getId());
...@@ -103,7 +134,7 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -103,7 +134,7 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
} }
} }
/* SitePdu site = new SitePdu(); *//* SitePdu site = new SitePdu();
site.setId(accessEntity.getSiteId()); site.setId(accessEntity.getSiteId());
site.setSiteName(accessEntity.getSiteName()); site.setSiteName(accessEntity.getSiteName());
site.setSiteCode(accessEntity.getSiteCode()); site.setSiteCode(accessEntity.getSiteCode());
...@@ -116,8 +147,8 @@ public class SiteStatTaskImpl implements ITaskExcuteService { ...@@ -116,8 +147,8 @@ public class SiteStatTaskImpl implements ITaskExcuteService {
updatePhQueueBusniessCache(site); updatePhQueueBusniessCache(site);
updatePhQueueSectionNameCache(site); updatePhQueueSectionNameCache(site);
updatePhQueueWindowsCache(site); updatePhQueueWindowsCache(site);
updatePhQueueHallNameCache(site);*/ updatePhQueueHallNameCache(site);*//*
} }*/
cacheService.set(RedisKey.KEY_SITE_STAT_COUNT_CHCHE,total); cacheService.set(RedisKey.KEY_SITE_STAT_COUNT_CHCHE,total);
......
...@@ -41,6 +41,9 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -41,6 +41,9 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;
/** /**
* 排队叫号汇总统计 * 排队叫号汇总统计
* *
...@@ -191,7 +194,27 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ ...@@ -191,7 +194,27 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
accessQuery.setTagNotList(Arrays.asList("")); accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery); List<AccessEntity> accessEntities = accessService.find(accessQuery);
List<SitePdu> sitePduList=new ArrayList<>();
for (AccessEntity accessEntity : accessEntities) { for (AccessEntity accessEntity : accessEntities) {
SitePdu sitePdu = new SitePdu();
sitePdu.setId(accessEntity.getId());
Rest<List<SitePdu>> sitesRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if(YesNoEnum.YES.getValue()==sitesRest.getCode()){
sitePduList.addAll(sitesRest.getData());
}
}
if(!ObjectUtils.isEmpty(sitePduList)){
sitePduList=sitePduList.stream().collect(
collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(SitePdu::getId))), ArrayList::new));
for (SitePdu site : sitePduList) {
updateSitePhStat(attendStart, compare, stopWatch, site, context);
}
}
/* for (AccessEntity accessEntity : accessEntities) {
//根据当前站点获取子站点 //根据当前站点获取子站点
SitePdu sitePdu = new SitePdu(); SitePdu sitePdu = new SitePdu();
sitePdu.setId(accessEntity.getId()); sitePdu.setId(accessEntity.getId());
...@@ -202,14 +225,14 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ ...@@ -202,14 +225,14 @@ public class PhQueueStatController extends BaseCRUDJsonBodyMappingController<PhQ
updateSitePhStat(attendStart, compare, stopWatch, site, context); updateSitePhStat(attendStart, compare, stopWatch, site, context);
} }
} }
/* *//*
SitePdu site = new SitePdu(); SitePdu site = new SitePdu();
site.setId(accessEntity.getSiteId()); site.setId(accessEntity.getSiteId());
site.setSiteName(accessEntity.getSiteName()); site.setSiteName(accessEntity.getSiteName());
site.setSiteCode(accessEntity.getSiteCode()); site.setSiteCode(accessEntity.getSiteCode());
site.setAreaCode(accessEntity.getAreaCode()); site.setAreaCode(accessEntity.getAreaCode());
updateSitePhStat(attendStart, compare, stopWatch, site, context);*/ updateSitePhStat(attendStart, compare, stopWatch, site, context);*//*
} }*/
/* SitePdu sitePdu = new SitePdu(); /* SitePdu sitePdu = new SitePdu();
sitePdu.setSize(-1); sitePdu.setSize(-1);
......
...@@ -38,6 +38,9 @@ import java.util.stream.Collectors; ...@@ -38,6 +38,9 @@ import java.util.stream.Collectors;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;
/** /**
* 评价汇总统计 * 评价汇总统计
* *
...@@ -191,6 +194,27 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -191,6 +194,27 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
accessQuery.setTagNotList(Arrays.asList("")); accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery); List<AccessEntity> accessEntities = accessService.find(accessQuery);
List<SitePdu> sitePduList=new ArrayList<>();
for (AccessEntity accessEntity : accessEntities) {
SitePdu sitePdu = new SitePdu();
sitePdu.setId(accessEntity.getId());
Rest<List<SitePdu>> sitesRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if(YesNoEnum.YES.getValue()==sitesRest.getCode()){
sitePduList.addAll(sitesRest.getData());
}
}
if(!ObjectUtils.isEmpty(sitePduList)){
sitePduList=sitePduList.stream().collect(
collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(SitePdu::getId))), ArrayList::new));
for (SitePdu site : sitePduList) {
updateSitePjStat(attendStart, compare, stopWatch, site, context);
}
}
/*
for (AccessEntity accessEntity : accessEntities) { for (AccessEntity accessEntity : accessEntities) {
//根据当前站点获取子站点 //根据当前站点获取子站点
SitePdu sitePdu = new SitePdu(); SitePdu sitePdu = new SitePdu();
...@@ -202,7 +226,7 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -202,7 +226,7 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
updateSitePjStat(attendStart, compare, stopWatch, site, context); updateSitePjStat(attendStart, compare, stopWatch, site, context);
} }
} }
} }*/
/* for (AccessEntity accessEntity : accessEntities) { /* for (AccessEntity accessEntity : accessEntities) {
SitePdu site = new SitePdu(); SitePdu site = new SitePdu();
......
...@@ -12,11 +12,16 @@ import com.mortals.xhx.base.system.param.service.ParamService; ...@@ -12,11 +12,16 @@ import com.mortals.xhx.base.system.param.service.ParamService;
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;
import com.mortals.xhx.feign.site.ISiteFeign; import com.mortals.xhx.feign.site.ISiteFeign;
import com.mortals.xhx.module.access.model.AccessEntity;
import com.mortals.xhx.module.access.model.AccessQuery;
import com.mortals.xhx.module.access.service.AccessService;
import com.mortals.xhx.module.access.service.AccessStatLogService;
import com.mortals.xhx.module.pj.model.PjEvaluateQuery; import com.mortals.xhx.module.pj.model.PjEvaluateQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity; import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.stat.model.StatQuery; import com.mortals.xhx.module.stat.model.StatQuery;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -32,19 +37,17 @@ import com.mortals.xhx.module.stat.service.StatService; ...@@ -32,19 +37,17 @@ import com.mortals.xhx.module.stat.service.StatService;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import com.mortals.framework.util.StringUtils; import com.mortals.framework.util.StringUtils;
import java.util.HashMap; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import java.util.Arrays;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import static com.mortals.framework.ap.SysConstains.*; import static com.mortals.framework.ap.SysConstains.*;
import static java.util.stream.Collectors.collectingAndThen;
import static java.util.stream.Collectors.toCollection;
import com.mortals.xhx.common.code.*; import com.mortals.xhx.common.code.*;
...@@ -65,6 +68,11 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic ...@@ -65,6 +68,11 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
@Autowired @Autowired
private StatService statService; private StatService statService;
@Autowired
private AccessService accessService;
@Autowired
private AccessStatLogService accessStatLogService;
public StatController() { public StatController() {
super.setModuleDesc("汇总统计"); super.setModuleDesc("汇总统计");
...@@ -95,6 +103,46 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic ...@@ -95,6 +103,46 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
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);
AccessQuery accessQuery = new AccessQuery();
accessQuery.setTagNotList(Arrays.asList(""));
List<AccessEntity> accessEntities = accessService.find(accessQuery);
List<SitePdu> sitePduList = new ArrayList<>();
for (AccessEntity accessEntity : accessEntities) {
SitePdu sitePdu = new SitePdu();
sitePdu.setId(accessEntity.getId());
Rest<List<SitePdu>> sitesRest = siteFeign.getFlatSitesBySiteId(sitePdu);
if (YesNoEnum.YES.getValue() == sitesRest.getCode()) {
sitePduList.addAll(sitesRest.getData());
}
}
if (!ObjectUtils.isEmpty(sitePduList)) {
sitePduList = sitePduList.stream().collect(
collectingAndThen(
toCollection(() -> new TreeSet<>(Comparator.comparing(SitePdu::getId))), ArrayList::new));
for (SitePdu site : sitePduList) {
for (int i = 0; i <= compare.intValue(); i++) {
DateTime curDate = DateUtil.offsetDay(attendStart, i);
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);
}
}
}
/*
SitePdu sitePdu = new SitePdu(); 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);
...@@ -121,12 +169,11 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic ...@@ -121,12 +169,11 @@ public class StatController extends BaseCRUDJsonBodyMappingController<StatServic
stopWatch.stop(); stopWatch.stop();
log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis()); log.info("日期:{} 完成,耗时:{}ms", curDate.toDateStr(), stopWatch.getLastTaskTimeMillis());
} }*/
} }
}; };
ThreadPool.getInstance().execute(runnable); 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