|
|
@@ -3,7 +3,9 @@ package com.yunfeiyun.agmp.iot.common.util.dev;
|
|
|
import com.yunfeiyun.agmp.iot.common.domain.IotSfElementfactor;
|
|
|
import com.yunfeiyun.agmp.iot.common.enums.EnumSfElementType;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
public class RunHaoSfElementUtil {
|
|
|
@@ -49,6 +51,21 @@ public class RunHaoSfElementUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取传感器类型映射表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Map<String, EnumSfElementType> getSensorTypeMap() {
|
|
|
+ Map<String, EnumSfElementType> sfElementMap = new HashMap<>();
|
|
|
+ sfElementMap.put("ph", EnumSfElementType.SENSOR);
|
|
|
+ sfElementMap.put("ec", EnumSfElementType.SENSOR);
|
|
|
+ sfElementMap.put("sw", EnumSfElementType.SENSOR);
|
|
|
+ sfElementMap.put("gdyl", EnumSfElementType.SENSOR);
|
|
|
+
|
|
|
+ return sfElementMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取水泵名称映射表
|
|
|
*
|
|
|
* @return 水泵名称映射表,Map<String, String>类型,键为水泵的简写,值为对应的水泵名称
|
|
|
@@ -88,6 +105,20 @@ public class RunHaoSfElementUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 获取传感器名称映射表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public static Map<String, String> getSensorNameMap() {
|
|
|
+ Map<String, String> sfElementMap = new HashMap<>();
|
|
|
+ sfElementMap.put("ph", "PH");
|
|
|
+ sfElementMap.put("ec", "EC");
|
|
|
+ sfElementMap.put("sw", "水温");
|
|
|
+ sfElementMap.put("gdyl", "管道压力");
|
|
|
+ return sfElementMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 根据键名获取泵类设备IotSfElementfactor对象
|
|
|
*
|
|
|
* @param key 设备元素因子的键名
|
|
|
@@ -191,4 +222,69 @@ public class RunHaoSfElementUtil {
|
|
|
|
|
|
return sfElementfactor;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据键名获取传感器设备IotSfElementfactor对象
|
|
|
+ *
|
|
|
+ * @param key 设备元素因子的键名
|
|
|
+ * @return 设备元素因子对象,如果无法解析则返回null
|
|
|
+ */
|
|
|
+ public static IotSfElementfactor getSensorElementFactor(String key) {
|
|
|
+ String[] temp = key.split("-");
|
|
|
+ String suffix = temp[1];
|
|
|
+
|
|
|
+ IotSfElementfactor sfElementfactor = new IotSfElementfactor();
|
|
|
+ String sfName = null;
|
|
|
+ EnumSfElementType elementType = null;
|
|
|
+ Map<String, String> sfNameMap = getSensorNameMap();
|
|
|
+ Map<String, EnumSfElementType> sfTypeMap = getSensorTypeMap();
|
|
|
+
|
|
|
+ for(Map.Entry<String, String> entry : sfNameMap.entrySet()){
|
|
|
+ String sfKey = entry.getKey();
|
|
|
+ if(suffix.startsWith(sfKey)){
|
|
|
+ sfName = entry.getValue() + suffix.replace(sfKey, "");
|
|
|
+ elementType = sfTypeMap.get(sfKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(elementType == null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ sfElementfactor.setSfType(elementType.getCode());
|
|
|
+ sfElementfactor.setSfName(elementType.getName());
|
|
|
+ sfElementfactor.setSfDisplayname(sfName);
|
|
|
+ sfElementfactor.setSfCode(key);
|
|
|
+
|
|
|
+ return sfElementfactor;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取流速流量IotSfElementfactor对象
|
|
|
+ *
|
|
|
+ * @param key 设备元素因子的键名
|
|
|
+ * @return 设备元素因子对象,如果无法解析则返回null
|
|
|
+ */
|
|
|
+ public static List<IotSfElementfactor> getLsLlFactor(String key) {
|
|
|
+ Map<String, String> sfNameMap = new HashMap<>();
|
|
|
+ sfNameMap.put("Num-ls", "流量");
|
|
|
+ sfNameMap.put("Num-LL", "流速");
|
|
|
+ String s = key.replace("Btn-fs", "");
|
|
|
+ List<IotSfElementfactor> factorList = new ArrayList<>();
|
|
|
+ for(Map.Entry<String, String> entry : sfNameMap.entrySet()){
|
|
|
+ String sfKey = entry.getKey();
|
|
|
+ String sfCode = sfKey + s;
|
|
|
+ String sfName = entry.getValue() + s;
|
|
|
+
|
|
|
+ IotSfElementfactor sfElementfactor = new IotSfElementfactor();
|
|
|
+ sfElementfactor.setSfType(EnumSfElementType.SENSOR.getCode());
|
|
|
+ sfElementfactor.setSfName(EnumSfElementType.SENSOR.getName());
|
|
|
+ sfElementfactor.setSfDisplayname(sfName);
|
|
|
+ sfElementfactor.setSfCode(sfCode);
|
|
|
+
|
|
|
+ factorList.add(sfElementfactor);
|
|
|
+ }
|
|
|
+
|
|
|
+ return factorList;
|
|
|
+ }
|
|
|
}
|