Commit 5c3c720a authored by 赵啸非's avatar 赵啸非

修改评价统计更新与组合查询

parent f1f69523
package com.mortals.xhx.module.pj.service.impl; package com.mortals.xhx.module.pj.service.impl;
import cn.hutool.core.util.StrUtil;
import com.mortals.framework.common.Rest; import com.mortals.framework.common.Rest;
import com.mortals.framework.model.OrderCol; import com.mortals.framework.model.OrderCol;
import com.mortals.framework.model.PageInfo; import com.mortals.framework.model.PageInfo;
import com.mortals.framework.model.Result; import com.mortals.framework.model.Result;
import com.mortals.xhx.common.code.TimeUnitEnum;
import com.mortals.xhx.common.utils.BeanUtil; import com.mortals.xhx.common.utils.BeanUtil;
import com.mortals.xhx.module.ph.model.PhQueueEntity;
import com.mortals.xhx.module.ph.model.PhQueueStatEntity;
import com.mortals.xhx.module.ph.model.PhQueueStatQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateEntity; import com.mortals.xhx.module.pj.model.PjEvaluateEntity;
import com.mortals.xhx.module.pj.model.PjEvaluateQuery; import com.mortals.xhx.module.pj.model.PjEvaluateQuery;
import com.mortals.xhx.module.pj.model.PjEvaluateStatQuery; import com.mortals.xhx.module.pj.model.PjEvaluateStatQuery;
import com.mortals.xhx.module.pj.service.PjEvaluateService; import com.mortals.xhx.module.pj.service.PjEvaluateService;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -84,11 +80,110 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat ...@@ -84,11 +80,110 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
updateSiteOptionPjCount(currentDate, entity, pjEvaluateEntities); updateSiteOptionPjCount(currentDate, entity, pjEvaluateEntities);
//组合条件更新
updateSiteConditionPhCount(entity, pjEvaluateEntities);
return Rest.ok(); return Rest.ok();
} }
private void updateSiteConditionPhCount(PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
//评价选项 部门 窗口
//评价选项+部门 busniess+sectionName
updatePjOptionAndSectionName(entity, pjEvaluateEntities);
//评价选型+窗口 busniess+WindowFromnum
updatePjOptionAndWindowFromnum(entity, pjEvaluateEntities);
//部门+窗口 sectionName+WindowFromnum
updateSectionNameAndWindowFromnum(entity, pjEvaluateEntities);
//评价选型+部门+窗口 busniess+sectionName+WindowFromnum
updatePjOptionAndSectionNameAndWindow(entity, pjEvaluateEntities);
}
private void updatePjOptionAndSectionName(PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
Map<String, Long> pjoptionAndSectionCollect = pjEvaluateEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getPjOption() + "&" + x.getSectionName(), Collectors.counting()));
List<PjEvaluateStatEntity> saveAndUpdatelist = pjoptionAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey();
String[] split = StrUtil.splitToArray(vals,"&");
if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null;
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PjEvaluateStatQuery pjEvaluateStatQuery = getPhQueueStatQuery(entity);
pjEvaluateStatQuery.setPjOption(split[0]);
pjEvaluateStatQuery.setSectionName(split[1]);
PjEvaluateStatEntity pjEvaluateStatEntity = getPjEvaluateStatEntity(entity, item.getValue(), pjEvaluateStatQuery);
pjEvaluateStatEntity.setPjOption(split[0]);
pjEvaluateStatEntity.setSectionName(split[1]);
return pjEvaluateStatEntity;
}).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePjEvaluateStatList(saveAndUpdatelist);
}
private void updatePjOptionAndWindowFromnum(PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
Map<String, Long> pjoptionAndSectionCollect = pjEvaluateEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getPjOption() + "&" + x.getWindowFromnum(), Collectors.counting()));
List<PjEvaluateStatEntity> saveAndUpdatelist = pjoptionAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey();
String[] split = StrUtil.splitToArray(vals,"&");
if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null;
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PjEvaluateStatQuery pjEvaluateStatQuery = getPhQueueStatQuery(entity);
pjEvaluateStatQuery.setPjOption(split[0]);
pjEvaluateStatQuery.setWindowFromnum(split[1]);
PjEvaluateStatEntity pjEvaluateStatEntity = getPjEvaluateStatEntity(entity, item.getValue(), pjEvaluateStatQuery);
pjEvaluateStatEntity.setPjOption(split[0]);
pjEvaluateStatEntity.setWindowFromnum(split[1]);
return pjEvaluateStatEntity;
}).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePjEvaluateStatList(saveAndUpdatelist);
}
private void updateSectionNameAndWindowFromnum(PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
Map<String, Long> pjoptionAndSectionCollect = pjEvaluateEntities.parallelStream()
.collect(Collectors.groupingBy(x -> x.getSectionName() + "&" + x.getWindowFromnum(), Collectors.counting()));
List<PjEvaluateStatEntity> saveAndUpdatelist = pjoptionAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey();
String[] split = StrUtil.splitToArray(vals,"&");
if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])) return null;
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PjEvaluateStatQuery pjEvaluateStatQuery = getPhQueueStatQuery(entity);
pjEvaluateStatQuery.setSectionName(split[0]);
pjEvaluateStatQuery.setWindowFromnum(split[1]);
PjEvaluateStatEntity pjEvaluateStatEntity = getPjEvaluateStatEntity(entity, item.getValue(), pjEvaluateStatQuery);
pjEvaluateStatEntity.setSectionName(split[0]);
pjEvaluateStatEntity.setWindowFromnum(split[1]);
return pjEvaluateStatEntity;
}).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePjEvaluateStatList(saveAndUpdatelist);
}
private void updatePjOptionAndSectionNameAndWindow(PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
Map<String, Long> pjoptionAndSectionCollect = pjEvaluateEntities.parallelStream()
.collect(Collectors.groupingBy(x ->x.getPjOption() + "&"+ x.getSectionName() + "&" + x.getWindowFromnum(), Collectors.counting()));
List<PjEvaluateStatEntity> saveAndUpdatelist = pjoptionAndSectionCollect.entrySet().parallelStream().map(item -> {
String vals = item.getKey();
String[] split = StrUtil.splitToArray(vals,"&");
if (ObjectUtils.isEmpty(split[0]) || ObjectUtils.isEmpty(split[1])|| ObjectUtils.isEmpty(split[2])) return null;
// log.info("更新站点排队统计数据,站点名称:{},日期:{},窗口:{},排队数量:{}", entity.getSiteName(), currentDate,window, phQueueEntities.size());
PjEvaluateStatQuery pjEvaluateStatQuery = getPhQueueStatQuery(entity);
pjEvaluateStatQuery.setPjOption(split[0]);
pjEvaluateStatQuery.setSectionName(split[1]);
pjEvaluateStatQuery.setWindowFromnum(split[2]);
PjEvaluateStatEntity pjEvaluateStatEntity = getPjEvaluateStatEntity(entity, item.getValue(), pjEvaluateStatQuery);
pjEvaluateStatEntity.setPjOption(split[0]);
pjEvaluateStatEntity.setSectionName(split[1]);
pjEvaluateStatEntity.setWindowFromnum(split[2]);
return pjEvaluateStatEntity;
}).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePjEvaluateStatList(saveAndUpdatelist);
}
private void updateSitePjCount(PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) { private void updateSitePjCount(PjEvaluateStatEntity entity, List<PjEvaluateEntity> pjEvaluateEntities) {
if (ObjectUtils.isEmpty(entity.getSiteId())) return; if (ObjectUtils.isEmpty(entity.getSiteId())) return;
...@@ -130,14 +225,13 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat ...@@ -130,14 +225,13 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
List<PjEvaluateStatEntity> saveAndUpdatelist = collect.entrySet().stream().map(item -> { List<PjEvaluateStatEntity> saveAndUpdatelist = collect.entrySet().stream().map(item -> {
String sectionName = item.getKey(); String sectionName = item.getKey();
if (ObjectUtils.isEmpty(sectionName)) return null; if (ObjectUtils.isEmpty(sectionName)) return null;
PjEvaluateStatQuery pjEvaluateStatQuery = getPhQueueStatQuery(entity); PjEvaluateStatQuery pjEvaluateStatQuery = getPhQueueStatQuery(entity);
pjEvaluateStatQuery.setSectionName(sectionName); pjEvaluateStatQuery.setSectionName(sectionName);
PjEvaluateStatEntity pjEvaluateStatEntity = getPjEvaluateStatEntity(entity, item.getValue(), pjEvaluateStatQuery); PjEvaluateStatEntity pjEvaluateStatEntity = getPjEvaluateStatEntity(entity, item.getValue(), pjEvaluateStatQuery);
pjEvaluateStatEntity.setSectionName(sectionName); pjEvaluateStatEntity.setSectionName(sectionName);
return pjEvaluateStatEntity; return pjEvaluateStatEntity;
}).filter(f -> f != null).collect(Collectors.toList()); }).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePhqueueStatList(saveAndUpdatelist); saveUpdatePjEvaluateStatList(saveAndUpdatelist);
} }
...@@ -153,7 +247,7 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat ...@@ -153,7 +247,7 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
pjEvaluateStatEntity.setHallName(hallName); pjEvaluateStatEntity.setHallName(hallName);
return pjEvaluateStatEntity; return pjEvaluateStatEntity;
}).filter(f -> f != null).collect(Collectors.toList()); }).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePhqueueStatList(saveAndUpdatelist); saveUpdatePjEvaluateStatList(saveAndUpdatelist);
} }
...@@ -168,7 +262,7 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat ...@@ -168,7 +262,7 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
pjEvaluateStatEntity.setWindowFromnum(windowFromnum); pjEvaluateStatEntity.setWindowFromnum(windowFromnum);
return pjEvaluateStatEntity; return pjEvaluateStatEntity;
}).filter(f -> f != null).collect(Collectors.toList()); }).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePhqueueStatList(saveAndUpdatelist); saveUpdatePjEvaluateStatList(saveAndUpdatelist);
} }
...@@ -185,7 +279,7 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat ...@@ -185,7 +279,7 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
pjEvaluateStatEntity.setPjOption(pjOption); pjEvaluateStatEntity.setPjOption(pjOption);
return pjEvaluateStatEntity; return pjEvaluateStatEntity;
}).filter(f -> f != null).collect(Collectors.toList()); }).filter(f -> f != null).collect(Collectors.toList());
saveUpdatePhqueueStatList(saveAndUpdatelist); saveUpdatePjEvaluateStatList(saveAndUpdatelist);
} }
...@@ -240,16 +334,16 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat ...@@ -240,16 +334,16 @@ public class PjEvaluateStatServiceImpl extends AbstractCRUDServiceImpl<PjEvaluat
return pjEvaluateStatQuery; return pjEvaluateStatQuery;
} }
private void saveUpdatePhqueueStatList(List<PjEvaluateStatEntity> saveAndUpdatelist) { private void saveUpdatePjEvaluateStatList(List<PjEvaluateStatEntity> saveAndUpdatelist) {
if (!ObjectUtils.isEmpty(saveAndUpdatelist)) { if (!ObjectUtils.isEmpty(saveAndUpdatelist)) {
Map<Boolean, List<PjEvaluateStatEntity>> saveUpdateCollect = saveAndUpdatelist.parallelStream().collect(Collectors.partitioningBy(i -> i.newEntity())); Map<Boolean, List<PjEvaluateStatEntity>> saveUpdateCollect = saveAndUpdatelist.parallelStream().collect(Collectors.partitioningBy(i -> i.newEntity()));
log.info("新增站点排队部门统计数据,数量:{}", saveUpdateCollect.get(true).size()); log.info("新增站点评价统计数据,数量:{}", saveUpdateCollect.get(true).size());
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(true))) { if (!ObjectUtils.isEmpty(saveUpdateCollect.get(true))) {
//新增列表 //新增列表
this.save(saveUpdateCollect.get(true)); this.save(saveUpdateCollect.get(true));
} }
log.info("更新站点排队部门统计数据,数量:{}", saveUpdateCollect.get(true).size()); log.info("更新站点评价统计数据,数量:{}", saveUpdateCollect.get(true).size());
if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) { if (!ObjectUtils.isEmpty(saveUpdateCollect.get(false))) {
//更新列表 //更新列表
this.update(saveUpdateCollect.get(true)); this.update(saveUpdateCollect.get(true));
......
...@@ -25,6 +25,7 @@ import com.mortals.framework.model.Context; ...@@ -25,6 +25,7 @@ import com.mortals.framework.model.Context;
import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity; import com.mortals.xhx.module.pj.model.PjEvaluateStatEntity;
import com.mortals.xhx.module.pj.service.PjEvaluateStatService; import com.mortals.xhx.module.pj.service.PjEvaluateStatService;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -63,9 +64,9 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -63,9 +64,9 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
PjEvaluateStatQuery pjEvaluateStatQuery = new PjEvaluateStatQuery(); PjEvaluateStatQuery pjEvaluateStatQuery = new PjEvaluateStatQuery();
pjEvaluateStatQuery.setSiteId((Long) siteId); pjEvaluateStatQuery.setSiteId((Long) siteId);
List<PjEvaluateStatEntity> pjEvaluateStatEntities = this.service.find(pjEvaluateStatQuery, context); List<PjEvaluateStatEntity> pjEvaluateStatEntities = this.service.find(pjEvaluateStatQuery, context);
Map<String, String> sectionNameMap = pjEvaluateStatEntities.stream().filter(f -> !ObjectUtils.isEmpty(f.getSectionName())).collect(Collectors.toMap(PjEvaluateStatEntity::getSectionName, PjEvaluateStatEntity::getSectionName, (k1, k2) -> k2)); Map<String, String> sectionNameMap = pjEvaluateStatEntities.parallelStream().filter(f -> !ObjectUtils.isEmpty(f.getSectionName())).collect(Collectors.toMap(PjEvaluateStatEntity::getSectionName, PjEvaluateStatEntity::getSectionName, (k1, k2) -> k2));
Map<String, String> hallNameMap = pjEvaluateStatEntities.stream().filter(f -> !ObjectUtils.isEmpty(f.getHallName())).collect(Collectors.toMap(PjEvaluateStatEntity::getHallName, PjEvaluateStatEntity::getHallName, (k1, k2) -> k2)); Map<String, String> hallNameMap = pjEvaluateStatEntities.parallelStream().filter(f -> !ObjectUtils.isEmpty(f.getHallName())).collect(Collectors.toMap(PjEvaluateStatEntity::getHallName, PjEvaluateStatEntity::getHallName, (k1, k2) -> k2));
Map<String, String> windowFromnumMap = pjEvaluateStatEntities.stream().filter(f -> !ObjectUtils.isEmpty(f.getWindowFromnum())).collect(Collectors.toMap(PjEvaluateStatEntity::getWindowFromnum, PjEvaluateStatEntity::getWindowFromnum, (k1, k2) -> k2)); Map<String, String> windowFromnumMap = pjEvaluateStatEntities.parallelStream().filter(f -> !ObjectUtils.isEmpty(f.getWindowFromnum())).collect(Collectors.toMap(PjEvaluateStatEntity::getWindowFromnum, PjEvaluateStatEntity::getWindowFromnum, (k1, k2) -> k2));
this.addDict(model, "sectionNameList", sectionNameMap); this.addDict(model, "sectionNameList", sectionNameMap);
this.addDict(model, "hallNameList", hallNameMap); this.addDict(model, "hallNameList", hallNameMap);
...@@ -79,13 +80,11 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController< ...@@ -79,13 +80,11 @@ public class PjEvaluateStatController extends BaseCRUDJsonBodyMappingController<
@Override @Override
protected void doListBefore(PjEvaluateStatEntity query, Map<String, Object> model, Context context) throws AppException { protected void doListBefore(PjEvaluateStatEntity query, Map<String, Object> model, Context context) throws AppException {
if (ObjectUtils.isEmpty(query.getHallName())) query.setHallName(""); if (ObjectUtils.isEmpty(query.getHallName())&&ObjectUtils.isEmpty(query.getHallNameList())&&ObjectUtils.isEmpty(query.getHallNameNotList())) query.setHallNameList(Arrays.asList(""));
if (ObjectUtils.isEmpty(query.getSectionName())) query.setSectionName(""); if (ObjectUtils.isEmpty(query.getSectionName())&&ObjectUtils.isEmpty(query.getSectionNameList())&&ObjectUtils.isEmpty(query.getSectionNameNotList())) query.setSectionNameList(Arrays.asList(""));
if (ObjectUtils.isEmpty(query.getPjOption())) query.setPjOption(""); if (ObjectUtils.isEmpty(query.getPjOption())&&ObjectUtils.isEmpty(query.getPjOptionList())&&ObjectUtils.isEmpty(query.getPjOptionNotList())) query.setPjOptionList(Arrays.asList(""));
if (ObjectUtils.isEmpty(query.getWindowFromnum())) query.setWindowFromnum(""); if (ObjectUtils.isEmpty(query.getWindowFromnum())&&ObjectUtils.isEmpty(query.getWindowFromnumList())&&ObjectUtils.isEmpty(query.getWindowFromnumNotList())) query.setWindowFromnumList(Arrays.asList(""));
//年月日 //年月日
//根据查询条件自动添加分组字段 //根据查询条件自动添加分组字段
addGroup(query); addGroup(query);
......
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