|
@@ -164,12 +164,18 @@ public class PostgreSQLClient implements ApplicationRunner {
|
|
|
// 高低限判断
|
|
|
if ("1".equals(ybIfFs)){
|
|
|
// 如果 仪表值 大于上限 或者 小于下限 则状态为 异常;两种情况不会同时满足
|
|
|
- if (Integer.parseInt(ybValueTag) > Integer.parseInt(upperLimit) || Integer.parseInt(ybValueTag) < Integer.parseInt(lowerLimit)){
|
|
|
+ //if (Integer.parseInt(ybValueTag) > Integer.parseInt(upperLimit) || Integer.parseInt(ybValueTag) < Integer.parseInt(lowerLimit)){
|
|
|
+ // ybStatus = "1";
|
|
|
+ //}
|
|
|
+ BigDecimal ybValueTagDecimal = new BigDecimal(ybValueTag);
|
|
|
+ BigDecimal upperLimitDecimal = new BigDecimal(upperLimit);
|
|
|
+ BigDecimal lowerLimitDecimal = new BigDecimal(lowerLimit);
|
|
|
+ if ((ybValueTagDecimal.compareTo(upperLimitDecimal) > 0) || (ybValueTagDecimal.compareTo(lowerLimitDecimal) < 0)) {
|
|
|
ybStatus = "1";
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- // 突变超限判断 规定时间内 (结束值-初始值)/初始值 * 100 百分比 是否大于 规定的阈值
|
|
|
+ // 突变超限判断 规定时间内 (结束值-初始值)/初始值 * 100 百分比 是否大于 (高限-底限) * 阈值
|
|
|
if ("2".equals(ybIfFs)){
|
|
|
// 如果 采集的频率 大于 规定的时间
|
|
|
// 例如 采集是一分钟采集一次 规定的时间的2s之内
|
|
@@ -182,15 +188,20 @@ public class PostgreSQLClient implements ApplicationRunner {
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
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); // 开始时间 规定时间的开始时间
|
|
|
QueryWrapper<InterlockTag> tagQuery = new QueryWrapper<>();
|
|
|
tagQuery.eq("interlock_condition_id",id).eq("parameter_type","8");
|
|
|
InterlockTag interlockTag = tagService.getOne(tagQuery);
|
|
|
IotedgeCollectData iotedgeData = iotedgeCollectDataService.getOneInfo(interlockTag.getDeviceId(),interlockTag.getModuleName(),interlockTag.getTagName(),beginDate);
|
|
|
- BigDecimal beginValue = BigDecimal.valueOf(Integer.parseInt(iotedgeData.getValue()));
|
|
|
- BigDecimal num = BigDecimal.valueOf(Integer.parseInt(ybValueTag)).subtract(beginValue);
|
|
|
- if ((num.divide(beginValue).compareTo(BigDecimal.valueOf(Integer.parseInt(yz)))) > 0){
|
|
|
+ BigDecimal beginValue = BigDecimal.valueOf(Double.parseDouble(iotedgeData.getValue()));
|
|
|
+ BigDecimal num = BigDecimal.valueOf(Double.parseDouble(ybValueTag)).subtract(beginValue);
|
|
|
+ // (高限-底限) * 阈值 (数据库中的阈值是去掉百分比的直接乘即可)
|
|
|
+ BigDecimal up = BigDecimal.valueOf(Double.parseDouble(upperLimit));
|
|
|
+ BigDecimal lower = BigDecimal.valueOf(Double.parseDouble(lowerLimit));
|
|
|
+ BigDecimal number = up.subtract(lower);
|
|
|
+ BigDecimal newYz = number.multiply(BigDecimal.valueOf(Double.parseDouble(yz)));
|
|
|
+ if ((num.divide(beginValue).compareTo(newYz)) > 0){
|
|
|
ybStatus = "1";
|
|
|
}
|
|
|
}
|