2 Коміти db4f21635f ... 12e6abc9d4

Автор SHA1 Опис Дата
  ‘xugp 12e6abc9d4 Merge remote-tracking branch 'origin/master' 1 рік тому
  ‘xugp 36646b841e 新增各个指标项差值,特殊指标项计算代码 1 рік тому

+ 2 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/dao/OrganizationEvaluationInfoMapper.java

@@ -25,4 +25,6 @@ public interface OrganizationEvaluationInfoMapper extends BaseMapper<Organizatio
 	List<OrganizationEvaluationInfoResDTO> selectListEvaluationInfoId(@Param("organizationEvaluationId") String organizationEvaluationId,
 																	  @Param("dept") String dept,
 																	  @Param("optionCode") String optionCode);
+
+	List<OrganizationEvaluationInfo> selectByEvaluationInfoId(@Param("organizationEvaluationId") String organizationEvaluationId);
 }

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

@@ -205,55 +205,55 @@ public class ScoreCalculationSchedule {
 
 
 
-//	public static void main(String[] args) {
-//
-//
-//		String sc = "maxnum(1)";
-//
-//
-//		String s2 = "if(if(2>0,max(1,2)+20,min(1,3)+10)>11,12,if(2<0,min(5,4)+1,max(1,3)+2))";
-//
-//		String s4 = "if(0.01<0,-0.01*2/min(1,0.07)+10,1/1*2/max(4,0.07)+10)";
-//		String s5 = "1+if(if(1<0,-1*2/min(2,1)+10,1*2/max(2,1)+10)>12,12,if(1<0,-1*2/min(2,1)+10,1*2/max(2,1)+10))";
-//		String s3 = "if(abs(99)<=5%,if(abs(99)>=1%,(5%-abs(99))/1%*0.25+5,6),if(abs(99)<=10%,(5%-abs(99))/1%*0.2+5,4))+if(99==0,5,if(99>0,6,4))";
-//		/*String sd = "max(1,min(1,2))";
-//		String sc = MathCalculatorUtil.calculator(sd);*/
-//		String ss = "if(max(1,3)<1,1,2)";
-//		String s9 = "maxmin()";
-//		ArrayList<Token> tokens = Analyzer.getTokens(sc);
-//
-//		//使用不同编码代替函数
-//		AlarmExpression alarmExpression = Analyzer.createAlarmExpression(tokens);
-//		if (alarmExpression.getVarList() != null && alarmExpression.getVarList().size() > 0) {
-//			List<AlarmExpression> alarmExpressions = alarmExpression.getChildren();
-//			for (AlarmExpression alarmExpression1 : alarmExpressions){
-//				if (alarmExpression1.getChildren().size() > 0 && alarmExpression1.getChildren() != null){
-//					for (AlarmExpression alarmExpression2 : alarmExpression1.getChildren()){
-//						if (alarmExpression2.getChildren().size() > 0 && alarmExpression2.getChildren() != null){
-//							List<AlarmExpression> al = alarmExpression2.getChildren();
-//							for (AlarmExpression alarmExpression3 : al){
-//								String calculator = MathCalculatorUtil.calculator(alarmExpression3.getExpression());
-//								alarmExpression2.setExpression(alarmExpression2.getExpression().replaceAll(alarmExpression3.getFunCode(), calculator));
-//							}
-//						}
-//						String calculator = MathCalculatorUtil.calculator(alarmExpression2.getExpression());
-//						alarmExpression1.setExpression(alarmExpression1.getExpression().replaceAll(alarmExpression2.getFunCode(), calculator));
-//					}
-//					String calculator = MathCalculatorUtil.calculator(alarmExpression1.getExpression());
-//					alarmExpression.setExpression(alarmExpression.getExpression().replaceAll(alarmExpression1.getFunCode(), calculator));
-//				}else {
-//					String calculator = MathCalculatorUtil.calculator(alarmExpression1.getExpression());
-//					alarmExpression.setExpression(alarmExpression.getExpression().replaceAll(alarmExpression1.getFunCode(), calculator));
-//				}
-//			}
-//		}
-////		Map<String,Object> map = new HashMap<>();
-////		Object o = ScriptShell.parseExpr(alarmExpression.getExpression(), map);
-////		System.out.println(o);
-//		//判断表达式返回结果
-//		String calculator = MathCalculatorUtil.calculator(alarmExpression.getExpression());
-//		System.out.println(calculator);
-//
-//	}
+	public static void main(String[] args) {
+
+
+		String sc = "if(1>0,-1*1/maxnum(1)+5,1*1/minnum(2)+5)*2";
+
+
+		String s2 = "if(1>0,-1*2/maxnum(2)+10,1*2/minnum(1)+10)";
+
+		String s4 = "if(0.01<0,-0.01*2/min(1,0.07)+10,1/1*2/max(4,0.07)+10)";
+		String s5 = "1+if(if(1<0,-1*2/min(2,1)+10,1*2/max(2,1)+10)>12,12,if(1<0,-1*2/min(2,1)+10,1*2/max(2,1)+10))";
+		String s3 = "if(abs(99)<=5%,if(abs(99)>=1%,(5%-abs(99))/1%*0.25+5,6),if(abs(99)<=10%,(5%-abs(99))/1%*0.2+5,4))+if(99==0,5,if(99>0,6,4))";
+		/*String sd = "max(1,min(1,2))";
+		String sc = MathCalculatorUtil.calculator(sd);*/
+		String ss = "if(max(1,3)<1,1,2)";
+		String s9 = "maxmin()";
+		ArrayList<Token> tokens = Analyzer.getTokens(s2);
+
+		//使用不同编码代替函数
+		AlarmExpression alarmExpression = Analyzer.createAlarmExpression(tokens);
+		if (alarmExpression.getVarList() != null && alarmExpression.getVarList().size() > 0) {
+			List<AlarmExpression> alarmExpressions = alarmExpression.getChildren();
+			for (AlarmExpression alarmExpression1 : alarmExpressions){
+				if (alarmExpression1.getChildren().size() > 0 && alarmExpression1.getChildren() != null){
+					for (AlarmExpression alarmExpression2 : alarmExpression1.getChildren()){
+						if (alarmExpression2.getChildren().size() > 0 && alarmExpression2.getChildren() != null){
+							List<AlarmExpression> al = alarmExpression2.getChildren();
+							for (AlarmExpression alarmExpression3 : al){
+								String calculator = MathCalculatorUtil.calculator(alarmExpression3.getExpression());
+								alarmExpression2.setExpression(alarmExpression2.getExpression().replaceAll(alarmExpression3.getFunCode(), calculator));
+							}
+						}
+						String calculator = MathCalculatorUtil.calculator(alarmExpression2.getExpression());
+						alarmExpression1.setExpression(alarmExpression1.getExpression().replaceAll(alarmExpression2.getFunCode(), calculator));
+					}
+					String calculator = MathCalculatorUtil.calculator(alarmExpression1.getExpression());
+					alarmExpression.setExpression(alarmExpression.getExpression().replaceAll(alarmExpression1.getFunCode(), calculator));
+				}else {
+					String calculator = MathCalculatorUtil.calculator(alarmExpression1.getExpression());
+					alarmExpression.setExpression(alarmExpression.getExpression().replaceAll(alarmExpression1.getFunCode(), calculator));
+				}
+			}
+		}
+//		Map<String,Object> map = new HashMap<>();
+//		Object o = ScriptShell.parseExpr(alarmExpression.getExpression(), map);
+//		System.out.println(o);
+		//判断表达式返回结果
+		String calculator = MathCalculatorUtil.calculator(alarmExpression.getExpression());
+		System.out.println(calculator);
+
+	}
 
 }

+ 49 - 20
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/CalculateIndicatorItemInfoServiceImpl.java

@@ -108,33 +108,62 @@ public class CalculateIndicatorItemInfoServiceImpl extends ServiceImpl<Calculate
 
 
 	public int saveCalculate(List<CalculateIndicatorItmeInfo> list) throws Exception {
+
 		//遍历list解析最大值和最小值
 		if (list.size() > 0){
 			Map<String, List<CalculateIndicatorItmeInfo>> collect = list.stream().collect(Collectors.groupingBy(CalculateIndicatorItmeInfo::getOptionCode));
 			for (Map.Entry<String, List<CalculateIndicatorItmeInfo>> listEntry : collect.entrySet()){
 				CalculateIndicatorItmeInfo maxNum = listEntry.getValue().stream().max(Comparator.comparing(CalculateIndicatorItmeInfo::getQuantifiedValue)).get();
-				CalculateIndicatorItmeInfo minNum = listEntry.getValue().stream().min(Comparator.comparing(CalculateIndicatorItmeInfo::getQuantifiedValue)).get();
-				if (listEntry.getKey().equals("CZ")){
-					//存储最大值
-					maxNum.setOptionCode("CZMAX");
-					calculateIndicatorItemInfoMapper.insert(maxNum);
-					//存储最小值
-					maxNum.setOptionCode("CZMIN");
-					calculateIndicatorItemInfoMapper.insert(minNum);
-				}else if (listEntry.getKey().equals("LRGXKL")){
-					maxNum.setOptionCode("LRGXKLMAX");
-					calculateIndicatorItemInfoMapper.insert(maxNum);
-					//存储最小值
-					maxNum.setOptionCode("LRGXKLMIN");
-					calculateIndicatorItemInfoMapper.insert(minNum);
-				}else if (listEntry.getKey().equals("DWQWLR")){
-					maxNum.setOptionCode("DWQWLRMAX");
-					calculateIndicatorItemInfoMapper.insert(maxNum);
-					//存储最小值
-					maxNum.setOptionCode("DWQWLRMIN");
-					calculateIndicatorItemInfoMapper.insert(minNum);
+				//判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
+				QueryWrapper<CalculateIndicatorItmeInfo> qw = new QueryWrapper<>();
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getYear, maxNum.getYear());
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getMonth, maxNum.getMonth());
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getOptionCode, maxNum.getOptionCode());
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getCheckCycle, maxNum.getCheckCycle());
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getOrganizationType, maxNum.getOrganizationType());
+				CalculateIndicatorItmeInfo calculateIndicatorItmeInfo = calculateIndicatorItemInfoMapper.selectOne(qw);
+				if (calculateIndicatorItmeInfo != null){
+					calculateIndicatorItemInfoMapper.deleteById(calculateIndicatorItmeInfo.getId());
+				}else {
+					if (listEntry.getKey().equals("CZ")){
+						//存储最大值
+						maxNum.setOptionCode("CZMAX");
+						calculateIndicatorItemInfoMapper.insert(maxNum);
+					}else if (listEntry.getKey().equals("LRGXKL")){
+						maxNum.setOptionCode("LRGXKLMAX");
+						calculateIndicatorItemInfoMapper.insert(maxNum);
+					}else if (listEntry.getKey().equals("DWQWLR")){
+						maxNum.setOptionCode("DWQWLRMAX");
+						calculateIndicatorItemInfoMapper.insert(maxNum);
+					}
 				}
 
