Sfoglia il codice sorgente

计算重构and添加新表

wangchangsheng 1 anno fa
parent
commit
6d8e732e88
19 ha cambiato i file con 515 aggiunte e 102 eliminazioni
  1. 20 0
      ims-service/ims-eval/src/main/java/com/ims/eval/controller/EvaluationWarningInfoController.java
  2. 20 0
      ims-service/ims-eval/src/main/java/com/ims/eval/controller/EvaluationWarningRuleController.java
  3. 1 1
      ims-service/ims-eval/src/main/java/com/ims/eval/dao/CalculateIndicatorItemInfoMapper.java
  4. 16 0
      ims-service/ims-eval/src/main/java/com/ims/eval/dao/EvaluationWarningInfoMapper.java
  5. 16 0
      ims-service/ims-eval/src/main/java/com/ims/eval/dao/EvaluationWarningRuleMapper.java
  6. 7 1
      ims-service/ims-eval/src/main/java/com/ims/eval/entity/CalculateIndicatorItemInfo.java
  7. 88 0
      ims-service/ims-eval/src/main/java/com/ims/eval/entity/EvaluationWarningInfo.java
  8. 93 0
      ims-service/ims-eval/src/main/java/com/ims/eval/entity/EvaluationWarningRule.java
  9. 1 1
      ims-service/ims-eval/src/main/java/com/ims/eval/entity/OrganizationEvaluationInfo.java
  10. 5 0
      ims-service/ims-eval/src/main/java/com/ims/eval/entity/dto/response/OrganizationEvaluationInfoResDTO.java
  11. 1 1
      ims-service/ims-eval/src/main/java/com/ims/eval/schedule/ScoreCalculationSchedule.java
  12. 16 0
      ims-service/ims-eval/src/main/java/com/ims/eval/service/IEvaluationWarningInfoService.java
  13. 16 0
      ims-service/ims-eval/src/main/java/com/ims/eval/service/IEvaluationWarningRuleService.java
  14. 75 61
      ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/CalculateIndicatorItemInfoServiceImpl.java
  15. 20 0
      ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationWarningInfoServiceImpl.java
  16. 20 0
      ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationWarningRuleServiceImpl.java
  17. 94 37
      ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationInfoServiceImpl.java
  18. 5 0
      ims-service/ims-eval/src/main/resources/mappers/CalculateIndicatorItemInfoMapper.xml
  19. 1 0
      ims-service/ims-eval/src/main/resources/mappers/OrganizationEvaluationInfoMapper.xml

+ 20 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/EvaluationWarningInfoController.java

@@ -0,0 +1,20 @@
+package com.ims.eval.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+@RestController
+@RequestMapping("//evaluation-warning-info")
+public class EvaluationWarningInfoController {
+
+}

+ 20 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/EvaluationWarningRuleController.java

@@ -0,0 +1,20 @@
+package com.ims.eval.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+@RestController
+@RequestMapping("//evaluation-warning-rule")
+public class EvaluationWarningRuleController {
+
+}

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

@@ -15,6 +15,6 @@ import java.util.List;
  */
 public interface CalculateIndicatorItemInfoMapper extends BaseMapper<CalculateIndicatorItemInfo> {
 
-	List<CalculateIndicatorItemInfo> selectList(String organizationType, String checkCycle, String year, String month,String binSection,String organizationEvaluationId);
+	List<CalculateIndicatorItemInfo> selectList(String organizationType, String checkCycle, String year, String month,String binSection,String organizationEvaluationId,String childCode);
 
 }

+ 16 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/dao/EvaluationWarningInfoMapper.java

@@ -0,0 +1,16 @@
+package com.ims.eval.dao;
+
+import com.ims.eval.entity.EvaluationWarningInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+public interface EvaluationWarningInfoMapper extends BaseMapper<EvaluationWarningInfo> {
+
+}

+ 16 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/dao/EvaluationWarningRuleMapper.java

