Commit 730b54dc authored by hcing's avatar hcing

fix(ymt): 96333码生成规则bugfix

parent df97418f
...@@ -47,8 +47,7 @@ public enum EquipmentCategoryEnum { ...@@ -47,8 +47,7 @@ public enum EquipmentCategoryEnum {
public static Map<String, String> getName = new HashMap<>(); public static Map<String, String> getName = new HashMap<>();
public static Map<String, String> getCode = new HashMap<>(); public static Map<String, String> getCode = new HashMap<>();
public static Map<String, String> getValue = new HashMap<>(); public static Map<String, String> getValue = new HashMap<>();
public static Map<String, String> getCityCode = new HashMap<>(); public static final Map<String, String> getCityCodeValue = new HashMap<>();
public static final Map<String, String> getCodeValueMap = new HashMap<>();
private static final Map<String, String> valueToCodeMap = new HashMap<>(); private static final Map<String, String> valueToCodeMap = new HashMap<>();
static { static {
...@@ -57,9 +56,8 @@ public enum EquipmentCategoryEnum { ...@@ -57,9 +56,8 @@ public enum EquipmentCategoryEnum {
getCode.put(e.value, e.code); getCode.put(e.value, e.code);
getValue.put(e.value, e.code); getValue.put(e.value, e.code);
if (e.cityCode != null) { if (e.cityCode != null) {
getCityCode.put(e.cityCode, e.code); getCityCodeValue.put(e.cityCode, e.value);
} }
getCodeValueMap.put(e.code, e.value);
valueToCodeMap.put("96333_" + e.value, e.getValue() + e.getCode()); valueToCodeMap.put("96333_" + e.value, e.getValue() + e.getCode());
} }
} }
...@@ -68,9 +66,4 @@ public enum EquipmentCategoryEnum { ...@@ -68,9 +66,4 @@ public enum EquipmentCategoryEnum {
public static String getCodeByValue(String value) { public static String getCodeByValue(String value) {
return valueToCodeMap.get(value); return valueToCodeMap.get(value);
} }
// 根据code获取对应的value
public static String getValueByCode(String code) {
return getCodeValueMap.get(code);
}
} }
...@@ -921,7 +921,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -921,7 +921,8 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
if (firstAvailableCode != null) { if (firstAvailableCode != null) {
elevatorCode.setLength(0); elevatorCode.setLength(0);
elevatorCode.append(prefix).append(firstAvailableCode); // firstAvailableCode 不足5位,前面补0
elevatorCode.append(prefix).append(String.format("%05d", firstAvailableCode.longValue()));
} else { } else {
//// 获取补零位长度 //// 获取补零位长度
// String elevatorCode1 = elevatorOtherInfo.getCode().substring(2); // String elevatorCode1 = elevatorOtherInfo.getCode().substring(2);
...@@ -2789,33 +2790,34 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD ...@@ -2789,33 +2790,34 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
} }
// 对应关系转化 // 对应关系转化
// city --> EquipmentCategoryEnum.code --> EquipmentCategoryEnum.value // city/county --> EquipmentCategoryEnum.value
private String cityCodeTo96333CodePrefix(String city, String county, String isNotXixian) { private String cityCodeTo96333CodePrefix(String city, String county, String isNotXixian) {
String code = EquipmentCategoryEnum.getCityCode.get(city); String prefixCode = "";
if (StringUtils.isEmpty(code)) { prefixCode = EquipmentCategoryEnum.getCityCodeValue.get(city);
throw new RuntimeException("未匹配到对应的cityCode:" + city);
}
// 西咸 // 西咸
if (XIAN.equals(city) && "0".equals(isNotXixian)) { if (XIAN.equals(city) && "0".equals(isNotXixian)) {
return EquipmentCategoryEnum.XXCSM.getValue(); prefixCode = EquipmentCategoryEnum.XXCSM.getValue();
} }
// 杨陵 // 杨陵
if (YANG_LING.equals(county)) { if (YANG_LING.equals(county)) {
return EquipmentCategoryEnum.YLCSM.getValue(); prefixCode = EquipmentCategoryEnum.YLCSM.getValue();
} }
// 韩城 // 韩城
if (HAN_CHENG.equals(county)) { if (HAN_CHENG.equals(county)) {
return EquipmentCategoryEnum.HCCSM.getValue(); prefixCode = EquipmentCategoryEnum.HCCSM.getValue();
} }
// 神木 // 神木
if (SHEN_MU.equals(county)) { if (SHEN_MU.equals(county)) {
return EquipmentCategoryEnum.SMCSM.getValue(); prefixCode = EquipmentCategoryEnum.SMCSM.getValue();
} }
// 府谷 // 府谷
if (FU_GU.equals(county)) { if (FU_GU.equals(county)) {
return EquipmentCategoryEnum.FGCSM.getValue(); prefixCode = EquipmentCategoryEnum.FGCSM.getValue();
}
if (StringUtils.isEmpty(prefixCode)) {
throw new RuntimeException("未匹配到对应的cityCode/countyCode:" + city + "/" + county);
} }
return EquipmentCategoryEnum.getValueByCode(code); return prefixCode;
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment