‘xugp преди 2 години
родител
ревизия
cb7ac287e6

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

@@ -1,5 +1,9 @@
 package com.ims.eval.controller;
 
+import com.ims.eval.entity.Function;
+import com.ims.eval.entity.SelfMathFormulaEnum;
+import com.ims.eval.entity.dto.result.R;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -14,15 +18,30 @@ import java.util.List;
  * @version: $
  */
 
+@Slf4j
 @RestController
 @RequestMapping("//function")
 public class FunctionController {
 
 
 	@RequestMapping(value = "list")
-	public List<String> functionList(){
-		List<String> list = new ArrayList<>();
+	public R functionList(){
 
-		return list;
+		List<Function> functionList = new ArrayList<>();
+		try {
+			List<SelfMathFormulaEnum> selfMathFormulas = SelfMathFormulaEnum.getSelfMathFormulas();
+			selfMathFormulas.stream().forEach(r ->{
+				Function function = new Function();
+				function.setDescription(r.getDescription());
+				function.setFormulaArgCount(r.getFormulaArgCount());
+				function.setFormulaExpresion(r.getFormulaExpresion());
+				function.setFormulaNameLength(r.getFormulaNameLength());
+				function.setFormulaName(r.getFormulaName());
+				functionList.add(function);
+			});
+		}catch (Exception e){
+			log.info(e.getMessage());
+		}
+		return R.ok().data(functionList);
 	}
  }

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

@@ -29,7 +29,7 @@ public class EvaluationScoreCount extends Model {
     /**
      * 考评记录id
      */
-    private String organizationEvaluationID;
+    private String organizationEvaluationId;
 
     /**
      * 指标id

+ 40 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/Function.java

@@ -0,0 +1,40 @@
+package com.ims.eval.entity;
+
+import lombok.Data;
+
+/**
+ * @author :xugp
+ * @date :Created in 2023/3/20 12:28
+ * @description:函数实体
+ * @modified By:
+ * @version: $
+ */
+@Data
+public class Function {
+
+	/**
+	 * 公式名称
+	 **/
+	private String formulaName;
+
+	/**
+	 * 公式参数数量
+	 **/
+	private Integer formulaArgCount;
+
+	/**
+	 * 公式名称长度
+	 **/
+	private Integer formulaNameLength;
+
+	/**
+	 * 公式表达式
+	 **/
+	private String formulaExpresion;
+
+	/**
+	 * 公式描述
+	 **/
+	private String description;
+
+}

+ 167 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/entity/SelfMathFormulaEnum.java

@@ -0,0 +1,167 @@
+package com.ims.eval.entity;
+
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * 自定义数学公式枚举
+ **/
+public enum SelfMathFormulaEnum {
+
+		abs("abs", 1, 3, "abs()", "返回数的绝对值"),
+		acos("acos", 1, 4,"acos()", "返回数的反余弦值"),
+		asin("asin", 1, 4,"asin()", "返回数的反正弦值"),
+		atan("atan", 1, 4,"atan()", "以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值"),
+		ceil("ceil", 1, 4,"ceil()", "对数进行上舍入"),
+		cos("cos", 1, 3,"cos()", "返回数的余弦"),
+		exp("exp", 1, 3,"exp()", "返回 e 的指数"),
+		floor("floor", 1, 5,"floor()", "对数进行下舍入"),
+		log("log", 1, 3,"log()", "返回数的自然对数(底为e)"),
+		max("max", 2, 3,"max()", "返回 x 和 y 中的最高值"),
+		min("min", 2, 3,"min()", "返回 x 和 y 中的最低值"),
+		pow("pow", 2, 3,"pow()", "返回 x 的 y 次幂"),
+		round("round", 1, 5,"round()", "把数四舍五入为最接近的整数"),
+		sin("sin", 1, 3,"sin()", "返回数的正弦"),
+		sqrt("sqrt", 1, 4,"sqrt()", "返回数的平方根"),
+		tan("tan", 1, 3,"tan()", "返回角的正切");
+
+
+		/**
+		 * 公式名称
+		 **/
+		private String formulaName;
+
+		/**
+		 * 公式参数数量
+		 **/
+		private Integer formulaArgCount;
+
+		/**
+		 * 公式名称长度
+		 **/
+		private Integer formulaNameLength;
+
+		/**
+		 * 公式表达式
+		 **/
+		private String formulaExpresion;
+
+		/**
+		 * 公式描述
+		 **/
+		private String description;
+
+		/**
+		 * @param formulaName
+		 * @param formulaArgCount
+		 * @return com.jxv.common.utils.MathCalculatorUtil.SelfMathFormulaEnum
+		 * @Author xugp
+		 * @Description 根据自定义公式名称,和参数数量返回匹配的枚举实体
+		 * @Date 2023/03/17 10:14
+		 **/
+		public static SelfMathFormulaEnum getSelfMathFormulaEnum(String formulaName, Integer formulaArgCount) {
+			for (SelfMathFormulaEnum selfMathFormulaEnum : SelfMathFormulaEnum.values()) {
+				if (selfMathFormulaEnum.getFormulaName().equals(formulaName) && selfMathFormulaEnum.getFormulaArgCount().equals(formulaArgCount)) {
+					return selfMathFormulaEnum;
+				}
+			}
+			return null;
+		}
+
+		/**
+		 * @Author xugp
+		 * @Description  根据名称获取函数名
+		 * @Date 2023/03/17 17:10
+		 * @param formulaName
+		 * @return com.jxv.common.utils.MathCalculatorUtil.SelfMathFormulaEnum
+		 **/
+		public static SelfMathFormulaEnum getSelfMathFormulaEnum(String formulaName) {
+			for (SelfMathFormulaEnum selfMathFormulaEnum : SelfMathFormulaEnum.values()) {
+				if (selfMathFormulaEnum.getFormulaName().equals(formulaName)) {
+					return selfMathFormulaEnum;
+				}
+			}
+			return null;
+		}
+
+		/**
+		 * @param
+		 * @return java.util.List<java.lang.String>
+		 * @Author xugp
+		 * @Description 获取自定义公式的简单名称集合
+		 * @Date 2023/03/17 14:44
+		 **/
+		public static List<String> getSelfMathFormulaNames() {
+			List<String> formulaNames = new ArrayList<>();
+			for (SelfMathFormulaEnum selfMathFormulaEnum : SelfMathFormulaEnum.values()) {
+				formulaNames.add(selfMathFormulaEnum.getFormulaName());
+			}
+			return formulaNames;
+		}
+
+		/**
+		 * @Author xugp
+		 * @Description  获取所有的自定义函数枚举
+		 * @Date 2021/1/6 10:27
+		 * @param
+		 * @return java.util.List<com.jxv.common.utils.MathCalculatorUtil.SelfMathFormulaEnum>
+		 **/
+		public static List<SelfMathFormulaEnum> getSelfMathFormulas() {
+			List<SelfMathFormulaEnum> formulaNames = new ArrayList<>();
+			for (SelfMathFormulaEnum selfMathFormulaEnum : SelfMathFormulaEnum.values()) {
+				formulaNames.add(selfMathFormulaEnum);
+			}
+			return formulaNames;
+		}
+
+
+		 SelfMathFormulaEnum(String formulaName, Integer formulaArgCount, Integer formulaNameLength, String formulaExpresion, String description) {
+			this.formulaName = formulaName;
+			this.formulaArgCount = formulaArgCount;
+			this.formulaNameLength = formulaNameLength;
+			this.formulaExpresion = formulaExpresion;
+			this.description = description;
+		}
+
+		public Integer getFormulaNameLength() {
+			return formulaNameLength;
+		}
+
+		public void setFormulaNameLength(Integer formulaNameLength) {
+			this.formulaNameLength = formulaNameLength;
+		}
+
+		public String getFormulaName() {
+			return formulaName;
+		}
+
+		public void setFormulaName(String formulaName) {
+			this.formulaName = formulaName;
+		}
+
+		public Integer getFormulaArgCount() {
+			return formulaArgCount;
+		}
+
+		public void setFormulaArgCount(Integer formulaArgCount) {
+			this.formulaArgCount = formulaArgCount;
+		}
+
+		public String getFormulaExpresion() {
+			return formulaExpresion;
+		}
+
+		public void setFormulaExpresion(String formulaExpresion) {
+			this.formulaExpresion = formulaExpresion;
+		}
+
+		public String getDescription() {
+			return description;
+		}
+
+		public void setDescription(String description) {
+			this.description = description;
+		}
+	}

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

@@ -75,7 +75,7 @@ public class ScoreCalculationSchedule {
 								log.info(indicator.getIndicatorCode()+"得分为" + calculation);
 								//将得分存入考评得分统计表
 								EvaluationScoreCount evaluationScoreCount = new EvaluationScoreCount();
-								evaluationScoreCount.setOrganizationEvaluationID(entry.getKey());
+								evaluationScoreCount.setOrganizationEvaluationId(entry.getKey());
 								evaluationScoreCount.setIndicatorId(listEntry.getKey());
 								evaluationScoreCount.setScore(calculation);
 								save = iEvaluatioinScoreCountService.save(evaluationScoreCount);

+ 4 - 168
ims-service/ims-eval/src/main/java/com/ims/eval/util/MathCalculatorUtil.java

@@ -1,6 +1,7 @@
 package com.ims.eval.util;
 
 import com.alibaba.fastjson.JSON;
+import com.ims.eval.entity.SelfMathFormulaEnum;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -12,8 +13,6 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.util.*;
 
-import static com.ims.eval.util.MathCalculatorUtil.SelfMathFormulaEnum.getSelfMathFormulaEnum;
-import static com.ims.eval.util.MathCalculatorUtil.SelfMathFormulaEnum.getSelfMathFormulaNames;
 
 /**
  * @Author xugp
@@ -48,168 +47,6 @@ public class MathCalculatorUtil {
 
 
 
-	/**
-	 * 自定义数学公式枚举
-	 **/
-	enum SelfMathFormulaEnum {
-
-
-		abs("abs", 1, 3, "abs(x)", "返回数的绝对值"),
-		acos("acos", 1, 4,"acos(x)", "返回数的反余弦值"),
-		asin("asin", 1, 4,"asin(x)", "返回数的反正弦值"),
-		atan("atan", 1, 4,"atan(x)", "以介于 -PI/2 与 PI/2 弧度之间的数值来返回 x 的反正切值"),
-		ceil("ceil", 1, 4,"ceil(x)", "对数进行上舍入"),
-		cos("cos", 1, 3,"cos(x)", "返回数的余弦"),
-		exp("exp", 1, 3,"exp(x)", "返回 e 的指数"),
-		floor("floor", 1, 5,"floor(x)", "对数进行下舍入"),
-		log("log", 1, 3,"log(x)", "返回数的自然对数(底为e)"),
-		max("max", 2, 3,"max(x,y)", "返回 x 和 y 中的最高值"),
-		min("min", 2, 3,"min(x,y)", "返回 x 和 y 中的最低值"),
-		pow("pow", 2, 3,"pow(x,y)", "返回 x 的 y 次幂"),
-		round("round", 1, 5,"round(x)", "把数四舍五入为最接近的整数"),
-		sin("sin", 1, 3,"sin(x)", "返回数的正弦"),
-		sqrt("sqrt", 1, 4,"sqrt(x)", "返回数的平方根"),
-		tan("tan", 1, 3,"tan(x)", "返回角的正切");
-
-
-		/**
-		 * 公式名称
-		 **/
-		private String formulaName;
-
-		/**
-		 * 公式参数数量
-		 **/
-		private Integer formulaArgCount;
-
-		/**
-		 * 公式名称长度
-		 **/
-		private Integer formulaNameLength;
-
-		/**
-		 * 公式表达式
-		 **/
-		private String formulaExpresion;
-
-		/**
-		 * 公式描述
-		 **/
-		private String description;
-
-		/**
-		 * @param formulaName
-		 * @param formulaArgCount
-		 * @return com.jxv.common.utils.MathCalculatorUtil.SelfMathFormulaEnum
-		 * @Author xugp
-		 * @Description 根据自定义公式名称,和参数数量返回匹配的枚举实体
-		 * @Date 2023/03/17 10:14
-		 **/
-		public static SelfMathFormulaEnum getSelfMathFormulaEnum(String formulaName, Integer formulaArgCount) {
-			for (SelfMathFormulaEnum selfMathFormulaEnum : SelfMathFormulaEnum.values()) {
-				if (selfMathFormulaEnum.getFormulaName().equals(formulaName) && selfMathFormulaEnum.getFormulaArgCount().equals(formulaArgCount)) {
-					return selfMathFormulaEnum;
-				}
-			}
-			return null;
-		}
-
-		/**
-		 * @Author xugp
-		 * @Description  根据名称获取函数名
-		 * @Date 2023/03/17 17:10
-		 * @param formulaName
-		 * @return com.jxv.common.utils.MathCalculatorUtil.SelfMathFormulaEnum
-		 **/
-		public static SelfMathFormulaEnum getSelfMathFormulaEnum(String formulaName) {
-			for (SelfMathFormulaEnum selfMathFormulaEnum : SelfMathFormulaEnum.values()) {
-				if (selfMathFormulaEnum.getFormulaName().equals(formulaName)) {
-					return selfMathFormulaEnum;
-				}
-			}
-			return null;
-		}
-
-		/**
-		 * @param
-		 * @return java.util.List<java.lang.String>
-		 * @Author xugp
-		 * @Description 获取自定义公式的简单名称集合
-		 * @Date 2023/03/17 14:44
-		 **/
-		public static List<String> getSelfMathFormulaNames() {
-			List<String> formulaNames = new ArrayList<>();
-			for (SelfMathFormulaEnum selfMathFormulaEnum : SelfMathFormulaEnum.values()) {
-				formulaNames.add(selfMathFormulaEnum.getFormulaName());
-			}
-			return formulaNames;
-		}
-
-		/**
-		 * @Author xugp
-		 * @Description  获取所有的自定义函数枚举
-		 * @Date 2021/1/6 10:27
-		 * @param
-		 * @return java.util.List<com.jxv.common.utils.MathCalculatorUtil.SelfMathFormulaEnum>
-		 **/
-		public static List<SelfMathFormulaEnum> getSelfMathFormulas() {
-			List<SelfMathFormulaEnum> formulaNames = new ArrayList<>();
-			for (SelfMathFormulaEnum selfMathFormulaEnum : SelfMathFormulaEnum.values()) {
-				formulaNames.add(selfMathFormulaEnum);
-			}
-			return formulaNames;
-		}
-
-
-		SelfMathFormulaEnum(String formulaName, Integer formulaArgCount, Integer formulaNameLength, String formulaExpresion, String description) {
-			this.formulaName = formulaName;
-			this.formulaArgCount = formulaArgCount;
-			this.formulaNameLength = formulaNameLength;
-			this.formulaExpresion = formulaExpresion;
-			this.description = description;
-		}
-
-		public Integer getFormulaNameLength() {
-			return formulaNameLength;
-		}
-
-		public void setFormulaNameLength(Integer formulaNameLength) {
-			this.formulaNameLength = formulaNameLength;
-		}
-
-		public String getFormulaName() {
-			return formulaName;
-		}
-
-		public void setFormulaName(String formulaName) {
-			this.formulaName = formulaName;
-		}
-
-		public Integer getFormulaArgCount() {
-			return formulaArgCount;
-		}
-
-		public void setFormulaArgCount(Integer formulaArgCount) {
-			this.formulaArgCount = formulaArgCount;
-		}
-
-		public String getFormulaExpresion() {
-			return formulaExpresion;
-		}
-
-		public void setFormulaExpresion(String formulaExpresion) {
-			this.formulaExpresion = formulaExpresion;
-		}
-
-		public String getDescription() {
-			return description;
-		}
-
-		public void setDescription(String description) {
-			this.description = description;
-		}
-	}
-
 
 	/**
 	 * JavaScript脚本引擎,Java SE 6开始支持
@@ -442,7 +279,7 @@ public class MathCalculatorUtil {
 				}
 			}
 			//将sb带入自定义公式进行校验
-			List<String> selfMathFormulaNames = getSelfMathFormulaNames();
+			List<String> selfMathFormulaNames = SelfMathFormulaEnum.getSelfMathFormulaNames();
 			if (!selfMathFormulaNames.contains(sb.reverse().toString())) {
 				throw new RuntimeException("非法逗号!");
 			}
@@ -509,7 +346,7 @@ public class MathCalculatorUtil {
 	 * @Date 2020/12/30 15:09
 	 **/
 	private static void checkSelfMathMark(String mathStr, int argCount) {
-		SelfMathFormulaEnum selfMathFormulaEnum = getSelfMathFormulaEnum(mathStr, argCount);
+		SelfMathFormulaEnum selfMathFormulaEnum = SelfMathFormulaEnum.getSelfMathFormulaEnum(mathStr, argCount);
 		if (selfMathFormulaEnum == null) {
 			throw new RuntimeException("自定义数学公式不匹配!");
 		}
@@ -709,7 +546,6 @@ public class MathCalculatorUtil {
 	}
 
 
-
 	/**
 	 * @Author xugp
 	 * @Description  去除自定义公式,todo 待优化
@@ -776,7 +612,7 @@ public class MathCalculatorUtil {
 		}
 		String[] args = digitStr.split(",", -1);
 
-		SelfMathFormulaEnum selfMathFormulaEnum = getSelfMathFormulaEnum(mathFormulaName);
+		SelfMathFormulaEnum selfMathFormulaEnum = SelfMathFormulaEnum.getSelfMathFormulaEnum(mathFormulaName);
 		if (selfMathFormulaEnum == null) {
 			throw new RuntimeException("非法数学公式名称");
 		}