+				CalculateIndicatorItmeInfo minNum = listEntry.getValue().stream().min(Comparator.comparing(CalculateIndicatorItmeInfo::getQuantifiedValue)).get();
+				//判断计算指标明细中之前是否存在记录 如果存在删除之前记录,重新新增
+				QueryWrapper<CalculateIndicatorItmeInfo> qw1 = new QueryWrapper<>();
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getYear, minNum.getYear());
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getMonth, minNum.getMonth());
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getOptionCode, minNum.getOptionCode());
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getCheckCycle, minNum.getCheckCycle());
+				qw.lambda().eq(CalculateIndicatorItmeInfo::getOrganizationType, minNum.getOrganizationType());
+				CalculateIndicatorItmeInfo calculateIndicatorItmeInfo1 = calculateIndicatorItemInfoMapper.selectOne(qw1);
+				if (calculateIndicatorItmeInfo1 != null){
+					calculateIndicatorItemInfoMapper.deleteById(calculateIndicatorItmeInfo1.getId());
+				}else {
+					if (listEntry.getKey().equals("CZ")){
+						//存储最小值
+						maxNum.setOptionCode("CZMIN");
+						calculateIndicatorItemInfoMapper.insert(minNum);
+					}else if (listEntry.getKey().equals("LRGXKL")){
+						//存储最小值
+						maxNum.setOptionCode("LRGXKLMIN");
+						calculateIndicatorItemInfoMapper.insert(minNum);
+					}else if (listEntry.getKey().equals("DWQWLR")){
+						//存储最小值
+						maxNum.setOptionCode("DWQWLRMIN");
+						calculateIndicatorItemInfoMapper.insert(minNum);
+					}
+				}
 			}
 		}else {
 			throw new Exception("计算指标项明细为空");

+ 59 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationInfoServiceImpl.java

@@ -13,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 import java.util.Map;
@@ -59,6 +60,64 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 				throw new CustomException("更新失败");
 			}
 		}
