|
|
@@ -0,0 +1,75 @@
|
|
|
+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.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+public class RunHaoSfElementUtil {
|
|
|
+
|
|
|
+ public static Map<String, EnumSfElementType> getBtnTypeMap() {
|
|
|
+ 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);
|
|
|
+
|
|
|
+ return sfElementMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Map<String, String> getBtnNameMap() {
|
|
|
+ Map<String, String> sfElementMap = new HashMap<>();
|
|
|
+ sfElementMap.put("ggbs", "灌溉泵");
|
|
|
+ sfElementMap.put("sfbs", "施肥泵");
|
|
|
+ sfElementMap.put("fs", "肥阀");
|
|
|
+ sfElementMap.put("js", "搅拌电机");
|
|
|
+ sfElementMap.put("fa", "井阀");
|
|
|
+ sfElementMap.put("qx", "灌区");
|
|
|
+
|
|
|
+ return sfElementMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static IotSfElementfactor getBtnElementfactor(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();
|
|
|
+
|
|
|
+ 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(sfName);
|
|
|
+ sfElementfactor.setSfCode(suffix);
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+}
|