From da3e0a43b4f8978608d26f3e2fd57614f407f07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=85=B4=E7=90=B3?= <1911390090@qq.com> Date: Fri, 6 Dec 2024 11:11:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E9=80=9A=E6=B5=81=E6=8B=A5=E5=A0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DcTrafficStatisticsServiceImpl.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java index 0b5caf67..845c0ac9 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java @@ -1247,12 +1247,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi .filter(device -> { int deviceStakeMarkMeters = StakeMarkUtils.stakeMarkToInt(device.getStakeMark()); // return deviceStakeMarkMeters >= StakeMarkUtils.stakeMarkToInt("K111+107") && deviceStakeMarkMeters <= StakeMarkUtils.stakeMarkToInt("K132+577") ; - return deviceStakeMarkMeters >= StakeMarkUtils.stakeMarkToInt(stakeMarkKilometre(stakeMark)) && deviceStakeMarkMeters <= StakeMarkUtils.stakeMarkToInt(stakeMarkKilometre(jsonObject.get("endMark").toString())) ; + return deviceStakeMarkMeters >= StakeMarkUtils.stakeMarkToInt(stakeMarkKilometreReductionOf(stakeMark)) && deviceStakeMarkMeters <= StakeMarkUtils.stakeMarkToInt(stakeMarkKilometre(jsonObject.get("endMark").toString())) ; }) .sorted(Comparator.comparingInt(device -> StakeMarkUtils.stakeMarkToInt(device.getStakeMark()))) .collect(Collectors.toList()); jsonObject.put("filteredDevices",filteredDevices); - } + } return jsonArray; } @@ -1280,6 +1280,17 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi // 将修改后的数字放回原字符串中 return stakeMark.replaceFirst(numberBeforePlus, String.valueOf(incrementedNumber)); } + private String stakeMarkKilometreReductionOf(String stakeMark) { + // 使用正则表达式匹配+号前的数字 + String numberBeforePlus = stakeMark.split("\\+")[0].replaceAll("[^0-9]", ""); + // 将匹配到的字符串转换为整数 + int number = Integer.parseInt(numberBeforePlus); + // 对数字加一 + int incrementedNumber = number -1; + + // 将修改后的数字放回原字符串中 + return stakeMark.replaceFirst(numberBeforePlus, String.valueOf(incrementedNumber)); + } /** * 各收费站日累计车流辆