Bladeren bron

新增 新普惠管式墒情设备适配

zhaiyifei 11 maanden geleden
bovenliggende
commit
7a545348f5

+ 6 - 12
src/main/java/com/yunfeiyun/agmp/iot/common/constant/device/ElementFormatUtil.java

@@ -9,6 +9,7 @@ import com.yunfeiyun.agmp.iot.common.domain.QxzDataDto;
 import com.yunfeiyun.agmp.iot.common.domain.dto.IotElementDto;
 import com.yunfeiyun.agmp.iot.common.enums.EnumAdznGssqElement;
 import com.yunfeiyun.agmp.iot.common.enums.EnumYfQxzElement;
+import com.yunfeiyun.agmp.iot.common.util.dev.QxzTypeUtil;
 
 import java.util.*;
 
@@ -96,18 +97,11 @@ public class ElementFormatUtil {
     private static IotElementDto getElement(IotDevice iotDevice, QxzDataDto dataitem, Map<String, List<Integer>> elementMap){
         IotElementDto iotElementDto = null;
         String devtypeBid = iotDevice.getDevtypeBid();
-        switch (devtypeBid){
-            case IotDeviceDictConst.TYPE_YF_QXZ:
-            case IotDeviceDictConst.TYPE_YF_SQZ:
-            case IotDeviceDictConst.TYPE_XPH_YF_QXZ:
-            case IotDeviceDictConst.TYPE_XPH_YF_SQZ:
-                iotElementDto = getYfQxzElement(dataitem, elementMap);
-                break;
-            case IotDeviceDictConst.TYPE_ADZN_GSSQ:
-                iotElementDto = getAdznGssqElement(dataitem, elementMap);
-                break;
-            default:
-                break;
+        boolean isQxz = QxzTypeUtil.isYfCommQxz(devtypeBid);
+        if(isQxz){
+            iotElementDto = getYfQxzElement(dataitem, elementMap);
+        }else if(IotDeviceDictConst.TYPE_ADZN_GSSQ.equals(devtypeBid)){
+            iotElementDto = getAdznGssqElement(dataitem, elementMap);
         }
         return iotElementDto;
     }

+ 6 - 0
src/main/java/com/yunfeiyun/agmp/iot/common/constant/devicetype/IotDeviceDictConst.java

@@ -217,6 +217,12 @@ public class IotDeviceDictConst {
      */
     public static final String TYPE_ADZN_GSSQ = "SQZ00003";
 
+    /**
+     * 新普惠-管式墒情
+     * 新普惠MQTT墒情站分管式和普通,都是一样的设备,数据也一样,只是类型上做区分
+     */
+    public static final String TYPE_XPH_YF_GSSQ = "SQZ00004";
+
 
 
     /*

+ 1 - 0
src/main/java/com/yunfeiyun/agmp/iot/common/constant/devicetype/IotDeviceDictEnum.java

@@ -89,6 +89,7 @@ public enum IotDeviceDictEnum {
 
     TYPE_YF_SQZ(IotDeviceDictConst.TYPE_YF_SQZ, "云飞-墒情站", ServiceNameConst.SERVICE_YF_SQZ, IotDeviceTypeLv1Enum.SQZ),
     TYPE_XPH_YF_SQZ(IotDeviceDictConst.TYPE_XPH_YF_SQZ, "新普惠-云飞-墒情站", ServiceNameConst.SERVICE_XPH_YF_SQZ, IotDeviceTypeLv1Enum.SQZ),
+    TYPE_XPH_YF_GSSQ(IotDeviceDictConst.TYPE_XPH_YF_GSSQ, "新普惠-云飞-管式墒情", ServiceNameConst.SERVICE_XPH_YF_SQZ, IotDeviceTypeLv1Enum.SQZ),
     TYPE_ADZN_GSSQ(IotDeviceDictConst.TYPE_ADZN_GSSQ, "爱迪智农-管式墒情", ServiceNameConst.SERVICE_ADZN_GSSQ, IotDeviceTypeLv1Enum.SQZ),
 
 

+ 5 - 0
src/main/java/com/yunfeiyun/agmp/iot/common/constant/devicetype/ServiceNameConst.java

@@ -193,4 +193,9 @@ public class ServiceNameConst {
      * 云飞吸虫塔设备
      * */
     public static final String SERVICE_YF_XCT = "YF_XCT_SERVICE";
+
+    /**
+     * 宁录性诱 不带拍照
+     */
+    public static final String SERVICE_NL_XYCB = "NL-XYCB-SERVICE";
 }

+ 37 - 41
src/main/java/com/yunfeiyun/agmp/iot/common/constant/mqtt/IotMqttConstant.java

@@ -1,6 +1,7 @@
 package com.yunfeiyun.agmp.iot.common.constant.mqtt;
 
 import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
+import com.yunfeiyun.agmp.iot.common.util.dev.QxzTypeUtil;
 
 /**
  * mqtt topic 厂家维护
@@ -233,47 +234,42 @@ public class IotMqttConstant {
 
     public static String getReportTopicByDevtype(String devtypeBid){
         String topic = null;
-        if(IotDeviceDictConst.TYPE_YF_SCD.equals(devtypeBid)){
-            topic =  YFCbdTopic.TOPIC_CBD_CMD_PREFIX;
-        }
-        switch (devtypeBid){
-            case IotDeviceDictConst.TYPE_YF_CBD:
-            case IotDeviceDictConst.TYPE_YF_SDCBD:
-            case IotDeviceDictConst.TYPE_YF_GKCBD:
-                topic = YFCbdTopic.TOPIC_CBD_REPORT_PREFIX;
-                break;
-            case IotDeviceDictConst.TYPE_BY_SFJ:
-                topic = BoByunSfTopic.TOPIC_PRE;
-                break;
-            case IotDeviceDictConst.TYPE_YF_SCD:
-            case IotDeviceDictConst.TYPE_YF_FXSSCD:
-            case IotDeviceDictConst.TYPE_YF_JGFXSSCD:
-                topic = YFScdTopic.TOPIC_SCD_REPORT_PREFIX;
-                break;
-            case IotDeviceDictConst.TYPE_YF_BZY:
-            case IotDeviceDictConst.TYPE_YF_L_BZY:
-                topic = YFBzyTopic.TOPIC_BZY_REPORT_PREFIX;
-                break;
-            case IotDeviceDictConst.TYPE_YF_QXZ:
-            case IotDeviceDictConst.TYPE_YF_SQZ:
-                topic = YFQxzTopic.TOPIC_QXZ_REPORT_PREFIX;
-                break;
-            case IotDeviceDictConst.TYPE_YF_XYCB_2:
-                topic = YFXycb2Topic.TOPIC_XYCB_2_REPORT_PREFIX;
-                break;
-            case IotDeviceDictConst.TYPE_XPH_YF_QXZ:
-            case IotDeviceDictConst.TYPE_XPH_YF_SQZ:
-                topic = XphDeviceTopic.TOPIC_XPH_REPORT_PREFIX;
-                break;
-            case IotDeviceDictConst.TYPE_HPF_WSMJ_ZNKG:
-                topic = HpfZnkgTopic.TOPIC_HPF_ZNKG_REPORT_PREFIX;
-                break;
-            case IotDeviceDictConst.TYPE_YR_SF:
-                topic = YrSfTopic.TOPIC_YR_SF_REPORT_PREFIX;
-                break;
-            case IotDeviceDictConst.TYPE_YF_XYCB_III:
-                topic = YFXycbIIITopic.TOPIC_XYCB_III_REPORT_PREFIX;
-                break;
+        if (QxzTypeUtil.isXphYfQxSq(devtypeBid)) {
+            topic = XphDeviceTopic.TOPIC_XPH_REPORT_PREFIX;
+        } else if (QxzTypeUtil.isYfQxSq(devtypeBid)) {
+            topic = YFQxzTopic.TOPIC_QXZ_REPORT_PREFIX;
+        } else{
+            switch (devtypeBid){
+                case IotDeviceDictConst.TYPE_YF_CBD:
+                case IotDeviceDictConst.TYPE_YF_SDCBD:
+                case IotDeviceDictConst.TYPE_YF_GKCBD:
+                    topic = YFCbdTopic.TOPIC_CBD_REPORT_PREFIX;
+                    break;
+                case IotDeviceDictConst.TYPE_BY_SFJ:
+                    topic = BoByunSfTopic.TOPIC_PRE;
+                    break;
+                case IotDeviceDictConst.TYPE_YF_SCD:
+                case IotDeviceDictConst.TYPE_YF_FXSSCD:
+                case IotDeviceDictConst.TYPE_YF_JGFXSSCD:
+                    topic = YFScdTopic.TOPIC_SCD_REPORT_PREFIX;
+                    break;
+                case IotDeviceDictConst.TYPE_YF_BZY:
+                case IotDeviceDictConst.TYPE_YF_L_BZY:
+                    topic = YFBzyTopic.TOPIC_BZY_REPORT_PREFIX;
+                    break;
+                case IotDeviceDictConst.TYPE_YF_XYCB_2:
+                    topic = YFXycb2Topic.TOPIC_XYCB_2_REPORT_PREFIX;
+                    break;
+                case IotDeviceDictConst.TYPE_HPF_WSMJ_ZNKG:
+                    topic = HpfZnkgTopic.TOPIC_HPF_ZNKG_REPORT_PREFIX;
+                    break;
+                case IotDeviceDictConst.TYPE_YR_SF:
+                    topic = YrSfTopic.TOPIC_YR_SF_REPORT_PREFIX;
+                    break;
+                case IotDeviceDictConst.TYPE_YF_XYCB_III:
+                    topic = YFXycbIIITopic.TOPIC_XYCB_III_REPORT_PREFIX;
+                    break;
+            }
         }
         return topic;
     }

+ 67 - 0
src/main/java/com/yunfeiyun/agmp/iot/common/util/dev/QxzTypeUtil.java

@@ -0,0 +1,67 @@
+package com.yunfeiyun.agmp.iot.common.util.dev;
+
+import com.yunfeiyun.agmp.iot.common.constant.devicetype.IotDeviceDictConst;
+
+public class QxzTypeUtil {
+    public static boolean isXphYfQxSq(String devtypeBid){
+        boolean isQxz = false;
+        switch (devtypeBid){
+            case IotDeviceDictConst.TYPE_XPH_YF_QXZ:
+            case IotDeviceDictConst.TYPE_XPH_YF_SQZ:
+            case IotDeviceDictConst.TYPE_XPH_YF_GSSQ:
+                isQxz = true;
+                break;
+        }
+        return isQxz;
+    }
+
+    public static boolean isYfCommQxz(String devtypeBid){
+        boolean isQxz = false;
+        switch (devtypeBid){
+            case IotDeviceDictConst.TYPE_YF_QXZ:
+            case IotDeviceDictConst.TYPE_YF_SQZ:
+            case IotDeviceDictConst.TYPE_XPH_YF_QXZ:
+            case IotDeviceDictConst.TYPE_XPH_YF_SQZ:
+            case IotDeviceDictConst.TYPE_XPH_YF_GSSQ:
+                isQxz = true;
+                break;
+        }
+        return isQxz;
+    }
+
+    public static boolean isYfQxSq(String devtypeBid){
+        boolean isQxz = false;
+        switch (devtypeBid){
+            case IotDeviceDictConst.TYPE_YF_QXZ:
+            case IotDeviceDictConst.TYPE_YF_SQZ:
+                isQxz = true;
+                break;
+        }
+        return isQxz;
+    }
+
+    public static String[] getAllQxzTypes(){
+        return new String[]{IotDeviceDictConst.TYPE_YF_QXZ, IotDeviceDictConst.TYPE_XPH_YF_QXZ};
+    }
+
+    public static String[] getPtQxzTypes(){
+        return new String[]{IotDeviceDictConst.TYPE_YF_QXZ, IotDeviceDictConst.TYPE_XPH_YF_QXZ};
+    }
+
+    public static String[] getAllSqzTypes(){
+        return new String[]{
+                IotDeviceDictConst.TYPE_YF_SQZ, IotDeviceDictConst.TYPE_XPH_YF_SQZ,
+                IotDeviceDictConst.TYPE_ADZN_GSSQ, IotDeviceDictConst.TYPE_XPH_YF_GSSQ
+        };
+    }
+
+    public static String[] getPtSqzTypes(){
+        return new String[]{
+                IotDeviceDictConst.TYPE_YF_SQZ, IotDeviceDictConst.TYPE_XPH_YF_SQZ
+        };
+    }
+
+    public static String[] getGssqTypes(){
+        return new String[]{IotDeviceDictConst.TYPE_XPH_YF_GSSQ, IotDeviceDictConst.TYPE_ADZN_GSSQ};
+    }
+}