|
@@ -325,15 +325,36 @@ public class AlarmConditionServiceImpl extends ServiceImpl<AlarmConditionMapper,
|
|
displayFormula.append(formula.getLabel());
|
|
displayFormula.append(formula.getLabel());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- MonitorIndicator indicator = monitorIndicatorService.queryMonitorIndicatorDetail(infoCodes);
|
|
|
|
- String monitorUnit = monitorIndicator.getUnit();
|
|
|
|
- String unit = indicator.getUnit();
|
|
|
|
- if (monitorUnit != null && unit != null && !monitorUnit.equals(unit)) {
|
|
|
|
- return ResultHelper.failure(ResponseCode.C0134.getCode(), "选择的指标与单位指标不一致");
|
|
|
|
- } else if (monitorUnit == null || unit == null) {
|
|
|
|
- return ResultHelper.failure(ResponseCode.C0134.getCode(), "公式错误");
|
|
|
|
|
|
+ if(isNumeric(displayFormula.toString())){
|
|
|
|
+ if(formulas.size()==1){
|
|
|
|
+ return ResultHelper.success();
|
|
|
|
+ }else{
|
|
|
|
+ return ResultHelper.failure(ResponseCode.C0134.getCode(), "公式不合法");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if(!"".equals(infoCodes)){
|
|
|
|
+ MonitorIndicator indicator = monitorIndicatorService.queryMonitorIndicatorDetail(infoCodes);
|
|
|
|
+ String monitorUnit = monitorIndicator.getUnit();
|
|
|
|
+ String unit = indicator.getUnit();
|
|
|
|
+ if (monitorUnit != null && unit != null && !monitorUnit.equals(unit)) {
|
|
|
|
+ return ResultHelper.failure(ResponseCode.C0134.getCode(), "选择的指标与单位指标不一致");
|
|
|
|
+ } else if (monitorUnit == null || unit == null) {
|
|
|
|
+ return ResultHelper.failure(ResponseCode.C0134.getCode(), "公式错误");
|
|
|
|
+ }
|
|
|
|
+ return this.validate(displayFormula.toString(), infoCodes);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ResultHelper.failure(ResponseCode.C0134.getCode(), "公式不合法");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static boolean isNumeric(String str) {
|
|
|
|
+ for (int i = 0; i < str.length(); i++) {
|
|
|
|
+ System.out.println(str.charAt(i));
|
|
|
|
+ if (!Character.isDigit(str.charAt(i))) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- return this.validate(displayFormula.toString(), infoCodes);
|
|
|
|
|
|
+ return true;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|