Browse Source

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

develop
王兴琳 6 months ago
parent
commit
aa969c698e
  1. 28
      zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java
  2. 7
      zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java
  3. 27
      zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java
  4. 9
      zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java
  5. 2
      zc-business/src/main/java/com/zc/business/service/IDcSdhsEventService.java
  6. 5
      zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java
  7. 125
      zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java
  8. 17
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java
  9. 25
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
  10. 47
      zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml
  11. BIN
      zc-business/src/main/resources/wordTemplate/charSection.docx
  12. BIN
      zc-business/src/main/resources/wordTemplate/typeAnalysis.docx

28
zc-business/src/main/java/com/zc/business/controller/CodeScanningAlarmController.java

@ -143,22 +143,20 @@ public class CodeScanningAlarmController extends BaseController {
dcWarning.setOtherConfig(String.valueOf(JSONObject.parseObject(JSONObject.toJSONString(otherConfig))));
dcWarningService.updateDcWarning(dcWarning);
String warningState = oldData.get("warningState").toString();
if (warningState.equals("2")){
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(oldData.get("id").toString());
dcEventProcess.setSource(2);
if (type.equals("video")){
dcEventProcess.setType("mp4");
} else {
dcEventProcess.setType("png");
}
dcEventProcess.setContext(url);
dcEventProcess.setOperatorName("上报人");
dcEventProcess.setOperationTime(new Date());
dcEventProcessMapper.insertDcEventProcess(dcEventProcess);
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(oldData.get("id").toString());
dcEventProcess.setSource(2);
if (type.equals("video")){
dcEventProcess.setType("mp4");
} else {
dcEventProcess.setType("png");
}
dcEventProcess.setContext(url);
dcEventProcess.setOperatorName("上报人");
dcEventProcess.setOperationTime(new Date());
dcEventProcessMapper.insertDcEventProcess(dcEventProcess);
return AjaxResult.success("添加成功");
}

7
zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java

@ -241,6 +241,13 @@ public class DcSdhsEventController {
return dcSdhsEventService.selectAccidentType(dcSdhsEventQuery);
}
@ApiOperation("查询天气情况统计")
@PostMapping("/selectWeather")
public AjaxResult selectWeather()
{
return dcSdhsEventService.selectWeather();
}
}

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

@ -2,7 +2,9 @@ package com.zc.business.controller;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.domain.DcEvent;
import com.zc.business.domain.DcEventListQuery;
import com.zc.business.domain.DcWarning;
import com.zc.business.domain.export.*;
import com.zc.business.enums.UniversalEnum;
import com.zc.business.service.IDcTrafficIncidentsService;
@ -10,6 +12,7 @@ import com.zc.common.core.httpclient.exception.HttpException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
@ -20,8 +23,10 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -670,4 +675,26 @@ public class DcTrafficIncidentsController {
ExcelUtil<EventTypeAnalysis> util = new ExcelUtil<>(EventTypeAnalysis.class);
util.exportExcel(response, list, "事故类型分析");
}
//事件时间数量占比
@PostMapping("/selectEventTimeProportion")
public AjaxResult selectEventTimeProportion(@RequestBody DcWarning dcWarning){
if (dcWarning==null|| StringUtils.isBlank(dcWarning.getDirection())||StringUtils.isBlank(dcWarning.getType())||
dcWarning.getCurrently()==null||dcWarning.getLastYear()==null){
return AjaxResult.success("参数存在异常");
}
Date currently = dcWarning.getCurrently();
Date lastYear = dcWarning.getLastYear();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String formattedDate = sdf.format(currently);
String format = sdf.format(lastYear);
List<HashMap<String, Object>> currentlyMap = trafficIncidentsService.selectEventTimeProportion(dcWarning.getDirection(),
dcWarning.getType(), formattedDate);
List<HashMap<String, Object>> lastYearMap = trafficIncidentsService.selectEventTimeProportion(dcWarning.getDirection(),
dcWarning.getType(), format);
HashMap<Object, Object> hashMap = new HashMap<>();
hashMap.put("currentlyMap",currentlyMap);
hashMap.put("lastYearMap",lastYearMap);
return AjaxResult.success(hashMap);
}
}

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

@ -4,6 +4,7 @@ import com.zc.business.domain.DcEventListQuery;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -329,4 +330,12 @@ public interface DcTrafficIncidentsMapper {
*/
List<Map<String,Object>> selectCongestionMileage();
//事件数量时间占比-天
List<HashMap<String,Object>> selectEventTimeProportionDay(@Param("direction") String direction,@Param("startTime") String startTime);
//事件数量时间占比-月
List<HashMap<String,Object>> selectEventTimeProportionMonth(@Param("direction") String direction,@Param("startTime") String startTime);
//事件数量时间占比-季度
List<HashMap<String,Object>> selectEventTimeProportionQUARTER(@Param("direction") String direction,@Param("startTime") String startTime);
//事件数量时间占比-年
List<HashMap<String,Object>> selectEventTimeProportionYear(@Param("direction") String direction,@Param("startTime") String startTime);
}

2
zc-business/src/main/java/com/zc/business/service/IDcSdhsEventService.java

@ -65,4 +65,6 @@ public interface IDcSdhsEventService
AjaxResult selectAccidentType(DcSdhsEventQuery dcSdhsEventQuery);
void exportAccidentType(XWPFDocument doc, DcSdhsEventQuery dcSdhsEventQuery);
AjaxResult selectWeather();
}

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

@ -7,6 +7,8 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -147,4 +149,7 @@ public interface IDcTrafficIncidentsService {
*/
// AjaxResult selectEventTypeAnalysis(Map<String,Object> params);
AjaxResult selectEventTypeAnalysis(String direction, String type, String startTime);
//事件时间数量占比
public List<HashMap<String,Object>> selectEventTimeProportion(String direction, String type, String startTime);
}

125
zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java

@ -7,6 +7,7 @@ import com.ruoyi.common.utils.StakeMarkUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.controller.WeatherForecastController;
import com.zc.business.domain.DcSdhsEvent;
import com.zc.business.domain.DcSdhsEventQuery;
import com.zc.business.enums.UniversalEnum;
@ -57,6 +58,8 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
@Autowired
private RedisCache redisCache;
@Autowired
private WeatherForecastController weatherForecastController;
@Override
@ -1209,4 +1212,126 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService {
addDescription(doc,UniversalEnum.NO_DATA_AVAILABLE.getValue());
}
}
/**
* @Description 查询天气情况统计
*
* @author liuwenge
* @date 2024/8/21 17:14
* @param
* @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
public AjaxResult selectWeather(){
HashMap<String,Object> params = new HashMap<>();
params.put("roadId",UniversalEnum.ROAD_ID.getValue());
params.put("stakeNum",UniversalEnum.STAKE_NUM.getValue());
params.put("forecastHour",UniversalEnum.TWENTY_FOUR.getValue());
AjaxResult ajaxResult = weatherForecastController.currentWeatherAndForecastInformation(params);
Map<String,Object> result = new HashMap<>();
Map<String,Object> column = new HashMap<>();
List<Map<String,Object>> dataList = new ArrayList<>();
if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
List<Map<String,Object>> data = (List<Map<String,Object>>) ajaxResult.get("data");
if (data != null && data.size() != UniversalEnum.ZERO.getNumber()){
DateTimeFormatter parseFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
data.forEach(dataItem ->{
Map<String,Object> regionMap = new HashMap<>();
if (UniversalEnum.STAKE_NUM_K60.getValue().equals(dataItem.get("stakeNum"))){
regionMap.put("regionName","长清区");
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) {
//第一行 格式化时间
LocalDateTime localDateTime = LocalDateTime.parse(weatherList.get(i).get("weatherTime").toString(), parseFormatter);
DateTimeFormatter formatFormatter = DateTimeFormatter.ofPattern("dd日HH时");
column.put("time"+(i+1),localDateTime.format(formatFormatter));
regionMap.put("time"+(i+1),weatherList.get(i).get("weatherDescription").toString());
}
} else if (UniversalEnum.STAKE_NUM_K105.getValue().equals(dataItem.get("stakeNum"))){
regionMap.put("regionName","平阴县");
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) {
regionMap.put("time"+(i+1),weatherList.get(i).get("weatherDescription").toString());
}
} else if (UniversalEnum.STAKE_NUM_K145.getValue().equals(dataItem.get("stakeNum"))){
regionMap.put("regionName","东平县");
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) {
regionMap.put("time"+(i+1),weatherList.get(i).get("weatherDescription").toString());
}
} else if (UniversalEnum.STAKE_NUM_K165.getValue().equals(dataItem.get("stakeNum"))){
regionMap.put("regionName","汶上县");
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) {
regionMap.put("time"+(i+1),weatherList.get(i).get("weatherDescription").toString());
}
} else if (UniversalEnum.STAKE_NUM_K175.getValue().equals(dataItem.get("stakeNum"))){
regionMap.put("regionName","梁山县");
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) {
regionMap.put("time"+(i+1),weatherList.get(i).get("weatherDescription").toString());
}
} else if (UniversalEnum.STAKE_NUM_K190.getValue().equals(dataItem.get("stakeNum"))){
regionMap.put("regionName","嘉祥县");
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) {
regionMap.put("time"+(i+1),weatherList.get(i).get("weatherDescription").toString());
}
} else if (UniversalEnum.STAKE_NUM_K200.getValue().equals(dataItem.get("stakeNum"))){
regionMap.put("regionName","巨野县");
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) {
regionMap.put("time"+(i+1),weatherList.get(i).get("weatherDescription").toString());
}
} else if (UniversalEnum.STAKE_NUM_K205.getValue().equals(dataItem.get("stakeNum"))){
regionMap.put("regionName","郓城县");
List<Map<String,Object>> weatherList = (List<Map<String,Object>>) dataItem.get("forecastList");
weatherList = weatherList.stream()
.sorted(Comparator.comparing(map -> LocalDateTime.parse(map.get("weatherTime").toString(), parseFormatter)))
.collect(Collectors.toList());
for (int i = UniversalEnum.ZERO.getNumber(); i < weatherList.size(); i++) {
regionMap.put("time"+(i+1),weatherList.get(i).get("weatherDescription").toString());
}
}
dataList.add(regionMap);
});
} else {
return AjaxResult.error("暂无数据");
}
} else {
return AjaxResult.error("查询失败");
}
result.put("column",column);
result.put("dataList",dataList);
return AjaxResult.success(result);
}
}

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

@ -538,4 +538,21 @@ public class DcTrafficIncidentsServiceImpl implements IDcTrafficIncidentsService
List<Map<String,Object>> list = trafficIncidentsMapper.selectEventTypeAnalysis(direction,type,startTime);
return AjaxResult.success(list);
}
//事件时间占比
@Override
public List<HashMap<String,Object>> selectEventTimeProportion(String direction, String type, String startTime) {
switch (type){
case "1":
return trafficIncidentsMapper.selectEventTimeProportionDay(direction,startTime);
case "2":
return trafficIncidentsMapper.selectEventTimeProportionMonth(direction,startTime);
case "3":
return trafficIncidentsMapper.selectEventTimeProportionQUARTER(direction,startTime);
case "4":
return trafficIncidentsMapper.selectEventTimeProportionYear(direction,startTime);
default:
return null;
}
}
}

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

@ -18,6 +18,7 @@ import com.zc.business.enums.UniversalEnum;
import com.zc.business.enums.ValueConverter;
import com.zc.business.enums.WarningSubclassEnum;
import com.zc.business.mapper.DcEventMapper;
import com.zc.business.mapper.DcEventProcessMapper;
import com.zc.business.mapper.DcProcessConfigMapper;
import com.zc.business.mapper.DcWarningMapper;
import com.zc.business.service.IDcEventService;
@ -67,6 +68,8 @@ public class DcWarningServiceImpl implements IDcWarningService {
@Autowired
private DcEventProcessServiceImpl dcEventProcessService;
@Autowired
private DcEventProcessMapper dcEventProcessMapper;
@Autowired
private IDcTrafficPoliceService dcTrafficPoliceService;
@Autowired
private DcProcessConfigMapper dcProcessConfigMapper;
@ -272,6 +275,28 @@ public class DcWarningServiceImpl implements IDcWarningService {
}
//事件推送至 Websocket
int i = dcWarningMapper.insertDcWarning(dcWarning);//如果没有配置策略直接加入数据库;
//扫码报警提前插入处置记录
if (dcWarning.getWarningSource() == 5){
DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(uuid);
dcEventProcess.setSource(2);
JSONObject otherConfig = new JSONObject(dcWarning.getOtherConfig());
String phone = otherConfig.getString("phone");
String direction = "1".equals(dcWarning.getDirection()) ? "菏泽方向" : "济南方向";
int eventType = ValueConverter.convertValueHost(dcWarning.getWarningType());
String typeName = ValueConverter.eventTypeName(String.valueOf(eventType));
String context = dcWarning.getStakeMark() + direction + "," + phone + "上报了一起" + typeName + "事件";
dcEventProcess.setContext(context);
dcEventProcess.setOperatorName("上报人");
dcEventProcess.setOperationTime(new Date());
dcEventProcessMapper.insertDcEventProcess(dcEventProcess);
}
extracted(dcWarning);
return i;
}

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

@ -627,5 +627,52 @@
on t3.mileageType = t4.mileageType
</select>
<select id="selectEventTimeProportionDay" resultType="java.util.HashMap">
select t1.n as time,IFNULL(t2.num,0)as number from
(SELECT 0 AS n 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
) t1
left join
(select HOUR(start_time) hours,count(*) num from dc_event
where date_format(start_time,'%Y-%m-%d') = date_format(#{startTime},'%Y-%m-%d')
and direction=#{direction}
GROUP BY hours) t2
on t1.n = t2.hours
</select>
<select id="selectEventTimeProportionMonth" resultType="java.util.HashMap">
select DATE(start_time) day,count(*) num from dc_event
where date_format(start_time,'%Y-%m') = date_format(#{startTime},'%Y-%m')
and direction=#{direction}
GROUP BY day
ORDER BY day
</select>
<select id="selectEventTimeProportionQUARTER" resultType="java.util.HashMap">
SELECT
MONTH(start_time) AS month,
COUNT(*) AS number
FROM dc_event
WHERE YEAR(start_time) = YEAR(#{startTime}) and QUARTER(start_time) = QUARTER(#{startTime})
AND direction=#{direction}
GROUP BY MONTH
ORDER BY MONTH;
</select>
<select id="selectEventTimeProportionYear" resultType="java.util.HashMap">
select t1.n as month,IFNULL(t2.num,0)as number from
(SELECT 0 AS n 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
) t1 left join
(select month(start_time) hours,count(*) num from dc_event t1
where DATE_FORMAT(t1.start_time,'%Y')=DATE_FORMAT(#{startTime},'%Y')
and direction=#{direction}
GROUP BY hours
) t2
on t1.n = t2.hours
</select>
</mapper>

BIN
zc-business/src/main/resources/wordTemplate/charSection.docx

Binary file not shown.

BIN
zc-business/src/main/resources/wordTemplate/typeAnalysis.docx

Binary file not shown.
Loading…
Cancel
Save