@@ -0,0 +1,16 @@
+package com.ims.eval.dao;
+
+import com.ims.eval.entity.EvaluationWarningRule;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+public interface EvaluationWarningRuleMapper extends BaseMapper<EvaluationWarningRule> {
+
+}

+ 7 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/entity/CalculateIndicatorItemInfo.java

@@ -22,7 +22,7 @@ public class CalculateIndicatorItemInfo extends Model implements Cloneable {
 	private String id;
 
 	/**
-	 * 考评记录id
+	 * 考评id
 	 */
 	private String organizationEvaluationId;
 
@@ -52,6 +52,12 @@ public class CalculateIndicatorItemInfo extends Model implements Cloneable {
 	private String indicatorId;
 
 	/**
+	 * 子指标code
+	 */
+	private String childCode;
+
+
+	/**
 	 * 生产经营id
 	 */
 	private String sectionId;

+ 88 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/EvaluationWarningInfo.java

@@ -0,0 +1,88 @@
+package com.ims.eval.entity;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import java.time.LocalDate;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class EvaluationWarningInfo extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 规则id
+     */
+    private String ruleId;
+
+    /**
+     * 业务板块code
+     */
+    private String binSection;
+
+    /**
+     * 指标id
+     */
+    private String indicatorId;
+
+    /**
+     * 预警编号
+     */
+    private String warningCode;
+
+    /**
+     * 预警标题
+     */
+    private String title;
+
+    /**
+     * 预警内容
+     */
+    private String content;
+
+    /**
+     * 是否确认
+     */
+    private Boolean isConfirm;
+
+    /**
+     * 确认时间
+     */
+    private LocalDate confirmTime;
+
+    /**
+     * 确认人
+     */
+    private String userName;
+
+    /**
+     * 确认人code
+     */
+    private String userCode;
+
+    /**
+     * 部门
+     */
+    private String deptId;
+
+    /**
+     * 创建时间
+     */
+    private LocalDate createTime;
+
+
+}

+ 93 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/EvaluationWarningRule.java

@@ -0,0 +1,93 @@
+package com.ims.eval.entity;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import java.time.LocalDate;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class EvaluationWarningRule extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键
+     */
+    private String id;
+
+    /**
+     * 业务板块code
+     */
+    private String binSection;
+
+    /**
+     * 指标id
+     */
+    private String indicatorId;
+
+    /**
+     * 指标信息(计划值、完成值、偏差等信息)
+     */
+    private String indicatorInfo;
+
+    /**
+     * 指标分类code
+     */
+    private String binStage;
+
+    /**
+     * 预警规则
+     */
+    private String rule;
+
+    /**
+     * 预警等级(1低级,2中级,3高级)
+     */
+    private Integer grade;
+
+    /**
+     * 规则名称
+     */
+    private String ruleName;
+
+    /**
+     * 规则描述
+     */
+    private String ruleDes;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 修改人
+     */
+    private String updateBy;
+
+    /**
+     * 创建时间
+     */
+    private LocalDate createTime;
+
+    /**
+     * 修改时间
+     */
+    private LocalDate updateTime;
+
+    /**
+     * 是否启用
+     */
+    private Boolean enable;
+
+
+}

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/entity/OrganizationEvaluationInfo.java

