Commit 525b5555 authored by 赵啸非's avatar 赵啸非

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

parent a2502573
...@@ -61,7 +61,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -61,7 +61,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
List<PhQueueEntity> phQueueEntities = phQueueService.find(phQueueQuery); List<PhQueueEntity> phQueueEntities = phQueueService.find(phQueueQuery);
// log.info("更新站点排队统计数据,站点ID:{},站点名称:{},日期:{},排队数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点ID:{},站点名称:{},日期:{},排队数量:{}", entity.getSiteId(), entity.getSiteName(), currentDate, phQueueEntities.size());
updateSitePhCount(entity, phQueueEntities); updateSitePhCount(entity, phQueueEntities);
//部门 //部门
...@@ -72,229 +72,99 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -72,229 +72,99 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
updateSiteBussinessPhCount(currentDate, entity, phQueueEntities); updateSiteBussinessPhCount(currentDate, entity, phQueueEntities);
//窗口 //窗口
updateSiteWindowPhCount(currentDate, entity, phQueueEntities); updateSiteWindowPhCount(currentDate, entity, phQueueEntities);
//平均等待时间 //组合条件更新
updateSiteConditionPhCount(entity, phQueueEntities);
return Rest.ok(); return Rest.ok();
} }
private void updateSitePhCount(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateSitePhCount(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
PhQueueStatQuery phQueueStatQuery = new PhQueueStatQuery(); PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
PhQueueStatEntity phQueueStatEntity = this.selectOne(phQueueStatQuery Double intAvg = phQueueEntities.parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
.siteId(entity.getSiteId()) PhQueueStatEntity phQueueStatEntity = getPhQueueStatEntity(entity, phQueueEntities, intAvg, phQueueStatQuery);
.year(entity.getYear())
.month(entity.getMonth())
.day(entity.getDay()));
Double intAvg = phQueueEntities.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
if (ObjectUtils.isEmpty(phQueueStatEntity)) { if (phQueueStatEntity.newEntity()) {
//统计当前站点新增所有评价数量 //统计当前站点新增所有评价数量
phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(entity.getSiteId());
phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setPhCount(phQueueEntities.size());
//计算平均等待时间
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setCreateTime(new Date());
phQueueStatEntity.setCreateUserId(1L);
this.save(phQueueStatEntity); this.save(phQueueStatEntity);
} else { } else {
phQueueStatEntity.setPhCount(phQueueEntities.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity); this.update(phQueueStatEntity);
} }
} }
private void updateSiteSectionNamePhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) { private void updateSiteSectionNamePhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> collect = phQueueEntities.stream().collect(Collectors.groupingBy(x -> x.getSectionName())); Map<String, List<PhQueueEntity>> collect = phQueueEntities.parallelStream().collect(Collectors.groupingBy(x -> x.getSectionName()));
collect.entrySet().stream().forEach(item -> {
List<PhQueueStatEntity> saveAndUpdatelist = collect.entrySet().parallelStream().map(item -> {
String sectionName = item.getKey(); String sectionName = item.getKey();
if (ObjectUtils.isEmpty(sectionName)) return; if (ObjectUtils.isEmpty(sectionName)) return null;
List<PhQueueEntity> value = item.getValue(); List<PhQueueEntity> value = item.getValue();
Double intAvg = value.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = value.parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},部门:{},排队数量:{}", entity.getSiteName(), currentDate,sectionName, phQueueEntities.size());
log.info("更新站点排队统计数据,站点名称:{},日期:{},部门:{},排队数量:{}", entity.getSiteName(), currentDate,sectionName, phQueueEntities.size()); PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery() phQueueStatQuery.setSectionName(sectionName);
.siteId(entity.getSiteId()) PhQueueStatEntity phQueueStatEntity = getPhQueueStatEntity(entity, value, intAvg, phQueueStatQuery);
.sectionName(sectionName) phQueueStatEntity.setSectionName(sectionName);
.year(entity.getYear()) return phQueueStatEntity;
.month(entity.getMonth()) }).filter(f -> f != null).collect(Collectors.toList());
.day(entity.getDay()));
if (ObjectUtils.isEmpty(phQueueStatEntity)) { saveUpdatePhqueueStatList(saveAndUpdatelist);
//统计当前站点新增所有评价数量
phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(entity.getSiteId());
phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setSectionName(sectionName);
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setCreateTime(new Date());
phQueueStatEntity.setCreateUserId(1L);
this.save(phQueueStatEntity);
} else {
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity);
}
});
}
}
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.stream().collect(Collectors.groupingBy(x -> x.getHallName())); Map<String, List<PhQueueEntity>> collect = phQueueEntities.parallelStream().collect(Collectors.groupingBy(x -> x.getHallName()));
collect.entrySet().stream().forEach(item -> { List<PhQueueStatEntity> saveAndUpdatelist =collect.entrySet().parallelStream().map(item -> {
String hallName = item.getKey(); String hallName = item.getKey();
if (ObjectUtils.isEmpty(hallName)) return; if (ObjectUtils.isEmpty(hallName)) return null;
List<PhQueueEntity> value = item.getValue(); List<PhQueueEntity> value = item.getValue();
Double intAvg = value.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = value.parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
log.info("更新站点排队统计数据,站点名称:{},日期:{},大厅:{},排队数量:{}", entity.getSiteName(), currentDate, hallName, phQueueEntities.size()); //log.info("更新站点排队统计数据,站点名称:{},日期:{},大厅:{},排队数量:{}", entity.getSiteName(), currentDate, hallName, phQueueEntities.size());
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery() PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
.siteId(entity.getSiteId()) phQueueStatQuery.setHallName(hallName);
.hallName(hallName) PhQueueStatEntity phQueueStatEntity = getPhQueueStatEntity(entity, value, intAvg, phQueueStatQuery);
.year(entity.getYear()) phQueueStatEntity.setHallName(hallName);
.month(entity.getMonth()) return phQueueStatEntity;
.day(entity.getDay())); }).filter(f -> f != null).collect(Collectors.toList());
if (ObjectUtils.isEmpty(phQueueStatEntity)) { saveUpdatePhqueueStatList(saveAndUpdatelist);
//统计当前站点新增所有评价数量
phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(entity.getSiteId());
phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setHallName(hallName);
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setCreateTime(new Date());
phQueueStatEntity.setCreateUserId(1L);
this.save(phQueueStatEntity);
} else {
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity);
}
});
} }
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.stream().collect(Collectors.groupingBy(x -> x.getBusiness())); List<PhQueueStatEntity> saveAndUpdatelist =collect.entrySet().parallelStream().map(item -> {
collect.entrySet().stream().forEach(item -> {
String bussiness = item.getKey(); String bussiness = item.getKey();
if (ObjectUtils.isEmpty(bussiness)) return; if (ObjectUtils.isEmpty(bussiness)) return null;
List<PhQueueEntity> value = item.getValue(); List<PhQueueEntity> value = item.getValue();
Double intAvg = value.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = value.parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
log.info("更新站点排队统计数据,站点名称:{},日期:{},业务:{},排队数量:{}", entity.getSiteName(), currentDate, bussiness, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点名称:{},日期:{},业务:{},排队数量:{}", entity.getSiteName(), currentDate, bussiness, phQueueEntities.size());
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery() PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
.siteId(entity.getSiteId()) phQueueStatQuery.setBusiness(bussiness);
.business(bussiness) PhQueueStatEntity phQueueStatEntity = getPhQueueStatEntity(entity, value, intAvg, phQueueStatQuery);
.year(entity.getYear()) phQueueStatEntity.setBusiness(bussiness);
.month(entity.getMonth()) return phQueueStatEntity;
.day(entity.getDay())); }).filter(f -> f != null).collect(Collectors.toList());
if (ObjectUtils.isEmpty(phQueueStatEntity)) { saveUpdatePhqueueStatList(saveAndUpdatelist);
//统计当前站点新增所有评价数量
phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(entity.getSiteId());
phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setBusiness(bussiness);
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setCreateTime(new Date());
phQueueStatEntity.setCreateUserId(1L);
this.save(phQueueStatEntity);
} else {
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity);
}
});
} }
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.stream().collect(Collectors.groupingBy(x -> x.getWindowFromnum())); Map<String, List<PhQueueEntity>> collect = phQueueEntities.parallelStream().collect(Collectors.groupingBy(x -> x.getWindowFromnum()));
collect.entrySet().stream().forEach(item -> { List<PhQueueStatEntity> saveAndUpdatelist =collect.entrySet().parallelStream().map(item -> {
String window = item.getKey(); String window = item.getKey();
if (ObjectUtils.isEmpty(window)) return; if (ObjectUtils.isEmpty(window)) return null;
List<PhQueueEntity> value = item.getValue(); List<PhQueueEntity> value = item.getValue();
Double intAvg = value.stream().mapToInt(e -> e.getWaitTime()).average().orElse(0D); Double intAvg = value.parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size()); // log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatEntity phQueueStatEntity = this.selectOne(new PhQueueStatQuery() PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
.siteId(entity.getSiteId()) phQueueStatQuery.setWindowFromnum(window);
.windowFromnum(window) PhQueueStatEntity phQueueStatEntity = getPhQueueStatEntity(entity, value, intAvg, phQueueStatQuery);
.year(entity.getYear()) phQueueStatEntity.setWindowFromnum(window);
.month(entity.getMonth()) return phQueueStatEntity;
.day(entity.getDay())); }).filter(f -> f != null).collect(Collectors.toList());
if (ObjectUtils.isEmpty(phQueueStatEntity)) { saveUpdatePhqueueStatList(saveAndUpdatelist);
//统计当前站点新增所有评价数量
phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(entity.getSiteId());
phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setWindowFromnum(window);
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setCreateTime(new Date());
phQueueStatEntity.setCreateUserId(1L);
this.save(phQueueStatEntity);
} else {
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
this.update(phQueueStatEntity);
}
});
} }
...@@ -325,4 +195,162 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD ...@@ -325,4 +195,162 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
return this.getDao().getStatList(query, pageInfo); return this.getDao().getStatList(query, pageInfo);
} }
private void updateSiteConditionPhCount(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
//业务+部门 busniess+sectionName
updateBusinessAndSectionName(entity, phQueueEntities);
//业务+窗口 busniess+WindowFromnum
updateBusinessAndWindowFromnum(entity, phQueueEntities);
//部门+窗口 sectionName+WindowFromnum
updateSectionNameAndWindowFromnum(entity, phQueueEntities);
//业务+部门+窗口 busniess+sectionName+WindowFromnum
updateBusinessAndSectionNameAndWindow(entity, phQueueEntities);
}
private void updateBusinessAndSectionName(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getSectionName()));
List<PhQueueStatEntity> saveAndUpdatelist =businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey();
String[] split = vals.split("&");
if (ObjectUtils.isEmpty(split[0])||ObjectUtils.isEmpty(split[1])) return null ;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
phQueueStatQuery.setBusiness(split[0]);
phQueueStatQuery.setSectionName(split[1]);
PhQueueStatEntity phQueueStatEntity = getPhQueueStatEntity(entity, item.getValue(), intAvg, phQueueStatQuery);
phQueueStatEntity.setBusiness(split[0]);
phQueueStatEntity.setSectionName(split[1]);
return phQueueStatEntity;
}).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePhqueueStatList(saveAndUpdatelist);
}
private void updateBusinessAndWindowFromnum(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist =businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey();
String[] split = vals.split("&");
if (ObjectUtils.isEmpty(split[0])||ObjectUtils.isEmpty(split[1])) return null ;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
phQueueStatQuery.setBusiness(split[0]);
phQueueStatQuery.setWindowFromnum(split[1]);
PhQueueStatEntity phQueueStatEntity = getPhQueueStatEntity(entity, item.getValue(), intAvg, phQueueStatQuery);
phQueueStatEntity.setBusiness(split[0]);
phQueueStatEntity.setWindowFromnum(split[1]);
return phQueueStatEntity;
}).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePhqueueStatList(saveAndUpdatelist);
}
private void updateSectionNameAndWindowFromnum(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getSectionName() + "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist =businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey();
String[] split = vals.split("&");
if (ObjectUtils.isEmpty(split[0])||ObjectUtils.isEmpty(split[1])) return null ;
Double intAvg = item.getValue().parallelStream().mapToInt(e -> e.getWaitTime()).average().orElse(0D);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
phQueueStatQuery.setSectionName(split[0]);
phQueueStatQuery.setWindowFromnum(split[1]);
PhQueueStatEntity phQueueStatEntity = getPhQueueStatEntity(entity, item.getValue(), intAvg, phQueueStatQuery);
phQueueStatEntity.setSectionName(split[0]);
phQueueStatEntity.setWindowFromnum(split[1]);
return phQueueStatEntity;
}).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePhqueueStatList(saveAndUpdatelist);
}
private void updateBusinessAndSectionNameAndWindow(PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
Map<String, List<PhQueueEntity>> businessAndSectionCollect = phQueueEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getBusiness() + "&" + x.getSectionName()+ "&" + x.getWindowFromnum()));
List<PhQueueStatEntity> saveAndUpdatelist =businessAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey();
String[] split = vals.split("&");
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);
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PhQueueStatQuery phQueueStatQuery = getPhQueueStatQuery(entity);
phQueueStatQuery.setBusiness(split[0]);
phQueueStatQuery.setSectionName(split[1]);
phQueueStatQuery.setWindowFromnum(split[2]);
PhQueueStatEntity phQueueStatEntity = getPhQueueStatEntity(entity, item.getValue(), intAvg, phQueueStatQuery);
phQueueStatEntity.setBusiness(split[0]);
phQueueStatEntity.setSectionName(split[1]);
phQueueStatEntity.setWindowFromnum(split[2]);
return phQueueStatEntity;
}).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePhqueueStatList(saveAndUpdatelist);
}
private static PhQueueStatQuery getPhQueueStatQuery(PhQueueStatEntity entity) {
PhQueueStatQuery phQueueStatQuery = new PhQueueStatQuery().siteId(entity.getSiteId())
.year(entity.getYear())
.month(entity.getMonth())
.day(entity.getDay());
return phQueueStatQuery;
}
private PhQueueStatEntity getPhQueueStatEntity(PhQueueStatEntity entity, List<PhQueueEntity> value, Double intAvg, PhQueueStatQuery phQueueStatQuery) {
PhQueueStatEntity phQueueStatEntity = this.selectOne(phQueueStatQuery);
if (ObjectUtils.isEmpty(phQueueStatEntity)) {
//统计当前站点新增所有评价数量
phQueueStatEntity = new PhQueueStatEntity();
phQueueStatEntity.initAttrValue();
phQueueStatEntity.setSiteId(entity.getSiteId());
phQueueStatEntity.setSiteCode(entity.getSiteCode());
phQueueStatEntity.setSiteName(entity.getSiteName());
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setCreateTime(new Date());
phQueueStatEntity.setCreateUserId(1L);
} else {
phQueueStatEntity.setPhCount(value.size());
phQueueStatEntity.setWaitTime(intAvg.intValue());
phQueueStatEntity.setYear(entity.getYear());
phQueueStatEntity.setMonth(entity.getMonth());
phQueueStatEntity.setDay(entity.getDay());
phQueueStatEntity.setUpdateTime(new Date());
phQueueStatEntity.setUpdateUserId(1L);
}
return phQueueStatEntity;
}
private void saveUpdatePhqueueStatList(List<PhQueueStatEntity> saveAndUpdatelist) {
if (!ObjectUtils.isEmpty(saveAndUpdatelist)) {
Map<Boolean, List<PhQueueStatEntity>> saveUpdateCollect = saveAndUpdatelist.parallelStream().collect(Collectors.partitioningBy(i -> i.newEntity()));
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(true))) {
//新增列表
log.info("更新站点排队部门统计数据,数量:{}", saveUpdateCollect.get(true).size());
this.update(saveUpdateCollect.get(true));
}
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) {
//更新列表
log.info("更新站点排队部门统计数据,数量:{}", saveUpdateCollect.get(true).size());
this.update(saveUpdateCollect.get(true));
}
}
}
} }
\ 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