Browse Source

1.事件管控分析接口

2.桩号距离计算工具
develop
lau572 10 months ago
parent
commit
708ee9059b
  1. 44
      ruoyi-common/src/main/java/com/ruoyi/common/utils/StakeMarkUtils.java
  2. 16
      zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java
  3. 23
      zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java
  4. 10
      zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java
  5. 19
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java
  6. 104
      zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml

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

@ -0,0 +1,44 @@
package com.ruoyi.common.utils;
import java.math.BigDecimal;
import java.math.RoundingMode;
/**
* @Description 桩号距离计算工具
*
* @author liuwenge
* @date 2024/1/17 14:43
*/
public class StakeMarkUtils {
/**
* @Description 计算桩号距离(公里)
*
* @author liuwenge
* @date 2024/1/17 14:45
* @param startStakeMark 开始桩号
* @param endStakeMark 结束桩号
* @return java.math.BigDecimal 距离
*/
public static BigDecimal getKilometre(String startStakeMark, String endStakeMark){
String start = startStakeMark.toLowerCase().replace("k","").replace("+",".");
String end = endStakeMark.toLowerCase().replace("k","").replace("+",".");
return new BigDecimal(end).subtract(new BigDecimal(start)).setScale(3, RoundingMode.HALF_UP);
}
/**
* @Description 计算桩号距离()
*
* @author liuwenge
* @date 2024/1/17 15:04
* @param startStakeMark 开始桩号
* @param endStakeMark 结束桩号
* @return java.math.BigDecimal 距离
*/
public static BigDecimal getMetre(String startStakeMark, String endStakeMark){
String start = startStakeMark.toLowerCase().replace("k","").replace("+",".");
String end = endStakeMark.toLowerCase().replace("k","").replace("+",".");
return new BigDecimal(end).subtract(new BigDecimal(start)).multiply(new BigDecimal("1000")).setScale(0, RoundingMode.HALF_UP);
}
}

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

@ -172,9 +172,23 @@ public class DcTrafficIncidentsController {
* @param params * @param params
* @return com.ruoyi.common.core.domain.AjaxResult * @return com.ruoyi.common.core.domain.AjaxResult
*/ */
@ApiOperation("收费站统计分析table") @ApiOperation("事故多发路段分析")
@PostMapping("/selectRoadSectionAnalysis") @PostMapping("/selectRoadSectionAnalysis")
public AjaxResult selectRoadSectionAnalysis(@RequestBody Map<String,Object> params){ public AjaxResult selectRoadSectionAnalysis(@RequestBody Map<String,Object> params){
return trafficIncidentsService.selectRoadSectionAnalysis(params); return trafficIncidentsService.selectRoadSectionAnalysis(params);
} }
/**
* @Description 路网管控-事件管控分析-事故类型分析
*
* @author liuwenge
* @date 2024/1/16 15:52
* @param params
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@ApiOperation("事故类型分析")
@PostMapping("/selectEventTypeAnalysis")
public AjaxResult selectEventTypeAnalysis(@RequestBody Map<String,Object> params){
return trafficIncidentsService.selectEventTypeAnalysis(params);
}
} }

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

@ -1,5 +1,7 @@
package com.zc.business.mapper; package com.zc.business.mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -190,4 +192,25 @@ public interface DcTrafficIncidentsMapper {
* @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>> getTollStationAnalysis(); List<Map<String,Object>> getTollStationAnalysis();
/**
* @Description 事故多发路段分析
*
* @author liuwenge
* @date 2024/1/17 14:18
* @param params
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/
List<Map<String,Object>> selectRoadSectionAnalysis(Map<String,Object> params);
/**
* @Description 事故类型分析
*
* @author liuwenge
* @date 2024/1/17 14:18
* @param params
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
*/
List<Map<String,Object>> selectEventTypeAnalysis(Map<String,Object> params);
} }

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

@ -115,4 +115,14 @@ public interface IDcTrafficIncidentsService {
* @return com.ruoyi.common.core.domain.AjaxResult * @return com.ruoyi.common.core.domain.AjaxResult
*/ */
AjaxResult selectRoadSectionAnalysis(Map<String,Object> params); AjaxResult selectRoadSectionAnalysis(Map<String,Object> params);
/**
* @Description 路网管控-事件管控分析-事故类型分析
*
* @author liuwenge
* @date 2024/1/16 15:52
* @param params
* @return com.ruoyi.common.core.domain.AjaxResult
*/
AjaxResult selectEventTypeAnalysis(Map<String,Object> params);
} }

19
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java

