Browse Source

高速云事件导出

develop
wangsixiang 7 months ago
parent
commit
5d3d3e2794
  1. 28
      zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java
  2. 26
      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. 1518
      zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java
  5. 115
      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("查询事故多发路段分析") @ApiOperation("查询事故多发路段分析")
@PostMapping("/sectionAnalysis") @PostMapping("/sectionAnalysis")
public AjaxResult sectionAnalysis(@RequestBody DcSdhsEventQuery dcSdhsEventQuery){ 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.error("参数异常");
} }
return AjaxResult.success(dcSdhsEventService.accidentSectionAnalysis(dcSdhsEventQuery)); return AjaxResult.success(dcSdhsEventService.accidentSectionAnalysis(dcSdhsEventQuery));
@ -85,7 +85,7 @@ public class DcSdhsEventController extends BaseController {
@ApiOperation("查询事件类型分析") @ApiOperation("查询事件类型分析")
@PostMapping("/typeAnalysis") @PostMapping("/typeAnalysis")
public AjaxResult accidentTypeAnalysis(@RequestBody DcSdhsEventQuery dcSdhsEventQuery){ 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.error("参数异常");
} }
return AjaxResult.success(dcSdhsEventService.accidentTypeAnalysis(dcSdhsEventQuery)); return AjaxResult.success(dcSdhsEventService.accidentTypeAnalysis(dcSdhsEventQuery));
@ -94,7 +94,7 @@ public class DcSdhsEventController extends BaseController {
@ApiOperation("查询事故拥堵时间分析") @ApiOperation("查询事故拥堵时间分析")
@PostMapping("/congestedTime") @PostMapping("/congestedTime")
public AjaxResult accidentCongestedTime(@RequestBody DcSdhsEventQuery dcSdhsEventQuery){ 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.error("参数异常");
} }
return AjaxResult.success(dcSdhsEventService.accidentCongestedTime(dcSdhsEventQuery)); return AjaxResult.success(dcSdhsEventService.accidentCongestedTime(dcSdhsEventQuery));
@ -103,7 +103,7 @@ public class DcSdhsEventController extends BaseController {
@ApiOperation("查询事故拥堵地点分析") @ApiOperation("查询事故拥堵地点分析")
@PostMapping("/congestedLocation") @PostMapping("/congestedLocation")
public AjaxResult accidentCongestedLocation(@RequestBody DcSdhsEventQuery dcSdhsEventQuery){ 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.error("参数异常");
} }
return AjaxResult.success(dcSdhsEventService.accidentCongestedLocation(dcSdhsEventQuery)); return AjaxResult.success(dcSdhsEventService.accidentCongestedLocation(dcSdhsEventQuery));
@ -113,16 +113,16 @@ public class DcSdhsEventController extends BaseController {
@PostMapping("/sectionTypeAnalysisExport") @PostMapping("/sectionTypeAnalysisExport")
public void sectionTypeAnalysisExport(HttpServletResponse response,@RequestBody DcSdhsEventQuery dcSdhsEventQuery) throws IOException { public void sectionTypeAnalysisExport(HttpServletResponse response,@RequestBody DcSdhsEventQuery dcSdhsEventQuery) throws IOException {
// 读取Word模板 // 读取Word模板
InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(UniversalEnum.EXPORT_TRAFFIC_REPORT.getValue()); // InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(UniversalEnum.EXPORT_TRAFFIC_REPORT.getValue());
XWPFDocument newDoc = new XWPFDocument(inputStream); // XWPFDocument newDoc = new XWPFDocument(inputStream);
dcSdhsEventService.sectionAnalysisExport(newDoc,dcSdhsEventQuery); // dcSdhsEventService.sectionAnalysisExport(newDoc,dcSdhsEventQuery);
dcSdhsEventService.accidentTypeAnalysisExport(newDoc,dcSdhsEventQuery); // dcSdhsEventService.accidentTypeAnalysisExport(newDoc,dcSdhsEventQuery);
dcSdhsEventService.accidentCongestedTimeExport(newDoc,dcSdhsEventQuery); // dcSdhsEventService.accidentCongestedTimeExport(newDoc,dcSdhsEventQuery);
dcSdhsEventService.accidentCongestedLocationExport(newDoc,dcSdhsEventQuery); // dcSdhsEventService.accidentCongestedLocationExport(newDoc,dcSdhsEventQuery);
// 不保存直接返回文件流 // // 不保存直接返回文件流
newDoc.write(response.getOutputStream()); // newDoc.write(response.getOutputStream());
// 关闭文档 // // 关闭文档
newDoc.close(); // newDoc.close();
System.out.println("生成通行情况快报成功!"); System.out.println("生成通行情况快报成功!");
} }
@PostMapping("/export") @PostMapping("/export")

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

@ -1,6 +1,7 @@
package com.zc.business.mapper; package com.zc.business.mapper;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -9,15 +10,15 @@ import org.apache.ibatis.annotations.Param;
/** /**
* 高速云事件Mapper接口 * 高速云事件Mapper接口
* *
* @author ruoyi * @author ruoyi
* @date 2024-09-09 * @date 2024-09-09
*/ */
public interface DcSdhsEventMapper public interface DcSdhsEventMapper
{ {
/** /**
* 查询高速云事件 * 查询高速云事件
* *
* @param id 高速云事件主键 * @param id 高速云事件主键
* @return 高速云事件 * @return 高速云事件
*/ */
@ -25,7 +26,7 @@ public interface DcSdhsEventMapper
/** /**
* 查询高速云事件列表 * 查询高速云事件列表
* *
* @param dcSdhsEvent 高速云事件 * @param dcSdhsEvent 高速云事件
* @return 高速云事件集合 * @return 高速云事件集合
*/ */
@ -33,7 +34,7 @@ public interface DcSdhsEventMapper
/** /**
* 新增高速云事件 * 新增高速云事件
* *
* @param dcSdhsEvent 高速云事件 * @param dcSdhsEvent 高速云事件
* @return 结果 * @return 结果
*/ */
@ -41,7 +42,7 @@ public interface DcSdhsEventMapper
/** /**
* 修改高速云事件 * 修改高速云事件
* *
* @param dcSdhsEvent 高速云事件 * @param dcSdhsEvent 高速云事件
* @return 结果 * @return 结果
*/ */
@ -49,7 +50,7 @@ public interface DcSdhsEventMapper
/** /**
* 删除高速云事件 * 删除高速云事件
* *
* @param id 高速云事件主键 * @param id 高速云事件主键
* @return 结果 * @return 结果
*/ */
@ -57,7 +58,7 @@ public interface DcSdhsEventMapper
/** /**
* 批量删除高速云事件 * 批量删除高速云事件
* *
* @param ids 需要删除的数据主键集合 * @param ids 需要删除的数据主键集合
* @return 结果 * @return 结果
*/ */
@ -93,4 +94,13 @@ public interface DcSdhsEventMapper
*/ */
List<DcSdhsEvent> selectAccidentModelAnalysis(@Param("type") String type, @Param("time") String time); 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 com.zc.business.domain.TrafficFlowStatisticsMap;
import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFDocument;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; 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); public void sectionAnalysisExport(XWPFDocument doc,DcSdhsEventQuery dcSdhsEventQuery);
//事故类型分析导出 //事故类型分析导出

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

File diff suppressed because it is too large

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

@ -3,7 +3,7 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zc.business.mapper.DcSdhsEventMapper"> <mapper namespace="com.zc.business.mapper.DcSdhsEventMapper">
<resultMap type="DcSdhsEvent" id="DcSdhsEventResult"> <resultMap type="DcSdhsEvent" id="DcSdhsEventResult">
<result property="id" column="id" /> <result property="id" column="id" />
<result property="road" column="road" /> <result property="road" column="road" />
@ -29,7 +29,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDcSdhsEventList" parameterType="DcSdhsEvent" resultMap="DcSdhsEventResult"> <select id="selectDcSdhsEventList" parameterType="DcSdhsEvent" resultMap="DcSdhsEventResult">
<include refid="selectDcSdhsEventVo"/> <include refid="selectDcSdhsEventVo"/>
<where> <where>
<if test="road != null and road != ''"> and road = #{road}</if> <if test="road != null and road != ''"> and road = #{road}</if>
<if test="dept != null and dept != ''"> and dept = #{dept}</if> <if test="dept != null and dept != ''"> and dept = #{dept}</if>
<if test="eventType != null and eventType != ''"> and event_type = #{eventType}</if> <if test="eventType != null and eventType != ''"> and event_type = #{eventType}</if>
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="weather != null and weather != ''"> and weather = #{weather}</if> <if test="weather != null and weather != ''"> and weather = #{weather}</if>
</where> </where>
</select> </select>
<select id="selectDcSdhsEventById" parameterType="Long" resultMap="DcSdhsEventResult"> <select id="selectDcSdhsEventById" parameterType="Long" resultMap="DcSdhsEventResult">
<include refid="selectDcSdhsEventVo"/> <include refid="selectDcSdhsEventVo"/>
where id = #{id} where id = #{id}
@ -171,6 +171,111 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
group by event_subclass) t3 group by event_subclass) t3
on t1.event_subclass = t3.event_subclass on t1.event_subclass = t3.event_subclass
</select> </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 id="getDataCalendar" resultType="java.lang.String">
SELECT DATE_FORMAT(start_time,'%Y-%m-%d') dateTime SELECT DATE_FORMAT(start_time,'%Y-%m-%d') dateTime
FROM `dc_sdhs_event` FROM `dc_sdhs_event`
@ -250,7 +355,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete> </delete>
<delete id="deleteDcSdhsEventByIds" parameterType="String"> <delete id="deleteDcSdhsEventByIds" parameterType="String">
delete from dc_sdhs_event where id in delete from dc_sdhs_event where id in
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
@ -276,4 +381,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
</mapper> </mapper>

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