Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
王兴琳 6 months ago
parent
commit
372658a064
  1. 50
      zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java
  2. 6
      zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java
  3. 4
      zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java
  4. 23
      zc-business/src/main/java/com/zc/business/domain/DcWarning.java
  5. 16
      zc-business/src/main/java/com/zc/business/mapper/DcPerceivedEventsWarningMapper.java
  6. 8
      zc-business/src/main/java/com/zc/business/service/IDCPerceivedEventsWarningService.java
  7. 6
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  8. 101
      zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java
  9. 36
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  10. 140
      zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml
  11. 2
      zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml

50
zc-business/src/main/java/com/zc/business/controller/DCPerceivedEventsWarningController.java

@ -72,11 +72,7 @@ public class DCPerceivedEventsWarningController extends BaseController {
startPage();
return getDataTable(perceivedEventsWarningService.selectWarningList(dcWarning));
}
//查询感知数量按照路段数量进行排名
@PostMapping("/sectionPerceivedList")
public AjaxResult getSectionPerceivedEventsList(){
return AjaxResult.success(perceivedEventsWarningService.selectSectionPerceivedEventsList());
}
//查询感知数量按照路段进行区分
@PostMapping("/sectionPerceivedNumber")
public AjaxResult getSectionPerceivedNumber(){
@ -246,4 +242,48 @@ public class DCPerceivedEventsWarningController extends BaseController {
}
return AjaxResult.success(perceivedEventsWarningService.selectNonAutomaticWarningFacility(dcWarning));
}
//新-感知事件多发时段
@PostMapping("/manyTimesInterval")
public AjaxResult manyTimesInterval(@RequestBody DcWarning dcWarning){
if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null
||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark())
||StringUtils.isBlank(dcWarning.getDirection())){
return AjaxResult.error("参数错误");
}
return AjaxResult.success(perceivedEventsWarningService.selectManyTimesInterval(dcWarning));
}
//新-感知事件类型分析
@PostMapping("/selectWarningType")
public AjaxResult selectWarningType(@RequestBody DcWarning dcWarning){
if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null
||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark())
||StringUtils.isBlank(dcWarning.getDirection())){
return AjaxResult.error("参数错误");
}
return AjaxResult.success(perceivedEventsWarningService.newSelectWarningType(dcWarning));
}
//新-感知事件桩号范围内事件分析
@PostMapping("/selectSection")
public AjaxResult selectSection(@RequestBody DcWarning dcWarning){
if (dcWarning==null||StringUtils.isBlank(dcWarning.getType())||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null
||StringUtils.isBlank(dcWarning.getStartStakeMark())||StringUtils.isBlank(dcWarning.getEndStakeMark())
||StringUtils.isBlank(dcWarning.getDirection())){
return AjaxResult.error("参数错误");
}
return AjaxResult.success(perceivedEventsWarningService.newSelectSection(dcWarning));
}
//新-感知事件路段处置类型分析
@PostMapping("/selectStateType")
public AjaxResult selectStateType(@RequestBody DcWarning dcWarning){
if (dcWarning==null||dcWarning.getCurrently()==null||dcWarning.getLastYear()==null){
return AjaxResult.error("参数错误");
}
return AjaxResult.success(perceivedEventsWarningService.newSelectStateType(dcWarning));
}
//查询感知数量按照路段数量进行排名
@PostMapping("/sectionPerceivedList")
public AjaxResult getSectionPerceivedEventsList(){
return AjaxResult.success(perceivedEventsWarningService.selectSectionPerceivedEventsList());
}
}

6
zc-business/src/main/java/com/zc/business/controller/DcEventProcessController.java

@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.exception.file.InvalidExtensionException;
@ -104,8 +105,11 @@ public class DcEventProcessController extends BaseController
// @PreAuthorize("@ss.hasPermi('system:process:add')")
@Log(title = "事件处理流程", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DcEventProcess dcEventProcess){
public AjaxResult add(@RequestBody @Valid DcEventProcess dcEventProcess){
DcEvent dcEvent = dcEventService.selectDcEventById(dcEventProcess.getEventId());
if (dcEvent == null){
return AjaxResult.error("事件信息有误!");
}
if (dcEvent.getEventState() == 2){
return AjaxResult.error("事件已结束,无法进行操作!");
}

4
zc-business/src/main/java/com/zc/business/domain/DcEventProcess.java

@ -9,7 +9,9 @@ import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
/**
* 事件处理流程对象 dc_event_process
@ -28,6 +30,7 @@ public class DcEventProcess
/** $column.columnComment */
@ApiModelProperty(value="事件ID")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@NotBlank(message = "事件ID不能为空")
private String eventId;
/** $column.columnComment */
@ -73,6 +76,7 @@ public class DcEventProcess
/** $column.columnComment */
@ApiModelProperty("内容")
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@Size(max = 500, message = "内容不能超过500个字符")
private String context;
/** $column.type */

23
zc-business/src/main/java/com/zc/business/domain/DcWarning.java

@ -120,6 +120,29 @@ public class DcWarning extends BaseEntity
//收费站
private String facilityName;
//去年同期时间参数
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
private Date lastYear;
//当下时间参数
@JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8")
private Date currently;
public Date getCurrently() {
return currently;
}
public void setCurrently(Date currently) {
this.currently = currently;
}
public Date getLastYear() {
return lastYear;
}
public void setLastYear(Date lastYear) {
this.lastYear = lastYear;
}
public String getRelieveReason() {
return relieveReason;
}

16
zc-business/src/main/java/com/zc/business/mapper/DcPerceivedEventsWarningMapper.java

@ -100,4 +100,20 @@ public interface DcPerceivedEventsWarningMapper {
List<HashMap<String,Object>> selectNonAutomaticWarningFacilityMonth(DcWarning dcWarning);
//查询非机预警数据按照年和收费站分组
List<HashMap<String,Object>> selectNonAutomaticWarningFacilityYear(DcWarning dcWarning);
//新-感知事件按照路段查询小时分组-日
List<HashMap<String,Object>> newSelectSectionDay(DcWarning dcWarning);
//新-感知事件按照路段查询小时分组-月
List<HashMap<String,Object>> newSelectSectionMonth(DcWarning dcWarning);
//新-感知事件按照路段查询小时分组-年
List<HashMap<String,Object>> newSelectSectionYear(DcWarning dcWarning);
//新-感知事件按照类型查询数量-日/月/年
List<HashMap<String,Object>> newSelectWarningType(DcWarning dcWarning);
//新-感知事件桩号范围内事件分析
List<HashMap<String,Object>> newSelectSection(DcWarning dcWarning);
//新-感知事件路段处置类型分析
List<HashMap<String,Object>> newSelectStateType(DcWarning dcWarning);
//新-感知事件路段处置类型分析-平均处置时长
List<HashMap<String,Object>> newStateDuration(DcWarning dcWarning);
}

8
zc-business/src/main/java/com/zc/business/service/IDCPerceivedEventsWarningService.java

@ -61,4 +61,12 @@ public interface IDCPerceivedEventsWarningService {
//查询非机预警数据按照日和收费站分组
List<HashMap<String,Object>> selectNonAutomaticWarningFacility(DcWarning dcWarning);
//新-感知时间多发时段
HashMap<String,Object> selectManyTimesInterval(DcWarning dcWarning);
//新-感知事件按照类型查询数量-日/月/年
HashMap<String,Object> newSelectWarningType(DcWarning dcWarning);
//新-感知事件桩号范围内事件分析
HashMap<String,Object> newSelectSection(DcWarning dcWarning);
//新-感知事件路段处置类型分析
HashMap<String,Object> newSelectStateType(DcWarning dcWarning);
}

6
zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java

@ -102,9 +102,11 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
@Override
public DcEvent selectDcEventById(String id) {
DcEvent dcEvent = dcEventMapper.selectDcEventById(id);
if (dcEvent != null){
List<DcProcessConfig> processConfigList = dcProcessConfigMapper.selectDcProcessConfigByEventType(Math.toIntExact(dcEvent.getEventType()));
dcEvent.setProcessConfigList(processConfigList);
}
List<DcProcessConfig> processConfigList = dcProcessConfigMapper.selectDcProcessConfigByEventType(Math.toIntExact(dcEvent.getEventType()));
dcEvent.setProcessConfigList(processConfigList);
return dcEvent;
}

101
zc-business/src/main/java/com/zc/business/service/impl/DcPerceivedEventsWarningServiceImpl.java

@ -11,9 +11,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author 王思祥
@ -310,6 +314,103 @@ public class DcPerceivedEventsWarningServiceImpl implements IDCPerceivedEventsWa
}
return null;
}
//新-感知时间多发时段
@Override
public HashMap<String, Object> selectManyTimesInterval(DcWarning dcWarning) {
String startStakeMark = StakeMarkUtils.formatMetre(dcWarning.getStartStakeMark());
dcWarning.setStartStakeMark(startStakeMark);
String endStakeMark = StakeMarkUtils.formatMetre(dcWarning.getEndStakeMark());
dcWarning.setEndStakeMark(endStakeMark);
String type = dcWarning.getType();
HashMap<String, Object> hashMap = new HashMap<>();
switch (type){
case "day":
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectSectionDay(dcWarning));
break;
case "month":
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectSectionMonth(dcWarning));
break;
case "year":
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectSectionYear(dcWarning));
break;
}
dcWarning.setCurrently(dcWarning.getLastYear());//把传入的去年的时间参数,转为当下时间作为查询参数(因为mapper中的查询提交参数是当下时间)
switch (type) {
case "day":
hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectSectionDay(dcWarning));
break;
case "month":
hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectSectionMonth(dcWarning));
break;
case "year":
hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectSectionYear(dcWarning));
break;
}
return hashMap;
}
//新-感知事件按照类型查询数量-日/月/年
@Override
public HashMap<String, Object> newSelectWarningType(DcWarning dcWarning) {
String startStakeMark = StakeMarkUtils.formatMetre(dcWarning.getStartStakeMark());
dcWarning.setStartStakeMark(startStakeMark);
String endStakeMark = StakeMarkUtils.formatMetre(dcWarning.getEndStakeMark());
dcWarning.setEndStakeMark(endStakeMark);
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectWarningType(dcWarning));
dcWarning.setCurrently(dcWarning.getLastYear());
hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectWarningType(dcWarning));
return hashMap;
}
//新-感知事件桩号范围内事件分析
@Override
public HashMap<String, Object> newSelectSection(DcWarning dcWarning) {
HashMap<String, Object> hashMap = new HashMap<>();
String startStakeMark = StakeMarkUtils.formatMetre(dcWarning.getStartStakeMark());
dcWarning.setStartStakeMark(startStakeMark);
String endStakeMark = StakeMarkUtils.formatMetre(dcWarning.getEndStakeMark());
dcWarning.setEndStakeMark(endStakeMark);
hashMap.put("currentlyMap", selectSectionUtils(dcWarning));
dcWarning.setCurrently(dcWarning.getLastYear());//时间参数转换,把去年的时间替换为查询时间参数
hashMap.put("lastYearMap", selectSectionUtils(dcWarning));
return hashMap;
}
public Map<String, Integer> selectSectionUtils(DcWarning dcWarning){
//数据
List<HashMap<String, Object>> mapList = perceivedEventsWarningMapper.newSelectSection(dcWarning);
// 用于存储结果的Map,key为stakeMark,value为对应的number总和
Map<String, Integer> stakeMarkToNumberSum = new HashMap<>();
// 遍历mapList
for (Map<String, Object> map : mapList) {
String stakeMarkValue =map.get("stakeMark").toString();
String stakeMark = stakeMarkValue.substring(0, stakeMarkValue.indexOf("+"));
Integer number = Integer.valueOf(map.get("number").toString());
// 如果stakeMarkToNumberSum中还没有这个stakeMark的条目,则添加并初始化为0
stakeMarkToNumberSum.putIfAbsent(stakeMark, 0);
// 将当前map的number加到对应stakeMark的总和中
Integer currentSum = stakeMarkToNumberSum.get(stakeMark);
stakeMarkToNumberSum.put(stakeMark, currentSum + number);
}
// 打印结果
// for (Map.Entry<String, Integer> entry : stakeMarkToNumberSum.entrySet()) {
// System.out.println("stakeMark: " + entry.getKey() + ", number sum: " + entry.getValue());
// }
return stakeMarkToNumberSum;
}
//新-感知事件路段处置类型分析-
@Override
public HashMap<String, Object> newSelectStateType(DcWarning dcWarning) {
HashMap<String, Object> hashMap = new HashMap<>();
hashMap.put("stateDuration", perceivedEventsWarningMapper.newStateDuration(dcWarning));
hashMap.put("currentlyMap", perceivedEventsWarningMapper.newSelectStateType(dcWarning));
dcWarning.setCurrently(dcWarning.getLastYear());
hashMap.put("lastYearMap", perceivedEventsWarningMapper.newSelectStateType(dcWarning));
return hashMap;
}
}

