Browse Source

高速云事件导出

develop
wangsixiang 2 months ago
parent
commit
5d3d3e2794
  1. 28
      zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java
  2. 10
      zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java
  3. 9
      zc-business/src/main/java/com/zc/business/service/IDcSdhsEventService.java
  4. 880
      zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java
  5. 105
      zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml
  6. BIN
      zc-business/src/main/resources/wordTemplate/charSection.docx
  7. BIN
      zc-business/src/main/resources/wordTemplate/congestedLocation.docx
  8. BIN
      zc-business/src/main/resources/wordTemplate/congestionTime.docx
  9. BIN
      zc-business/src/main/resources/wordTemplate/typeAnalysis.docx

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

@ -76,7 +76,7 @@ public class DcSdhsEventController extends BaseController {
@ApiOperation("查询事故多发路段分析")
@PostMapping("/sectionAnalysis")
public AjaxResult sectionAnalysis(@RequestBody DcSdhsEventQuery dcSdhsEventQuery){
if (dcSdhsEventQuery.getStartTime()==null||dcSdhsEventQuery.getEndTime()==null){
if (dcSdhsEventQuery.getType()==null||dcSdhsEventQuery.getThisTime()==null||dcSdhsEventQuery.getLastTime()==null){
return AjaxResult.error("参数异常");
}
return AjaxResult.success(dcSdhsEventService.accidentSectionAnalysis(dcSdhsEventQuery));
@ -85,7 +85,7 @@ public class DcSdhsEventController extends BaseController {
@ApiOperation("查询事件类型分析")
@PostMapping("/typeAnalysis")
public AjaxResult accidentTypeAnalysis(@RequestBody DcSdhsEventQuery dcSdhsEventQuery){
if (dcSdhsEventQuery.getStartTime()==null||dcSdhsEventQuery.getEndTime()==null){
if (dcSdhsEventQuery.getType()==null||dcSdhsEventQuery.getThisTime()==null||dcSdhsEventQuery.getLastTime()==null){
return AjaxResult.error("参数异常");
}
return AjaxResult.success(dcSdhsEventService.accidentTypeAnalysis(dcSdhsEventQuery));
@ -94,7 +94,7 @@ public class DcSdhsEventController extends BaseController {
@ApiOperation("查询事故拥堵时间分析")
@PostMapping("/congestedTime")
public AjaxResult accidentCongestedTime(@RequestBody DcSdhsEventQuery dcSdhsEventQuery){
if (dcSdhsEventQuery.getStartTime()==null||dcSdhsEventQuery.getEndTime()==null){
if (dcSdhsEventQuery.getType()==null||dcSdhsEventQuery.getThisTime()==null||dcSdhsEventQuery.getLastTime()==null){
return AjaxResult.error("参数异常");
}
return AjaxResult.success(dcSdhsEventService.accidentCongestedTime(dcSdhsEventQuery));
@ -103,7 +103,7 @@ public class DcSdhsEventController extends BaseController {
@ApiOperation("查询事故拥堵地点分析")
@PostMapping("/congestedLocation")
public AjaxResult accidentCongestedLocation(@RequestBody DcSdhsEventQuery dcSdhsEventQuery){
if (dcSdhsEventQuery.getStartTime()==null||dcSdhsEventQuery.getEndTime()==null){
if (dcSdhsEventQuery.getType()==null||dcSdhsEventQuery.getThisTime()==null||dcSdhsEventQuery.getLastTime()==null){
return AjaxResult.error("参数异常");
}
return AjaxResult.success(dcSdhsEventService.accidentCongestedLocation(dcSdhsEventQuery));
@ -113,16 +113,16 @@ public class DcSdhsEventController extends BaseController {
@PostMapping("/sectionTypeAnalysisExport")
public void sectionTypeAnalysisExport(HttpServletResponse response,@RequestBody DcSdhsEventQuery dcSdhsEventQuery) throws IOException {
// 读取Word模板
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(UniversalEnum.EXPORT_TRAFFIC_REPORT.getValue());
XWPFDocument newDoc = new XWPFDocument(inputStream);
dcSdhsEventService.sectionAnalysisExport(newDoc,dcSdhsEventQuery);
dcSdhsEventService.accidentTypeAnalysisExport(newDoc,dcSdhsEventQuery);
dcSdhsEventService.accidentCongestedTimeExport(newDoc,dcSdhsEventQuery);
dcSdhsEventService.accidentCongestedLocationExport(newDoc,dcSdhsEventQuery);
// 不保存直接返回文件流
newDoc.write(response.getOutputStream());
// 关闭文档
newDoc.close();
// InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(UniversalEnum.EXPORT_TRAFFIC_REPORT.getValue());
// XWPFDocument newDoc = new XWPFDocument(inputStream);
// dcSdhsEventService.sectionAnalysisExport(newDoc,dcSdhsEventQuery);
// dcSdhsEventService.accidentTypeAnalysisExport(newDoc,dcSdhsEventQuery);
// dcSdhsEventService.accidentCongestedTimeExport(newDoc,dcSdhsEventQuery);
// dcSdhsEventService.accidentCongestedLocationExport(newDoc,dcSdhsEventQuery);
// // 不保存直接返回文件流
// newDoc.write(response.getOutputStream());
// // 关闭文档
// newDoc.close();
System.out.println("生成通行情况快报成功!");
}
@PostMapping("/export")

10
zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java

@ -1,6 +1,7 @@
package com.zc.business.mapper;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -93,4 +94,13 @@ public interface DcSdhsEventMapper
*/
List<DcSdhsEvent> selectAccidentModelAnalysis(@Param("type") String type, @Param("time") String time);
//事故多发路段分析
List<HashMap<String,Object>> accidentSectionAnalysis(@Param("type") String type,@Param("thisTime") String thisTime);
//事件类型分析
List<HashMap<String,Object>> accidentTypeAnalysis(@Param("type") String type,@Param("thisTime") String thisTime, @Param("lastTime") String lastTime);
//事故拥堵时间分析
List<DcSdhsEvent> accidentCongestedTime(@Param("type") String type,@Param("thisTime") String thisTime);
//事故拥堵地点分析
List<HashMap<String,Object>> accidentCongestedLocation(@Param("type") String type,@Param("thisTime") String thisTime, @Param("lastTime") String lastTime);
}

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

@ -7,6 +7,7 @@ import com.zc.business.domain.DcTollStationStatisticsDataMap;
import com.zc.business.domain.TrafficFlowStatisticsMap;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -27,13 +28,13 @@ public interface IDcSdhsEventService
//事故多发路段分析
public Map<String, Integer> accidentSectionAnalysis(DcSdhsEventQuery dcSdhsEventQuery);
public List<Map<String, Object>> accidentSectionAnalysis(DcSdhsEventQuery dcSdhsEventQuery);
//事件类型分析
public Map<String, Integer> accidentTypeAnalysis(DcSdhsEventQuery dcSdhsEventQuery);
public List<HashMap<String, Object>> accidentTypeAnalysis(DcSdhsEventQuery dcSdhsEventQuery);
//事故拥堵地点
public Map<String,Integer> accidentCongestedLocation(DcSdhsEventQuery dcSdhsEventQuery);
public List<HashMap<String, Object>> accidentCongestedLocation(DcSdhsEventQuery dcSdhsEventQuery);
//事故拥堵时间
public Map<String,String> accidentCongestedTime(DcSdhsEventQuery dcSdhsEventQuery);
public List<Map<String, Object>> accidentCongestedTime(DcSdhsEventQuery dcSdhsEventQuery);
//事故多发路段分析导出
public void sectionAnalysisExport(XWPFDocument doc,DcSdhsEventQuery dcSdhsEventQuery);
//事故类型分析导出

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

File diff suppressed because it is too large

105
zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml

@ -171,6 +171,111 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by event_subclass) t3
on t1.event_subclass = t3.event_subclass
</select>
<select id="accidentSectionAnalysis" resultType="java.util.HashMap">
SELECT stake_mark stakeMark FROM `dc_sdhs_event`
<where>
<if test="type != null and type == '0'.toString">
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
</if>
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
</if>
</where>
</select>
<select id="accidentTypeAnalysis" resultType="java.util.HashMap">
SELECT e.event_type AS eventType,
IFNULL(t1.num, 0) AS thisTimeList,
IFNULL(t2.num, 0) AS lastTimeList
FROM `dc_sdhs_event` e
LEFT JOIN (SELECT event_type,
COUNT(*) AS num FROM
`dc_sdhs_event`
<where>
<if test="type != null and type == '0'.toString">
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
</if>
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
</if>
</where>
GROUP BY event_type ) t1 ON e.event_type = t1.event_type
LEFT JOIN (SELECT
event_type, COUNT(*) AS num
FROM `dc_sdhs_event`
<where>
<if test="type != null and type == '0'.toString">
and DATE_FORMAT(start_time,'%Y') = #{lastTime}
</if>
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(start_time,'%Y-%m') = #{lastTime}
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{lastTime}
</if>
</where>
GROUP BY event_type ) t2 ON e.event_type = t2.event_type
GROUP BY e.event_type;
</select>
<select id="accidentCongestedTime" resultType="com.zc.business.domain.DcSdhsEvent">
SELECT stake_mark stakeMark,start_time startTime,end_time endTime,event_type eventType FROM `dc_sdhs_event`
<where>
event_type='交通拥堵'
<if test="type != null and type == '0'.toString">
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
</if>
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
</if>
</where>
</select>
<select id="accidentCongestedLocation" resultType="java.util.HashMap">
SELECT
e.event_subclass AS eventSubclass,
IFNULL(t1.num, 0) AS thisTimeList,
IFNULL(t2.num, 0) AS lastTimeList
FROM `dc_sdhs_event` e
LEFT JOIN (SELECT event_subclass, COUNT(*) AS num
FROM `dc_sdhs_event`
<where>
<if test="type != null and type == '0'.toString">
and DATE_FORMAT(start_time,'%Y') = #{thisTime}
</if>
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(start_time,'%Y-%m') = #{thisTime}
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{thisTime}
</if>
</where>
GROUP BY event_subclass ) t1 ON e.event_subclass = t1.event_subclass
LEFT JOIN
(SELECT event_subclass, COUNT(*) AS num
FROM `dc_sdhs_event`
<where>
<if test="type != null and type == '0'.toString">
and DATE_FORMAT(start_time,'%Y') = #{lastTime}
</if>
<if test="type != null and type == '1'.toString">
and DATE_FORMAT(start_time,'%Y-%m') = #{lastTime}
</if>
<if test="type != null and type == '2'.toString">
and DATE_FORMAT(start_time,'%Y-%m-%d') = #{lastTime}
</if>
</where>
GROUP BY event_subclass
) t2 ON e.event_subclass = t2.event_subclass
where e .event_type='交通拥堵'
GROUP BY e.event_subclass;
</select>
<select id="getDataCalendar" resultType="java.lang.String">
SELECT DATE_FORMAT(start_time,'%Y-%m-%d') dateTime
FROM `dc_sdhs_event`

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.

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

Binary file not shown.
Loading…
Cancel
Save