diff --git a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/DetectorIdFormat.java b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/DetectorIdFormat.java index 4bbd6814..835897aa 100644 --- a/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/DetectorIdFormat.java +++ b/jeecg-boot-base-core/src/main/java/org/jeecg/common/properties/DetectorIdFormat.java @@ -45,4 +45,31 @@ public class DetectorIdFormat { Integer detectorId = Integer.valueOf(prefixFormatResult + suffixFormatResult); return detectorId; } + + /** + * 格式化探测器id解析出台站id + * @param detectorCode + * @return + */ + public Integer formatDetectorCodeToStationId(String detectorCode){ + if(!detectorCode.contains(StringConstant.UNDER_LINE)){ + throw new RuntimeException("The "+detectorCode+" detector code is illegal"); + } + //举例:FRP28_007 + final String[] arr = detectorCode.split(StringConstant.UNDER_LINE); + final String prefix = arr[0]; + + Integer stationId = null; + //格式化前缀 + for(int i=prefix.length()-1;i>=0;i--){ + final String letter = String.valueOf(prefix.charAt(i)); + if(StringUtils.isAlpha(letter)){ + final String mapVal = suffixMap.getOrDefault(letter, "-1"); + stationId = Integer.valueOf(mapVal + prefix.substring(i + 1)); + break; + } + } + + return stationId; + } } diff --git a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsDetectorsServiceImpl.java b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsDetectorsServiceImpl.java index 1b6b6d8a..9a70a65f 100644 --- a/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsDetectorsServiceImpl.java +++ b/jeecg-module-auto-process/src/main/java/org/jeecg/modules/service/impl/GardsDetectorsServiceImpl.java @@ -37,6 +37,7 @@ public class GardsDetectorsServiceImpl extends ServiceImpl