|
@@ -1,6 +1,7 @@
|
|
|
package com.ims.eval.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.ims.common.utils.DoubleUtils;
|
|
|
import com.ims.common.utils.StringUtils;
|
|
|
import com.ims.eval.cache.CacheContext;
|
|
|
import com.ims.eval.config.CustomException;
|
|
@@ -44,13 +45,46 @@ public class OrganizationEvaluationCommonInfoServiceImpl extends ServiceImpl<Org
|
|
|
private IIndicatorDictionaryService indicatorDictionaryService;
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IOrganizationEvaluationInfoService organizationEvaluationInfoService;
|
|
|
+
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public boolean addEvaluationCommonInfo(List<AddEvaluationInfoDTO> addEvaluationInfoDTOs) {
|
|
|
+
|
|
|
+
|
|
|
+ //获取公共性息;为后面汇总业务做准备业务做准备
|
|
|
+ String organizationEvaluationId = null;
|
|
|
+ String organizationId = null;
|
|
|
+ String indicatorId = null;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //0.移除现有数据
|
|
|
+ boolean flag = true;
|
|
|
+ Integer indx = 1;
|
|
|
for (AddEvaluationInfoDTO addEvaluationInfoDTO : addEvaluationInfoDTOs) {
|
|
|
+ if(flag){
|
|
|
+ flag = false;
|
|
|
+ //5.删除原有记录
|
|
|
+ List<OrganizationEvaluationCommonInfo> infoResDTOList = baseMapper.selectListAll(addEvaluationInfoDTO.getOrganizationEvaluationId(),addEvaluationInfoDTO.getIndicatorId(),addEvaluationInfoDTO.getOrganizationId(),"");
|
|
|
+ //判断是否已存在记录
|
|
|
+ if(null != infoResDTOList && infoResDTOList.size()>0){
|
|
|
+ //当前部门存在记录;移除保存
|
|
|
+ List<String> commonIds = infoResDTOList.stream().map(OrganizationEvaluationCommonInfo::getId).collect(Collectors.toList());
|
|
|
+ boolean b = this.removeByIds(commonIds);
|
|
|
+ if(!b){
|
|
|
+ return b;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//1.获取考评id(获取此考评记录)
|
|
|
- String organizationEvaluationId = addEvaluationInfoDTO.getOrganizationEvaluationId();
|
|
|
+ organizationEvaluationId = addEvaluationInfoDTO.getOrganizationEvaluationId();
|
|
|
+ organizationId = addEvaluationInfoDTO.getOrganizationId();
|
|
|
+ indicatorId = addEvaluationInfoDTO.getIndicatorId();
|
|
|
|
|
|
if (StringUtils.isEmpty(organizationEvaluationId)) {
|
|
|
throw new CustomException("保存失败");
|
|
@@ -82,19 +116,18 @@ public class OrganizationEvaluationCommonInfoServiceImpl extends ServiceImpl<Org
|
|
|
Map<String, Object> optionMap = addEvaluationInfoDTO.getOptionMap();
|
|
|
|
|
|
|
|
|
- //5.删除原有记录
|
|
|
- List<OrganizationEvaluationCommonInfo> infoResDTOList = baseMapper.selectListAll(addEvaluationInfoDTO.getOrganizationEvaluationId(),addEvaluationInfoDTO.getIndicatorId(),addEvaluationInfoDTO.getOrganizationId(),optionMap.get("deptName").toString());
|
|
|
- //判断是否已存在记录
|
|
|
- if(null != infoResDTOList && infoResDTOList.size()>0){
|
|
|
- //当前部门存在记录;移除保存
|
|
|
- List<String> commonIds = infoResDTOList.stream().map(OrganizationEvaluationCommonInfo::getId).collect(Collectors.toList());
|
|
|
- boolean b = this.removeByIds(commonIds);
|
|
|
- if(!b){
|
|
|
- throw new CustomException("保存失败");
|
|
|
- }
|
|
|
+
|
|
|
+ //5.获取部门性息
|
|
|
+ DataDictionary di =null;
|
|
|
+ if (StringUtils.isNotEmpty(optionMap.get("deptName").toString()) && CacheContext.ddSuperKeyMap.containsKey("BM0001")){
|
|
|
+ Optional<DataDictionary> any = CacheContext.ddSuperKeyMap.get("BM0001").stream().filter(t -> t.getKeyName().equals(optionMap.get("deptName").toString())).findAny();
|
|
|
+ di = any.isPresent() ? any.get() : null;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
//6.保存指标
|
|
|
for (Map.Entry<String, List<IndicatorResDTO>> childCodeEntry : groupedChildCode.entrySet()) {
|
|
|
|
|
@@ -121,19 +154,38 @@ public class OrganizationEvaluationCommonInfoServiceImpl extends ServiceImpl<Org
|
|
|
}
|
|
|
}
|
|
|
info.setChildCode(d.getChildCode());
|
|
|
- CacheContext.ddSuperKeyMap.containsKey("BM0001");
|
|
|
-
|
|
|
- if (StringUtils.isNotEmpty(optionMap.get("deptName").toString()) && CacheContext.ddSuperKeyMap.containsKey("BM0001")){
|
|
|
- Optional<DataDictionary> any = CacheContext.ddSuperKeyMap.get("BM0001").stream().filter(t -> t.getKeyName().equals(optionMap.get("deptName").toString())).findAny();
|
|
|
- DataDictionary di = any.isPresent() ? any.get() : null;
|
|
|
- info.setDeptId(di.getDataKey());
|
|
|
- info.setDeptName(optionMap.get("deptName").toString());
|
|
|
- }
|
|
|
+ info.setDeptId(di.getDataKey());
|
|
|
+ info.setDeptName(optionMap.get("deptName").toString());
|
|
|
+ info.setIndx(indx);//标记
|
|
|
saveOrUpdate(info);
|
|
|
}
|
|
|
}
|
|
|
+ indx++;
|
|
|
}
|
|
|
- return true;
|
|
|
+
|
|
|
+ //获取明细
|
|
|
+ List<OrganizationEvaluationInfo> evaluationInfoList = organizationEvaluationInfoService.getConvergeCommonInfo(organizationEvaluationId,organizationId,indicatorId);
|
|
|
+ List<OrganizationEvaluationCommonInfo> evaluationCommonInfos = getEvaluationCommonInfo(organizationEvaluationId,organizationId,indicatorId,"");
|
|
|
+
|
|
|
+ //按照指标项id分组
|
|
|
+ Map<String, List<OrganizationEvaluationCommonInfo>> groupOptionData = evaluationCommonInfos.stream()
|
|
|
+ .collect(Collectors.groupingBy(OrganizationEvaluationCommonInfo::getIndicatorDictionaryId));
|
|
|
+
|
|
|
+ for (OrganizationEvaluationInfo oei : evaluationInfoList){
|
|
|
+ List<OrganizationEvaluationCommonInfo> oeci = null != groupOptionData.get(oei.getIndicatorDictionaryId()) ? groupOptionData.get(oei.getIndicatorDictionaryId()) :null;
|
|
|
+ if(null !=oeci ){
|
|
|
+// String ss = oei.getIsQuantified() ? oeci."" : "";
|
|
|
+ if(oei.getIsQuantified()){
|
|
|
+ double ageSum = oeci.stream().mapToDouble(OrganizationEvaluationCommonInfo::getQuantifiedValue).sum();
|
|
|
+ oei.setQuantifiedValue(DoubleUtils.getRoundingNum(ageSum,2));
|
|
|
+ oei.setNonQuantifiedValue(DoubleUtils.getRoundingNum(ageSum,2)+"");
|
|
|
+ }else {
|
|
|
+ oei.setNonQuantifiedValue("见详情");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ boolean b = organizationEvaluationInfoService.saveOrUpdateBatch(evaluationInfoList);
|
|
|
+ return b;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -166,8 +218,14 @@ public class OrganizationEvaluationCommonInfoServiceImpl extends ServiceImpl<Org
|
|
|
List<OrganizationEvaluationCommonInfo> list = baseMapper.selectListAll(organizationEvaluationId,indicatorId,organizationId,deptId);
|
|
|
|
|
|
//根据部门id分组
|
|
|
+// Map<String, List<OrganizationEvaluationCommonInfo>> groupedData = list.stream()
|
|
|
+// .collect(Collectors.groupingBy(OrganizationEvaluationCommonInfo::getDeptId));
|
|
|
+
|
|
|
Map<String, List<OrganizationEvaluationCommonInfo>> groupedData = list.stream()
|
|
|
- .collect(Collectors.groupingBy(OrganizationEvaluationCommonInfo::getDeptId));
|
|
|
+ .collect(Collectors.groupingBy(item -> item.getDeptId() + "_" + item.getIndx()));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
List<Map> mapList = new ArrayList<>();
|
|
|
//遍历按照部门分组的数据
|
|
|
for (Map.Entry<String, List<OrganizationEvaluationCommonInfo>> entry : groupedData.entrySet()) {
|
|
@@ -209,7 +267,30 @@ public class OrganizationEvaluationCommonInfoServiceImpl extends ServiceImpl<Org
|
|
|
return data;
|
|
|
}
|
|
|
|
|
|
-// @Override
|
|
|
+ @Override
|
|
|
+ public List<OrganizationEvaluationCommonInfo> getEvaluationCommonInfo(String organizationEvaluationId, String organizationId, String indicatorId, String indicatorDictionaryId) {
|
|
|
+ QueryWrapper<OrganizationEvaluationCommonInfo> qw = new QueryWrapper<>();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(organizationEvaluationId)) {
|
|
|
+ qw.lambda().eq(OrganizationEvaluationCommonInfo::getOrganizationEvaluationId, organizationEvaluationId);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(organizationId)) {
|
|
|
+ qw.lambda().eq(OrganizationEvaluationCommonInfo::getOrganizationId, organizationId);
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotEmpty(indicatorId)) {
|
|
|
+ qw.lambda().eq(OrganizationEvaluationCommonInfo::getIndicatorId, indicatorId);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(indicatorDictionaryId)) {
|
|
|
+ qw.lambda().eq(OrganizationEvaluationCommonInfo::getIndicatorDictionaryId, indicatorDictionaryId);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<OrganizationEvaluationCommonInfo> list = baseMapper.selectList(qw);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // @Override
|
|
|
// public boolean removeCommonInfos(String organizationEvaluationId, String indicatorId, String organizationId, String deptId) {
|
|
|
// QueryWrapper<OrganizationEvaluationCommonInfo> qw = new QueryWrapper<>();
|
|
|
//
|