From 993471e7e2c4971f94adff0efd18efcce7ab1dd4 Mon Sep 17 00:00:00 2001 From: zhanghan11 Date: Mon, 11 Nov 2024 08:40:49 +0800 Subject: [PATCH] =?UTF-8?q?plc=E8=A7=84=E5=88=99=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ipc/utils/IpcRedisCacheConfiguration.java | 4 +- .../java/com/inspur/ipc/utils/IpcUtil.java | 47 +++++++++++-------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcRedisCacheConfiguration.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcRedisCacheConfiguration.java index 65b87b9..0127f63 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcRedisCacheConfiguration.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcRedisCacheConfiguration.java @@ -56,7 +56,7 @@ public class IpcRedisCacheConfiguration { // 查询是否需要更新 IpcCacheSync ipcCacheSync = new IpcCacheSync(deptId, null, model); List 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(""); diff --git a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcUtil.java b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcUtil.java index f151e7e..8bab902 100644 --- a/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcUtil.java +++ b/tzipc-server/tzipc-system/src/main/java/com/inspur/ipc/utils/IpcUtil.java @@ -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 { - flag = true; + 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; }