Browse Source

AI预测接口 一类交调站数据

develop
lau572 1 week ago
parent
commit
b6bd54b4b5
  1. 8
      zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java
  2. 26
      zc-business/src/main/java/com/zc/business/domain/DcTrafficSurveyData.java
  3. 2
      zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java
  4. 3
      zc-business/src/main/java/com/zc/business/service/IDcTrafficSurveyDataService.java
  5. 27
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java
  6. 14
      zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml

8
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));
}
/**
* 查询一类交调数据列表
*/

26
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)

2
zc-business/src/main/java/com/zc/business/mapper/DcTrafficSurveyDataMapper.java

@ -76,4 +76,6 @@ public interface DcTrafficSurveyDataMapper
List<DcTrafficSpeedData> selectSpeed(DcTrafficSurveyDataQueryParams dcTrafficSurveyDataQueryParams);
DcDevice selectDeviceByIotId(@Param("iotDeviceId") String iotDeviceId);
List<DcTrafficSurveyData> getTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData);
}

3
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<DcTrafficSurveyData> getTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData) throws ParseException;
}

27
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<DcTrafficSurveyData> getTrafficSurveyDataList(DcTrafficSurveyData dcTrafficSurveyData) throws ParseException {
Date startTime = DateUtil.beginOfHour(dcTrafficSurveyData.getStartTime());
Date endTime = DateUtil.endOfHour(dcTrafficSurveyData.getEndTime());
List<DateTime> dateRangeList = DateUtil.rangeToList(startTime, endTime, DateField.HOUR_OF_DAY, 1);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<String> timeList = new ArrayList<>();
for (DateTime dateTime : dateRangeList) {
timeList.add(df.format(dateTime));
}
List<DcTrafficSurveyData> list = dcTrafficSurveyDataMapper.getTrafficSurveyDataList(dcTrafficSurveyData);
Map<String, List<DcTrafficSurveyData>> 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;
}
}

14
zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml

@ -209,6 +209,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectDeviceByIotId" resultType="com.zc.business.domain.DcDevice">
SELECT * FROM `dc_device` where device_type = '11' and iot_device_id = #{iotDeviceId}
</select>
<select id="getTrafficSurveyDataList" resultType="com.zc.business.domain.DcTrafficSurveyData">
select * from dc_traffic_survey_data
<where>
<if test="iotDeviceId != null and iotDeviceId != ''">
and iot_device_id = #{iotDeviceId}
</if>
<if test="direction != null and direction != ''">
and direction = #{direction}
</if>
<if test="startTime != null and endTime != null">
and `timestamp` BETWEEN #{startTime} and #{endTime}
</if>
</where>
</select>
<insert id="insertDcTrafficSurveyData" parameterType="DcTrafficSurveyData" useGeneratedKeys="true" keyProperty="id">
insert into dc_traffic_survey_data

Loading…
Cancel
Save