Browse Source

新增 设备配置下发设备状态检测功能

zhaiyifei 10 months atrás
parent
commit
af56a20d03

+ 1 - 1
src/main/java/com/yunfeiyun/agmp/iots/warn/model/WarnQxSqInfoDto.java

@@ -10,7 +10,7 @@ import java.util.List;
 import java.util.Map;
 
 @Data
-public class WarnQxSqInfoDto {
+public class WarnInfoDto {
     private IotDevice iotDevice;
     private List<WarnConfigInfo> configList;
     private JSONObject jsonObject;

+ 34 - 34
src/main/java/com/yunfeiyun/agmp/iots/warn/service/WarnService.java

@@ -12,7 +12,7 @@ import com.yunfeiyun.agmp.iot.common.domain.IotWarnconfig;
 import com.yunfeiyun.agmp.iot.common.enums.EnumWarnRuleOp;
 import com.yunfeiyun.agmp.iots.service.IIotDevicefactorService;
 import com.yunfeiyun.agmp.iots.warn.model.WarnConfigInfo;
-import com.yunfeiyun.agmp.iots.warn.model.WarnQxSqInfoDto;
+import com.yunfeiyun.agmp.iots.warn.model.WarnInfoDto;
 import com.yunfeiyun.agmp.iots.warn.model.WarnResult;
 import com.yunfeiyun.agmp.iots.warn.model.WarnStatusDto;
 import com.yunfeiyun.agmp.iots.warn.util.CompareUtil;
@@ -107,23 +107,23 @@ public class WarnService {
                 List<WarnConfigInfo> configList = entry.getValue();
                 WarnResult warnResult = null;
 
-                WarnQxSqInfoDto warnQxSqInfoDto = new WarnQxSqInfoDto();
-                warnQxSqInfoDto.setIotDevice(iotDevice);
-                warnQxSqInfoDto.setConfigList(configList);
-                warnQxSqInfoDto.setJsonObject(data);
-                warnQxSqInfoDto.setFactorMap(factorMap);
-                warnQxSqInfoDto.setIotDeviceTypeLv1Enum(iotDeviceTypeLv1Enum);
+                WarnInfoDto warnInfoDto = new WarnInfoDto();
+                warnInfoDto.setIotDevice(iotDevice);
+                warnInfoDto.setConfigList(configList);
+                warnInfoDto.setJsonObject(data);
+                warnInfoDto.setFactorMap(factorMap);
+                warnInfoDto.setIotDeviceTypeLv1Enum(iotDeviceTypeLv1Enum);
 
                 try{
                     switch (iotDeviceTypeLv1Enum) {
                         case QXZ: {
-                            warnResult = comparableQxzReportData(warnQxSqInfoDto);
+                            warnResult = comparableQxzReportData(warnInfoDto);
+                            break;
+                        }
+                        case SQZ: {
+                            warnResult = comparableSqzReportData(warnInfoDto);
                             break;
                         }
-//                        case SQZ: {
-//                            warnResult = comparableSqzReportData(warnQxSqInfoDto);
-//                            break;
-//                        }
 //                        case GSSQ: {
 //                            warnResult = comparableGssqReportData(warnQxSqInfoDto);
 //                            break;
@@ -218,12 +218,12 @@ public class WarnService {
         return wiName;
     }
 
-    private WarnStatusDto getQxzWarnStatusDto(WarnConfigInfo config, WarnQxSqInfoDto warnQxSqInfoDto) {
-        IotDevice iotDevice = warnQxSqInfoDto.getIotDevice();
+    private WarnStatusDto getQxzWarnStatusDto(WarnConfigInfo config, WarnInfoDto warnInfoDto) {
+        IotDevice iotDevice = warnInfoDto.getIotDevice();
         String devCode = iotDevice.getDevCode();
-        Map<String, String> currentValueMap = warnQxSqInfoDto.getCurrentValueMap();
-        Map<String, IotDevicefactor> factorMap = warnQxSqInfoDto.getFactorMap();
-        IotDeviceTypeLv1Enum iotDeviceTypeLv1Enum = warnQxSqInfoDto.getIotDeviceTypeLv1Enum();
+        Map<String, String> currentValueMap = warnInfoDto.getCurrentValueMap();
+        Map<String, IotDevicefactor> factorMap = warnInfoDto.getFactorMap();
+        IotDeviceTypeLv1Enum iotDeviceTypeLv1Enum = warnInfoDto.getIotDeviceTypeLv1Enum();
 
         String targetValue = config.getWiValue();
         String wiAddress = config.getWiAddress();
@@ -292,11 +292,11 @@ public class WarnService {
      * @param devCode
      * @return
      */
-    public WarnResult comparableQxzSingleIndicator(WarnResult warnResult, WarnQxSqInfoDto warnQxSqInfoDto) {
-        List<WarnConfigInfo> configList = warnQxSqInfoDto.getConfigList();
+    public WarnResult comparableQxzSingleIndicator(WarnResult warnResult, WarnInfoDto warnInfoDto) {
+        List<WarnConfigInfo> configList = warnInfoDto.getConfigList();
         WarnStatusDto warnStatusDto = null;
         for (WarnConfigInfo config : configList) {
-            warnStatusDto = getQxzWarnStatusDto(config, warnQxSqInfoDto);
+            warnStatusDto = getQxzWarnStatusDto(config, warnInfoDto);
             // 如果没有预警配置,直接返回null,不进行预警判断
             if(warnStatusDto == null){
                 continue;
@@ -330,12 +330,12 @@ public class WarnService {
      * @param jsonObject 上报的数据
      * @return WarnResult 包含是否触发告警的信息
      */
-    public WarnResult comparableQxzMultipleIndicators(WarnResult warnResult, WarnQxSqInfoDto warnQxSqInfoDto) {
-        List<WarnConfigInfo> configList = warnQxSqInfoDto.getConfigList();
+    public WarnResult comparableQxzMultipleIndicators(WarnResult warnResult, WarnInfoDto warnInfoDto) {
+        List<WarnConfigInfo> configList = warnInfoDto.getConfigList();
         WarnStatusDto warnStatusDto = null;
         List<WarnStatusDto> warnStatusDtos = new ArrayList<>();
         for (WarnConfigInfo config : configList) {
-            warnStatusDto = getQxzWarnStatusDto(config, warnQxSqInfoDto);
+            warnStatusDto = getQxzWarnStatusDto(config, warnInfoDto);
             // 如果没有预警配置,直接返回null,不进行预警判断
             if(warnStatusDto == null){
                 continue;
@@ -382,14 +382,14 @@ public class WarnService {
      * @param config     对应的配置
      * @param jsonObject 上报的数据
      */
-    private WarnResult comparableQxzReportData(WarnQxSqInfoDto warnQxSqInfoDto) {
-        IotDevice iotDevice = warnQxSqInfoDto.getIotDevice();
-        List<WarnConfigInfo> configList = warnQxSqInfoDto.getConfigList();
-        JSONObject jsonObject = warnQxSqInfoDto.getJsonObject();
+    private WarnResult comparableQxzReportData(WarnInfoDto warnInfoDto) {
+        IotDevice iotDevice = warnInfoDto.getIotDevice();
+        List<WarnConfigInfo> configList = warnInfoDto.getConfigList();
+        JSONObject jsonObject = warnInfoDto.getJsonObject();
         JSONArray jsonArray = jsonObject.getJSONArray("data");
         Map<String, String> currentValueMap = getQxzCurrentValueMap(iotDevice, jsonArray);
 
-        warnQxSqInfoDto.setCurrentValueMap(currentValueMap);
+        warnInfoDto.setCurrentValueMap(currentValueMap);
 
         String devBid = iotDevice.getDevBid();
         WarnConfigInfo configInfo = configList.get(0);
@@ -410,9 +410,9 @@ public class WarnService {
         warnResult.setTriggered(false);
 
         if("0".equals(wcCondition)){
-            warnResult = comparableQxzSingleIndicator(warnResult, warnQxSqInfoDto);
+            warnResult = comparableQxzSingleIndicator(warnResult, warnInfoDto);
         } else {
-            warnResult = comparableQxzMultipleIndicators(warnResult, warnQxSqInfoDto);
+            warnResult = comparableQxzMultipleIndicators(warnResult, warnInfoDto);
         }
         return warnResult;
     }
@@ -422,8 +422,8 @@ public class WarnService {
      * 【墒情站】比较该设备上报的要素和配置是否达到预警条件
      *
      */
-    WarnResult comparableSqzReportData(WarnQxSqInfoDto warnQxSqInfoDto) {
-        return comparableQxzReportData(warnQxSqInfoDto);
+    WarnResult comparableSqzReportData(WarnInfoDto warnInfoDto) {
+        return comparableQxzReportData(warnInfoDto);
 
     }
 
@@ -431,8 +431,8 @@ public class WarnService {
      * 【管式墒情】比较该设备上报的要素和配置是否达到预警条件
      *
      */
-    WarnResult comparableGssqReportData(WarnQxSqInfoDto warnQxSqInfoDto) {
-        return comparableQxzReportData(warnQxSqInfoDto);
+    WarnResult comparableGssqReportData(WarnInfoDto warnInfoDto) {
+        return comparableQxzReportData(warnInfoDto);
 
     }