|
|
@@ -111,4 +111,50 @@ public class PtlAreaLicenseServiceImpl extends ServiceImpl<PtlAreaLicenseMapper,
|
|
|
Map<String, PtlAreaLicense> areaLicenseMap = this.queryAllAreaLicenseMap();
|
|
|
return this.convertAreaNumber2License(areaLicenseMap, areaNumbers);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将车牌号转换为对应的地区编码
|
|
|
+ *
|
|
|
+ * @param licenseMap 车牌号和地区编码的对应集
|
|
|
+ * @param licenses 车牌号,支持多个拼接,例如晋A,晋B,晋C
|
|
|
+ * @return String 地区编码,例如1401,1402,1403
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String convertLicense2AreaNumber(Map<String, PtlAreaLicense> licenseMap, String licenses) {
|
|
|
+ if (StrUtil.isEmpty(licenses)) {
|
|
|
+ return StrUtil.EMPTY;
|
|
|
+ }
|
|
|
+ if (CollUtil.isEmpty(licenseMap)) {
|
|
|
+ return licenses;
|
|
|
+ }
|
|
|
+ String[] split = licenses.split(",");
|
|
|
+ List<String> areaNumbers = new ArrayList<>();
|
|
|
+ for (String s : split) {
|
|
|
+ PtlAreaLicense ptlAreaLicense = licenseMap.getOrDefault(s, null);
|
|
|
+ if (ptlAreaLicense != null) {
|
|
|
+ areaNumbers.add(ptlAreaLicense.getAreaNumber());
|
|
|
+ } else {
|
|
|
+ areaNumbers.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String collect = String.join(",", areaNumbers);
|
|
|
+ log.info("车牌编码[{}]转换后的地区编码是[{}]", licenses, collect);
|
|
|
+ return collect;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将车牌号转换为对应的地区编码
|
|
|
+ *
|
|
|
+ * @param licenses 车牌号,支持多个拼接,例如晋A,晋B,晋C
|
|
|
+ * @return String 地区编码,例如1401,1402,1403
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public String convertLicense2AreaNumber(String licenses) {
|
|
|
+ Map<String, PtlAreaLicense> licenseMap = this.queryAllAreaLicense().stream()
|
|
|
+ .filter(action -> StrUtil.isNotEmpty(action.getLicense()))
|
|
|
+ .collect(Collectors.toMap(PtlAreaLicense::getLicense,
|
|
|
+ action -> action,
|
|
|
+ (oldItem, newItem) -> newItem));
|
|
|
+ return this.convertLicense2AreaNumber(licenseMap, licenses);
|
|
|
+ }
|
|
|
}
|