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

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

parent 63b2d619
......@@ -52,7 +52,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");//yyyy-年,MM-月,dd-日,HH-时,mm-分,ss-秒
String currentDate = date.format(calendar.getTime());
PhQueueQuery phQueueQuery = new PhQueueQuery();
PhQueueQuery phQueueQuery = new PhQueueQuery();
phQueueQuery.setSiteId(entity.getSiteId());
phQueueQuery.setTaketimeStart(currentDate);
phQueueQuery.setTaketimeEnd(currentDate);
......@@ -116,7 +116,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateSiteHallPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
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();
if (ObjectUtils.isEmpty(hallName)) return null;
List<PhQueueEntity> value = item.getValue();
......@@ -134,7 +134,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateSiteBussinessPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
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();
if (ObjectUtils.isEmpty(bussiness)) return null;
List<PhQueueEntity> value = item.getValue();
......@@ -152,7 +152,7 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
private void updateSiteWindowPhCount(String currentDate, PhQueueStatEntity entity, List<PhQueueEntity> phQueueEntities) {
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();
if (ObjectUtils.isEmpty(window)) return null;
List<PhQueueEntity> value = item.getValue();
......@@ -215,10 +215,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
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 -> {
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 ;
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);
......@@ -236,10 +236,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
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 -> {
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 ;
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);
......@@ -257,10 +257,10 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
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 -> {
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 ;
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);
......@@ -276,11 +276,12 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
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 -> {
.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 ;
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);
......@@ -333,23 +334,29 @@ public class PhQueueStatServiceImpl extends AbstractCRUDServiceImpl<PhQueueStatD
}
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.save(saveUpdateCollect.get(true));
}
try {
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) {
//更新列表
if (!ObjectUtils.isEmpty(saveAndUpdatelist)) {
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))) {
//新增列表
this.save(saveUpdateCollect.get(true));
}
log.info("更新站点排队部门统计数据,数量:{}", saveUpdateCollect.get(true).size());
this.update(saveUpdateCollect.get(true));
}
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) {
//更新列表
this.update(saveUpdateCollect.get(true));
}
}
} catch (Exception e) {
log.error("异常,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