Browse Source

模板+管控事件接口

develop
wangsixiang 3 months ago
parent
commit
876bbed4b9
  1. 27
      zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java
  2. 9
      zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java
  3. 5
      zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java
  4. 17
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java
  5. 47
      zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml
  6. BIN
      zc-business/src/main/resources/wordTemplate/charSection.docx
  7. BIN
      zc-business/src/main/resources/wordTemplate/typeAnalysis.docx

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);
}

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);
}

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;
}
}
}

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