|
@@ -291,15 +291,19 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
|
|
|
String beginDate = beginDateTime.format(formatter); // 开始时间 规定时间的开始时间
|
|
|
|
|
|
IotedgeCollectData iotedgeData = iotedgeCollectDataService.getOneInfo(interlockDetail.getYsmnlDeviceId(),interlockDetail.getYsmnlModuleName(),interlockDetail.getYsmnlTag(),beginDate);
|
|
|
- BigDecimal beginValue = new BigDecimal(iotedgeData.getValue());
|
|
|
- //如果原来的模拟量是0的话
|
|
|
- if(beginValue.equals(BigDecimal.ZERO)){
|
|
|
- beginValue=BigDecimal.valueOf(0.001);
|
|
|
- if(ysmnlValue.equals(BigDecimal.ZERO)){
|
|
|
- ysmnlValue=BigDecimal.valueOf(0.001);
|
|
|
- }
|
|
|
+ BigDecimal beginValue = new BigDecimal("0");
|
|
|
+ if(iotedgeData != null){
|
|
|
+ beginValue = new BigDecimal(iotedgeData.getValue());
|
|
|
}
|
|
|
- System.out.println("beginValue:" + beginValue);
|
|
|
+// BigDecimal beginValue = new BigDecimal(iotedgeData.getValue());
|
|
|
+// //如果原来的模拟量是0的话
|
|
|
+// if(beginValue.equals(BigDecimal.ZERO)){
|
|
|
+// beginValue=BigDecimal.valueOf(0.001);
|
|
|
+// if(ysmnlValue.equals(BigDecimal.ZERO)){
|
|
|
+// ysmnlValue=BigDecimal.valueOf(0.001);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// System.out.println("beginValue:" + beginValue);
|
|
|
BigDecimal num = ysmnlValue.subtract(beginValue);
|
|
|
|
|
|
// (高限-底限) * 阈值 (数据库中的阈值是去掉百分比的直接乘即可)
|
|
@@ -312,9 +316,17 @@ public class InterlockAvoidCircularServiceImpl implements InterlockAvoidCircular
|
|
|
// dto.setInstrumentStatus(instrumentStatusAbnormal); // 故障
|
|
|
// }else dto.setInstrumentStatus(instrumentStatusNormal); // 正常
|
|
|
//有可能出现无限循环小数,保留三位小数
|
|
|
- if ((num.divide(beginValue,2, RoundingMode.HALF_UP).compareTo(newYz)) > 0){
|
|
|
+ BigDecimal orgYz = new BigDecimal(100);//默认增量百分比为百分百
|
|
|
+ if(!beginValue.equals(new BigDecimal("0"))){
|
|
|
+ orgYz = num.divide(beginValue,2,RoundingMode.HALF_UP);
|
|
|
+ }
|
|
|
+ if ((orgYz.compareTo(newYz)) > 0){
|
|
|
interlockDetail.setInstrumentStatus(instrumentStatusAbnormal); // 故障
|
|
|
}else interlockDetail.setInstrumentStatus(instrumentStatusNormal); // 正常
|
|
|
+
|
|
|
+// if ((num.divide(beginValue,2, RoundingMode.HALF_UP).compareTo(newYz)) > 0){
|
|
|
+// interlockDetail.setInstrumentStatus(instrumentStatusAbnormal); // 故障
|
|
|
+// }else interlockDetail.setInstrumentStatus(instrumentStatusNormal); // 正常
|
|
|
}
|
|
|
} else if(InterlockAllStatus.INSTRUMENT_STATUS_JUDGE3.equals(interlockDetail.getInstrumentStatusJuge())){
|
|
|
//3默认正常
|