diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java index 88744a8b..c8609e4e 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTrafficIncidentsController.java +++ b/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 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> currentlyMap = trafficIncidentsService.selectEventTimeProportion(dcWarning.getDirection(), + dcWarning.getType(), formattedDate); + List> lastYearMap = trafficIncidentsService.selectEventTimeProportion(dcWarning.getDirection(), + dcWarning.getType(), format); + HashMap hashMap = new HashMap<>(); + hashMap.put("currentlyMap",currentlyMap); + hashMap.put("lastYearMap",lastYearMap); + return AjaxResult.success(hashMap); + } } diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java index dfaf12ee..8b497e92 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficIncidentsMapper.java +++ b/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; @@ -238,7 +239,7 @@ public interface DcTrafficIncidentsMapper { /** * @Description 交通管制情况 - * + * * @author liuwenge * @date 2024/3/27 18:32 * @param startTime @@ -292,10 +293,10 @@ public interface DcTrafficIncidentsMapper { /** * @Description 事故类型统计--当天按小时 - * + * * @author liuwenge * @date 2024/3/28 16:28 - * @param + * @param * @return java.util.List> */ List> selectTrafficAccidents(); @@ -329,4 +330,12 @@ public interface DcTrafficIncidentsMapper { */ List> selectCongestionMileage(); + //事件数量时间占比-天 + List> selectEventTimeProportionDay(@Param("direction") String direction,@Param("startTime") String startTime); + //事件数量时间占比-月 + List> selectEventTimeProportionMonth(@Param("direction") String direction,@Param("startTime") String startTime); + //事件数量时间占比-季度 + List> selectEventTimeProportionQUARTER(@Param("direction") String direction,@Param("startTime") String startTime); + //事件数量时间占比-年 + List> selectEventTimeProportionYear(@Param("direction") String direction,@Param("startTime") String startTime); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java b/zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java index 4fa04614..2ead6853 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcTrafficIncidentsService.java +++ b/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 params); AjaxResult selectEventTypeAnalysis(String direction, String type, String startTime); + + //事件时间数量占比 + public List> selectEventTimeProportion(String direction, String type, String startTime); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java index 11616ede..f41af1dc 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficIncidentsServiceImpl.java @@ -538,4 +538,21 @@ public class DcTrafficIncidentsServiceImpl implements IDcTrafficIncidentsService List> list = trafficIncidentsMapper.selectEventTypeAnalysis(direction,type,startTime); return AjaxResult.success(list); } + + //事件时间占比 + @Override + public List> 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; + } + } } diff --git a/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml b/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml index c68de440..573ae47d 100644 --- a/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcTrafficIncidentsMapper.xml @@ -627,5 +627,52 @@ on t3.mileageType = t4.mileageType + + + + - \ No newline at end of file + diff --git a/zc-business/src/main/resources/wordTemplate/charSection.docx b/zc-business/src/main/resources/wordTemplate/charSection.docx new file mode 100644 index 00000000..e189db73 Binary files /dev/null and b/zc-business/src/main/resources/wordTemplate/charSection.docx differ diff --git a/zc-business/src/main/resources/wordTemplate/typeAnalysis.docx b/zc-business/src/main/resources/wordTemplate/typeAnalysis.docx new file mode 100644 index 00000000..db896b4e Binary files /dev/null and b/zc-business/src/main/resources/wordTemplate/typeAnalysis.docx differ