Просмотр исходного кода

新增 获取未配置的水肥要素接口

zhaiyifei 8 месяцев назад
Родитель
Сommit
f1841ee9b6

+ 47 - 24
src/main/java/com/yunfeiyun/agmp/iot/common/util/dev/RunHaoSfElementUtil.java

@@ -8,39 +8,55 @@ import java.util.Map;
 
 public class RunHaoSfElementUtil {
 
-    public static Map<String, EnumSfElementType> getBtnTypeMap() {
+    /**
+     * 获取泵类型映射表
+     *
+     * @return 泵类型映射表,键为泵类型的标识,值为泵类型对应的枚举值
+     */
+    public static Map<String, EnumSfElementType> getPumpTypeMap() {
         Map<String, EnumSfElementType> sfElementMap = new HashMap<>();
         sfElementMap.put("ggbs", EnumSfElementType.WATER_SOURCE);
         sfElementMap.put("sfbs", EnumSfElementType.FERILIZER);
         sfElementMap.put("fs", EnumSfElementType.SUCTION);
         sfElementMap.put("js", EnumSfElementType.MIXING);
-        sfElementMap.put("fa", EnumSfElementType.SOLENOID_VALVE);
-        sfElementMap.put("qx", EnumSfElementType.GROUP);
+//        sfElementMap.put("fa", EnumSfElementType.SOLENOID_VALVE);
+//        sfElementMap.put("qx", EnumSfElementType.GROUP);
 
         return sfElementMap;
     }
 
-    public static Map<String, String> getBtnNameMap() {
+    /**
+     * 获取水泵名称映射表
+     *
+     * @return 水泵名称映射表,Map<String, String>类型,键为水泵的简写,值为对应的水泵名称
+     */
+    public static Map<String, String> getPumpNameMap() {
         Map<String, String> sfElementMap = new HashMap<>();
         sfElementMap.put("ggbs", "灌溉泵");
         sfElementMap.put("sfbs", "施肥泵");
         sfElementMap.put("fs", "肥阀");
         sfElementMap.put("js", "搅拌电机");
-        sfElementMap.put("fa", "井阀");
-        sfElementMap.put("qx", "灌区");
+//        sfElementMap.put("fa", "井阀");
+//        sfElementMap.put("qx", "灌区");
 
         return sfElementMap;
     }
 
-    public static IotSfElementfactor getBtnElementfactor(String key) {
-        String[] temp = key.split("_");
+    /**
+     * 根据键名获取泵类设备IotSfElementfactor对象
+     *
+     * @param key 设备元素因子的键名
+     * @return 设备元素因子对象,如果无法解析则返回null
+     */
+    public static IotSfElementfactor getPumpElementFactor(String key) {
+        String[] temp = key.split("-");
         String suffix = temp[1];
 
         IotSfElementfactor sfElementfactor = new IotSfElementfactor();
         String sfName = null;
         EnumSfElementType elementType = null;
-        Map<String, String> sfNameMap = getBtnNameMap();
-        Map<String, EnumSfElementType> sfTypeMap = getBtnTypeMap();
+        Map<String, String> sfNameMap = getPumpNameMap();
+        Map<String, EnumSfElementType> sfTypeMap = getPumpTypeMap();
 
         for(Map.Entry<String, String> entry : sfNameMap.entrySet()){
             String sfKey = entry.getKey();
@@ -54,22 +70,29 @@ public class RunHaoSfElementUtil {
         }
 
         sfElementfactor.setSfType(elementType.getCode());
-        sfElementfactor.setSfName(sfName);
-        sfElementfactor.setSfCode(suffix);
+        sfElementfactor.setSfName(elementType.getName());
+        sfElementfactor.setSfDisplayname(sfName);
+        sfElementfactor.setSfCode(key);
 
         return sfElementfactor;
     }
 
-    public static IotSfElementfactor getSfElementfactor(String key) {
-        String[] temp = key.split("_");
-        if(temp.length != 2){
-            return null;
-        }
-        IotSfElementfactor iotSfElementfactor = null;
-        String prefix = temp[0];
-        if("Btn".equals(prefix)){
-            iotSfElementfactor = getBtnElementfactor(key);
-        }
-        return iotSfElementfactor;
-    }
+//    /**
+//     * 根据给定的键获取相应的IotSfElementfactor对象
+//     *
+//     * @param key 键值
+//     * @return 返回对应的IotSfElementfactor对象,若键不符合规范则返回null
+//     */
+//    public static IotSfElementfactor getSfElementfactor(String key) {
+//        String[] temp = key.split("-");
+//        if(temp.length != 2){
+//            return null;
+//        }
+//        IotSfElementfactor iotSfElementfactor = null;
+//        String prefix = temp[0];
+//        if("Btn".equals(prefix)){
+//            iotSfElementfactor = getBtnElementfactor(key);
+//        }
+//        return iotSfElementfactor;
+//    }
 }