From b6bd54b4b56de4de8e8bb15ed39cdb3848d84f39 Mon Sep 17 00:00:00 2001 From: lau572 <1010031226@qq.com> Date: Fri, 22 Aug 2025 14:25:56 +0800 Subject: [PATCH] =?UTF-8?q?AI=E9=A2=84=E6=B5=8B=E6=8E=A5=E5=8F=A3=20?= =?UTF-8?q?=E4=B8=80=E7=B1=BB=E4=BA=A4=E8=B0=83=E7=AB=99=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcTrafficSurveyDataController.java | 8 ++++++ .../business/domain/DcTrafficSurveyData.java | 26 ++++++++++++++++++ .../mapper/DcTrafficSurveyDataMapper.java | 2 ++ .../service/IDcTrafficSurveyDataService.java | 3 +++ .../impl/DcTrafficSurveyDataServiceImpl.java | 27 +++++++++++++++++++ .../business/DcTrafficSurveyDataMapper.xml | 14 ++++++++++ 6 files changed, 80 insertions(+) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java b/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java index 410371a0..6509d668 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java @@ -344,6 +344,14 @@ public class DcTrafficSurveyDataController extends BaseController return dcTrafficSurveyDataService.selectDcTrafficSurveyDataList(dcTrafficSurveyData); } + /** + * 查询一类交调数据列表 + */ + @GetMapping("/getTrafficSurveyDataList") + public AjaxResult getTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData) throws ParseException { + return AjaxResult.success(dcTrafficSurveyDataService.getTrafficSurveyDataList(dcTrafficSurveyData)); + } + /** * 查询一类交调数据列表 */ diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java index 5728f93a..06d9e42a 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java @@ -414,6 +414,32 @@ public class DcTrafficSurveyData extends BaseEntity this.goodsCar = goodsCar; } + public DcTrafficSurveyData(){} + public DcTrafficSurveyData(Integer initData){ + this.trafficVolume = initData.longValue(); + this.followingPercentage = initData; + this.timeOccupancyRate = initData; + this.averageHeadway = initData; + this.trafficNumberOfInAndSmall = initData; + this.inAndSmallAverageVehicleSpeed = initData; + this.busTrafficVolume = initData; + this.averageSpeedOfBus = initData; + this.trafficVolumeOfSmallTrucks = initData; + this.smallTrucksAverageVehicleSpeed = initData; + this.mediumTruckTrafficVolume = initData; + this.averageSpeedOfMediumSizeTrucks = initData; + this.largeTruckTrafficVolume = initData; + this.averageSpeedOfLargeTrucks = initData; + this.averageSpeedOfExtraLargeTrucks = initData; + this.extraLargeTrucksTrafficVolume = initData; + this.containerTruckTrafficVolume = initData; + this.averageSpeedOfContainerTruck = initData; + this.motorcycleTrafficVolume = initData; + this.averageSpeedOfMotorcycle = initData; + this.tractorTrafficVolume = initData; + this.averageSpeedOfTractor = initData; + this.avgSpeed = initData; + } @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java index bfa1e6f0..4991899d 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java @@ -76,4 +76,6 @@ public interface DcTrafficSurveyDataMapper List selectSpeed(DcTrafficSurveyDataQueryParams dcTrafficSurveyDataQueryParams); DcDevice selectDeviceByIotId(@Param("iotDeviceId") String iotDeviceId); + + List getTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData); } diff --git a/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java b/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java index 3762ab9c..e0923c89 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java @@ -1,6 +1,7 @@ package com.zc.business.service; import java.io.IOException; +import java.text.ParseException; import java.util.List; import com.alibaba.fastjson.JSONArray; @@ -127,4 +128,6 @@ public interface IDcTrafficSurveyDataService AjaxResult selectRealTimeData(DcTrafficSurveyDataQueryParams dcTrafficSurveyDataQueryParams) throws IOException, HttpException; DcDevice selectDeviceByIotId(String iotDeviceId); + + List getTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData) throws ParseException; } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java index 1af8594a..a2505922 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java @@ -1,10 +1,14 @@ package com.zc.business.service.impl; import java.io.IOException; +import java.math.BigDecimal; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; @@ -1886,4 +1890,27 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi public DcDevice selectDeviceByIotId(String iotDeviceId){ return dcTrafficSurveyDataMapper.selectDeviceByIotId(iotDeviceId); } + + @Override + public List getTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData) throws ParseException { + Date startTime = DateUtil.beginOfHour(dcTrafficSurveyData.getStartTime()); + Date endTime = DateUtil.endOfHour(dcTrafficSurveyData.getEndTime()); + List dateRangeList = DateUtil.rangeToList(startTime, endTime, DateField.HOUR_OF_DAY, 1); + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + List timeList = new ArrayList<>(); + for (DateTime dateTime : dateRangeList) { + timeList.add(df.format(dateTime)); + } + List list = dcTrafficSurveyDataMapper.getTrafficSurveyDataList(dcTrafficSurveyData); + Map> collect = list.stream().collect(Collectors.groupingBy(item -> df.format(item.getTimestamp()))); + for (String time : timeList) { + if (!collect.containsKey(time)){ + DcTrafficSurveyData trafficSurveyData = new DcTrafficSurveyData(0); + trafficSurveyData.setTimestamp(df.parse(time)); + list.add(trafficSurveyData); + } + } + list = list.stream().sorted(Comparator.comparing(DcTrafficSurveyData::getTimestamp)).collect(Collectors.toList()); + return list; + } } diff --git a/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml index 28667b87..c92a9b20 100644 --- a/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml @@ -209,6 +209,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + insert into dc_traffic_survey_data