From 00dbca3abff494a5d1eb6bcde4dd63f5539d0fc8 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Tue, 10 Sep 2024 11:14:39 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E9=80=9F=E4=BA=91=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=85=A5=E5=BA=93=20=E6=9F=A5=E8=AF=A2=E4=BA=8B=E6=95=85?= =?UTF-8?q?=E5=9C=B0=E5=B8=82=E5=88=86=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcSdhsEventController.java | 51 --------- .../com/zc/business/domain/DcSdhsEvent.java | 12 ++ .../zc/business/domain/DcSdhsEventQuery.java | 24 +++- .../zc/business/mapper/DcSdhsEventMapper.java | 7 +- .../business/service/IDcSdhsEventService.java | 12 +- .../service/impl/DcSdhsEventServiceImpl.java | 108 +++++------------- .../mapper/business/DcSdhsEventMapper.xml | 58 +++++++++- 7 files changed, 122 insertions(+), 150 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java b/zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java index 4f2d858e..7bf4753a 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcSdhsEventController.java @@ -8,26 +8,10 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.zc.business.domain.DcSdhsEvent; import com.zc.business.domain.DcSdhsEventQuery; import com.zc.business.enums.UniversalEnum; -import com.zc.business.domain.DcSdhsEventQuery; -import com.zc.business.enums.UniversalEnum; -import com.ruoyi.common.utils.SecurityUtils; -import com.zc.business.domain.DcSdhsEvent; -import com.zc.business.domain.DcSdhsEventQuery; -import com.zc.business.enums.UniversalEnum; import com.zc.business.service.IDcSdhsEventService; import com.zc.business.utils.PoiUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.apache.poi.xwpf.usermodel.XWPFChart; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.apache.poi.xwpf.usermodel.XWPFTable; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth; import io.swagger.annotations.ApiParam; import org.apache.poi.xwpf.usermodel.ParagraphAlignment; import org.apache.poi.xwpf.usermodel.XWPFDocument; @@ -36,53 +20,18 @@ import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTBr; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP; import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR; import org.openxmlformats.schemas.wordprocessingml.x2006.main.STBrType; -import org.apache.catalina.security.SecurityUtil; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.apache.poi.xwpf.usermodel.*; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.*; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; -import sun.reflect.generics.tree.VoidDescriptor; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.InputStream; -import java.math.BigInteger; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static com.ruoyi.common.utils.PageUtils.startPage; -import static com.zc.business.utils.PoiUtil.mergeChart; -import static com.zc.business.utils.PoiUtil.setTableFonts; - -import javax.servlet.http.HttpServletResponse; -import java.io.FileOutputStream; -import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; -import java.util.Map; import static com.zc.business.utils.PoiUtil.insertTOC; -import javax.servlet.http.HttpServletResponse; -import java.io.InputStream; -import java.math.BigInteger; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.List; -import java.util.Map; - -import static com.zc.business.utils.PoiUtil.*; -import static com.zc.business.utils.PoiUtil.createLineBreak; - /** * @Description 高速云事件分析Controller * diff --git a/zc-business/src/main/java/com/zc/business/domain/DcSdhsEvent.java b/zc-business/src/main/java/com/zc/business/domain/DcSdhsEvent.java index b1cca730..43f03e8b 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcSdhsEvent.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcSdhsEvent.java @@ -80,6 +80,10 @@ public class DcSdhsEvent extends BaseEntity @Excel(name = "天气") private String weather; + /** 桩号里程 */ + @Excel(name = "桩号里程") + private Long mileage; + public Long getId() { return id; } @@ -208,6 +212,14 @@ public class DcSdhsEvent extends BaseEntity this.weather = weather; } + public Long getMileage() { + return mileage; + } + + public void setMileage(Long mileage) { + this.mileage = mileage; + } + @Override public String toString() { return new ToStringBuilder(this) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcSdhsEventQuery.java b/zc-business/src/main/java/com/zc/business/domain/DcSdhsEventQuery.java index 8a75bbc4..773ba042 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcSdhsEventQuery.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcSdhsEventQuery.java @@ -1,14 +1,10 @@ package com.zc.business.domain; import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.common.annotation.Excel; -import com.ruoyi.common.core.domain.BaseEntity; import org.apache.commons.lang3.builder.ToStringBuilder; -import org.springframework.format.annotation.DateTimeFormat; import java.util.Date; import java.util.List; -import java.util.Map; /** * 高速云事件分析查询对象 @@ -37,6 +33,10 @@ public class DcSdhsEventQuery /** 需要导出的键 */ private List exportKey; + private String thisTime; + + private String lastTime; + public String getDirection() { return direction; } @@ -77,6 +77,22 @@ public class DcSdhsEventQuery this.exportKey = exportKey; } + public String getThisTime() { + return thisTime; + } + + public void setThisTime(String thisTime) { + this.thisTime = thisTime; + } + + public String getLastTime() { + return lastTime; + } + + public void setLastTime(String lastTime) { + this.lastTime = lastTime; + } + @Override public String toString() { return new ToStringBuilder(this) diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java index b8cab80a..d325c698 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcSdhsEventMapper.java @@ -2,9 +2,10 @@ package com.zc.business.mapper; import java.util.Date; import java.util.List; +import java.util.Map; -import com.ruoyi.system.domain.SysUserPost; import com.zc.business.domain.DcSdhsEvent; +import org.apache.ibatis.annotations.Param; /** * 高速云事件Mapper接口 @@ -72,5 +73,7 @@ public interface DcSdhsEventMapper */ public boolean batchInsert(List dcSdhsEventList); - boolean deleteByTimeRange(String startTime, String endTime); + boolean deleteByTimeRange(@Param("startTime") String startTime,@Param("endTime") String endTime); + + List> selectRegionAnalysis(@Param("type") String type,@Param("thisTime") String thisTime, @Param("lastTime") String lastTime); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcSdhsEventService.java b/zc-business/src/main/java/com/zc/business/service/IDcSdhsEventService.java index b1a826df..6405f374 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcSdhsEventService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcSdhsEventService.java @@ -3,21 +3,13 @@ package com.zc.business.service; import com.ruoyi.common.core.domain.AjaxResult; import com.zc.business.domain.DcSdhsEvent; import com.zc.business.domain.DcSdhsEventQuery; -import org.apache.poi.xddf.usermodel.XDDFAdjustHandleXY; +import com.zc.business.domain.DcTollStationStatisticsDataMap; +import com.zc.business.domain.TrafficFlowStatisticsMap; import org.apache.poi.xwpf.usermodel.XWPFDocument; -import com.zc.business.domain.*; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import com.zc.business.domain.DcSdhsEventQuery; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.multipart.MultipartFile; -import java.util.Date; import java.util.List; import java.util.Map; -import javax.servlet.http.HttpServletResponse; - /** * 高速云事件分析Service接口 * diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java index caa49a3e..5c07f7ad 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcSdhsEventServiceImpl.java @@ -21,17 +21,6 @@ import com.zc.business.utils.PoiUtil; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.xssf.usermodel.XSSFSheet; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; -import org.apache.poi.xwpf.usermodel.XWPFChart; -import org.apache.poi.xwpf.usermodel.XWPFDocument; -import org.apache.poi.xwpf.usermodel.XWPFTable; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTblWidth; -import org.openxmlformats.schemas.wordprocessingml.x2006.main.STTblWidth; -import com.zc.business.utils.PoiUtil; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.Row; import org.apache.poi.xssf.usermodel.XSSFCell; import org.apache.poi.xssf.usermodel.XSSFRow; import org.apache.poi.xssf.usermodel.XSSFSheet; @@ -47,19 +36,9 @@ import java.io.IOException; import java.io.InputStream; import java.math.BigInteger; import java.text.DecimalFormat; -import java.util.ArrayList; - - -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.io.InputStream; -import java.math.BigInteger; import java.text.SimpleDateFormat; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.LocalTime; import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.time.temporal.TemporalAdjusters; @@ -70,9 +49,6 @@ import java.util.stream.Collectors; import static com.zc.business.utils.PoiUtil.*; -import static com.zc.business.utils.PoiUtil.mergeChart; -import static com.zc.business.utils.PoiUtil.setTableFonts; - /** * 高速云事件分析Service业务层处理 * @@ -154,31 +130,37 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { String stakeMark = dcSdhsEvent.getStakeMark(); - if (StringUtils.isNotEmpty(stakeMark) && !"无".equals(stakeMark) && !StakeMarkUtils.checkStakeMark(stakeMark)) { - //尝试桩号补零 - List numbers = new ArrayList<>(); + if (StringUtils.isNotEmpty(stakeMark) && !"无".equals(stakeMark)) { + if (!StakeMarkUtils.checkStakeMark(stakeMark)){ - // 匹配大小桩号数字 - Pattern pattern = Pattern.compile("\\d+"); - Matcher matcher = pattern.matcher(stakeMark); - while (matcher.find()) { - numbers.add(matcher.group()); // 将匹配到的数字字符串添加到列表中 - } - List formattedNumbers = new ArrayList<>(); - for (String number : numbers) { - while (number.length() < 3) { - number = "0" + number; + //尝试桩号补零 + List numbers = new ArrayList<>(); + + // 匹配大小桩号数字 + Pattern pattern = Pattern.compile("\\d+"); + Matcher matcher = pattern.matcher(stakeMark); + while (matcher.find()) { + numbers.add(matcher.group()); // 将匹配到的数字字符串添加到列表中 } - formattedNumbers.add(number); - } - stakeMark = "K" + String.join("+", formattedNumbers); + List formattedNumbers = new ArrayList<>(); + for (String number : numbers) { + while (number.length() < 3) { + number = "0" + number; + } + formattedNumbers.add(number); + } + stakeMark = "K" + String.join("+", formattedNumbers); - //如果还验证不通过 则此条信息作废 - if (!StakeMarkUtils.checkStakeMark(stakeMark)) { - continue; + //如果还验证不通过 则此条信息作废 + if (!StakeMarkUtils.checkStakeMark(stakeMark)) { + continue; + } } dcSdhsEvent.setStakeMark(stakeMark); + + dcSdhsEvent.setMileage(StakeMarkUtils.formatMetreLong(stakeMark)); + } eventList.add(dcSdhsEvent); @@ -1310,46 +1292,10 @@ public class DcSdhsEventServiceImpl implements IDcSdhsEventService { @Override public AjaxResult selectRegionAnalysis(DcSdhsEventQuery dcSdhsEventQuery) { - List eventList = redisCache.getCacheList(RedisKeyConstants.SDHS_EVENT); - if (eventList == null || eventList.size() == 0) { - return AjaxResult.error("请先导入数据"); - } + List> thisTimeData = dcSdhsEventMapper.selectRegionAnalysis(dcSdhsEventQuery.getType(),dcSdhsEventQuery.getThisTime(),dcSdhsEventQuery.getLastTime()); - //先筛选时间范围 - eventList = eventList.stream() - .filter(item -> item.getStartTime() != null - && item.getStartTime().getTime() >= dcSdhsEventQuery.getStartTime().getTime() - && item.getStartTime().getTime() <= dcSdhsEventQuery.getEndTime().getTime() - && item.getEventType().equals("交通事故")) - .collect(Collectors.toList()); - - //筛选方向 - /*if (StringUtils.isNotEmpty(dcSdhsEventQuery.getDirection())){ - if (dcSdhsEventQuery.getDirection().equals("1")){ - //菏泽方向 - eventList = eventList.stream() - .filter(item -> item.getDirection().equals("广州方向") || item.getDirection().equals("双向")) - .collect(Collectors.toList()); - } else if (dcSdhsEventQuery.getDirection().equals("3")){ - //济南方向 - eventList = eventList.stream() - .filter(item -> item.getDirection().equals("济南方向") || item.getDirection().equals("双向")) - .collect(Collectors.toList()); - } - }*/ - //地市统计 - Map region = eventList.stream() - .collect(Collectors.groupingBy(item -> getRange(item.getStakeMark()), Collectors.counting())); - List> list = new ArrayList<>(); - for (String key : region.keySet()) { - Map map = new HashMap<>(); - map.put("regionName", key); - map.put("num", region.get(key)); - list.add(map); - } - list = list.stream().sorted(Comparator.comparing(item -> getCitySorted(item.get("regionName").toString()))).collect(Collectors.toList()); - return AjaxResult.success(list); + return AjaxResult.success(thisTimeData); } private int getCitySorted(String city){ diff --git a/zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml b/zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml index e4eab739..6baf8149 100644 --- a/zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcSdhsEventMapper.xml @@ -55,6 +55,60 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + insert into dc_sdhs_event @@ -95,9 +149,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into dc_sdhs_event(road,dept,event_type,start_time,end_time,status,source,title,event_subclass,car_type,car_num,multi_vehicle,direction,stake_mark,weather) values + insert into dc_sdhs_event(road,dept,event_type,start_time,end_time,status,source,title,event_subclass,car_type,car_num,multi_vehicle,direction,stake_mark,weather,mileage) values - (#{item.road},#{item.dept},#{item.eventType},#{item.startTime},#{item.endTime},#{item.status},#{item.source},#{item.title},#{item.eventSubclass},#{item.carType},#{item.carNum},#{item.multiVehicle},#{item.direction},#{item.stakeMark},#{item.weather}) + (#{item.road},#{item.dept},#{item.eventType},#{item.startTime},#{item.endTime},#{item.status},#{item.source},#{item.title},#{item.eventSubclass},#{item.carType},#{item.carNum},#{item.multiVehicle},#{item.direction},#{item.stakeMark},#{item.weather},#{item.mileage})