From fb15ad9a012ebc0acf499197cfb1fc98b4ef919e Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Mon, 11 Mar 2024 08:57:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E6=A1=A9=E5=8F=B7=E7=AD=9B?= =?UTF-8?q?=E9=80=89=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/common/utils/StakeMarkUtils.java | 22 ++++++-- .../DcTrafficIncidentsController.java | 9 ++-- .../zc/business/domain/DcEventListQuery.java | 51 +++++++++++++++++++ .../mapper/DcTrafficIncidentsMapper.java | 5 +- .../service/IDcTrafficIncidentsService.java | 5 +- .../impl/DcTrafficIncidentsServiceImpl.java | 21 ++++++-- .../business/DcTrafficIncidentsMapper.xml | 12 ++++- 7 files changed, 108 insertions(+), 17 deletions(-) create mode 100644 zc-business/src/main/java/com/zc/business/domain/DcEventListQuery.java 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 97ba251f..6c61fa9a 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 @@ -19,12 +19,26 @@ public class StakeMarkUtils { * @param stakeMark 桩号:"K123+123" * @return 公里数:123.123 */ - public BigDecimal format(String stakeMark){ + public static String formatKilometre(String stakeMark){ if (StringUtils.isEmpty(stakeMark)){ - return BigDecimal.ZERO; + return ""; + } + return stakeMark.toLowerCase().replace("k","").replace("+","."); + } + + /** + * @Description 桩号转米 + * + * @author liuwenge + * @date 2024/3/6 11:06 + * @param stakeMark 桩号:"K123+123" + * @return 公里数:123123 + */ + public static String formatMetre(String stakeMark){ + if (StringUtils.isEmpty(stakeMark)){ + return ""; } - String kilometre = stakeMark.toLowerCase().replace("k","").replace("+","."); - return new BigDecimal(kilometre); + return stakeMark.toLowerCase().replace("k","").replace("+",""); } /** diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java index 4fd32ec0..300436e5 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java @@ -1,6 +1,7 @@ package com.zc.business.controller; import com.ruoyi.common.core.domain.AjaxResult; +import com.zc.business.domain.DcEventListQuery; import com.zc.business.service.IDcTrafficIncidentsService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -45,13 +46,13 @@ public class DcTrafficIncidentsController { * * @author liuwenge * @date 2024/1/13 14:27 - * @param eventType + * @param * @return com.ruoyi.common.core.domain.AjaxResult */ @ApiOperation("根据类型获取事件列表") - @GetMapping("/getEventList/{eventType}") - public AjaxResult getEventList(@ApiParam(value = "事件类型", name = "eventType",required = true) @PathVariable("eventType") String eventType){ - return trafficIncidentsService.getEventListByType(eventType); + @PostMapping("/getEventList") + public AjaxResult getEventList(DcEventListQuery dcEventListQuery){ + return trafficIncidentsService.getEventListByType(dcEventListQuery); } /** diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEventListQuery.java b/zc-business/src/main/java/com/zc/business/domain/DcEventListQuery.java new file mode 100644 index 00000000..691256a4 --- /dev/null +++ b/zc-business/src/main/java/com/zc/business/domain/DcEventListQuery.java @@ -0,0 +1,51 @@ +package com.zc.business.domain; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +import java.util.List; +import java.util.Map; + +/** + * 事件类型查询对象 + * + * @author ruoyi + * @date 2024-01-05 + */ +@ApiModel("事件类型查询对象") +public class DcEventListQuery +{ + + @ApiModelProperty(value = "事件类型", required = true) + private String eventType; + + @ApiModelProperty(value = "开始桩号") + private String startStakeMark; + + @ApiModelProperty(value = "结束桩号") + private String endStakeMark; + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String getStartStakeMark() { + return startStakeMark; + } + + public void setStartStakeMark(String startStakeMark) { + this.startStakeMark = startStakeMark; + } + + public String getEndStakeMark() { + return endStakeMark; + } + + public void setEndStakeMark(String endStakeMark) { + this.endStakeMark = endStakeMark; + } +} diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java index d0cfeb9b..d01d8a09 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java @@ -1,5 +1,6 @@ package com.zc.business.mapper; +import com.zc.business.domain.DcEventListQuery; import org.apache.ibatis.annotations.Param; import java.util.Date; @@ -49,10 +50,10 @@ public interface DcTrafficIncidentsMapper { * * @author liuwenge * @date 2024/1/13 14:29 - * @param eventType + * @param dcEventListQuery * @return java.util.List> */ - List> getEventListByType(String eventType); + List> getEventListByType(DcEventListQuery dcEventListQuery); /** * @Description 获取本日的交通事件数量 diff --git a/zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java b/zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java index 8687a48a..4fa04614 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java @@ -1,6 +1,7 @@ package com.zc.business.service; import com.ruoyi.common.core.domain.AjaxResult; +import com.zc.business.domain.DcEventListQuery; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -26,13 +27,13 @@ public interface IDcTrafficIncidentsService { AjaxResult getKeyData(); /** - * @param eventType + * @param dcEventListQuery * @return com.ruoyi.common.core.domain.AjaxResult * @Description 首页-事件专题-根据事件类型获取事件列表 * @author liuwenge * @date 2024/1/13 14:26 */ - AjaxResult getEventListByType(String eventType); + AjaxResult getEventListByType(DcEventListQuery dcEventListQuery); /** * @param eventId diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java index 4e0dea1e..54e2c14e 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java @@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.StakeMarkUtils; import com.ruoyi.common.utils.StringUtils; import com.zc.business.domain.DcEvent; +import com.zc.business.domain.DcEventListQuery; import com.zc.business.domain.DcEventType; import com.zc.business.mapper.DcTrafficIncidentsMapper; import com.zc.business.service.IDcTrafficIncidentsService; @@ -58,13 +59,27 @@ public class DcTrafficIncidentsServiceImpl implements IDcTrafficIncidentsService * * @author liuwenge * @date 2024/1/13 14:28 - * @param eventType + * @param dcEventListQuery * @return com.ruoyi.common.core.domain.AjaxResult */ @Override - public AjaxResult getEventListByType(String eventType){ + public AjaxResult getEventListByType(DcEventListQuery dcEventListQuery){ - List> eventList = trafficIncidentsMapper.getEventListByType(eventType); + if (StringUtils.isEmpty(dcEventListQuery.getEventType())){ + return AjaxResult.error("请选择事件类型!"); + } + + if (StringUtils.isNotEmpty(dcEventListQuery.getStartStakeMark())){ + String startStakeMark = StakeMarkUtils.formatMetre(dcEventListQuery.getStartStakeMark()); + dcEventListQuery.setStartStakeMark(startStakeMark); + } + + if (StringUtils.isNotEmpty(dcEventListQuery.getEndStakeMark())){ + String endStakeMark = StakeMarkUtils.formatMetre(dcEventListQuery.getEndStakeMark()); + dcEventListQuery.setEndStakeMark(endStakeMark); + } + + List> eventList = trafficIncidentsMapper.getEventListByType(dcEventListQuery); return AjaxResult.success(eventList); } diff --git a/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml b/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml index 3dc0613b..46746935 100644 --- a/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml @@ -21,10 +21,18 @@ where event_type = '7' and event_state != '2' - select t1.id,t1.stake_mark stakeMark,t1.direction,t1.lang, t2.longitude,t2.latitude from dc_event t1 left join dc_stake_mark t2 on t1.stake_mark = t2.stake_mark and t1.direction = t2.direction - where t1.event_type = #{eventType} and t1.event_state != '2' + + t1.event_type = #{eventType} and t1.event_state != '2' + + and t2.mileage >= #{startStakeMark} + + + and t2.mileage <= #{endStakeMark} + +