@ -1,6 +1,7 @@
package com.zc.business.service.impl; package com.zc.business.service.impl;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.StakeMarkUtils;
import com.zc.business.domain.DcEvent; import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcEventType; import com.zc.business.domain.DcEventType;
import com.zc.business.mapper.DcTrafficIncidentsMapper; import com.zc.business.mapper.DcTrafficIncidentsMapper;
@ -421,6 +422,22 @@ public class DcTrafficIncidentsServiceImpl implements IDcTrafficIncidentsService
@Override @Override
public AjaxResult selectRoadSectionAnalysis(Map<String,Object> params){ public AjaxResult selectRoadSectionAnalysis(Map<String,Object> params){
return AjaxResult.success(); List<Map<String,Object>> list = trafficIncidentsMapper.selectRoadSectionAnalysis(params);
return AjaxResult.success(list);
}
/**
* @Description 路网管控-事件管控分析-事故类型分析
*
* @author liuwenge
* @date 2024/1/16 15:52
* @param params
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult selectEventTypeAnalysis(Map<String,Object> params){
List<Map<String,Object>> list = trafficIncidentsMapper.selectEventTypeAnalysis(params);
return AjaxResult.success(list);
} }
} }

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

@ -236,4 +236,108 @@
on t3.id = t4.facilityId on t3.id = t4.facilityId
</select> </select>
<select id="selectRoadSectionAnalysis" resultType="java.util.Map">
select t3.section_name,t3.mileage,IFNULL(t4.num,0) num,IFNULL(t5.lastNum,0) lastNum,
ROUND(IFNULL( t4.num / t3.mileage * 100, 0 ),2) avgNum
from
(select * from dc_road_section) t3
LEFT JOIN
(select t2.section_id, count(*) num
from dc_event t1
left join dc_stake_mark t2 on t1.stake_mark = t2.id and t1.direction = t2.direction
where
t1.event_type = '1' and t1.direction = #{direction}
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(t1.start_time,'%Y%m%d') = DATE_FORMAT(#{startTime},'%Y%m%d')
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(t1.start_time,'%Y%m') = DATE_FORMAT(#{startTime},'%Y%m')
</if>
<if test="type != null and type == '3'.toString">
and YEAR(t1.start_time) = YEAR(#{startTime}) and QUARTER(t1.start_time) = QUARTER(#{startTime})
</if>
<if test="type != null and type == '4'.toString">
and YEAR(t1.start_time) = YEAR(#{startTime})
</if>
GROUP BY t2.section_id) t4
on t3.id = t4.section_id
LEFT JOIN
(select t2.section_id, count(*) lastNum
from dc_event t1
left join dc_stake_mark t2 on t1.stake_mark = t2.id and t1.direction = t2.direction
where
t1.event_type = '1' and t1.direction = #{direction}
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(t1.start_time,'%Y%m%d') = DATE_FORMAT(DATE_SUB(#{startTime},INTERVAL 1 DAY),'%Y%m%d')
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(t1.start_time,'%Y%m') = DATE_FORMAT(DATE_SUB(#{startTime},INTERVAL 1 MONTH),'%Y%m')
</if>
<if test="type != null and type == '3'.toString">
and YEAR(t1.start_time) = YEAR(DATE_SUB(#{startTime},INTERVAL 1 QUARTER)) and QUARTER(t1.start_time) = QUARTER(DATE_SUB(#{startTime},INTERVAL 1 QUARTER))
</if>
<if test="type != null and type == '4'.toString">
and YEAR(t1.start_time) = YEAR(DATE_SUB(#{startTime},INTERVAL 1 YEAR))
</if>
GROUP BY t2.section_id) t5
on t3.id = t5.section_id
</select>
<select id="selectEventTypeAnalysis" resultType="java.util.Map">
select t1.eventSubclass,t1.eventSubclassName,
IFNULL(t2.minuteTime,0) minuteTime,ROUND(IFNULL(t2.minuteTime/t2.num,0)) avgTime,
IFNULL(t3.minuteTime,0) lastMinuteTime,ROUND(IFNULL(t3.minuteTime/t3.num,0)) lastAvgTime
from
(select '1-1' eventSubclass, '追尾' eventSubclassName
UNION ALL select '1-2' eventSubclass, '侧翻' eventSubclassName
UNION ALL select '1-3' eventSubclass, '撞护栏' eventSubclassName
UNION ALL select '1-4' eventSubclass, '自燃' eventSubclassName
UNION ALL select '1-5' eventSubclass, '其他事故' eventSubclassName) t1
LEFT JOIN
(select event_subclass, count(*) num ,
sum(case when ISNULL(end_time)
then TIMESTAMPDIFF(MINUTE,start_time,now())
else TIMESTAMPDIFF(MINUTE,start_time,end_time)
end) minuteTime
from dc_event
where event_type = '1'
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(start_time,'%Y%m%d') = DATE_FORMAT(#{startTime},'%Y%m%d')
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(start_time,'%Y%m') = DATE_FORMAT(#{startTime},'%Y%m')
</if>
<if test="type != null and type == '3'.toString">
and YEAR(start_time) = YEAR(#{startTime}) and QUARTER(start_time) = QUARTER(#{startTime})
</if>
<if test="type != null and type == '4'.toString">
and YEAR(start_time) = YEAR(#{startTime})
</if>
group by event_subclass) t2
on t1.eventSubclass = t2.event_subclass
LEFT JOIN
(select event_subclass, count(*) num ,
sum(case when ISNULL(end_time)
then TIMESTAMPDIFF(MINUTE,start_time,now())
else TIMESTAMPDIFF(MINUTE,start_time,end_time)
end) minuteTime
from dc_event
where event_type = '1'
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(start_time,'%Y%m%d') = DATE_FORMAT(DATE_SUB(#{startTime},INTERVAL 1 DAY),'%Y%m%d')
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(start_time,'%Y%m') = DATE_FORMAT(DATE_SUB(#{startTime},INTERVAL 1 MONTH),'%Y%m')
</if>
<if test="type != null and type == '3'.toString">
and YEAR(start_time) = YEAR(DATE_SUB(#{startTime},INTERVAL 1 QUARTER)) and QUARTER(start_time) = QUARTER(DATE_SUB(#{startTime},INTERVAL 1 QUARTER))
</if>
<if test="type != null and type == '4'.toString">
and YEAR(start_time) = YEAR(DATE_SUB(#{startTime},INTERVAL 1 YEAR))
</if>
group by event_subclass) t3 on t1.eventSubclass = t3.event_subclass
</select>
</mapper> </mapper>
Loading…
Cancel
Save