plc规则判断优化

This commit is contained in:
zhanghan11 2024-11-11 08:40:49 +08:00
parent b7ccb76e7a
commit 993471e7e2
2 changed files with 30 additions and 21 deletions

View File

@ -56,7 +56,7 @@ public class IpcRedisCacheConfiguration {
// 查询是否需要更新 // 查询是否需要更新
IpcCacheSync ipcCacheSync = new IpcCacheSync(deptId, null, model); IpcCacheSync ipcCacheSync = new IpcCacheSync(deptId, null, model);
List<IpcCacheSync> list = iIpcCacheSyncService.selectIpcCacheSyncList(ipcCacheSync); List<IpcCacheSync> list = iIpcCacheSyncService.selectIpcCacheSyncList(ipcCacheSync);
System.out.println("缓存更新"+list.size()+"---"+list.toString()); System.out.println("缓存更新"+deptId);
if(!list.isEmpty()){ if(!list.isEmpty()){
for(IpcCacheSync cacheSync:list){ for(IpcCacheSync cacheSync:list){
@ -81,7 +81,7 @@ public class IpcRedisCacheConfiguration {
public void deleteExpDataByDate(Integer params) public void deleteExpDataByDate(Integer params)
{ {
System.out.println("执行有参方法" + params); System.out.println("执行有参方法删除过期数据" + params);
InfluxDBService i = SpringUtils.getBean(InfluxDBService.class); InfluxDBService i = SpringUtils.getBean(InfluxDBService.class);
StringBuffer sql1 = new StringBuffer(""); StringBuffer sql1 = new StringBuffer("");
StringBuffer sql2 = new StringBuffer(""); StringBuffer sql2 = new StringBuffer("");

View File

@ -18,12 +18,12 @@ public class IpcUtil {
* 根据报警规则判断是否正常 * 根据报警规则判断是否正常
* *
* @param realValueObj 实际值 * @param realValueObj 实际值
* @param referenceValue1 参考值1 * @param alertUpperBound 参考值1上限值
* @param referenceValue2 参考值2 * @param alertLowerBound 参考值2下限值
* @param referenceCon 比较标准 * @param referenceCon 比较标准
* @return 是否报警 * @return 是否报警
*/ */
public static Boolean judgeAlarm(Object realValueObj, BigDecimal referenceValue1, BigDecimal referenceValue2, String referenceCon) { public static Boolean judgeAlarm(Object realValueObj, BigDecimal alertUpperBound, BigDecimal alertLowerBound, String referenceCon) {
// 是否报警 // 是否报警
Boolean flag = false; Boolean flag = false;
BigDecimal realValue; BigDecimal realValue;
@ -42,22 +42,31 @@ public class IpcUtil {
flag = true; flag = true;
return flag; return flag;
} }
if (IpcConstant.GREATER.equals(referenceCon)) { switch (referenceCon) {
flag = realValue.compareTo(referenceValue1) > 0; case IpcConstant.GREATER:
} else if (IpcConstant.GREATER_EQUAL.equals(referenceCon)) { flag = realValue.compareTo(alertUpperBound) > 0;
flag = realValue.compareTo(referenceValue1) >= 0; break;
} else if (IpcConstant.LESS.equals(referenceCon)) { case IpcConstant.GREATER_EQUAL:
flag = realValue.compareTo(referenceValue1) < 0; flag = realValue.compareTo(alertUpperBound) >= 0;
} else if (IpcConstant.LESS_EQUAL.equals(referenceCon)) { break;
flag = realValue.compareTo(referenceValue1) <= 0; case IpcConstant.LESS:
} else if (IpcConstant.EQUAL.equals(referenceCon)) { flag = realValue.compareTo(alertUpperBound) < 0;
flag = realValue.compareTo(referenceValue1) == 0; break;
} else if (IpcConstant.OUTSIDE_INTERVAL.equals(referenceCon)) { case IpcConstant.LESS_EQUAL:
flag = realValue.compareTo(referenceValue1) >= 0 && realValue.compareTo(referenceValue2) <= 0; flag = realValue.compareTo(alertUpperBound) <= 0;
} else if (IpcConstant.WIDTHIN_INTERVAL.equals(referenceCon)) { break;
flag = realValue.compareTo(referenceValue1) <= 0 || realValue.compareTo(referenceValue2) >= 0; case IpcConstant.EQUAL:
} else { flag = realValue.compareTo(alertUpperBound) == 0;
break;
case IpcConstant.WIDTHIN_INTERVAL:
flag = realValue.compareTo(alertLowerBound) >= 0 && realValue.compareTo(alertUpperBound) <= 0;
break;
case IpcConstant.OUTSIDE_INTERVAL:
flag = realValue.compareTo(alertLowerBound) <= 0 || realValue.compareTo(alertUpperBound) >= 0;
break;
default:
flag = true; flag = true;
break;
} }
return flag; return flag;
} }