|
@@ -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);
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|