From d0ff7a2ca149311f7707fea85e4d14703b6b1b36 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Tue, 26 Mar 2024 09:30:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=A1=A9=E5=8F=B7=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/utils/StakeMarkUtils.java | 20 +++++++---- .../controller/DcStakeMarkController.java | 4 +-- .../business/service/IDcStakeMarkService.java | 2 +- .../service/impl/DcStakeMarkServiceImpl.java | 34 ++++++++++++++++--- 4 files changed, 47 insertions(+), 13 deletions(-) diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java index 686b4c29..4a42e0a3 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java @@ -41,9 +41,10 @@ public class StakeMarkUtils { if (!checkStakeMark(stakeMark)){ return ""; } - return stakeMark.toLowerCase().replace("k","").replace("+","."); + return stakeMark.replace("K","").replace("+","."); } + /** * @Description 桩号转米 * @@ -52,11 +53,18 @@ public class StakeMarkUtils { * @param stakeMark 桩号:"K123+123" * @return 公里数:123123 */ + public static Long formatMetreLong(String stakeMark){ + if (!checkStakeMark(stakeMark)){ + return null; + } + return Long.valueOf(stakeMark.replace("K","").replace("+","")); + } + public static String formatMetre(String stakeMark){ if (!checkStakeMark(stakeMark)){ return ""; } - return stakeMark.toLowerCase().replace("k","").replace("+",""); + return stakeMark.replace("K","").replace("+",""); } /** @@ -72,8 +80,8 @@ public class StakeMarkUtils { if (!checkStakeMark(startStakeMark) || !checkStakeMark(endStakeMark)){ return BigDecimal.ZERO; } - String start = startStakeMark.toLowerCase().replace("k","").replace("+","."); - String end = endStakeMark.toLowerCase().replace("k","").replace("+","."); + String start = startStakeMark.replace("K","").replace("+","."); + String end = endStakeMark.replace("K","").replace("+","."); BigDecimal startKilometre = new BigDecimal(start); BigDecimal endKilometre = new BigDecimal(end); if (startKilometre.compareTo(endKilometre) > 0){ @@ -96,8 +104,8 @@ public class StakeMarkUtils { if (!checkStakeMark(startStakeMark) || !checkStakeMark(endStakeMark)){ return BigDecimal.ZERO; } - String start = startStakeMark.toLowerCase().replace("k","").replace("+","."); - String end = endStakeMark.toLowerCase().replace("k","").replace("+","."); + String start = startStakeMark.replace("K","").replace("+","."); + String end = endStakeMark.replace("K","").replace("+","."); BigDecimal startKilometre = new BigDecimal(start); BigDecimal endKilometre = new BigDecimal(end); if (startKilometre.compareTo(endKilometre) > 0){ diff --git a/zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java b/zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java index b926ae3f..ee7a0f91 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcStakeMarkController.java @@ -115,8 +115,8 @@ public class DcStakeMarkController extends BaseController { @ApiOperation("根据json文件路径导入桩号") @PostMapping("importStakeMarkByJsonFilePath") - public AjaxResult importJsonStakeMark(String filePath) throws IOException { - return dcStakeMarkService.importJsonStakeMark(filePath); + public AjaxResult importJsonStakeMark(String filePath,String direction) throws IOException { + return dcStakeMarkService.importJsonStakeMark(filePath, direction); } } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java b/zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java index f508f7dc..0131c4d2 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcStakeMarkService.java @@ -70,5 +70,5 @@ public interface IDcStakeMarkService extends IService { * @param filePath json文件路径 * @return */ - AjaxResult importJsonStakeMark(String filePath) throws IOException; + AjaxResult importJsonStakeMark(String filePath,String direction) throws IOException; } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java index e2d3022b..ae0d23b4 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcStakeMarkServiceImpl.java @@ -9,7 +9,9 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.PageUtils; import com.ruoyi.common.utils.StakeMarkUtils; +import com.zc.business.domain.DcRoadSection; import com.zc.business.domain.DcStakeMark; +import com.zc.business.mapper.DcRoadSectionMapper; import com.zc.business.mapper.DcStakeMarkMapper; import com.zc.business.service.IDcStakeMarkService; import org.springframework.stereotype.Service; @@ -30,6 +32,8 @@ public class DcStakeMarkServiceImpl extends ServiceImpl stakeMarkQueryWrapper(DcStakeMark dcStakeMark) { @@ -142,7 +146,7 @@ public class DcStakeMarkServiceImpl extends ServiceImpl> map = JSON.parseObject(jsonStr, new TypeReference>>() {}); List stakeMarkList = new ArrayList<>(); + List dcRoadSectionList = dcRoadSectionMapper.selectDcRoadSectionList(null); + //桩号格式校验 List errorKey = new ArrayList<>(); map.keySet().forEach(key ->{ @@ -170,9 +176,11 @@ public class DcStakeMarkServiceImpl extends ServiceImpl roadSectionList,String stakeMark){ + + if (roadSectionList == null || roadSectionList.size() < 1){ + return null; + } + Long metre = StakeMarkUtils.formatMetreLong(stakeMark); + for (DcRoadSection dcRoadSection : roadSectionList) { + Long startStakeMark = StakeMarkUtils.formatMetreLong(dcRoadSection.getStartStakeMark()); + Long endStakeMark = StakeMarkUtils.formatMetreLong(dcRoadSection.getEndStakeMark()); + if (metre >= startStakeMark && metre < endStakeMark){ + return dcRoadSection.getId(); + } + } + + return null; + + } + }