@@ -45,7 +45,7 @@ public class OrganizationEvaluationInfo extends Model {
     private String indicatorId;
 
     /**
-     * 指标编码
+     * 子指标id
      */
     private String indicatorDictionaryId;
 

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

@@ -89,6 +89,11 @@ public class OrganizationEvaluationInfoResDTO {
 	private String childName;
 
 	/**
+	 * 子指标code
+	 */
+	private String childCode;
+
+	/**
 	 * 指标项
 	 */
 	private String optionName;

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/schedule/ScoreCalculationSchedule.java

@@ -180,7 +180,7 @@ public class ScoreCalculationSchedule {
 				//添加计算指标项的code和值  例如:差值最大值和最小值
 				OrganizationEvaluation organizationEvaluation = organizationEvaluationMapper.selectById(list.get(0).getOrganizationEvaluationId());
 				OrganizationEvaluationRule organizationEvaluationRule = organizationEvaluationRuleMapper.selectById(list.get(0).getOrganizationEvaluationRuleId());
-				List<CalculateIndicatorItemInfo> calculateIndicatorItemInfos = calculateIndicatorItemInfoMapper.selectList(organizationEvaluation.getOrganizationType(),organizationEvaluation.getCheckCycle(),organizationEvaluation.getYear(),organizationEvaluation.getMonth(),organizationEvaluationRule.getBinSection(),"");
+				List<CalculateIndicatorItemInfo> calculateIndicatorItemInfos = calculateIndicatorItemInfoMapper.selectList(organizationEvaluation.getOrganizationType(),organizationEvaluation.getCheckCycle(),organizationEvaluation.getYear(),organizationEvaluation.getMonth(),organizationEvaluationRule.getBinSection(),"","");
 				if (calculateIndicatorItemInfos.size() < 0){
 					throw new CustomException("计算指标项为空");
 				}

+ 16 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IEvaluationWarningInfoService.java

@@ -0,0 +1,16 @@
+package com.ims.eval.service;
+
+import com.ims.eval.entity.EvaluationWarningInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+public interface IEvaluationWarningInfoService extends IService<EvaluationWarningInfo> {
+
+}

+ 16 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IEvaluationWarningRuleService.java

@@ -0,0 +1,16 @@
+package com.ims.eval.service;
+
+import com.ims.eval.entity.EvaluationWarningRule;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+public interface IEvaluationWarningRuleService extends IService<EvaluationWarningRule> {
+
+}

+ 75 - 61
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/CalculateIndicatorItemInfoServiceImpl.java

@@ -67,7 +67,7 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 							calculateIndicatorItemInfo.setCheckCycle(organizationEvaluationResDTO.getCheckCycle());
 							calculateIndicatorItemInfo.setYear(organizationEvaluationResDTO.getYear());
 							calculateIndicatorItemInfo.setMonth(organizationEvaluationResDTO.getMonth());
-							calculateIndicatorItemInfo.setOrganizationEvaluationId(organizationEvaluationResDTO.getId());
+//							calculateIndicatorItemInfo.setOrganizationEvaluationId(organizationEvaluationResDTO.getId());
 							list.add(calculateIndicatorItemInfo);
 						}
 					}
@@ -81,23 +81,26 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 	@Override
 	public int saveIndicatorInfoDTO(List<OrganizationEvaluationInfoResDTO> infoResDTOS) throws Exception {
 		List<CalculateIndicatorItemInfo> list = new ArrayList<>();
-
 		OrganizationEvaluationResDTO organizationEvaluationResDTO = organizationEvaluationMapper.selectById(infoResDTOS.get(0).getOrganizationEvaluationId());
-		//对考评规则id进行分组
-				//对指标id进行分组
-					for (OrganizationEvaluationInfoResDTO r : infoResDTOS){
-						if (r.getOptionCode().equals("CZ") || 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(organizationEvaluationResDTO.getId());
-							list.add(calculateIndicatorItemInfo);
+		Map<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropList = infoResDTOS.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getChildCode));
+
+		for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
+			//对指标id进行分组
+			for (OrganizationEvaluationInfoResDTO r : childCodeGropListEntry.getValue()){
+				if (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);
+				}
 			}
 		}
 
@@ -106,62 +109,73 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 
 
 	@Transactional
