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)); + } /** * 各收费站日累计车流辆