+
+		OrganizationEvaluationInfo organizationEvaluationInfo = baseMapper.selectById(evaluationInfoUpdateDTOS.get(0).getId());
+		//查询本次考评所有考评指标明细
+		List<OrganizationEvaluationInfo> organizationEvaluationInfos = baseMapper.selectByEvaluationInfoId(organizationEvaluationInfo.getOrganizationEvaluationId());
+		//根据考评规则分组
+		Map<String, List<OrganizationEvaluationInfo>> collect1 = organizationEvaluationInfos.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId));
+		for (Map.Entry<String, List<OrganizationEvaluationInfo>> entry1 : collect1.entrySet()){
+			//根据指标id分组
+			Map<String, List<OrganizationEvaluationInfo>> collect = entry1.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getIndicatorId));
+			for(Map.Entry<String, List<OrganizationEvaluationInfo>> entry : collect.entrySet()){
+				//过滤差值考评指标明细
+				List<OrganizationEvaluationInfo> cz = entry.getValue().stream().filter(r -> r.getOptionCode().equals("CZ")).collect(Collectors.toList());
+				if (cz.size() == 1){
+					List<OrganizationEvaluationInfo> wcz = entry.getValue().stream().filter(r -> r.getOptionCode().equals("WCZ")).collect(Collectors.toList());
+					List<OrganizationEvaluationInfo> value = entry.getValue().stream().filter(r -> r.getOptionCode().equals("JHZ") || r.getOptionCode().equals("DBZ") || r.getOptionCode().equals("MBZ")).collect(Collectors.toList());
+
+					//todo  后续添加需要计算的指标项
+					//完成值与目标值 ||计划值||对标值进行计算
+					if (wcz.size() == 1 && value.size() == 1){
+						double wczValue = wcz.get(0).getQuantifiedValue();
+						double dbzvalue = value.get(0).getQuantifiedValue();
+						cz.get(0).setQuantifiedValue(wczValue - dbzvalue);
+						cz.get(0).setCreateTime(new Date());
+						boolean b = super.saveOrUpdate(cz.get(0));
+						if(!b){
+							throw new CustomException("更新失败");
+						}
+					}
+				}
+
+				//过滤单位千瓦利润考评指标明细
+				List<OrganizationEvaluationInfo> dwqwlr = entry.getValue().stream().filter(r -> r.getOptionCode().equals("DWQWLR")).collect(Collectors.toList());
+				if (dwqwlr.size() == 1){
+					List<OrganizationEvaluationInfo> lrgxl = entry.getValue().stream().filter(r -> r.getOptionCode().equals("LRGXL")).collect(Collectors.toList());
+					List<OrganizationEvaluationInfo> zjrl = entry.getValue().stream().filter(r -> r.getOptionCode().equals("ZJRL")).collect(Collectors.toList());
+
+					//完成值与目标值 ||计划值||对标值进行计算
+					if (lrgxl.size() == 1 && zjrl.size() == 1){
+						double wczValue = lrgxl.get(0).getQuantifiedValue();
+						double dbzvalue = zjrl.get(0).getQuantifiedValue();
+						if (dbzvalue == 0 || dbzvalue == 0.0){
+							throw new CustomException("被除数不能为零");
+						}else{
+							//double保留两位小数
+							double v = new BigDecimal(wczValue / dbzvalue).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
+							dwqwlr.get(0).setQuantifiedValue(v);
+							dwqwlr.get(0).setCreateTime(new Date());
+							boolean b = super.saveOrUpdate(dwqwlr.get(0));
+							if(!b){
+								throw new CustomException("更新失败");
+							}
+						}
+					}
+				}
+
+			}
+		}
+
 		return true;
 	}
 }

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

@@ -73,4 +73,17 @@
 
     </select>
 
+
+    <select id="selectByEvaluationInfoId" resultType="com.ims.eval.entity.OrganizationEvaluationInfo">
+        SELECT
+        *
+        FROM
+        organization_evaluation_info a
+        <where>
+            1=1
+            <if test="organizationEvaluationId !=null and organizationEvaluationId !=''">
+                and a.organization_evaluation_id=#{organizationEvaluationId}
+            </if>
+        </where>
+    </select>
 </mapper>