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

修改排队统计更新与组合查询

parent 63b2d619
...@@ -116,7 +116,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -116,7 +116,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateSiteHallPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateSiteHallPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> collect = phQueueEntities.parallelStream().collect(Collectors.groupingBy(x -> x.getHallName())); Map<String, List<PhQueueEntity>> collect = phQueueEntities.parallelStream().collect(Collectors.groupingBy(x -> x.getHallName()));
List<PhQueueStatEntity> saveAndUpdatelist =collect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = collect.entrySet().parallelStream().map(item -> {
String hallName = item.getKey(); String hallName = item.getKey();
if (ObjectUtils.isEmpty(hallName)) return null; if (ObjectUtils.isEmpty(hallName)) return null;
List<PhQueueEntity> value = item.getValue(); List<PhQueueEntity> value = item.getValue();
...@@ -134,7 +134,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -134,7 +134,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateSiteBussinessPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateSiteBussinessPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> collect = phQueueEntities.parallelStream().collect(Collectors.groupingBy(x -> x.getBusiness())); Map<String, List<PhQueueEntity>> collect = phQueueEntities.parallelStream().collect(Collectors.groupingBy(x -> x.getBusiness()));
List<PhQueueStatEntity> saveAndUpdatelist =collect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = collect.entrySet().parallelStream().map(item -> {
String bussiness = item.getKey(); String bussiness = item.getKey();
if (ObjectUtils.isEmpty(bussiness)) return null; if (ObjectUtils.isEmpty(bussiness)) return null;
List<PhQueueEntity> value = item.getValue(); List<PhQueueEntity> value = item.getValue();
...@@ -152,7 +152,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -152,7 +152,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateSiteWindowPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateSiteWindowPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> collect = phQueueEntities.parallelStream().collect(Collectors.groupingBy(x -> x.getWindowFromnum())); Map<String, List<PhQueueEntity>> collect = phQueueEntities.parallelStream().collect(Collectors.groupingBy(x -> x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist =collect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = collect.entrySet().parallelStream().map(item -> {
String window = item.getKey(); String window = item.getKey();
if (ObjectUtils.isEmpty(window)) return null; if (ObjectUtils.isEmpty(window)) return null;
List<PhQueueEntity> value = item.getValue(); List<PhQueueEntity> value = item.getValue();
...@@ -215,10 +215,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -215,10 +215,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateBusinessAndSectionName(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateBusinessAndSectionName(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream() Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getSectionName())); .collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getSectionName()));
List<PhQueueStatEntity> saveAndUpdatelist =businessAndSectionCollect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey(); String vals = item.getKey();
String[] split = vals.split("&"); String[] split = vals.split("&");
if (ObjectUtils.isEmpty(split[0])||ObjectUtils.isEmpty(split[1])) return null ; if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity); PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
...@@ -236,10 +236,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -236,10 +236,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateBusinessAndWindowFromnum(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateBusinessAndWindowFromnum(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream() Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getWindowFromnum())); .collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist =businessAndSectionCollect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey(); String vals = item.getKey();
String[] split = vals.split("&"); String[] split = vals.split("&");
if (ObjectUtils.isEmpty(split[0])||ObjectUtils.isEmpty(split[1])) return null ; if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity); PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
...@@ -257,10 +257,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -257,10 +257,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateSectionNameAndWindowFromnum(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateSectionNameAndWindowFromnum(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream() Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getSectionName() + "&" + x.getWindowFromnum())); .collect(Collectors.groupingBy(x -> x.getSectionName() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist =businessAndSectionCollect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey(); String vals = item.getKey();
String[] split = vals.split("&"); String[] split = vals.split("&");
if (ObjectUtils.isEmpty(split[0])||ObjectUtils.isEmpty(split[1])) return null ; if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity); PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
...@@ -276,11 +276,12 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -276,11 +276,12 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateBusinessAndSectionNameAndWindow(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateBusinessAndSectionNameAndWindow(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream() Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getSectionName()+ "&" + x.getWindowFromnum())); .collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getSectionName() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist =businessAndSectionCollect.entrySet().parallelStream().map(item -> { List<PhQueueStatEntity> saveAndUpdatelist = businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey(); String vals = item.getKey();
String[] split = vals.split("&"); String[] split = vals.split("&");
if (ObjectUtils.isEmpty(split[0])||ObjectUtils.isEmpty(split[1])||ObjectUtils.isEmpty(split[2])) return null ; if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1]) || ObjectUtils.isEmpty(split[2]))
return null;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity); PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
...@@ -333,24 +334,30 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -333,24 +334,30 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
} }
private void saveUpdatePhqueueStatList(List<PhQueueStatEntity> saveAndUpdatelist) { private void saveUpdatePhqueueStatList(List<PhQueueStatEntity> saveAndUpdatelist) {
try {
if (!ObjectUtils.isEmpty(saveAndUpdatelist)) { if (!ObjectUtils.isEmpty(saveAndUpdatelist)) {
Map<Boolean, List<PhQueueStatEntity>> saveUpdateCollect = saveAndUpdatelist.parallelStream().collect(Collectors.partitioningBy(i -> i.newEntity())); Map<Boolean, List<PhQueueStatEntity>> saveUpdateCollect = saveAndUpdatelist.parallelStream().collect(Collectors.partitioningBy(i -> i.newEntity()));
log.info("新增站点排队部门统计数据,数量:{}", saveUpdateCollect.get(true).size());
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(true))) { if (!ObjectUtils.isEmpty(saveUpdateCollect.get(true))) {
//新增列表 //新增列表
log.info("新增站点排队部门统计数据,数量:{}", saveUpdateCollect.get(true).size());
this.save(saveUpdateCollect.get(true)); this.save(saveUpdateCollect.get(true));
} }
log.info("更新站点排队部门统计数据,数量:{}", saveUpdateCollect.get(true).size());
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) { if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) {
//更新列表 //更新列表
log.info("更新站点排队部门统计数据,数量:{}", saveUpdateCollect.get(true).size());
this.update(saveUpdateCollect.get(true)); this.update(saveUpdateCollect.get(true));
} }
} }
} catch (Exception e) {
log.error("异常,e");
}
} }
} }
\ No newline at end of file
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