Browse Source

Merge remote-tracking branch 'origin/master'

wangchangsheng 1 year ago
parent
commit
fbcebb6eb0

+ 3 - 3
ims-service/ims-eval/src/main/java/com/ims/eval/controller/IntervalScoringTableController.java

@@ -59,10 +59,10 @@ public class IntervalScoringTableController {
 			String decode = URLDecoder.decode(intervalScoringTable.getRange(), "UTF-8");
 			String s = decode.replaceAll(" ", "+");
 			intervalScoringTable.setRange(s);
-			String regularExpression = intervalScoringTable.getRegularExpression();
 			//字符串空格替换
-			regularExpression.replaceAll("","+");
-			intervalScoringTable.setRegularExpression(regularExpression);
+			String decode1 = URLDecoder.decode(intervalScoringTable.getRegularExpression(), "UTF-8");
+			String s1 = decode1.replaceAll("", "+");
+			intervalScoringTable.setRegularExpression(s);
 			boolean b = intervalScoringTableService.saveOrUpdate(intervalScoringTable);
 			if (b) {
 				return R.ok().data(b);

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

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

+ 5 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/EvaluationScoreCount.java

@@ -33,6 +33,11 @@ public class EvaluationScoreCount extends Model {
      */
     private String organizationEvaluationId;
 
+	/**
+	 * 考评规则id
+	 */
+	private String organizationEvaluationRuleId;
+
     /**
      * 指标id
      */

+ 65 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/OrganizationIndicatorItmeInfo.java

@@ -0,0 +1,65 @@
+package com.ims.eval.entity;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+
+/**
+ * @author :xugp
+ * @date :Created in 2023/3/25 16:43
+ * @description:考评指标项明细
+ * @modified By:
+ * @version: $
+ */
+
+@Data
+public class OrganizationIndicatorItmeInfo extends Model {
+
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 主键id
+	 */
+	private String id;
+
+	/**
+	 * 指标id
+	 */
+	private String indicatorId;
+
+	/**
+	 * 生成经营id
+	 */
+	private String sectionId;
+
+	/**
+	 * 差值最小值
+	 */
+	private String minnum;
+
+	/**
+	 * 差值最大值
+	 */
+	private String maxnum;
+
+	/**
+	 * 利润贡献考核最小值
+	 */
+	private String minLrgxl;
+
+	/**
+	 * 利润贡献考核最大值
+	 */
+	private String maxLrgxl;
+
+	/**
+	 * 单位利润千瓦最小值
+	 */
+	private String minDwlrqw;
+
+	/**
+	 * 单位利润千瓦最大值
+	 */
+	private String maxDwlrqw;
+
+
+}

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

@@ -26,7 +26,9 @@ public enum SelfMathFormulaEnum {
 		sin("sin", 1, 3,"sin()", "返回数的正弦"),
 		sqrt("sqrt", 1, 4,"sqrt()", "返回数的平方根"),
 		tan("tan", 1, 3,"tan()", "返回角的正切"),
-	    ifs("if",3, 2,"if(,,)", "if表达式");
+	    ifs("if",3, 2,"if(,,)", "if表达式"),
+		maxnum("maxnum",1,6,"maxnum()","返回一组数据的最大值"),
+	    minnum("maxnum",1,6,"minnum()","返回一组数据的最小值");
 
 
 		/**

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

@@ -44,6 +44,9 @@ public class ScoreCalculationSchedule {
 	private IndicatorMapper indicatorMapper;
 
 	@Autowired
+	private OrganizationEvaluationMapper organizationEvaluationMapper;
+
+	@Autowired
 	private IEvaluationScoreCountService iEvaluatioinScoreCountService;
 
 	/*@Scheduled(cron = "* 10 11 ? * 3")*/
@@ -51,40 +54,54 @@ public class ScoreCalculationSchedule {
 
 		boolean save = true;
 		try {
-			//加载考评指标明细数据
-			QueryWrapper<OrganizationEvaluationInfo> qw = new QueryWrapper<>();
-			List<OrganizationEvaluationInfo> organizationEvaluationInfos= organizationEvaluationInfoMapper.selectList(qw);
-			if (organizationEvaluationInfos.size() > 0){
-				//对考评记录id进行分组
-				Map<String, List<OrganizationEvaluationInfo>> collect = organizationEvaluationInfos.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getOrganizationEvaluationId));
-				for (Map.Entry<String, List<OrganizationEvaluationInfo>> entry : collect.entrySet()){
-					//对指标id进行分组
-					if (entry.getValue().size() > 0){
-						Map<String, List<OrganizationEvaluationInfo>> collectIn = entry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getIndicatorId));
-						for (Map.Entry<String, List<OrganizationEvaluationInfo>> listEntry : collectIn.entrySet()){
-							Indicator indicator = indicatorMapper.selectById(listEntry.getKey());
-							QueryWrapper<EvaluationScoringRule> e = new QueryWrapper<>();
-							if (StringUtils.isNotEmpty(indicator.getIndicatorCode())) {
-								e.lambda().eq(EvaluationScoringRule::getIndicatorId,indicator.getIndicatorCode());
-							}
-							EvaluationScoringRule evaluationScoringRule = evaluationScoringRuleMapper.selectOne(e);
-							if (evaluationScoringRule != null){
-								String calculation = replace(listEntry.getValue(), evaluationScoringRule);
-								log.info(indicator.getIndicatorCode()+"得分为" + calculation);
-								//将得分存入考评得分统计表
-								EvaluationScoreCount evaluationScoreCount = EvaluationScoreCount.builder()
-									.indicatorId(listEntry.getKey())
-									.organizationEvaluationId(entry.getKey())
-									.score(calculation)
-									.build();
-								save = iEvaluatioinScoreCountService.save(evaluationScoreCount);
+
+			//加载单位/部门考评记录
+			//todo 后续添加查询条件
+			QueryWrapper<OrganizationEvaluation> or = new QueryWrapper<>();
+			List<OrganizationEvaluation> organizationEvaluations = organizationEvaluationMapper.selectList(or);
+			if (organizationEvaluations.size() <= 0){
+				throw new Exception("考评记录为空!!!");
+			}
+			for (OrganizationEvaluation organizationEvaluation : organizationEvaluations){
+				//加载该考评记录下的考评指标明细数据
+				QueryWrapper<OrganizationEvaluationInfo> qw = new QueryWrapper<>();
+				if (StringUtils.isNotEmpty(organizationEvaluation.getOrganizationEvaluationRuleId())) {
+					qw.lambda().in(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId,organizationEvaluation.getOrganizationEvaluationRuleId());
+				}
+				List<OrganizationEvaluationInfo> organizationEvaluationInfos= organizationEvaluationInfoMapper.selectList(qw);
+				if (organizationEvaluationInfos.size() > 0){
+					//对考评规则id进行分组
+					Map<String, List<OrganizationEvaluationInfo>> collect = organizationEvaluationInfos.stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getOrganizationEvaluationRuleId));
+					for (Map.Entry<String, List<OrganizationEvaluationInfo>> entry : collect.entrySet()){
+						//对指标id进行分组
+						if (entry.getValue().size() > 0){
+							Map<String, List<OrganizationEvaluationInfo>> collectIn = entry.getValue().stream().collect(Collectors.groupingBy(OrganizationEvaluationInfo::getIndicatorId));
+							for (Map.Entry<String, List<OrganizationEvaluationInfo>> listEntry : collectIn.entrySet()){
+								Indicator indicator = indicatorMapper.selectById(listEntry.getKey());
+								QueryWrapper<EvaluationScoringRule> e = new QueryWrapper<>();
+								if (StringUtils.isNotEmpty(indicator.getIndicatorCode())) {
+									e.lambda().eq(EvaluationScoringRule::getIndicatorId,indicator.getIndicatorCode());
+								}
+								EvaluationScoringRule evaluationScoringRule = evaluationScoringRuleMapper.selectOne(e);
+								if (evaluationScoringRule != null){
+									String calculation = replace(listEntry.getValue(), evaluationScoringRule);
+									log.info(indicator.getIndicatorCode()+"得分为" + calculation);
+									//将得分存入考评得分统计表
+									EvaluationScoreCount evaluationScoreCount = EvaluationScoreCount.builder()
+										.indicatorId(listEntry.getKey())
+										.organizationEvaluationRuleId(entry.getKey())
+										.organizationEvaluationId(organizationEvaluation.getId())
+										.score(calculation)
+										.build();
+									save = iEvaluatioinScoreCountService.save(evaluationScoreCount);
+								}
 							}
 						}
 					}
-				}
 
-			}else {
-				throw new Exception("考评指标明细数据为空!!");
+				}else {
+					throw new Exception("考评指标明细数据为空!!");
+				}
 			}
 
 		}catch (Exception e){
@@ -107,6 +124,7 @@ public class ScoreCalculationSchedule {
 			List<IntervalScoringTable> intervalScoringTables = intervalScoringTableMapper.selectList(qw);
 			for (Map.Entry<String, Double> entry : doubleMap.entrySet()){
 				intervalScoringTables.stream().forEach(r ->{
+
 					r.setRange(r.getRange().replaceAll(entry.getKey(), entry.getValue() + ""));
 					r.setRegularExpression(r.getRegularExpression().replaceAll(entry.getKey(),entry.getValue() + ""));
 				});
@@ -178,51 +196,57 @@ public class ScoreCalculationSchedule {
 
 
 
-//	public static void main(String[] args) {
-//
-//
-//		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)";
-//		ArrayList<Token> tokens = Analyzer.getTokens(s4);
-//
-//		//使用不同编码代替函数
-//		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 = "max(sc,sd)+maxnum(sc)";
+		boolean contains = sc.contains("maxnum");
+
+		System.out.println(contains);
+
+		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(s4);
+
+		//使用不同编码代替函数
+		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);
+
+	}
 
 }

+ 7 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/util/MathCalculatorUtil.java

@@ -673,6 +673,9 @@ public class MathCalculatorUtil {
 			case sqrt:
 				result = Math.sqrt(Double.parseDouble(args[0]));
 				break;
+			case tan:
+				result = Math.tan(Double.parseDouble(args[0]));
+				break;
 			case ifs:
 				if (args[0].equals("1")) {
 					String calculator = calculator(args[1]);
@@ -681,7 +684,10 @@ public class MathCalculatorUtil {
 					result  = Double.valueOf(calculator(args[2]));
 				}
 				break;
-			case tan:
+			case maxnum:
+				result = Math.tan(Double.parseDouble(args[0]));
+				break;
+			case minnum:
 				result = Math.tan(Double.parseDouble(args[0]));
 				break;
 			default: