|
@@ -180,6 +180,9 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
|
|
|
interlockTagService.save(createInterlockTag(interlockAddDTO.getDeviceId(),interlockAddDTO.getModuleName(), interlockAddDTO.getInterlockOutValueTag(), interlockAddDTO.getInterlockOutValue(), InterlockConstants.INTERLOCK_OUT_VALUE,summaryId,summaryId));
|
|
|
|
|
|
for (InterlockDetailAddDTO dto : interlockDetailAddDTOList){
|
|
|
+ //TODO
|
|
|
+ dto.setThresholdTimeUnit("s");
|
|
|
+
|
|
|
dto.setSummaryid(summaryId);
|
|
|
|
|
|
//联锁状态 0未投用1投用; 旁路状态是多个的话,任何一个旁路是1(是),则联锁状态是0未投用。
|
|
@@ -187,39 +190,48 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
|
|
|
|
|
|
//仪表状态:0正常1故障
|
|
|
if(dto.getInstrumentStatusJuge()!=null){
|
|
|
- if("0".equals(dto.getInstrumentStatusJuge())){ //0直接读取位号
|
|
|
+ if("0".equals(dto.getInstrumentStatusJuge())){
|
|
|
+ //0直接读取位号
|
|
|
dto.setInstrumentStatus(dto.getInstrumentStatusValue());
|
|
|
- } else if("1".equals(dto.getInstrumentStatusJuge())){ //1高低限判断
|
|
|
+
|
|
|
+ } else if("1".equals(dto.getInstrumentStatusJuge())){
|
|
|
+ //1高低限判断
|
|
|
BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue());
|
|
|
BigDecimal lowerLimit = new BigDecimal(dto.getLowerLimit());
|
|
|
BigDecimal upperLimit = new BigDecimal(dto.getUpperLimit());
|
|
|
- if(ysmnlValue.compareTo(lowerLimit) == 1 && ysmnlValue.compareTo(upperLimit) == 1) dto.setInstrumentStatus("0");
|
|
|
+ if(ysmnlValue.compareTo(lowerLimit) >= 0 && ysmnlValue.compareTo(upperLimit) <= 0) dto.setInstrumentStatus("0");
|
|
|
else dto.setInstrumentStatus("1");
|
|
|
+
|
|
|
} else if("2".equals(dto.getInstrumentStatusJuge())){ //2突变超限判断
|
|
|
- //TODO 通过判断原始模拟量位号突变(与iotedge_collect_data表的数据进行比较???)超过某阈值得出值
|
|
|
- // 如果 采集的频率 大于 规定的时间
|
|
|
- // 例如 采集是一分钟采集一次 规定的时间的2s之内
|
|
|
- // 如果 采集的频率 小于等于 规定的时间
|
|
|
- // 例如 2S之内 去采集数据表中根据 设备id+模块名称+点位名称 查询2s之前的数据,但是表中的数据量大 时间?
|
|
|
-// BigDecimal yz = new BigDecimal(dto.getThresholdValue()); //阈值
|
|
|
+ //通过判断原始模拟量位号突变(与iotedge_collect_data表的数据进行比较)超过某阈值得出值
|
|
|
+ // 去采集数据表中根据 设备id+模块名称+点位名称 查询设置的s之前的数据
|
|
|
String yz = dto.getThresholdValue(); // 阈值
|
|
|
String time = dto.getThresholdTime(); // 规定的时间
|
|
|
String dw = dto.getThresholdTimeUnit(); // 时间单位
|
|
|
+
|
|
|
if ("s".equals(dw)){
|
|
|
- BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue()); // 本次原始模拟量值
|
|
|
+ // 本次原始模拟量值
|
|
|
+ BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue());
|
|
|
+
|
|
|
// 查询上一次原始模拟量值
|
|
|
String endDate = DateUtils.getDate("yyyy-MM-dd HH:mm:ss"); // 当前时间 规定时间的结束时间
|
|
|
LocalDateTime endDateTime = LocalDateTime.parse(endDate, formatter);
|
|
|
- LocalDateTime beginDateTime = endDateTime.minus(Duration.ofSeconds(2));
|
|
|
+ LocalDateTime beginDateTime = endDateTime.minus(Duration.ofSeconds(Long.parseLong(time)));
|
|
|
String beginDate = beginDateTime.format(formatter); // 开始时间 规定时间的开始时间
|
|
|
|
|
|
IotedgeCollectData iotedgeData = iotedgeCollectDataService.getOneInfo(dto.getYsmnlDeviceId(),dto.getYsmnlModuleName(),dto.getYsmnlTag(),beginDate);
|
|
|
- BigDecimal beginValue = BigDecimal.valueOf(Integer.parseInt(iotedgeData.getValue()));
|
|
|
- BigDecimal num = BigDecimal.valueOf(Integer.parseInt(dto.getYsmnlValue())).subtract(beginValue);
|
|
|
+ BigDecimal beginValue = new BigDecimal(iotedgeData.getValue());
|
|
|
+ BigDecimal num = ysmnlValue.subtract(beginValue);
|
|
|
+
|
|
|
+ // (高限-底限) * 阈值 (数据库中的阈值是去掉百分比的直接乘即可)
|
|
|
+ BigDecimal lowerLimit = new BigDecimal(dto.getLowerLimit());
|
|
|
+ BigDecimal upperLimit = new BigDecimal(dto.getUpperLimit());
|
|
|
|
|
|
- if ((num.divide(beginValue).compareTo(BigDecimal.valueOf(Integer.parseInt(yz)))) > 0){
|
|
|
+ BigDecimal number = upperLimit.subtract(lowerLimit);
|
|
|
+ BigDecimal newYz = number.multiply(new BigDecimal(yz));
|
|
|
+ if ((num.divide(beginValue).compareTo(newYz)) > 0){
|
|
|
dto.setInstrumentStatus("1"); //仪表状态(0正常1故障)
|
|
|
- }
|
|
|
+ }else dto.setInstrumentStatus("0");
|
|
|
}
|
|
|
|
|
|
|
|
@@ -289,6 +301,9 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
|
|
|
interlockTagService.save(createInterlockTag(interlockAddDTO.getDeviceId(),interlockAddDTO.getModuleName(), interlockAddDTO.getInterlockOutValueTag(), interlockAddDTO.getInterlockOutValue(), InterlockConstants.INTERLOCK_OUT_VALUE,summaryId,summaryId));
|
|
|
|
|
|
for (InterlockDetailAddDTO dto : interlockDetailAddDTOList){
|
|
|
+ //TODO
|
|
|
+ dto.setThresholdTimeUnit("s");
|
|
|
+
|
|
|
dto.setSummaryid(summaryId);
|
|
|
|
|
|
//联锁状态 0未投用1投用; 旁路状态是多个的话,任何一个旁路是1(是),则联锁状态是0未投用。
|
|
@@ -296,44 +311,53 @@ public class InterlockSummaryServiceImpl extends ServiceImpl<InterlockSummaryMap
|
|
|
|
|
|
//仪表状态:0正常1故障
|
|
|
if(dto.getInstrumentStatusJuge()!=null){
|
|
|
- if("0".equals(dto.getInstrumentStatusJuge())){ //0直接读取位号
|
|
|
+ if("0".equals(dto.getInstrumentStatusJuge())){
|
|
|
+ //0直接读取位号
|
|
|
dto.setInstrumentStatus(dto.getInstrumentStatusValue());
|
|
|
- } else if("1".equals(dto.getInstrumentStatusJuge())){ //1高低限判断
|
|
|
+
|
|
|
+ } else if("1".equals(dto.getInstrumentStatusJuge())){
|
|
|
+ //1高低限判断
|
|
|
BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue());
|
|
|
BigDecimal lowerLimit = new BigDecimal(dto.getLowerLimit());
|
|
|
BigDecimal upperLimit = new BigDecimal(dto.getUpperLimit());
|
|
|
- if(ysmnlValue.compareTo(lowerLimit) == 1 && ysmnlValue.compareTo(upperLimit) == 1) dto.setInstrumentStatus("0");
|
|
|
+ if(ysmnlValue.compareTo(lowerLimit) >= 0 && ysmnlValue.compareTo(upperLimit) <= 0) dto.setInstrumentStatus("0");
|
|
|
else dto.setInstrumentStatus("1");
|
|
|
+
|
|
|
} else if("2".equals(dto.getInstrumentStatusJuge())){ //2突变超限判断
|
|
|
- //TODO 通过判断原始模拟量位号突变(与iotedge_collect_data表的数据进行比较???)超过某阈值得出值
|
|
|
- // 如果 采集的频率 大于 规定的时间
|
|
|
- // 例如 采集是一分钟采集一次 规定的时间的2s之内
|
|
|
- // 如果 采集的频率 小于等于 规定的时间
|
|
|
- // 例如 2S之内 去采集数据表中根据 设备id+模块名称+点位名称 查询2s之前的数据,但是表中的数据量大 时间?
|
|
|
-// BigDecimal yz = new BigDecimal(dto.getThresholdValue()); //阈值
|
|
|
+ //通过判断原始模拟量位号突变(与iotedge_collect_data表的数据进行比较)超过某阈值得出值
|
|
|
+ // 去采集数据表中根据 设备id+模块名称+点位名称 查询设置的s之前的数据
|
|
|
String yz = dto.getThresholdValue(); // 阈值
|
|
|
String time = dto.getThresholdTime(); // 规定的时间
|
|
|
String dw = dto.getThresholdTimeUnit(); // 时间单位
|
|
|
+
|
|
|
if ("s".equals(dw)){
|
|
|
- BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue()); // 本次原始模拟量值
|
|
|
+ // 本次原始模拟量值
|
|
|
+ BigDecimal ysmnlValue = new BigDecimal(dto.getYsmnlValue());
|
|
|
+
|
|
|
// 查询上一次原始模拟量值
|
|
|
String endDate = DateUtils.getDate("yyyy-MM-dd HH:mm:ss"); // 当前时间 规定时间的结束时间
|
|
|
LocalDateTime endDateTime = LocalDateTime.parse(endDate, formatter);
|
|
|
- LocalDateTime beginDateTime = endDateTime.minus(Duration.ofSeconds(2));
|
|
|
+ LocalDateTime beginDateTime = endDateTime.minus(Duration.ofSeconds(Long.parseLong(time)));
|
|
|
String beginDate = beginDateTime.format(formatter); // 开始时间 规定时间的开始时间
|
|
|
|
|
|
IotedgeCollectData iotedgeData = iotedgeCollectDataService.getOneInfo(dto.getYsmnlDeviceId(),dto.getYsmnlModuleName(),dto.getYsmnlTag(),beginDate);
|
|
|
- BigDecimal beginValue = BigDecimal.valueOf(Integer.parseInt(iotedgeData.getValue()));
|
|
|
- BigDecimal num = BigDecimal.valueOf(Integer.parseInt(dto.getYsmnlValue())).subtract(beginValue);
|
|
|
+ BigDecimal beginValue = new BigDecimal(iotedgeData.getValue());
|
|
|
+ BigDecimal num = ysmnlValue.subtract(beginValue);
|
|
|
+
|
|
|
+ // (高限-底限) * 阈值 (数据库中的阈值是去掉百分比的直接乘即可)
|
|
|
+ BigDecimal lowerLimit = new BigDecimal(dto.getLowerLimit());
|
|
|
+ BigDecimal upperLimit = new BigDecimal(dto.getUpperLimit());
|
|
|
|
|
|
- if ((num.divide(beginValue).compareTo(BigDecimal.valueOf(Integer.parseInt(yz)))) > 0){
|
|
|
+ BigDecimal number = upperLimit.subtract(lowerLimit);
|
|
|
+ BigDecimal newYz = number.multiply(new BigDecimal(yz));
|
|
|
+ if ((num.divide(beginValue).compareTo(newYz)) > 0){
|
|
|
dto.setInstrumentStatus("1"); //仪表状态(0正常1故障)
|
|
|
- }
|
|
|
+ }else dto.setInstrumentStatus("0");
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
- if(dto.getInstrumentStatus().equals("1")) instrumentStatus = "1";
|
|
|
+ if(dto.getInstrumentStatus()!=null && dto.getInstrumentStatus().equals("1")) instrumentStatus = "1";
|
|
|
}
|
|
|
//控制系统状态 TODO
|
|
|
if("非正常".equals(dto.getMpStatus()) || "非正常".equals(dto.getMpStatus()) || "非正常".equals(dto.getMpStatus())) {
|