-	public int saveCalculate(List<CalculateIndicatorItemInfo> list) throws Exception {
+	public int saveCalculate(List<CalculateIndicatorItemInfo> listall) throws Exception {
 
-		if (list.size() > 0){
+		if (listall.size() > 0){
 
-			//判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
-			List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList(list.get(0).getOrganizationType(),list.get(0).getCheckCycle(),list.get(0).getYear(),list.get(0).getMonth(),list.get(0).getSectionId(),list.get(0).getOrganizationEvaluationId());
 
-			if (calculateIndicatorItemInfo.size() > 0){
-				List<String> idList = calculateIndicatorItemInfo.stream().map(CalculateIndicatorItemInfo::getId).collect(Collectors.toList());
-				calculateIndicatorItemInfoMapper.deleteBatchIds(idList);
-			}
+			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());
 
-			//遍历list解析最大值和最小值
-			Map<String, List<CalculateIndicatorItemInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItemInfo::getOptionCode));
-			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;
+				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
 						}
-						return 0; //相等为0
-					}
-				});
+					});
 
-				CalculateIndicatorItemInfo maxNum =  (CalculateIndicatorItemInfo)listEntry.getValue().get(listEntry.getValue().size()-1).clone();
-				maxNum.setMark("1");
+					CalculateIndicatorItemInfo maxNum =  (CalculateIndicatorItemInfo)listEntry.getValue().get(listEntry.getValue().size()-1).clone();
+					maxNum.setMark("1");
 
-				CalculateIndicatorItemInfo minNum  = (CalculateIndicatorItemInfo)listEntry.getValue().get(0).clone();
+					CalculateIndicatorItemInfo minNum  = (CalculateIndicatorItemInfo)listEntry.getValue().get(0).clone();
 
-				minNum.setMark("0");
+					minNum.setMark("0");
 
 
-				if (listEntry.getKey().equals("CZ")){
-					//存储最大值
-					maxNum.setOptionCode("CZMAX");
-					minNum.setOptionCode("CZMIN");
-				}else if (listEntry.getKey().equals("LRGXL")){
-					maxNum.setOptionCode("LRGXKLMAX");
-					minNum.setOptionCode("LRGXKLMIN");
-				}else if (listEntry.getKey().equals("DWQWLR")){
-					maxNum.setOptionCode("DWQWLRMAX");
-					minNum.setOptionCode("DWQWLRMIN");
-				}
-				int insert = calculateIndicatorItemInfoMapper.insert(maxNum);
+					if (listEntry.getKey().equals("CZ")){
+						//存储最大值
+						maxNum.setOptionCode("CZMAX");
+						minNum.setOptionCode("CZMIN");
+					}else if (listEntry.getKey().equals("LRGXL")){
+						maxNum.setOptionCode("LRGXKLMAX");
+						minNum.setOptionCode("LRGXKLMIN");
+					}else if (listEntry.getKey().equals("DWQWLR")){
+						maxNum.setOptionCode("DWQWLRMAX");
+						minNum.setOptionCode("DWQWLRMIN");
+					}else if (listEntry.getKey().equals("LRGXKH")){
+						maxNum.setOptionCode("LRGXKHMAX");
+						minNum.setOptionCode("LRGXKHMIN");
+					}
+
+
+					int insert = calculateIndicatorItemInfoMapper.insert(maxNum);
 
-				int insert1 = calculateIndicatorItemInfoMapper.insert(minNum);
-				System.out.println(insert1);
+					int insert1 = calculateIndicatorItemInfoMapper.insert(minNum);
+					System.out.println(insert1);
+				}
 			}
+
 		}else {
 			throw new Exception("计算指标项明细为空");
 		}

+ 20 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationWarningInfoServiceImpl.java

@@ -0,0 +1,20 @@
+package com.ims.eval.service.impl;
+
+import com.ims.eval.entity.EvaluationWarningInfo;
+import com.ims.eval.dao.EvaluationWarningInfoMapper;
+import com.ims.eval.service.IEvaluationWarningInfoService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+@Service
+public class EvaluationWarningInfoServiceImpl extends ServiceImpl<EvaluationWarningInfoMapper, EvaluationWarningInfo> implements IEvaluationWarningInfoService {
+
+}

