From d91fb094423d92b0ed52bd65ec9d09d240c15fa9 Mon Sep 17 00:00:00 2001 From: panbaolin <123456> Date: Thu, 4 Jan 2024 19:35:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:1.=E4=BF=AE=E6=94=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=8E=A2=E6=B5=8B=E5=99=A8=E6=97=B6=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=B0=E7=AB=99id=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/properties/DetectorIdFormat.java | 27 +++++++++++++++++++ .../impl/GardsDetectorsServiceImpl.java | 1 + 2 files changed, 28 insertions(+) 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