wangchangsheng 1 рік тому
батько
коміт
d856fab696

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/dao/CiteCalculationIndicatorMapper.java

@@ -24,7 +24,7 @@ public interface CiteCalculationIndicatorMapper extends BaseMapper<CiteCalculati
 																	  @Param("binSection") String binSection);
 
 
-	List<Map> selectListLikeIndicatorIds(@Param("indicatorIds") String indicatorIds);
+	List<CiteCalculationIndicator> selectListLikeIndicatorIds(@Param("indicatorIds") String indicatorIds);
 
 
 }

+ 5 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/dto/response/IndicatorResDTO.java

@@ -19,6 +19,11 @@ public class IndicatorResDTO {
 	 */
 	private String indicatorId;
 
+	/**
+	 * 板块id
+	 */
+	private String  binSection;
+
 
 	/**
 	 * 指标name

+ 3 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/ICiteCalculationIndicatorService.java

@@ -19,4 +19,7 @@ public interface ICiteCalculationIndicatorService extends IService<CiteCalculati
 
 	List<CiteCalculationIndicator> getCiteCalculationIndicatorList(Integer pageNum, Integer pageSize,String citeCalculationName, String binSection);
 
+
+	List<CiteCalculationIndicator> getListLikeIndicatorIds(String indicatorIds);
+
 }

+ 160 - 40
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/CalculateIndicatorItemInfoServiceImpl.java

@@ -41,42 +41,6 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 	private IndicatorMapper indicatorMapper;
 
 
-	@Override
-	public int saveIndicatorInfo(List<OrganizationEvaluationInfo> organizationEvaluationInfos) throws Exception {
-
-		List<CalculateIndicatorItemInfo> list = new ArrayList<>();
-
-		OrganizationEvaluationResDTO organizationEvaluationResDTO = organizationEvaluationMapper.selectById(organizationEvaluationInfos.get(0).getOrganizationEvaluationId());
-		//对考评规则id进行分组
-		Map<String, List<OrganizationEvaluationInfo>> collect = organizationEvaluationInfos.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId));
-		for (Map.Entry<String, List<OrganizationEvaluationInfo>> entry : collect.entrySet()) {
-			if (entry.getValue().size() > 0) {
-				//对指标id进行分组
-				Map<String, List<OrganizationEvaluationInfo>> collectIn = entry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getIndicatorId));
-				for (Map.Entry<String, List<OrganizationEvaluationInfo>> listEntry : collectIn.entrySet()) {
-					List<OrganizationEvaluationInfo> listEntryValue = listEntry.getValue();
-					for (OrganizationEvaluationInfo r : listEntryValue){
-						if (r.getOptionCode().equals("CZ") || r.getOptionCode().equals("LRGXL") || r.getOptionCode().equals("DWQWLR")) {
-							CalculateIndicatorItemInfo calculateIndicatorItemInfo = new CalculateIndicatorItemInfo();
-
-							calculateIndicatorItemInfo.setIndicatorId(listEntry.getKey());
-							calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
-							calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
-							calculateIndicatorItemInfo.setSectionId(indicatorMapper.selectById(listEntry.getKey()).getBinSection());
-							calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
-							calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
-							calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
-							calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
-//							calculateIndicatorItemInfo.setOrganizationEvaluationId(organizationEvaluationResDTO.getId());
-							list.add(calculateIndicatorItemInfo);
-						}
-					}
-				}
-			}
-		}
-
-		return saveCalculate(list);
-	}
 
 	@Override
 	public int saveIndicatorInfoDTO(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
@@ -93,10 +57,10 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 					calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
 					calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
 					calculateIndicatorItemInfo.setSectionId(r.getBinSection());
-					calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
-					calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
-					calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
-					calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
+//					calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
+//					calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
+//					calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
+//					calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
 					calculateIndicatorItemInfo.setOrganizationEvaluationId(r.getOrganizationEvaluationId());
 					calculateIndicatorItemInfo.setChildCode(r.getChildCode());
 					list.add(calculateIndicatorItemInfo);
@@ -108,6 +72,29 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 	}
 
 
+	@Override
+	public int saveIndicatorInfoDTO2(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
+		List<CalculateIndicatorItemInfo> list = new ArrayList<>();
+		for (OrganizationEvaluationInfoResDTO r : infoResDTOS){
+			if (r.getOptionCode().equals("LRZE") || r.getOptionCode().equals("CZ") ||  r.getOptionCode().equals("LRGXKH")|| r.getOptionCode().equals("LRGXL") || r.getOptionCode().equals("DWQWLR")) {
+				CalculateIndicatorItemInfo calculateIndicatorItemInfo = new CalculateIndicatorItemInfo();
+				calculateIndicatorItemInfo.setIndicatorId(r.getIndicatorId());
+				calculateIndicatorItemInfo.setOptionCode(r.getOptionCode());
+				calculateIndicatorItemInfo.setQuantifiedValue(r.getQuantifiedValue());
+				calculateIndicatorItemInfo.setSectionId(r.getBinSection());
+//				calculateIndicatorItemInfo.setOrganizationType(organizationEvaluationResDTO.getOrganizationType());
+//				calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
+//				calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
+//				calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
+				calculateIndicatorItemInfo.setOrganizationEvaluationId(r.getOrganizationEvaluationId());
+				calculateIndicatorItemInfo.setChildCode(r.getChildCode());
+				list.add(calculateIndicatorItemInfo);
+			}
+		}
+
+		return 0;
+	}
+
 	@Transactional
 	public int saveCalculate(List<CalculateIndicatorItemInfo> listall) throws Exception {
 
@@ -180,4 +167,137 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 		}
 		return 1;
 	}
+
+
+
+	@Transactional
+	public int saveCalculate2(List<CalculateIndicatorItemInfo> listall) throws Exception {
+
+		if (listall.size() > 0){
+
+			//集合是包含所有需要求最大值和最小值的对象(先使用属性分组)
+
+
+			Map<String, List<CalculateIndicatorItemInfo>> optionCodeGropList = listall.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
+
+			for (Map.Entry<String, List<CalculateIndicatorItemInfo>> optionCodeGropListEntry : optionCodeGropList.entrySet()){
+
+				//从小到大的顺序排序
+				Collections.sort(optionCodeGropListEntry.getValue(), new Comparator<CalculateIndicatorItemInfo>() {
+					@Override
+					public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
+						double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
+						BigDecimal two = new BigDecimal(diff);
+						double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
+						if (three > 0) {
+							return 1;
+						} else if (three < 0) {
+							return -1;
+						}
+						return 0; //相等为0
+					}
+				});
+
+
+				CalculateIndicatorItemInfo maxNum =  (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(optionCodeGropListEntry.getValue().size()-1).clone();
+				maxNum.setMark("1");
+
+				CalculateIndicatorItemInfo minNum  = (CalculateIndicatorItemInfo)optionCodeGropListEntry.getValue().get(0).clone();
+
+				minNum.setMark("0");
+
+
+				Map<String, List<CalculateIndicatorItemInfo>> childCodeGropList = optionCodeGropListEntry.getValue().stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getChildCode));
+				for (Map.Entry<String, List<CalculateIndicatorItemInfo>> childCodeGropListEntry : childCodeGropList.entrySet()){
+					String  childCode  = childCodeGropListEntry.getKey();
+
+				}
+
+
+			}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+			////---------------------------------------------------------------------
+			Map<String, List<CalculateIndicatorItemInfo>> childCodeGropList = listall.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getChildCode));
+			for (Map.Entry<String, List<CalculateIndicatorItemInfo>> childCodeGropListEntry : childCodeGropList.entrySet()){
+
+				List<CalculateIndicatorItemInfo> list = childCodeGropListEntry.getValue();
+				//遍历list解析最大值和最小值
+				Map<String, List<CalculateIndicatorItemInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
+				//判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
+				List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","","",list.get(0).getOrganizationEvaluationId(),list.get(0).getChildCode());
+
+				if (calculateIndicatorItemInfo.size() > 0){
+					List<String> idList = calculateIndicatorItemInfo.stream().map(CalculateIndicatorItemInfo::getId).collect(Collectors.toList());
+					calculateIndicatorItemInfoMapper.deleteBatchIds(idList);
+				}
+				for (Map.Entry<String, List<CalculateIndicatorItemInfo>> listEntry : collect.entrySet()){
+
+					//从小到大的顺序排序
+					Collections.sort(listEntry.getValue(), new Comparator<CalculateIndicatorItemInfo>() {
+						@Override
+						public int compare(CalculateIndicatorItemInfo u1, CalculateIndicatorItemInfo u2) {
+							double diff = u1.getQuantifiedValue() - u2.getQuantifiedValue();
+							BigDecimal two = new BigDecimal(diff);
+							double three = two.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue();
+							if (three > 0) {
+								return 1;
+							} else if (three < 0) {
+								return -1;
+							}
+							return 0; //相等为0
+						}
+					});
+
+					CalculateIndicatorItemInfo maxNum =  (CalculateIndicatorItemInfo)listEntry.getValue().get(listEntry.getValue().size()-1).clone();
+					maxNum.setMark("1");
+
+					CalculateIndicatorItemInfo minNum  = (CalculateIndicatorItemInfo)listEntry.getValue().get(0).clone();
+
+					minNum.setMark("0");
+
+
+					if (listEntry.getKey().equals("CZ")){
+						//存储最大值
+						maxNum.setOptionCode("CZMAX");
+						minNum.setOptionCode("CZMIN");
+					}else if (listEntry.getKey().equals("LRGXL")){
+						//利润贡献
+						maxNum.setOptionCode("LRGXLMAX");
+						minNum.setOptionCode("LRGXLMIN");
+					}else if (listEntry.getKey().equals("DWQWLR")){
+						maxNum.setOptionCode("DWQWLRMAX");
+						minNum.setOptionCode("DWQWLRMIN");
+					}else if (listEntry.getKey().equals("LRGXKH")){
+						maxNum.setOptionCode("LRGXKHMAX");
+						minNum.setOptionCode("LRGXKHMIN");
+					}else if (listEntry.getKey().equals("LRZE")){
+						maxNum.setOptionCode("LRZEMAX");
+						minNum.setOptionCode("LRZEMIN");
+					}
+
+					calculateIndicatorItemInfoMapper.insert(maxNum);
+					calculateIndicatorItemInfoMapper.insert(minNum);
+				}
+			}
+
+		}
+		return 1;
+	}
 }

+ 6 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/CiteCalculationIndicatorServiceImpl.java

@@ -37,6 +37,12 @@ public class CiteCalculationIndicatorServiceImpl extends ServiceImpl<CiteCalcula
 	}
 
 	@Override
+	public List<CiteCalculationIndicator> getListLikeIndicatorIds(String indicatorIds) {
+		List<CiteCalculationIndicator> list  = baseMapper.selectListLikeIndicatorIds(indicatorIds);
+		return list;
+	}
+
+	@Override
 	public boolean saveOrUpdate(CiteCalculationIndicator entity) {
 		return super.saveOrUpdate(entity);
 	}

+ 5 - 6
ims-service/ims-eval/src/main/resources/mappers/CiteCalculationIndicatorMapper.xml

@@ -21,17 +21,16 @@
         </where>
     </select>
 
-    <select id="selectListLikeIndicatorIds" resultType="java.util.Map">
 
-        SELECT concat(bs.section_name, ',', '') as indicator_names,
-        i.id indicator_id,cci.section_name,cci.cite_calculation_name
+
+    <select id="selectListLikeIndicatorIds" resultType="com.ims.eval.entity.CiteCalculationIndicator">
+
+        SELECT *
         FROM cite_calculation_indicator cci
-        JOIN LATERAL unnest(string_to_array(cci.indicator_ids, ',')) AS indicator_id ON TRUE
-        JOIN indicator i ON i.id = indicator_id
-        LEFT JOIN bin_section bs on bs.id = i.bin_section
         <where>
             and cci.indicator_ids like   CONCAT('%',#{indicatorIds},'%')
         </where>
 
     </select>
+
 </mapper>

+ 1 - 0
ims-service/ims-eval/src/main/resources/mappers/IndicatorMapper.xml

@@ -95,6 +95,7 @@
         d.id ,
         i.id indicatorId,
         i.dept_id,
+        i.bin_section,
         i.is_quantified isQuantified,
         d.option_code optionCode,
         d.option_name optionName,