+ 20 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluationWarningRuleServiceImpl.java

@@ -0,0 +1,20 @@
+package com.ims.eval.service.impl;
+
+import com.ims.eval.entity.EvaluationWarningRule;
+import com.ims.eval.dao.EvaluationWarningRuleMapper;
+import com.ims.eval.service.IEvaluationWarningRuleService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author wang
+ * @since 2023-05-19
+ */
+@Service
+public class EvaluationWarningRuleServiceImpl extends ServiceImpl<EvaluationWarningRuleMapper, EvaluationWarningRule> implements IEvaluationWarningRuleService {
+
+}

+ 94 - 37
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationInfoServiceImpl.java

@@ -4,23 +4,21 @@ import com.ims.common.utils.Constant;
 import com.ims.common.utils.FormulaUtils;
 import com.ims.common.utils.StringUtils;
 import com.ims.eval.config.CustomException;
-import com.ims.eval.entity.IndicatorDictionary;
-import com.ims.eval.entity.Myuser;
-import com.ims.eval.entity.OrganizationEvaluationInfo;
+import com.ims.eval.dao.CalculateIndicatorItemInfoMapper;
+import com.ims.eval.entity.*;
 import com.ims.eval.dao.OrganizationEvaluationInfoMapper;
 import com.ims.eval.entity.dto.response.MyuserResDTO;
 import com.ims.eval.entity.dto.response.OrganizationEvaluationInfoResDTO;
 import com.ims.eval.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -34,6 +32,7 @@ import java.util.stream.Collectors;
  * @since 2023-03-16
  */
 @Service
+@Log4j2
 public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<OrganizationEvaluationInfoMapper, OrganizationEvaluationInfo> implements IOrganizationEvaluationInfoService {
 
 	@Autowired
@@ -48,6 +47,11 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 
 	@Autowired
 	private IEvaluationScoreCountService iEvaluatioinScoreCountService;
+
+
+	@Autowired
+	private CalculateIndicatorItemInfoMapper calculateIndicatorItemInfoMapper;
+
 	@Override
 	public Map finishValueList(String organizationEvaluationId, String dept, HttpServletRequest request) {
 
@@ -207,58 +211,111 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 					Map<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropList = binSectionGropEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getIndicatorId));
 
 
+					//计算前置属性(差值、利润贡献、单位千瓦利润)的最大最小值
 					for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropListEntry : indicatorGropList.entrySet()){
-	//					List<OrganizationEvaluationInfoResDTO> indicator = indicatorGropListEntry.getValue();
 
+						if (indicatorGropListEntry.getValue().size() > 0){
+							//按照公司规则分组
+							Map<String, List<OrganizationEvaluationInfoResDTO>> ruleIdGropList = indicatorGropListEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getOrganizationEvaluationRuleId));
+
+							//遍历公司指标
+							for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> ruleIdGropListEntry : ruleIdGropList.entrySet()){
+								if (ruleIdGropListEntry.getValue().size() > 0) {
+
+									List<OrganizationEvaluationInfoResDTO> indicator = ruleIdGropListEntry.getValue();
+									Map<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropList = indicator.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getChildCode));
+
+									double totalScore = 0.00;
+									for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
+										for (OrganizationEvaluationInfoResDTO dto : childCodeGropListEntry.getValue()) {
+
+											if ((!dto.getOptionCode().equals("CZ") && !dto.getOptionCode().equals("LRGXL") && !dto.getOptionCode().equals("DWQWLR")) || StringUtils.isEmpty(dto.getFormula())) {
+												continue;//当前属性没有配置公式跳过
+											}
+
+											for (OrganizationEvaluationInfoResDTO f : childCodeGropListEntry.getValue()) {
+												dto.setFormula(dto.getFormula().replace("[" + f.getOptionCode() + "]", f.getQuantifiedValue() + ""));
+											}
+											double score = FormulaUtils.caculateFormula(dto.getFormula());
+											if (StringUtils.inStringIgnoreCase("DF", dto.getOptionCode())) {
+												totalScore = totalScore + score;
+											}
+											log.info(dto.getOrganizationShortName() + "|" + dto.getChildName()+"|"+dto.getOptionCode() + "----------" + dto.getFormula() + "=" + score);
+											OrganizationEvaluationInfo info = baseMapper.selectById(dto.getId());
+											//将计算结果保存
+											info.setQuantifiedValue(score);
+											dto.setQuantifiedValue(score);
+											this.saveOrUpdate(info);
+										}
+								}
+								}
+							}
+						}
 						//计算差值等的最大值最小值