36
zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

@ -1,13 +1,19 @@
package com.zc.business.service.impl;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.zc.business.domain.*;
import com.zc.business.domain.DcDispatch;
import com.zc.business.domain.DcDispatchResource;
import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcEventProcess;
import com.zc.business.domain.DcTrafficPolice;
import com.zc.business.domain.DcWaringStrategy;
import com.zc.business.domain.DcWarning;
import com.zc.business.domain.DcWarningBatchConvert;
import com.zc.business.enums.ValueConverter;
import com.zc.business.enums.WarningSubclassEnum;
import com.zc.business.mapper.DcEventMapper;
@ -22,21 +28,18 @@ import com.zc.common.core.websocket.constant.WebSocketEvent;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.lang.reflect.Array;
import java.rmi.MarshalledObject;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -629,6 +632,10 @@ public class DcWarningServiceImpl implements IDcWarningService
public AjaxResult commandAndDispatch(DcWarning dcWarning) {
Map<String, Object> mapAll = new HashMap<>();
HashMap<String, Object> dcDispatch = dcWarningMapper.selectDcDispatch(dcWarning.getId());//查询是否存在调度记录
if (dcDispatch==null){
mapAll.put("existence",0);
return AjaxResult.success(mapAll);
}
//逻辑,调用全部的机构信息,计算传入的桩号与机构桩号的距离作为排序使用,使用机构的id调出车辆,人员,值班等信息
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
@ -662,10 +669,7 @@ public class DcWarningServiceImpl implements IDcWarningService
DcTrafficPolice dcTrafficPolice = dcTrafficPoliceService.selectEvent(dcWarning.getStakeMark());
mapAll.put("trafficPolice",dcTrafficPolice);
}
if (dcDispatch==null){
mapAll.put("existence",0);
return AjaxResult.success(mapAll);
}
mapAll.put("dispatchId",dcDispatch.get("id"));
mapAll.put("existence",1);
HashMap<String, Object> map = dcWarningMapper.selectDcDispatch(dcWarning.getId());//获取机构id与资源id
@ -776,6 +780,10 @@ public class DcWarningServiceImpl implements IDcWarningService
dcDispatch.setStartTime(DateUtils.getNowDate());
dcDispatch.setDispatchStatus(2L);//进行中状态
dcDispatch.setRemark(remark);
HashMap<String, Object> dispatch = dcWarningMapper.selectDcDispatch(eventId);//查询是否存在调度记录
if (dispatch!=null){ //不为空说明已经存在处置记录,不在新增
return AjaxResult.success("已经存在记录");
}
Integer integer = dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
if (integer==0){
return AjaxResult.error();
@ -810,7 +818,7 @@ public class DcWarningServiceImpl implements IDcWarningService
}
return dcWarningMapper.updateDcDispatch(dcDispatch);
}
//4.新增指挥调度资源记录
@Override
@Transactional(rollbackFor = Exception.class)
public Integer insertDispatchSource(HashMap map) {
@ -823,6 +831,10 @@ public class DcWarningServiceImpl implements IDcWarningService
dcDispatch.setStartTime(DateUtils.getNowDate());
dcDispatch.setDispatchStatus(2L);//进行中状态
dcDispatch.setRemark(remark);
HashMap<String, Object> dispatch = dcWarningMapper.selectDcDispatch(eventId);//查询是否存在调度记录
if (dispatch!=null){ //不为空说明已经存在处置记录,不在新增
return 1;
}
dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
Long dispatchId = dcDispatch.getId();
dcWarningMapper.deleteDispatchResource(dispatchId);//删除全部属于该调度记录下的全部资源

140
zc-business/src/main/resources/mapper/business/DcPerceivedEventsWarningMapper.xml

@ -119,7 +119,7 @@
order by warning.warning_time desc
</select>
<select id="selectSectionPerceivedEventsList" resultType="hashmap">
SELECT s.section_name AS sectionName, COALESCE(w_count.number, 0) AS number2
SELECT s.section_name AS sectionName, COALESCE(w_count.number, 0) AS number
FROM dc_road_section AS s
LEFT JOIN ( SELECT mark.section_id, COUNT(1) AS number FROM dc_warning AS w JOIN
dc_stake_mark AS mark ON mark.stake_mark = w.stake_mark AND mark.direction = w.direction
@ -542,5 +542,141 @@
<!-- HAVING sectionNumber!=0-->
<!-- </select>-->
<select id="newSelectSectionDay" resultType="java.util.HashMap">
SELECT
DATE_FORMAT(#{currently} + INTERVAL a.a HOUR, '%Y-%m-%d %H') AS time,
IFNULL(SUM(CASE WHEN dw.warning_source != 6 AND
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark,'+',1),2)AS UNSIGNED)*1000
+ CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED)&gt;#{startStakeMark} AND
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark,'+',1),2)AS UNSIGNED)*1000
+ CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED)&lt;#{endStakeMark}
THEN 1 ELSE 0 END), 0) AS number
FROM (
SELECT 0 AS a
UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12
UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15
UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18
UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21
UNION ALL SELECT 22 UNION ALL SELECT 23
) AS a
LEFT JOIN dc_warning dw ON DATE_FORMAT(dw.warning_time, '%Y-%m-%d %H')
= DATE_FORMAT(#{currently} + INTERVAL a.a HOUR, '%Y-%m-%d %H') and dw.warning_source!=6
and dw.direction=#{direction}
GROUP BY time
ORDER BY time;
</select>
<select id="newSelectSectionMonth" resultType="java.util.HashMap">
SELECT
h.hour_num AS time,
COUNT(dw.warning_time) AS number
FROM (
SELECT 0 AS hour_num UNION ALL
SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12
UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15
UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18
UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21
UNION ALL SELECT 22 UNION ALL SELECT 23
) h
LEFT JOIN dc_warning dw ON HOUR(dw.warning_time) = h.hour_num
AND DATE_FORMAT(dw.warning_time, '%Y-%m') = DATE_FORMAT(#{currently}, '%Y-%m')
AND dw.warning_source != 6
AND (
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 +
CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED) >= #{startStakeMark} AND
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 +
CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED) &lt;#{endStakeMark}
) and dw.direction=#{direction}
GROUP BY h.hour_num
ORDER BY h.hour_num;
</select>
<select id="newSelectSectionYear" resultType="java.util.HashMap">
SELECT
h.hour_num AS time,
COUNT(dw.warning_time) AS number
FROM (
SELECT 0 AS hour_num UNION ALL
SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3
UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6
UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9
UNION ALL SELECT 10 UNION ALL SELECT 11 UNION ALL SELECT 12
UNION ALL SELECT 13 UNION ALL SELECT 14 UNION ALL SELECT 15
UNION ALL SELECT 16 UNION ALL SELECT 17 UNION ALL SELECT 18
UNION ALL SELECT 19 UNION ALL SELECT 20 UNION ALL SELECT 21
UNION ALL SELECT 22 UNION ALL SELECT 23
) h
LEFT JOIN dc_warning dw ON HOUR(dw.warning_time) = h.hour_num
AND YEAR(dw.warning_time) = YEAR(#{currently})
AND dw.warning_source != 6
AND (
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 +
CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED) >= #{startStakeMark} AND
CAST(SUBSTRING(SUBSTRING_INDEX(dw.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 +
CAST(SUBSTRING_INDEX(dw.stake_mark, '+', -1) AS UNSIGNED)&lt;#{endStakeMark}
) and dw.direction=#{direction}
GROUP BY h.hour_num
ORDER BY h.hour_num;
</select>
<select id="newSelectWarningType" resultType="java.util.HashMap">
SELECT warning.warning_type warningType,
COUNT(*) AS number
FROM dc_warning as warning
where
<if test = 'type == "day"' > DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{currently},'%Y-%m-%d')</if>
<if test = 'type == "month"' > DATE_FORMAT(warning_time,'%Y-%m') =DATE_FORMAT(#{currently},'%Y-%m')</if>
<if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{currently},'%Y')</if>
AND warning.direction=#{direction} and warning.warning_source!=6
AND (
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 +
CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)>= #{startStakeMark} AND
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 +
CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)&lt;#{endStakeMark}
)
GROUP BY warning_type
ORDER BY number DESC
</select>
<select id="newSelectSection" resultType="java.util.HashMap">
SELECT warning.stake_mark stakeMark,
COUNT(*) AS number
FROM dc_warning as warning
where
<if test = 'type == "day"' > DATE_FORMAT(warning.warning_time,'%Y-%m-%d')=DATE_FORMAT(#{currently},'%Y-%m-%d')</if>
<if test = 'type == "month"' > DATE_FORMAT(warning_time,'%Y-%m') =DATE_FORMAT(#{currently},'%Y-%m')</if>
<if test = 'type == "year"' > YEAR(warning_time) =DATE_FORMAT(#{currently},'%Y')</if>
AND warning.direction=#{direction} and warning.warning_source!=6
AND (
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 +
CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED) >= #{startStakeMark} AND
CAST(SUBSTRING(SUBSTRING_INDEX(warning.stake_mark, '+', 1), 2) AS UNSIGNED) * 1000 +
CAST(SUBSTRING_INDEX(warning.stake_mark, '+', -1) AS UNSIGNED)&lt;#{endStakeMark}
)
GROUP BY stakeMark
ORDER BY number DESC
</select>
<select id="newSelectStateType" resultType="java.util.HashMap">
SELECT s.section_name sectionName, w.warning_state AS warningState, COUNT(*) AS num
FROM dc_warning AS w
LEFT JOIN dc_stake_mark AS sm ON w.stake_mark = sm.stake_mark and w.direction=sm.direction
LEFT JOIN dc_road_section AS s ON sm.section_id = s.id
WHERE w.warning_source != 6 AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{currently}, '%Y-%m-%d')
GROUP BY w.warning_state,sectionName
ORDER BY sectionName
</select>
<select id="newStateDuration" resultType="java.util.HashMap">
SELECT s.section_name sectionName, s.id sectionId,
ROUND(AVG(TIMESTAMPDIFF(MINUTE, w.warning_time, w.end_time)), 2) AS avg
FROM dc_warning AS w
LEFT JOIN
dc_stake_mark AS sm ON w.stake_mark = sm.stake_mark AND w.direction = sm.direction
LEFT JOIN
dc_road_section AS s ON sm.section_id = s.id
WHERE w.warning_source != 6
AND DATE_FORMAT(w.warning_time, '%Y-%m-%d') = DATE_FORMAT(#{currently}, '%Y-%m-%d')
GROUP BY s.section_name;
</select>
</mapper>

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

@ -57,7 +57,7 @@
<select id="selectTrafficIncidentsAllProcessing" resultType="java.lang.Long">
select count(*) from dc_event
where event_state != '2'
where event_state = '1'
</select>
<select id="selectEventTypeList" resultType="java.util.Map">

Loading…
Cancel
Save