Browse Source

根据桩号筛选事件

develop
lau572 9 months ago
parent
commit
fb15ad9a01
  1. 22
      ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java
  2. 9
      zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java
  3. 51
      zc-business/src/main/java/com/zc/business/domain/DcEventListQuery.java
  4. 5
      zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java
  5. 5
      zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java
  6. 21
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java
  7. 12
      zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml

22
ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java

@ -19,12 +19,26 @@ public class StakeMarkUtils {
* @param stakeMark 桩号:"K123+123" * @param stakeMark 桩号:"K123+123"
* @return 公里数:123.123 * @return 公里数:123.123
*/ */
public BigDecimal format(String stakeMark){ public static String formatKilometre(String stakeMark){
if (StringUtils.isEmpty(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 stakeMark.toLowerCase().replace("k","").replace("+","");
return new BigDecimal(kilometre);
} }
/** /**

9
zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java

@ -1,6 +1,7 @@
package com.zc.business.controller; package com.zc.business.controller;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcEventListQuery;
import com.zc.business.service.IDcTrafficIncidentsService; import com.zc.business.service.IDcTrafficIncidentsService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -45,13 +46,13 @@ public class DcTrafficIncidentsController {
* *
* @author liuwenge * @author liuwenge
* @date 2024/1/13 14:27 * @date 2024/1/13 14:27
* @param eventType * @param
* @return com.ruoyi.common.core.domain.AjaxResult * @return com.ruoyi.common.core.domain.AjaxResult
*/ */
@ApiOperation("根据类型获取事件列表") @ApiOperation("根据类型获取事件列表")
@GetMapping("/getEventList/{eventType}") @PostMapping("/getEventList")
public AjaxResult getEventList(@ApiParam(value = "事件类型", name = "eventType",required = true) @PathVariable("eventType") String eventType){ public AjaxResult getEventList(DcEventListQuery dcEventListQuery){
return trafficIncidentsService.getEventListByType(eventType); return trafficIncidentsService.getEventListByType(dcEventListQuery);
} }
/** /**

51
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;
}
}

5
zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java

@ -1,5 +1,6 @@
package com.zc.business.mapper; package com.zc.business.mapper;
import com.zc.business.domain.DcEventListQuery;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.Date; import java.util.Date;
@ -49,10 +50,10 @@ public interface DcTrafficIncidentsMapper {
* *
* @author liuwenge * @author liuwenge
* @date 2024/1/13 14:29 * @date 2024/1/13 14:29
* @param eventType * @param dcEventListQuery
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>> * @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/ */
List<Map<String,Object>> getEventListByType(String eventType); List<Map<String,Object>> getEventListByType(DcEventListQuery dcEventListQuery);
/** /**
* @Description 获取本日的交通事件数量 * @Description 获取本日的交通事件数量

5
zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java

@ -1,6 +1,7 @@
package com.zc.business.service; package com.zc.business.service;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.zc.business.domain.DcEventListQuery;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@ -26,13 +27,13 @@ public interface IDcTrafficIncidentsService {
AjaxResult getKeyData(); AjaxResult getKeyData();
/** /**
* @param eventType * @param dcEventListQuery
* @return com.ruoyi.common.core.domain.AjaxResult * @return com.ruoyi.common.core.domain.AjaxResult
* @Description 首页-事件专题-根据事件类型获取事件列表 * @Description 首页-事件专题-根据事件类型获取事件列表
* @author liuwenge * @author liuwenge
* @date 2024/1/13 14:26 * @date 2024/1/13 14:26
*/ */
AjaxResult getEventListByType(String eventType); AjaxResult getEventListByType(DcEventListQuery dcEventListQuery);
/** /**
* @param eventId * @param eventId

21
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.StakeMarkUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.zc.business.domain.DcEvent; import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcEventListQuery;
import com.zc.business.domain.DcEventType; import com.zc.business.domain.DcEventType;
import com.zc.business.mapper.DcTrafficIncidentsMapper; import com.zc.business.mapper.DcTrafficIncidentsMapper;
import com.zc.business.service.IDcTrafficIncidentsService; import com.zc.business.service.IDcTrafficIncidentsService;
@ -58,13 +59,27 @@ public class DcTrafficIncidentsServiceImpl implements IDcTrafficIncidentsService
* *
* @author liuwenge * @author liuwenge
* @date 2024/1/13 14:28 * @date 2024/1/13 14:28
* @param eventType * @param dcEventListQuery
* @return com.ruoyi.common.core.domain.AjaxResult * @return com.ruoyi.common.core.domain.AjaxResult
*/ */
@Override @Override
public AjaxResult getEventListByType(String eventType){ public AjaxResult getEventListByType(DcEventListQuery dcEventListQuery){
List<Map<String,Object>> 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<Map<String,Object>> eventList = trafficIncidentsMapper.getEventListByType(dcEventListQuery);
return AjaxResult.success(eventList); return AjaxResult.success(eventList);
} }

12
zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml

@ -21,10 +21,18 @@
where event_type = '7' and event_state != '2' where event_type = '7' and event_state != '2'
</select> </select>
<select id="getEventListByType" resultType="java.util.Map" parameterType="String"> <select id="getEventListByType" resultType="java.util.Map" parameterType="DcEventListQuery">
select t1.id,t1.stake_mark stakeMark,t1.direction,t1.lang, t2.longitude,t2.latitude 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 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' <where>
t1.event_type = #{eventType} and t1.event_state != '2'
<if test="startStakeMark != null and startStakeMark != ''">
and t2.mileage >= #{startStakeMark}
</if>
<if test="endStakeMark != null and endStakeMark != ''">
and t2.mileage &lt;= #{endStakeMark}
</if>
</where>
</select> </select>
<select id="selectTrafficIncidentsDay" resultType="Long"> <select id="selectTrafficIncidentsDay" resultType="Long">

Loading…
Cancel
Save