-						//iCalculateIndicatorItemInfoService.saveIndicatorInfoDTO(indicatorGropListEntry.getValue());
+						iCalculateIndicatorItemInfoService.saveIndicatorInfoDTO(indicatorGropListEntry.getValue());
+					}
 
 
+//					//计算前置属性(差值、利润贡献、单位千瓦利润)的最大最小值
+					for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> indicatorGropListEntry : indicatorGropList.entrySet()){
+						for (OrganizationEvaluationInfoResDTO d : indicatorGropListEntry.getValue()){
+							System.out.println(d.getOrganizationShortName()+"|"+d.getIndicatorName()+"|"+d.getOptionName()+"|"+d.getQuantifiedValue());
+						}
 
 						if (indicatorGropListEntry.getValue().size() > 0){
 							//按照公司规则分组
 							Map<String, List<OrganizationEvaluationInfoResDTO>> ruleIdGropList = indicatorGropListEntry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getOrganizationEvaluationRuleId));
 
+
 							//遍历公司指标
 							for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> ruleIdGropListEntry : ruleIdGropList.entrySet()){
 								if (ruleIdGropListEntry.getValue().size() > 0){
 
 									List<OrganizationEvaluationInfoResDTO> indicator = ruleIdGropListEntry.getValue();
-//									EvaluationScoreCount scoreCount = new EvaluationScoreCount();
+									Map<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropList = indicator.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfoResDTO::getChildCode));
 									double totalScore = 0.00;
