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

View File

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