-									for (OrganizationEvaluationInfoResDTO dto: indicator){
-										if(!optionCode.equals(dto.getOptionCode()) ||"DF".equals(dto.getOptionCode()) || "DF2".equals(dto.getOptionCode()) || StringUtils.isEmpty(dto.getFormula())){
-											continue;//当前属性没有配置公式跳过
-										}
-//										System.out.println("**************"+dto.getFormula());
-										for (OrganizationEvaluationInfoResDTO f : indicator){
-											if(f.getOptionCode().endsWith("MIN") || f.getOptionCode().endsWith("MAX")){
-												//查询对应的最大值和最小值
-											}
+									EvaluationScoreCount scoreCount = new EvaluationScoreCount();
 
-											dto.setFormula(dto.getFormula().replace("["+f.getOptionCode()+"]", f.getQuantifiedValue() + ""));
-//											System.out.println("----------"+dto.getFormula());
+									for (Map.Entry<String, List<OrganizationEvaluationInfoResDTO>> childCodeGropListEntry : childCodeGropList.entrySet()){
 
+										List<CalculateIndicatorItemInfo> calculateIndicatorItemInfo = calculateIndicatorItemInfoMapper.selectList("","","","","",childCodeGropListEntry.getValue().get(0).getOrganizationEvaluationId(),childCodeGropListEntry.getValue().get(0).getChildCode());
+										Map<String ,Double>  map = new HashMap<>();
+										for (CalculateIndicatorItemInfo itemInfo :calculateIndicatorItemInfo){
+											map.put(itemInfo.getOptionCode(),itemInfo.getQuantifiedValue());
 										}
-//										scoreCount.setIndicatorId(dto.getIndicatorId());
-//										scoreCount.setOrganizationEvaluationRuleId(dto.getOrganizationEvaluationRuleId());
-//										scoreCount.setOrganizationEvaluationId(dto.getOrganizationEvaluationId());
-
-										System.out.print(dto.getOrganizationShortName()+"|"+dto.getIndicatorName()+"----------"+dto.getFormula()+"=");
-										double score = FormulaUtils.caculateFormula(dto.getFormula());
-										if(StringUtils.inStringIgnoreCase("DF",dto.getOptionCode())){
-											totalScore = totalScore+score;
+										for (OrganizationEvaluationInfoResDTO dto: childCodeGropListEntry.getValue()){
+											if ((dto.getOptionCode().endsWith("MAX") ||dto.getOptionCode().endsWith("MIN")
+												||dto.getOptionCode().equals("CZ") || dto.getOptionCode().equals("LRGXL")
+												|| dto.getOptionCode().equals("DWQWLR")) || StringUtils.isEmpty(dto.getFormula())){
+												continue;//当前属性没有配置公式跳过或者不需要参与此次计算的属性
+											}
+											scoreCount.setOrganizationEvaluationId(dto.getOrganizationEvaluationId());
+											scoreCount.setOrganizationEvaluationRuleId(dto.getOrganizationEvaluationRuleId());
+											scoreCount.setIndicatorId(dto.getIndicatorId());
+											for (OrganizationEvaluationInfoResDTO f : indicator){
+												if(f.getOptionCode().endsWith("MIN") || f.getOptionCode().endsWith("MAX")){
+													f.setQuantifiedValue(map.get(f.getOptionCode()));
+												}
+												dto.setFormula(dto.getFormula().replace("["+f.getOptionCode()+"]", f.getQuantifiedValue() + ""));
+											}
+											double score = FormulaUtils.caculateFormula(dto.getFormula());
+											if(StringUtils.inStringIgnoreCase("DF",dto.getOptionCode())){
+												totalScore = totalScore+score;
+											}
+											log.info(dto.getOrganizationShortName()+"|"+dto.getIndicatorName()+"----------"+dto.getFormula()+"="+score);
+											OrganizationEvaluationInfo info  = baseMapper.selectById(dto.getId());
+											//将计算结果保存
+											info.setQuantifiedValue(score);
+											dto.setQuantifiedValue(score);
+											this.saveOrUpdate(info);
 										}
-										System.out.println(score);
-										OrganizationEvaluationInfo info  = baseMapper.selectById(dto.getId());
-										info.setQuantifiedValue(score);
-										this.saveOrUpdate(info);
 									}
-									//得分存入数据库
-//									scoreCount.setIsQuantified("1");
-//									scoreCount.setScore(totalScore);
-//									scoreCount.setObversionScore(totalScore);
-//									boolean save = iEvaluatioinScoreCountService.save(scoreCount);
+
+									log.info("综合得分:"+totalScore);
+									scoreCount.setScore(totalScore);
+									scoreCount.setObversionScore(totalScore);
+									scoreCount.setIsQuantified("1");
+									iEvaluatioinScoreCountService.save(scoreCount);
 								}
 							}
 						}

+ 5 - 0
ims-service/ims-eval/src/main/resources/mappers/CalculateIndicatorItemInfoMapper.xml

@@ -29,6 +29,11 @@
                 and a.organization_evaluation_id=#{organizationEvaluationId}
             </if>
 
+            <if test="childCode !=null and childCode !=''">
+                and a.child_code=#{childCode}
+            </if>
+
+
         </where>
     </select>
 

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

@@ -205,6 +205,7 @@
         it.type_name,
         i.indicator_name,
         id.child_name,
+        id.child_code,
         id.option_name,
         id.option_code,
         id.formula,