Browse Source

Merge remote-tracking branch 'origin/develop' into develop

develop
wangsixiang 3 months ago
parent
commit
7d4fcb9647
  1. 5
      zc-business/src/main/java/com/zc/business/constant/RedisKeyConstants.java
  2. 147
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  3. 8
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java
  4. 174
      zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java
  5. 75
      zc-business/src/main/java/com/zc/business/controller/RadarController.java
  6. 4
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  7. 325
      zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedDirectionData.java
  8. 11
      zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeData.java
  9. 325
      zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeDirectionData.java
  10. 52
      zc-business/src/main/java/com/zc/business/enums/TrafficFlowDoorFrameSection.java
  11. 3
      zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java
  12. 41
      zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java
  13. 93
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java
  14. 237
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java
  15. 54
      zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml
  16. 39
      zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml
  17. 65
      zc-business/src/main/resources/mapper/business/DcTrafficSurveyDataMapper.xml

5
zc-business/src/main/java/com/zc/business/constant/RedisKeyConstants.java

@ -68,4 +68,9 @@ public class RedisKeyConstants
* 设备离线记录
*/
public static final String DC_DEVICE_OFFLINE_RECORD = "dc:deviceOfflineRecord";
/**
* 交调站小时数据 失败请求
*/
public static final String TRAFFIC_SURVEY_HOURS_DATA = "trafficSurveyHoursData";
}

147
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -11,6 +11,7 @@ import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.spring.SpringUtils;
@ -22,6 +23,7 @@ import com.zc.business.enums.UniversalEnum;
import com.zc.business.interfaces.OperationLog;
import com.zc.business.request.DeviceGetPropertiesOperateRequest;
import com.zc.business.service.IDcDeviceService;
import com.zc.business.service.IDcWarningService;
import com.zc.common.core.httpclient.OkHttp;
import com.zc.common.core.httpclient.exception.HttpException;
import com.zc.common.core.httpclient.request.RequestParams;
@ -63,7 +65,8 @@ import java.util.stream.Collectors;
@RestController
@RequestMapping("/business/device")
public class DcDeviceController extends BaseController {
@Resource
private RedisCache redisCache;
@Resource
private IDcDeviceService dcDeviceService;
@Resource
@ -406,8 +409,130 @@ private VideoController videoController;
}
@ApiOperation("太阳能状况统计")
@GetMapping("/properties/history/oneDay/{propertyId}")
public AjaxResult queryDevicePropertiesDay(
@PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException, ParseException {
public AjaxResult queryDevicePropertiesDay(@PathVariable @Parameter(description = "属性ID") String propertyId) throws HttpException, IOException, ParseException {
// HashMap<String, Object> props = new HashMap<>();
// // 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
// props.put("terms[0].column", "timestamp$BTW");
// ArrayList<String> dateList = new ArrayList<>();
// // 添加当前日期的开始和结束时间到列表,用于设定时间范围
// dateList.add(DateUtil.beginOfDay(new Date()).toString());
// dateList.add(DateUtil.endOfDay(new Date()).toString());
// // 将日期列表以逗号分隔并设置为查询条件的值
// props.put("terms[0].value", String.join(",", dateList));
// props.put("paging", false);
// props.put("sorts[0].order", "asc");
// props.put("sorts[0].name", "timestamp");
// Map<String, Object> parameter = new HashMap<>();
// String[] endStakeMark = {"208", "979"};
// String[] startStakeMark = {"054", "378"};
// parameter.put("deviceType", "15");
// parameter.put("endStakeMark", endStakeMark);
// parameter.put("startStakeMark", startStakeMark);
// // parameter.put("deviceState","1");
// // 创建一个映射来存储按小时汇总的数据
// Map<String, Double> allDevicesHourlyAggregates = new TreeMap<>();
//
// List<DcDevice> dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
// for (DcDevice dcDevice : dcDevices) {
// AjaxResult ajaxResult = queryDeviceProperties(dcDevice.getIotDeviceId(), propertyId, props);
// if (!ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
// return ajaxResult;
// }
// // 定义时间格式
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//
// Object data = JSON.parseObject(ajaxResult.get("data").toString()).get("data");
// JSONArray dataArray = JSON.parseArray(data.toString());
// // 创建一个映射来存储单个设备按小时汇总的数据
// Map<String, Map<String, Object>> deviceHourlyLatestData = new TreeMap<>();
//
// DecimalFormat decimalFormat = new DecimalFormat("#.##");
// decimalFormat.setRoundingMode(RoundingMode.HALF_UP);
//
// // 处理每个数据点
// for (Object o : dataArray) {
// JSONObject jsonObject = JSON.parseObject(o.toString());
// String formatValueStr = jsonObject.getString("formatValue");
// String timestampStr = jsonObject.getString("timestamp");
//
// // 将 Unix 时间戳转换为 Date 对象
// long timestamp = Long.parseLong(timestampStr);
// Date date = new Date(timestamp);
//
// // 将 Date 对象格式化为字符串
// String formattedTimestamp = sdf.format(date);
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
//
// // 提取小时部分
// int hour = calendar.get(Calendar.HOUR_OF_DAY);
// String key = String.format("%d-%02d-%02d %02d:00:00",
// calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1,
// calendar.get(Calendar.DAY_OF_MONTH), hour);
//
// // 转换为 double 类型,去除单位
// String valueWithoutUnit = formatValueStr.replaceAll("[^\\d.]", "");
// double parsedValue = Double.parseDouble(valueWithoutUnit);
// // 保留两位小数
// double formatValue = Double.parseDouble(decimalFormat.format(parsedValue));
//
// // 检查当前小时是否有数据,如果没有则直接添加
// if (!deviceHourlyLatestData.containsKey(key)) {
// Map<String, Object> dataPoint = new HashMap<>();
// dataPoint.put("value", formatValue);
// dataPoint.put("timestamp", timestamp);
// deviceHourlyLatestData.put(key, dataPoint);
// } else {
// // 如果已经有数据,比较时间戳,保留最新的数据
// long existingTimestamp = (long) deviceHourlyLatestData.get(key).get("timestamp");
// if (timestamp > existingTimestamp) {
// Map<String, Object> dataPoint = new HashMap<>();
// dataPoint.put("value", formatValue);
// dataPoint.put("timestamp", timestamp);
// deviceHourlyLatestData.put(key, dataPoint);
// }
// }
// }
//
// // 将设备的数据合并到所有设备的汇总数据中
// for (String key : deviceHourlyLatestData.keySet()) {
// double latestValue = (double) deviceHourlyLatestData.get(key).get("value");
// allDevicesHourlyAggregates.merge(key, latestValue, (oldVal, newVal) -> {
// double sum = oldVal + newVal;
// return Double.parseDouble(decimalFormat.format(sum));
// });
// }
// }
Map<String, Double> allDevicesHourlyAggregates= redisCache.getCacheObject(propertyId);
return AjaxResult.success(allDevicesHourlyAggregates);
}
public void solarEnergyConditionStatisticsOne() {
RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
Map<String, Double> stringDoubleMap = solarEnergyConditionStatistics("dailyAccumulatedCharge");
if (stringDoubleMap != null) {
redisCache.setCacheObject("dailyAccumulatedCharge", stringDoubleMap);
}
}
public void solarEnergyConditionStatisticsTwo(){
RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
Map<String, Double> stringDoubleMap = solarEnergyConditionStatistics("cumulativeElectricityConsumptionOnTheDay");
if (stringDoubleMap!=null) {
redisCache.setCacheObject("cumulativeElectricityConsumptionOnTheDay", stringDoubleMap);
}
}
public void solarEnergyConditionStatisticsThree(){
RedisCache redisCache = SpringUtils.getBean(RedisCache.class);
Map<String, Double> stringDoubleMap = solarEnergyConditionStatistics("generatingPower");
if (stringDoubleMap!=null){
redisCache.setCacheObject("generatingPower", stringDoubleMap);
}
}
public Map<String, Double> solarEnergyConditionStatistics (String propertyId) {
IDcDeviceService dcDeviceService = SpringUtils.getBean(IDcDeviceService.class);
HashMap<String, Object> props = new HashMap<>();
// 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
props.put("terms[0].column", "timestamp$BTW");
@ -432,9 +557,17 @@ private VideoController videoController;
List<DcDevice> dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
for (DcDevice dcDevice : dcDevices) {
AjaxResult ajaxResult = queryDeviceProperties(dcDevice.getIotDeviceId(), propertyId, props);
AjaxResult ajaxResult = null;
try {
ajaxResult = queryDeviceProperties(dcDevice.getIotDeviceId(), propertyId, props);
} catch (HttpException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
if (!ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
return ajaxResult;
return null;
}
// 定义时间格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@ -501,10 +634,8 @@ private VideoController videoController;
});
}
}
return AjaxResult.success(allDevicesHourlyAggregates);
return allDevicesHourlyAggregates;
}
@ApiOperation("太阳能重点数据")
@GetMapping("/properties/latestOne")
public AjaxResult getDeviceLatest() throws HttpException, IOException {

8
zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java

@ -969,6 +969,14 @@ public class DcTrafficStatisticsController extends BaseController {
// 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(a);
}
@ApiOperation("收费站日累计车流辆分车型")
@GetMapping("/history/trafficFlowAtTollTypes")
public AjaxResult trafficFlowAtTollTypes(String startDate) throws HttpException, IOException {
// 调用服务层方法,获取当前交通指标数据
Map<String,Integer> a = dcTrafficStatisticsService.trafficFlowAtTollTypes(startDate);
// 将获取到的交通指标数据封装为成功的结果并返回
return AjaxResult.success(a);
}
@ApiOperation("收费站昨日累计车流辆")
@GetMapping("/history/yesterdayTrafficFlowAtToll")

174
zc-business/src/main/java/com/zc/business/controller/DcTrafficSurveyDataController.java

@ -1,6 +1,8 @@
package com.zc.business.controller;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import javax.annotation.Resource;
@ -11,7 +13,9 @@ import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.system.domain.SysLogininfor;
import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.domain.*;
import com.zc.business.enums.UniversalEnum;
import com.zc.common.core.httpclient.exception.HttpException;
@ -55,8 +59,20 @@ public class DcTrafficSurveyDataController extends BaseController
@Resource
private DcDeviceController dcDeviceController;
@Scheduled(cron = "0 5 * * * ?")
public void syncTrafficSectionData() throws HttpException, IOException {
@Resource
private RedisCache redisCache;
/**
* 每小时执行一次
* 如果请求失败则将当前设备时间范围放入redis
* 下次执行时先处理redis中之前未成功的最多执行三次
*/
@Scheduled(cron = "0 13 * * * ?")
public void syncTrafficSectionData() throws HttpException, IOException, ParseException {
//先执行之前不成功的
executeFailedData();
HashMap<String, Object> props = new HashMap<>();
// 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
@ -68,8 +84,10 @@ public class DcTrafficSurveyDataController extends BaseController
Date lastHourStart = DateUtil.beginOfHour(DateUtil.offsetHour(now, -1));
Date lastHourEnd = DateUtil.endOfHour(DateUtil.offsetHour(now, -1));
// 将上一个小时的开始和结束时间添加到列表
dateList.add(DateUtil.format(lastHourStart, "yyyy-MM-dd HH:mm:ss"));
dateList.add(DateUtil.format(lastHourEnd, "yyyy-MM-dd HH:mm:ss"));
String startTime = DateUtil.format(lastHourStart, "yyyy-MM-dd HH:mm:ss");
String endTime = DateUtil.format(lastHourEnd, "yyyy-MM-dd HH:mm:ss");
dateList.add(startTime);
dateList.add(endTime);
// 将日期列表以逗号分隔并设置为查询条件的值
props.put("terms[0].value", String.join(UniversalEnum.COMMA.getValue(), dateList));
props.put("paging", false);
@ -83,7 +101,21 @@ public class DcTrafficSurveyDataController extends BaseController
List<DcTrafficSurveyData> batchData = new ArrayList<>();
for (DcDevice dcDevice : deviceList) {
Object data = JSON.parseObject(dcDeviceController.queryDeviceProperties(dcDevice.getIotDeviceId(), propertyId, props).get("data").toString()).get("data");
Object data = null;
AjaxResult ajaxResult = dcDeviceController.queryDeviceProperties(dcDevice.getIotDeviceId(), propertyId, props);
if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber()) && ajaxResult.containsKey("data") && ajaxResult.get("data") != null) {
data = JSON.parseObject(ajaxResult.get("data").toString()).get("data");
} else {
//超时、错误等异常状态,放入缓存下次定时执行时再次请求一遍
Map<String,Object> cacheMap = new HashMap<>();
cacheMap.put("iotDeviceId",dcDevice.getIotDeviceId());
cacheMap.put("stakeMark",dcDevice.getStakeMark());
cacheMap.put("startTime",startTime);
cacheMap.put("endTime",endTime);
cacheMap.put("count",3); //剩余请求次数
redisCache.setCacheMapValue(RedisKeyConstants.TRAFFIC_SURVEY_HOURS_DATA,dcDevice.getIotDeviceId()+startTime,cacheMap);
break;
}
JSONArray dataArray = JSON.parseArray(data.toString());
if (dataArray == null || dataArray.size() < 1){
break;
@ -151,6 +183,122 @@ public class DcTrafficSurveyDataController extends BaseController
}
/**
* @Description 再次执行之前未成功请求的
*
* @author liuwenge
* @date 2024/12/25 9:36
* @param
* @return void
*/
public void executeFailedData() throws IOException, HttpException, ParseException {
Map<String,Map<String,Object>> cache = redisCache.getCacheMap(RedisKeyConstants.TRAFFIC_SURVEY_HOURS_DATA);
if (cache == null || cache.size() == 0) {
return;
}
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
List<DcTrafficSurveyData> batchData = new ArrayList<>();
for (Map<String, Object> value : cache.values()) {
String iotDeviceId = value.get("iotDeviceId").toString();
String stakeMark = value.get("stakeMark").toString();
String startTime = value.get("startTime").toString();
String endTime = value.get("endTime").toString();
int count = Integer.parseInt(value.get("count").toString());
HashMap<String, Object> props = new HashMap<>();
// 设置查询条件的键为“timestamp$BTW”,表示时间戳在一定范围内
props.put("terms[0].column", "timestamp$BTW");
ArrayList<String> dateList = new ArrayList<>();
dateList.add(startTime);
dateList.add(endTime);
// 将日期列表以逗号分隔并设置为查询条件的值
props.put("terms[0].value", String.join(UniversalEnum.COMMA.getValue(), dateList));
props.put("paging", false);
props.put("sorts[0].order", "asc");
props.put("sorts[0].name", "timestamp");
Object data = null;
AjaxResult ajaxResult = dcDeviceController.queryDeviceProperties(iotDeviceId, "01", props);
if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber()) && ajaxResult.containsKey("data") && ajaxResult.get("data") != null) {
data = JSON.parseObject(ajaxResult.get("data").toString()).get("data");
redisCache.delCacheMapValue(RedisKeyConstants.TRAFFIC_SURVEY_HOURS_DATA,iotDeviceId+startTime);
} else {
count--;
if (count < 1){
redisCache.delCacheMapValue(RedisKeyConstants.TRAFFIC_SURVEY_HOURS_DATA,iotDeviceId+startTime);
} else {
value.put("count",count);
redisCache.setCacheMapValue(RedisKeyConstants.TRAFFIC_SURVEY_HOURS_DATA,iotDeviceId+startTime,value);
}
break;
}
JSONArray dataArray = JSON.parseArray(data.toString());
if (dataArray == null || dataArray.size() < 1){
break;
}
Integer hezeTotal = 0;
Integer jinanTotal = 0;
//一小时内所有的车道数据
JSONArray lanesData = new JSONArray();
for (Object o : dataArray) {
JSONObject jsonObject = JSON.parseObject(o.toString());
JSONObject formatValue = JSON.parseObject(jsonObject.get("formatValue").toString());
hezeTotal += Integer.parseInt(formatValue.get("1").toString());
jinanTotal += Integer.parseInt(formatValue.get("3").toString());
//车道数据
JSONArray lanes = formatValue.getJSONArray("lanes");
lanesData.addAll(lanes);
}
// 转换类型 以便使用stream
List<JSONObject> lanesList = lanesData.toJavaList(JSONObject.class);
Map<String, JSONArray> dataList = lanesList.stream()
.collect(Collectors.groupingBy(
item -> item.getString("laneNumber").substring(0, 1), // 提取 laneNumber 的第一个字符作为 key
Collectors.mapping(item -> item,
Collectors.collectingAndThen(
Collectors.toList(),
list -> { // 然后将 List<JSONObject> 转换为 JSONArray
JSONArray jsonArray = new JSONArray();
jsonArray.addAll(list);
return jsonArray;
}
)
)
));
//菏泽方向数据
DcTrafficSurveyData hezeData = new DcTrafficSurveyData();
hezeData.setIotDeviceId(iotDeviceId);
hezeData.setStakeMark(stakeMark);
hezeData.setDirection("1");
hezeData.setTimestamp(formatter.parse(startTime));
hezeData.setTrafficVolume(Long.valueOf(hezeTotal));
//济南方向数据
DcTrafficSurveyData jinanData = new DcTrafficSurveyData();
jinanData.setIotDeviceId(iotDeviceId);
jinanData.setStakeMark(stakeMark);
jinanData.setDirection("3");
jinanData.setTimestamp(formatter.parse(startTime));
jinanData.setTrafficVolume(Long.valueOf(jinanTotal));
//各方向车道级数据
if (dataList != null && dataList.size() > 0){
JSONArray hezeLanesData = dataList.get("1");
dcTrafficSurveyDataService.formatTrafficSurveyData(hezeData,hezeLanesData);
JSONArray jinanLanesData = dataList.get("3");
dcTrafficSurveyDataService.formatTrafficSurveyData(jinanData,jinanLanesData);
}
batchData.add(hezeData);
batchData.add(jinanData);
}
dcTrafficSurveyDataService.batchInsert(batchData);
}
/**
* 查询一类交调数据列表
*/
@ -301,19 +449,35 @@ public class DcTrafficSurveyDataController extends BaseController
public AjaxResult selectComprehensiveData(@RequestBody DcTrafficSurveyDataQueryParams dcTrafficSurveyDataQueryParams){
return dcTrafficSurveyDataService.selectComprehensiveData(dcTrafficSurveyDataQueryParams);
}
/**
* 导出综合查询
*/
@PostMapping("/exportComprehensiveData")
public void exportComprehensiveData(HttpServletResponse response,@RequestBody DcTrafficSurveyDataQueryParams dcTrafficSurveyDataQueryParams)
{
AjaxResult ajaxResult = dcTrafficSurveyDataService.selectComprehensiveData(dcTrafficSurveyDataQueryParams);
if (ajaxResult.get("code").equals(UniversalEnum.TWO_HUNDRED.getNumber())) {
if (dcTrafficSurveyDataQueryParams.getDataType().equals("1")){
if (dcTrafficSurveyDataQueryParams.getDirection().equals("2")) {
List<DcTrafficVolumeData> dcTrafficVolumeData = (List<DcTrafficVolumeData>) ajaxResult.get("data");
ExcelUtil<DcTrafficVolumeData> util = new ExcelUtil<>(DcTrafficVolumeData.class);
util.exportExcel(response, dcTrafficVolumeData, "综合查询");
} else if (dcTrafficSurveyDataQueryParams.getDirection().equals("1")) {
List<DcTrafficVolumeDirectionData> dcTrafficVolumeData = (List<DcTrafficVolumeDirectionData>) ajaxResult.get("data");
ExcelUtil<DcTrafficVolumeDirectionData> util = new ExcelUtil<>(DcTrafficVolumeDirectionData.class);
util.exportExcel(response, dcTrafficVolumeData, "综合查询");
}
} else {
if (dcTrafficSurveyDataQueryParams.getDirection().equals("2")) {
List<DcTrafficSpeedData> dcTrafficSpeedData = (List<DcTrafficSpeedData>) ajaxResult.get("data");
ExcelUtil<DcTrafficSpeedData> util = new ExcelUtil<>(DcTrafficSpeedData.class);
util.exportExcel(response, dcTrafficSpeedData, "综合查询");
} else if (dcTrafficSurveyDataQueryParams.getDirection().equals("1")) {
List<DcTrafficSpeedDirectionData> dcTrafficSpeedData = (List<DcTrafficSpeedDirectionData>) ajaxResult.get("data");
ExcelUtil<DcTrafficSpeedDirectionData> util = new ExcelUtil<>(DcTrafficSpeedDirectionData.class);
util.exportExcel(response, dcTrafficSpeedData, "综合查询");
}
}
}
}

75
zc-business/src/main/java/com/zc/business/controller/RadarController.java

@ -22,6 +22,9 @@ import java.time.Duration;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
/**
*
@ -42,57 +45,80 @@ public class RadarController {
LocalDateTime fifteenMinutesAgo = now.minus(Duration.ofMinutes(5));
String FifteenMinutesAgo = fifteenMinutesAgo.format(formatter);
// 获取当前时间前20分钟的时间点
LocalDateTime twentyMinutesAgo = now.minus(Duration.ofMinutes(20));
// 获取当前时间前25分钟的时间点
LocalDateTime twentyMinutesAgo = now.minus(Duration.ofMinutes(25));
String TwentyMinutesAgo = twentyMinutesAgo.format(formatter);
DcWarning dcWarning = new DcWarning();
dcWarning.setStartDate(TwentyMinutesAgo);
dcWarning.setEndDate(FifteenMinutesAgo);
List<DcWarning> radarList = dcWarningService.radarList(dcWarning);
// 创建一个固定大小的线程池
ExecutorService executor = Executors.newFixedThreadPool(3); // 线程池大小
try {
radarList.forEach(radar -> {
if (radar.getId() != null) {
if (radar != null && radar.getId() != null) {
executor.submit(() -> processRadarEvent(radar, now));
}
});
// 关闭线程池,并等待所有任务完成
executor.shutdown();
executor.awaitTermination(1, TimeUnit.HOURS); // 设置超时时间
} catch (InterruptedException e) {
Thread.currentThread().interrupt(); // 恢复中断状态
log.error("线程池关闭过程中发生中断", e);
} finally {
if (!executor.isTerminated()) {
executor.shutdownNow(); // 强制关闭未完成的任务
}
}
}
private void processRadarEvent(DcWarning radar, LocalDateTime now) {
try {
// 获取雷达事件视频
String baseUrl = dcWarningService.getRadarIncidentVideo(radar.getId());
// String baseUrl = "http://10.0.11.252:9021/profile/mp4/G35 长清大学城站 内广场_20241108_090235_60.mp4";
System.out.println("雷达视频地址:" + baseUrl);
if (baseUrl == null || baseUrl.isEmpty()) {
log.warn("雷达事件ID {} 没有对应的视频URL", radar.getId());
return;
}
String ftpServer= configService.selectConfigByKey("FTP-IP");//密钥
// int port = 21;
int port= Integer.parseInt(configService.selectConfigByKey("FTP-PORT"));
//ftpuser
//String user = "1911390090@qq.com";
String username= configService.selectConfigByKey("FTP-USER");//密钥
//Dxc123!@#
String password= configService.selectConfigByKey("FPT-PASSWORD");//密钥
/* String ftpServer = "10.168.71.135";
int port = 21;
String username = "1911390090@qq.com";
String password = "989878wxl";*/
String[] split = StringUtils.split(baseUrl, "_");
// String ftpServer = "192.168.3.1";
// int port = 21;
// String username = "1911390090@qq.com";
// String password = "989878wxl";
String[] split = StringUtils.split(baseUrl, "/");
// 拼接文件名
String fileName = radar.getStakeMark() + "_" + split[1] + "_" + split[2] + "_" + split[3];
String fileName = split[split.length - 1];
DateTimeFormatter dirFormatter = DateTimeFormatter.ofPattern("yyyyMMdd");
DateTimeFormatter hourFormatter = DateTimeFormatter.ofPattern("HH");
String datePart = now.format(dirFormatter);
String hourPart = now.format(hourFormatter);
// 文件路径
// String remoteFilePath = "/path/to/remote/directory";
String remoteFilePath = "/radar/" + datePart + "/" + hourPart;
String download = directDownloadToFtp(baseUrl, ftpServer, port, username, password, remoteFilePath, fileName);
DcWarning dcWarning1 = new DcWarning();
dcWarning1.setId(radar.getId());
dcWarning1.setRadarUrl(download);
int i = dcWarningService.updateDcWarning(dcWarning1);
} catch (Exception e) {
throw new RuntimeException(e);
if (i <= 0) {
log.error("更新数据库失败,ID: {}", radar.getId());
}
} catch (Exception e) {
log.error("处理雷达事件ID {} 时发生异常", radar.getId(), e);
}
});
}
public static String directDownloadToFtp(String baseUrl, String ftpServer, int port, String user, String pass, String remotePath, String fileName) throws IOException, URISyntaxException, InterruptedException {
FTPClient ftpClient = new FTPClient();
HttpURLConnection httpConn = null;
@ -104,8 +130,7 @@ public class RadarController {
System.out.println("encodedUrl: " + encodedUrl);
URI uri = new URI(encodedUrl);
URL url = uri.toURL();
// 睡眠3秒钟
Thread.sleep(3000); //
httpConn = (HttpURLConnection) url.openConnection();
int responseCode = httpConn.getResponseCode();
@ -115,7 +140,7 @@ public class RadarController {
ftpClient.connect(ftpServer, port);
boolean loginResult = ftpClient.login(user, pass);
if (!loginResult) {
throw new IOException("FTP登录失败");
log.info("FTP登录失败");
}
log.info("成功登录到FTP服务器");
// 设置为二进制传输模式和被动模式
@ -145,7 +170,7 @@ public class RadarController {
log.info("最终工作目录: " + ftpClient.printWorkingDirectory());
}
// 上传文件到FTP服务器
boolean done = ftpClient.storeFile(fileName, inputStream);
boolean done = ftpClient.storeFile(new String(fileName.getBytes("GBK"),"ISO-8859-1"), inputStream);
if (done) {
log.info("文件上传成功");
return URL+ftpClient.printWorkingDirectory()+"/" + fileName;

4
zc-business/src/main/java/com/zc/business/controller/VideoController.java

@ -633,6 +633,10 @@ public class VideoController extends BaseController {
}
}
}
}else {
jsonResult.put("code",200);
jsonResult.put("data", new JSONObject());
jsonResult.put("msg","摄像机连接失败");
}
}
}catch (Exception e) {

325
zc-business/src/main/java/com/zc/business/domain/DcTrafficSpeedDirectionData.java

@ -0,0 +1,325 @@
package com.zc.business.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 一类交调数据对象(分方向) dc_traffic_survey_data
*
* @author liuwenge
* @date 2024-10-29
*/
public class DcTrafficSpeedDirectionData extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 物联设备主键 */
private String iotDeviceId;
/** 方向1-上行,2-中,3-下行 */
private String direction;
/** 时间 */
@Excel(name = "时间")
private String time;
/** 中小客车平均地点车速 */
@Excel(name = "中小客车-菏泽")
private Integer inAndSmallAverageVehicleSpeedHZ;
/** 中小客车平均地点车速 */
@Excel(name = "中小客车-济南")
private Integer inAndSmallAverageVehicleSpeedJN;
/** 大客车平均地点车速 */
@Excel(name = "大客车-菏泽")
private Integer averageSpeedOfBusHZ;
/** 大客车平均地点车速 */
@Excel(name = "大客车-济南")
private Integer averageSpeedOfBusJN;
/** 小型货车平均地点车速 */
@Excel(name = "小型货车-菏泽")
private Integer smallTrucksAverageVehicleSpeedHZ;
/** 小型货车平均地点车速 */
@Excel(name = "小型货车-济南")
private Integer smallTrucksAverageVehicleSpeedJN;
/** 中型货车平均地点车速 */
@Excel(name = "中型货车-菏泽")
private Integer averageSpeedOfMediumSizeTrucksHZ;
/** 中型货车平均地点车速 */
@Excel(name = "中型货车-济南")
private Integer averageSpeedOfMediumSizeTrucksJN;
/** 大型货车平均地点车速 */
@Excel(name = "大型货车-菏泽")
private Integer averageSpeedOfLargeTrucksHZ;
/** 大型货车平均地点车速 */
@Excel(name = "大型货车-济南")
private Integer averageSpeedOfLargeTrucksJN;
/** 特大型货车平均地点车速 */
@Excel(name = "特大型货车-菏泽")
private Integer averageSpeedOfExtraLargeTrucksHZ;
/** 特大型货车平均地点车速 */
@Excel(name = "特大型货车-济南")
private Integer averageSpeedOfExtraLargeTrucksJN;
/** 集装箱车平均地点车速 */
@Excel(name = "集装箱车-菏泽")
private Integer averageSpeedOfContainerTruckHZ;
/** 集装箱车平均地点车速 */
@Excel(name = "集装箱车-济南")
private Integer averageSpeedOfContainerTruckJN;
/** 摩托车平均地点车速 */
@Excel(name = "摩托车-菏泽")
private Integer averageSpeedOfMotorcycleHZ;
/** 摩托车平均地点车速 */
@Excel(name = "摩托车-济南")
private Integer averageSpeedOfMotorcycleJN;
/** 拖拉机平均地点车速 */
@Excel(name = "拖拉机-菏泽")
private Integer averageSpeedOfTractorHZ;
/** 拖拉机平均地点车速 */
@Excel(name = "拖拉机-济南")
private Integer averageSpeedOfTractorJN;
/** 平均地点车速 */
@Excel(name = "平均车速-菏泽")
private Integer avgSpeedHZ;
/** 平均地点车速 */
@Excel(name = "平均车速-济南")
private Integer avgSpeedJN;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getIotDeviceId() {
return iotDeviceId;
}
public void setIotDeviceId(String iotDeviceId) {
this.iotDeviceId = iotDeviceId;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public Integer getInAndSmallAverageVehicleSpeedHZ() {
return inAndSmallAverageVehicleSpeedHZ;
}
public void setInAndSmallAverageVehicleSpeedHZ(Integer inAndSmallAverageVehicleSpeedHZ) {
this.inAndSmallAverageVehicleSpeedHZ = inAndSmallAverageVehicleSpeedHZ;
}
public Integer getInAndSmallAverageVehicleSpeedJN() {
return inAndSmallAverageVehicleSpeedJN;
}
public void setInAndSmallAverageVehicleSpeedJN(Integer inAndSmallAverageVehicleSpeedJN) {
this.inAndSmallAverageVehicleSpeedJN = inAndSmallAverageVehicleSpeedJN;
}
public Integer getAverageSpeedOfBusHZ() {
return averageSpeedOfBusHZ;
}
public void setAverageSpeedOfBusHZ(Integer averageSpeedOfBusHZ) {
this.averageSpeedOfBusHZ = averageSpeedOfBusHZ;
}
public Integer getAverageSpeedOfBusJN() {
return averageSpeedOfBusJN;
}
public void setAverageSpeedOfBusJN(Integer averageSpeedOfBusJN) {
this.averageSpeedOfBusJN = averageSpeedOfBusJN;
}
public Integer getSmallTrucksAverageVehicleSpeedHZ() {
return smallTrucksAverageVehicleSpeedHZ;
}
public void setSmallTrucksAverageVehicleSpeedHZ(Integer smallTrucksAverageVehicleSpeedHZ) {
this.smallTrucksAverageVehicleSpeedHZ = smallTrucksAverageVehicleSpeedHZ;
}
public Integer getSmallTrucksAverageVehicleSpeedJN() {
return smallTrucksAverageVehicleSpeedJN;
}
public void setSmallTrucksAverageVehicleSpeedJN(Integer smallTrucksAverageVehicleSpeedJN) {
this.smallTrucksAverageVehicleSpeedJN = smallTrucksAverageVehicleSpeedJN;
}
public Integer getAverageSpeedOfMediumSizeTrucksHZ() {
return averageSpeedOfMediumSizeTrucksHZ;
}
public void setAverageSpeedOfMediumSizeTrucksHZ(Integer averageSpeedOfMediumSizeTrucksHZ) {
this.averageSpeedOfMediumSizeTrucksHZ = averageSpeedOfMediumSizeTrucksHZ;
}
public Integer getAverageSpeedOfMediumSizeTrucksJN() {
return averageSpeedOfMediumSizeTrucksJN;
}
public void setAverageSpeedOfMediumSizeTrucksJN(Integer averageSpeedOfMediumSizeTrucksJN) {
this.averageSpeedOfMediumSizeTrucksJN = averageSpeedOfMediumSizeTrucksJN;
}
public Integer getAverageSpeedOfLargeTrucksHZ() {
return averageSpeedOfLargeTrucksHZ;
}
public void setAverageSpeedOfLargeTrucksHZ(Integer averageSpeedOfLargeTrucksHZ) {
this.averageSpeedOfLargeTrucksHZ = averageSpeedOfLargeTrucksHZ;
}
public Integer getAverageSpeedOfLargeTrucksJN() {
return averageSpeedOfLargeTrucksJN;
}
public void setAverageSpeedOfLargeTrucksJN(Integer averageSpeedOfLargeTrucksJN) {
this.averageSpeedOfLargeTrucksJN = averageSpeedOfLargeTrucksJN;
}
public Integer getAverageSpeedOfExtraLargeTrucksHZ() {
return averageSpeedOfExtraLargeTrucksHZ;
}
public void setAverageSpeedOfExtraLargeTrucksHZ(Integer averageSpeedOfExtraLargeTrucksHZ) {
this.averageSpeedOfExtraLargeTrucksHZ = averageSpeedOfExtraLargeTrucksHZ;
}
public Integer getAverageSpeedOfExtraLargeTrucksJN() {
return averageSpeedOfExtraLargeTrucksJN;
}
public void setAverageSpeedOfExtraLargeTrucksJN(Integer averageSpeedOfExtraLargeTrucksJN) {
this.averageSpeedOfExtraLargeTrucksJN = averageSpeedOfExtraLargeTrucksJN;
}
public Integer getAverageSpeedOfContainerTruckHZ() {
return averageSpeedOfContainerTruckHZ;
}
public void setAverageSpeedOfContainerTruckHZ(Integer averageSpeedOfContainerTruckHZ) {
this.averageSpeedOfContainerTruckHZ = averageSpeedOfContainerTruckHZ;
}
public Integer getAverageSpeedOfContainerTruckJN() {
return averageSpeedOfContainerTruckJN;
}
public void setAverageSpeedOfContainerTruckJN(Integer averageSpeedOfContainerTruckJN) {
this.averageSpeedOfContainerTruckJN = averageSpeedOfContainerTruckJN;
}
public Integer getAverageSpeedOfMotorcycleHZ() {
return averageSpeedOfMotorcycleHZ;
}
public void setAverageSpeedOfMotorcycleHZ(Integer averageSpeedOfMotorcycleHZ) {
this.averageSpeedOfMotorcycleHZ = averageSpeedOfMotorcycleHZ;
}
public Integer getAverageSpeedOfMotorcycleJN() {
return averageSpeedOfMotorcycleJN;
}
public void setAverageSpeedOfMotorcycleJN(Integer averageSpeedOfMotorcycleJN) {
this.averageSpeedOfMotorcycleJN = averageSpeedOfMotorcycleJN;
}
public Integer getAverageSpeedOfTractorHZ() {
return averageSpeedOfTractorHZ;
}
public void setAverageSpeedOfTractorHZ(Integer averageSpeedOfTractorHZ) {
this.averageSpeedOfTractorHZ = averageSpeedOfTractorHZ;
}
public Integer getAverageSpeedOfTractorJN() {
return averageSpeedOfTractorJN;
}
public void setAverageSpeedOfTractorJN(Integer averageSpeedOfTractorJN) {
this.averageSpeedOfTractorJN = averageSpeedOfTractorJN;
}
public Integer getAvgSpeedHZ() {
return avgSpeedHZ;
}
public void setAvgSpeedHZ(Integer avgSpeedHZ) {
this.avgSpeedHZ = avgSpeedHZ;
}
public Integer getAvgSpeedJN() {
return avgSpeedJN;
}
public void setAvgSpeedJN(Integer avgSpeedJN) {
this.avgSpeedJN = avgSpeedJN;
}
public DcTrafficSpeedDirectionData(){}
public DcTrafficSpeedDirectionData(Integer initData){
this.inAndSmallAverageVehicleSpeedHZ = initData;
this.inAndSmallAverageVehicleSpeedJN = initData;
this.averageSpeedOfBusHZ = initData;
this.averageSpeedOfBusJN = initData;
this.smallTrucksAverageVehicleSpeedHZ = initData;
this.smallTrucksAverageVehicleSpeedJN = initData;
this.averageSpeedOfMediumSizeTrucksHZ = initData;
this.averageSpeedOfMediumSizeTrucksJN = initData;
this.averageSpeedOfLargeTrucksHZ = initData;
this.averageSpeedOfLargeTrucksJN = initData;
this.averageSpeedOfExtraLargeTrucksHZ = initData;
this.averageSpeedOfExtraLargeTrucksJN = initData;
this.averageSpeedOfContainerTruckHZ = initData;
this.averageSpeedOfContainerTruckJN = initData;
this.averageSpeedOfMotorcycleHZ = initData;
this.averageSpeedOfMotorcycleJN = initData;
this.averageSpeedOfTractorHZ = initData;
this.averageSpeedOfTractorJN = initData;
this.avgSpeedHZ = initData;
this.avgSpeedJN = initData;
}
}

11
zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeData.java

@ -25,6 +25,9 @@ public class DcTrafficVolumeData extends BaseEntity
/** 物联设备主键 */
private String iotDeviceId;
/** 方向 */
private String direction;
/** 时间 */
@Excel(name = "时间")
private String time;
@ -85,6 +88,14 @@ public class DcTrafficVolumeData extends BaseEntity
this.iotDeviceId = iotDeviceId;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public String getTime() {
return time;
}

325
zc-business/src/main/java/com/zc/business/domain/DcTrafficVolumeDirectionData.java

@ -0,0 +1,325 @@
package com.zc.business.domain;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 一类交调数据对象(区分方向) dc_traffic_survey_data
*
* @author liuwenge
* @date 2024-10-29
*/
public class DcTrafficVolumeDirectionData extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 物联设备主键 */
private String iotDeviceId;
/** 方向 */
private String direction;
/** 时间 */
@Excel(name = "时间")
private String time;
/** 中小客车交通量 */
@Excel(name = "中小客车-菏泽")
private Integer trafficNumberOfInAndSmallHZ;
/** 中小客车交通量 */
@Excel(name = "中小客车-济南")
private Integer trafficNumberOfInAndSmallJN;
/** 大客车交通量 */
@Excel(name = "大客车-菏泽")
private Integer busTrafficVolumeHZ;
/** 大客车交通量 */
@Excel(name = "大客车-济南")
private Integer busTrafficVolumeJN;
/** 小型货车交通量 */
@Excel(name = "小型货车-菏泽")
private Integer trafficVolumeOfSmallTrucksHZ;
/** 小型货车交通量 */
@Excel(name = "小型货车-济南")
private Integer trafficVolumeOfSmallTrucksJN;
/** 中型货车交通量 */
@Excel(name = "中型货车-菏泽")
private Integer mediumTruckTrafficVolumeHZ;
/** 中型货车交通量 */
@Excel(name = "中型货车-济南")
private Integer mediumTruckTrafficVolumeJN;
/** 大型货车交通量 */
@Excel(name = "大型货车-菏泽")
private Integer largeTruckTrafficVolumeHZ;
/** 大型货车交通量 */
@Excel(name = "大型货车-济南")
private Integer largeTruckTrafficVolumeJN;
/** 特大型货车交通量 */
@Excel(name = "特大型货车-菏泽")
private Integer extraLargeTrucksTrafficVolumeHZ;
/** 特大型货车交通量 */
@Excel(name = "特大型货车-济南")
private Integer extraLargeTrucksTrafficVolumeJN;
/** 集装箱车交通量 */
@Excel(name = "集装箱车-菏泽")
private Integer containerTruckTrafficVolumeHZ;
/** 集装箱车交通量 */
@Excel(name = "集装箱车-济南")
private Integer containerTruckTrafficVolumeJN;
/** 摩托车交通量 */
@Excel(name = "摩托车-菏泽")
private Integer motorcycleTrafficVolumeHZ;
/** 摩托车交通量 */
@Excel(name = "摩托车-济南")
private Integer motorcycleTrafficVolumeJN;
/** 拖拉机交通量 */
@Excel(name = "拖拉机-菏泽")
private Integer tractorTrafficVolumeHZ;
/** 拖拉机交通量 */
@Excel(name = "拖拉机-济南")
private Integer tractorTrafficVolumeJN;
/** 合计 */
@Excel(name = "合计-菏泽")
private Integer trafficVolumeHZ;
/** 合计 */
@Excel(name = "合计-济南")
private Integer trafficVolumeJN;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getIotDeviceId() {
return iotDeviceId;
}
public void setIotDeviceId(String iotDeviceId) {
this.iotDeviceId = iotDeviceId;
}
public String getDirection() {
return direction;
}
public void setDirection(String direction) {
this.direction = direction;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public Integer getTrafficNumberOfInAndSmallJN() {
return trafficNumberOfInAndSmallJN;
}
public void setTrafficNumberOfInAndSmallJN(Integer trafficNumberOfInAndSmallJN) {
this.trafficNumberOfInAndSmallJN = trafficNumberOfInAndSmallJN;
}
public Integer getTrafficNumberOfInAndSmallHZ() {
return trafficNumberOfInAndSmallHZ;
}
public void setTrafficNumberOfInAndSmallHZ(Integer trafficNumberOfInAndSmallHZ) {
this.trafficNumberOfInAndSmallHZ = trafficNumberOfInAndSmallHZ;
}
public Integer getBusTrafficVolumeJN() {
return busTrafficVolumeJN;
}
public void setBusTrafficVolumeJN(Integer busTrafficVolumeJN) {
this.busTrafficVolumeJN = busTrafficVolumeJN;
}
public Integer getBusTrafficVolumeHZ() {
return busTrafficVolumeHZ;
}
public void setBusTrafficVolumeHZ(Integer busTrafficVolumeHZ) {
this.busTrafficVolumeHZ = busTrafficVolumeHZ;
}
public Integer getTrafficVolumeOfSmallTrucksJN() {
return trafficVolumeOfSmallTrucksJN;
}
public void setTrafficVolumeOfSmallTrucksJN(Integer trafficVolumeOfSmallTrucksJN) {
this.trafficVolumeOfSmallTrucksJN = trafficVolumeOfSmallTrucksJN;
}
public Integer getTrafficVolumeOfSmallTrucksHZ() {
return trafficVolumeOfSmallTrucksHZ;
}
public void setTrafficVolumeOfSmallTrucksHZ(Integer trafficVolumeOfSmallTrucksHZ) {
this.trafficVolumeOfSmallTrucksHZ = trafficVolumeOfSmallTrucksHZ;
}
public Integer getMediumTruckTrafficVolumeJN() {
return mediumTruckTrafficVolumeJN;
}
public void setMediumTruckTrafficVolumeJN(Integer mediumTruckTrafficVolumeJN) {
this.mediumTruckTrafficVolumeJN = mediumTruckTrafficVolumeJN;
}
public Integer getMediumTruckTrafficVolumeHZ() {
return mediumTruckTrafficVolumeHZ;
}
public void setMediumTruckTrafficVolumeHZ(Integer mediumTruckTrafficVolumeHZ) {
this.mediumTruckTrafficVolumeHZ = mediumTruckTrafficVolumeHZ;
}
public Integer getLargeTruckTrafficVolumeJN() {
return largeTruckTrafficVolumeJN;
}
public void setLargeTruckTrafficVolumeJN(Integer largeTruckTrafficVolumeJN) {
this.largeTruckTrafficVolumeJN = largeTruckTrafficVolumeJN;
}
public Integer getLargeTruckTrafficVolumeHZ() {
return largeTruckTrafficVolumeHZ;
}
public void setLargeTruckTrafficVolumeHZ(Integer largeTruckTrafficVolumeHZ) {
this.largeTruckTrafficVolumeHZ = largeTruckTrafficVolumeHZ;
}
public Integer getExtraLargeTrucksTrafficVolumeJN() {
return extraLargeTrucksTrafficVolumeJN;
}
public void setExtraLargeTrucksTrafficVolumeJN(Integer extraLargeTrucksTrafficVolumeJN) {
this.extraLargeTrucksTrafficVolumeJN = extraLargeTrucksTrafficVolumeJN;
}
public Integer getExtraLargeTrucksTrafficVolumeHZ() {
return extraLargeTrucksTrafficVolumeHZ;
}
public void setExtraLargeTrucksTrafficVolumeHZ(Integer extraLargeTrucksTrafficVolumeHZ) {
this.extraLargeTrucksTrafficVolumeHZ = extraLargeTrucksTrafficVolumeHZ;
}
public Integer getContainerTruckTrafficVolumeJN() {
return containerTruckTrafficVolumeJN;
}
public void setContainerTruckTrafficVolumeJN(Integer containerTruckTrafficVolumeJN) {
this.containerTruckTrafficVolumeJN = containerTruckTrafficVolumeJN;
}
public Integer getContainerTruckTrafficVolumeHZ() {
return containerTruckTrafficVolumeHZ;
}
public void setContainerTruckTrafficVolumeHZ(Integer containerTruckTrafficVolumeHZ) {
this.containerTruckTrafficVolumeHZ = containerTruckTrafficVolumeHZ;
}
public Integer getMotorcycleTrafficVolumeJN() {
return motorcycleTrafficVolumeJN;
}
public void setMotorcycleTrafficVolumeJN(Integer motorcycleTrafficVolumeJN) {
this.motorcycleTrafficVolumeJN = motorcycleTrafficVolumeJN;
}
public Integer getMotorcycleTrafficVolumeHZ() {
return motorcycleTrafficVolumeHZ;
}
public void setMotorcycleTrafficVolumeHZ(Integer motorcycleTrafficVolumeHZ) {
this.motorcycleTrafficVolumeHZ = motorcycleTrafficVolumeHZ;
}
public Integer getTractorTrafficVolumeJN() {
return tractorTrafficVolumeJN;
}
public void setTractorTrafficVolumeJN(Integer tractorTrafficVolumeJN) {
this.tractorTrafficVolumeJN = tractorTrafficVolumeJN;
}
public Integer getTractorTrafficVolumeHZ() {
return tractorTrafficVolumeHZ;
}
public void setTractorTrafficVolumeHZ(Integer tractorTrafficVolumeHZ) {
this.tractorTrafficVolumeHZ = tractorTrafficVolumeHZ;
}
public Integer getTrafficVolumeJN() {
return trafficVolumeJN;
}
public void setTrafficVolumeJN(Integer trafficVolumeJN) {
this.trafficVolumeJN = trafficVolumeJN;
}
public Integer getTrafficVolumeHZ() {
return trafficVolumeHZ;
}
public void setTrafficVolumeHZ(Integer trafficVolumeHZ) {
this.trafficVolumeHZ = trafficVolumeHZ;
}
public DcTrafficVolumeDirectionData(){}
public DcTrafficVolumeDirectionData(Integer initData){
this.trafficNumberOfInAndSmallJN = initData;
this.trafficNumberOfInAndSmallHZ = initData;
this.busTrafficVolumeJN = initData;
this.busTrafficVolumeHZ = initData;
this.trafficVolumeOfSmallTrucksJN = initData;
this.trafficVolumeOfSmallTrucksHZ = initData;
this.mediumTruckTrafficVolumeJN = initData;
this.mediumTruckTrafficVolumeHZ = initData;
this.largeTruckTrafficVolumeJN = initData;
this.largeTruckTrafficVolumeHZ = initData;
this.extraLargeTrucksTrafficVolumeJN = initData;
this.extraLargeTrucksTrafficVolumeHZ = initData;
this.containerTruckTrafficVolumeJN = initData;
this.containerTruckTrafficVolumeHZ = initData;
this.motorcycleTrafficVolumeJN = initData;
this.motorcycleTrafficVolumeHZ = initData;
this.tractorTrafficVolumeJN = initData;
this.tractorTrafficVolumeHZ = initData;
this.trafficVolumeJN = initData;
this.trafficVolumeHZ = initData;
}
}

52
zc-business/src/main/java/com/zc/business/enums/TrafficFlowDoorFrameSection.java

@ -0,0 +1,52 @@
package com.zc.business.enums;
/**
*
*/
public enum TrafficFlowDoorFrameSection {
ONE(57354, 57586, 1,"殷家林枢纽-长清大学城"),
TWO(70796, 70939,2, "长清大学城-长清虚"),
THREE(74902, 74989,3, "长清虚-松竹枢纽"),
FOUR(97470, 97593,4, "孝里虚-平阴北虚"),
FIVE(102782, 102908,5, "平阴北虚-平阴虚"),
SIX(107996, 108102, 6,"平阴虚-孔村枢纽"),
SEVEN(123944, 124074,7, "孔村枢纽-平阴南虚"),
EIGHT(128101, 128204,8, "平阴南虚-魏雪枢纽"),
NINE(147847, 147949, 9,"东平虚-东济济广枢纽"),
WEIXUE_JUNCTION(171803, 171903, 10,"东济济广枢纽-梁山东虚"),
TEN(175649, 175749, 11,"梁山东虚-梁山虚"),
DONGPING_LAKE_HUB(180847,180952,12,"梁山虚-信楼枢纽"),
LIANGSHANDONG_INTERCHANGE(192299,192403,13,"嘉祥西虚-王官屯枢纽");
private final int stakeMark;
private final int endMark;
private final int identification;
private final String description;
public int getStakeMark() {
return stakeMark;
}
public int getEndMark() {
return endMark;
}
public String getDescription() {
return description;
}
public int getIdentification() {
return identification;
}
TrafficFlowDoorFrameSection(int stakeMark, int endMark, int identification, String description) {
this.stakeMark = stakeMark;
this.endMark = endMark;
this.identification = identification;
this.description = description;
}
}

3
zc-business/src/main/java/com/zc/business/service/IDcTrafficStatisticsService.java

@ -71,4 +71,7 @@ public interface IDcTrafficStatisticsService {
* 交通流统计分析重点数据查询交通流异常信息
*/
JSONArray exampleQueryTrafficFlowAnomalies(String startTime, String endTime) throws HttpException;
Map<String,Integer> trafficFlowAtTollTypes(String startDate);
}

41
zc-business/src/main/java/com/zc/business/service/impl/DcMeteorologicalDetectorDataServiceImpl.java

@ -1,6 +1,7 @@
package com.zc.business.service.impl;
import com.ruoyi.common.utils.DateUtils;
import com.zc.business.domain.DcDevice;
import com.zc.business.domain.DcMeteorologicalDetectorData;
import com.zc.business.enums.UniversalEnum;
import com.zc.business.mapper.DcMeteorologicalDetectorDataMapper;
@ -8,8 +9,10 @@ import com.zc.business.service.IDcMeteorologicalDetectorDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 气象检测器数据Service业务层处理
@ -22,7 +25,8 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica
{
@Autowired
private DcMeteorologicalDetectorDataMapper dcMeteorologicalDetectorDataMapper;
@Resource
private DcDeviceServiceImpl dcDeviceServiceImpl;
/**
* 查询气象检测器数据
@ -113,7 +117,36 @@ public class DcMeteorologicalDetectorDataServiceImpl implements IDcMeteorologica
@Override
public List<DcMeteorologicalDetectorData> selectlistAll(DcMeteorologicalDetectorData dcMeteorologicalDetectorData) {
return dcMeteorologicalDetectorDataMapper.selectlistAll(dcMeteorologicalDetectorData);
Map<String,Object> parameter =new HashMap<>();
parameter.put("deviceType","3");
List<DcDevice> dcDevices = dcDeviceServiceImpl.devicePileNumberQueryDevice(parameter);
Map<String, DcDevice> deviceStateMap = dcDevices.stream()
.filter(Objects::nonNull) // DcDevice 对象不为空
.collect(Collectors.toMap(
DcDevice::getIotDeviceId,
Function.identity(),
(existing, replacement) -> existing) // 重复键,默认保留第一个值
);
List<DcMeteorologicalDetectorData> dcMeteorologicalDetectorDataList = dcMeteorologicalDetectorDataMapper.selectlistAll(dcMeteorologicalDetectorData);
// 遍历气象检测数据并设置对应的设备状态和桩号
for (DcMeteorologicalDetectorData data : dcMeteorologicalDetectorDataList) {
String iotDeviceId = data.getIotDeviceId();
if (deviceStateMap.containsKey(iotDeviceId)) {
DcDevice device = deviceStateMap.get(iotDeviceId);
// 设置设备状态
data.setDeviceState(device.getDeviceState());
// 设置桩号
data.setStakeMark(device.getStakeMark());
}
}
// 按照桩号排序
List<DcMeteorologicalDetectorData> sortedList = dcMeteorologicalDetectorDataList.stream()
.sorted(Comparator.comparing(DcMeteorologicalDetectorData::getStakeMark))
.collect(Collectors.toList());
return sortedList;
}
@Override

93
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java

@ -12,6 +12,7 @@ import com.zc.business.constant.RedisKeyConstants;
import com.zc.business.domain.*;
import com.zc.business.enums.LocationEnum;
import com.zc.business.enums.StakeMarkRange;
import com.zc.business.enums.TrafficFlowDoorFrameSection;
import com.zc.business.enums.UniversalEnum;
import com.zc.business.service.IDcDeviceService;
import com.zc.business.service.IDcFacilityService;
@ -932,7 +933,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
// 初始化计数器和描述映射
Map<Integer, Integer> flowCounts = new HashMap<>();
Map<Integer, String> descriptions = new HashMap<>();
for (int i = UniversalEnum.ONE.getNumber(); i <= 16; i++) {
for (int i = UniversalEnum.ONE.getNumber(); i <= 13; i++) {
flowCounts.put(i, UniversalEnum.ZERO.getNumber());
descriptions.put(i, UniversalEnum.EMPTY_STRING.getValue());
}
@ -957,12 +958,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
.anyMatch(dcFacility -> dcFacility.getId().equals(dcFacility2.getId()));
if (exists) {
int extractedNumber = Integer.parseInt(extract(stakeMark));
int identification = Arrays.stream(StakeMarkRange.values())
int identification = Arrays.stream(TrafficFlowDoorFrameSection.values())
.filter(smRange -> extractedNumber >= smRange.getStakeMark() && extractedNumber <= smRange.getEndMark())
.mapToInt(StakeMarkRange::getIdentification)
.mapToInt(TrafficFlowDoorFrameSection::getIdentification)
.findFirst()
.orElse(UniversalEnum.ZERO.getNumber());
String description = getDescriptionByIdentification(identification);
String description = getTrafficFlowDoorFrameSection(identification);
descriptions.put(identification, description);
flowCounts.put(identification, flowCounts.get(identification) + totalFlow);
}
@ -971,9 +972,9 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
}
// 构建结果列表
List<Map<String, Object>> mapList = new ArrayList<>();
for (int i = UniversalEnum.ONE.getNumber(); i <= 16; i++) {
for (int i = UniversalEnum.ONE.getNumber(); i <= 13; i++) {
Map<String, Object> map = new HashMap<>();
map.put("name", getDescriptionByIdentification(i));
map.put("name", getTrafficFlowDoorFrameSection(i));
map.put("totalFlow", flowCounts.get(i));
mapList.add(map);
}
@ -1039,6 +1040,14 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
}
return UniversalEnum.EMPTY_STRING.getValue();
}
public static String getTrafficFlowDoorFrameSection(int identification) {
for (TrafficFlowDoorFrameSection range : TrafficFlowDoorFrameSection.values()) {
if (range.getIdentification() == identification) {
return range.getDescription();
}
}
return UniversalEnum.EMPTY_STRING.getValue();
}
public List<Map<String, Object>> queryTheGantryDataByPileNumber(String startDate, String stakeMark) throws HttpException, IOException {
@ -1474,6 +1483,78 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi
}
}
@Override
public Map<String, Integer> trafficFlowAtTollTypes(String startDate) {
Map<String, Integer> map = new HashMap<>();
try {
Response response = getResponseTrafficFlowAtToll(startDate, UniversalEnum.ONE.getValue());
Response responseTwo = getResponseTrafficFlowAtToll(startDate, UniversalEnum.TWO.getValue());
ResponseBody body = response.body();
ResponseBody bodyTwo = responseTwo.body();
Integer bus;
Integer truck;
Integer bus1_flow = UniversalEnum.ZERO.getNumber();
Integer bus2_flow = UniversalEnum.ZERO.getNumber();
Integer bus3_flow = UniversalEnum.ZERO.getNumber();
Integer bus4_flow = UniversalEnum.ZERO.getNumber();
Integer truck1_flow = UniversalEnum.ZERO.getNumber();
Integer truck2_flow = UniversalEnum.ZERO.getNumber();
Integer truck3_flow = UniversalEnum.ZERO.getNumber();
Integer truck4_flow = UniversalEnum.ZERO.getNumber();
Integer truck5_flow = UniversalEnum.ZERO.getNumber();
Integer truck6_flow = UniversalEnum.ZERO.getNumber();
if (body != null) {
String jsonString = body.string();
if (JSON.isValidArray(jsonString)) {
JSONArray jsonArray = JSON.parseArray(jsonString);
for (Object item : jsonArray) {
JSONObject jsonObject = (JSONObject) item;
bus1_flow = bus1_flow + jsonObject.getInteger("bus1_flow");
bus2_flow = bus2_flow + jsonObject.getInteger("bus2_flow");
bus3_flow = bus3_flow + jsonObject.getInteger("bus3_flow");
bus4_flow = bus4_flow + jsonObject.getInteger("bus4_flow");
truck1_flow = truck1_flow + jsonObject.getInteger("truck1_flow");
truck2_flow = truck2_flow + jsonObject.getInteger("truck2_flow");
truck3_flow = truck3_flow + jsonObject.getInteger("truck3_flow");
truck4_flow = truck4_flow + jsonObject.getInteger("truck4_flow");
truck5_flow = truck5_flow + jsonObject.getInteger("truck5_flow");
truck6_flow = truck6_flow + jsonObject.getInteger("truck6_flow");
}
}
}
if (bodyTwo != null) {
String jsonString = bodyTwo.string();
if (JSON.isValidArray(jsonString)) {
JSONArray jsonArray = JSON.parseArray(jsonString);
for (Object item : jsonArray) {
JSONObject jsonObject = (JSONObject) item;
bus1_flow = bus1_flow + jsonObject.getInteger("bus1_flow");
bus2_flow = bus2_flow + jsonObject.getInteger("bus2_flow");
bus3_flow = bus3_flow + jsonObject.getInteger("bus3_flow");
bus4_flow = bus4_flow + jsonObject.getInteger("bus4_flow");
truck1_flow = truck1_flow + jsonObject.getInteger("truck1_flow");
truck2_flow = truck2_flow + jsonObject.getInteger("truck2_flow");
truck3_flow = truck3_flow + jsonObject.getInteger("truck3_flow");
truck4_flow = truck4_flow + jsonObject.getInteger("truck4_flow");
truck5_flow = truck5_flow + jsonObject.getInteger("truck5_flow");
truck6_flow = truck6_flow + jsonObject.getInteger("truck6_flow");
}
}
}
bus = bus1_flow + bus2_flow + bus3_flow + bus4_flow;
truck = truck1_flow + truck2_flow + truck3_flow + truck4_flow + truck5_flow + truck6_flow;
map.put("bus", bus);
map.put("truck", truck);
return map;
} catch (IOException e) {
// 处理异常
e.printStackTrace();
return map;
} catch (HttpException e) {
throw new RuntimeException(e);
}
}
private Response getResponseTrafficFlowAtToll(String startDate, String stationType) throws HttpException, IOException {
// 创建OkHttpClient.Builder实例

237
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSurveyDataServiceImpl.java

@ -274,11 +274,155 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi
return AjaxResult.error("请选择时间类型");
} else if (StringUtils.isEmpty(dcTrafficSurveyDataQueryParams.getDataType())){
return AjaxResult.error("请选择数据类型");
} else if (StringUtils.isEmpty(dcTrafficSurveyDataQueryParams.getDirection())){
return AjaxResult.error("请选择方向");
}
if (dcTrafficSurveyDataQueryParams.getDataType().equals("1")){
//车流量
List<DcTrafficVolumeData> dcTrafficVolumeData = dcTrafficSurveyDataMapper.selectTrafficVolume(dcTrafficSurveyDataQueryParams);
if (dcTrafficVolumeData.size() > 0){
//判断是否区分方向
if (dcTrafficSurveyDataQueryParams.getDirection().equals("1")){
List<DcTrafficVolumeDirectionData> result = new ArrayList<>();
//区分方向时将两个方向的数据合并为一条
Map<String,List<DcTrafficVolumeData>> group = dcTrafficVolumeData.stream().collect(Collectors.groupingBy(DcTrafficVolumeData::getTime));
for (List<DcTrafficVolumeData> value : group.values()) {
DcTrafficVolumeDirectionData dcTrafficVolumeDirectionData = new DcTrafficVolumeDirectionData(0);
dcTrafficVolumeDirectionData.setIotDeviceId(value.get(0).getIotDeviceId());
dcTrafficVolumeDirectionData.setTime(value.get(0).getTime());
for (DcTrafficVolumeData trafficVolumeData : value) {
if (trafficVolumeData.getDirection().equals("1")){
dcTrafficVolumeDirectionData.setTrafficNumberOfInAndSmallHZ(trafficVolumeData.getTrafficNumberOfInAndSmall());
dcTrafficVolumeDirectionData.setBusTrafficVolumeHZ(trafficVolumeData.getBusTrafficVolume());
dcTrafficVolumeDirectionData.setTrafficVolumeOfSmallTrucksHZ(trafficVolumeData.getTrafficVolumeOfSmallTrucks());
dcTrafficVolumeDirectionData.setMediumTruckTrafficVolumeHZ(trafficVolumeData.getMediumTruckTrafficVolume());
dcTrafficVolumeDirectionData.setLargeTruckTrafficVolumeHZ(trafficVolumeData.getLargeTruckTrafficVolume());
dcTrafficVolumeDirectionData.setExtraLargeTrucksTrafficVolumeHZ(trafficVolumeData.getExtraLargeTrucksTrafficVolume());
dcTrafficVolumeDirectionData.setContainerTruckTrafficVolumeHZ(trafficVolumeData.getContainerTruckTrafficVolume());
dcTrafficVolumeDirectionData.setMotorcycleTrafficVolumeHZ(trafficVolumeData.getMotorcycleTrafficVolume());
dcTrafficVolumeDirectionData.setTractorTrafficVolumeHZ(trafficVolumeData.getTractorTrafficVolume());
dcTrafficVolumeDirectionData.setTrafficVolumeHZ(trafficVolumeData.getTrafficVolume());
} else if (trafficVolumeData.getDirection().equals("3")){
dcTrafficVolumeDirectionData.setTrafficNumberOfInAndSmallJN(trafficVolumeData.getTrafficNumberOfInAndSmall());
dcTrafficVolumeDirectionData.setBusTrafficVolumeJN(trafficVolumeData.getBusTrafficVolume());
dcTrafficVolumeDirectionData.setTrafficVolumeOfSmallTrucksJN(trafficVolumeData.getTrafficVolumeOfSmallTrucks());
dcTrafficVolumeDirectionData.setMediumTruckTrafficVolumeJN(trafficVolumeData.getMediumTruckTrafficVolume());
dcTrafficVolumeDirectionData.setLargeTruckTrafficVolumeJN(trafficVolumeData.getLargeTruckTrafficVolume());
dcTrafficVolumeDirectionData.setExtraLargeTrucksTrafficVolumeJN(trafficVolumeData.getExtraLargeTrucksTrafficVolume());
dcTrafficVolumeDirectionData.setContainerTruckTrafficVolumeJN(trafficVolumeData.getContainerTruckTrafficVolume());
dcTrafficVolumeDirectionData.setMotorcycleTrafficVolumeJN(trafficVolumeData.getMotorcycleTrafficVolume());
dcTrafficVolumeDirectionData.setTractorTrafficVolumeJN(trafficVolumeData.getTractorTrafficVolume());
dcTrafficVolumeDirectionData.setTrafficVolumeJN(trafficVolumeData.getTrafficVolume());
}
}
result.add(dcTrafficVolumeDirectionData);
}
//自然合计值
DcTrafficVolumeDirectionData naturalTotal = new DcTrafficVolumeDirectionData(0);
naturalTotal.setTime("自然合计值");
for (DcTrafficVolumeDirectionData dcTrafficVolumeDirectionDatum : result) {
naturalTotal.setTrafficNumberOfInAndSmallHZ(naturalTotal.getTrafficNumberOfInAndSmallHZ() + dcTrafficVolumeDirectionDatum.getTrafficNumberOfInAndSmallHZ());
naturalTotal.setTrafficNumberOfInAndSmallJN(naturalTotal.getTrafficNumberOfInAndSmallJN() + dcTrafficVolumeDirectionDatum.getTrafficNumberOfInAndSmallJN());
naturalTotal.setBusTrafficVolumeHZ(naturalTotal.getBusTrafficVolumeHZ() + dcTrafficVolumeDirectionDatum.getBusTrafficVolumeHZ());
naturalTotal.setBusTrafficVolumeJN(naturalTotal.getBusTrafficVolumeJN() + dcTrafficVolumeDirectionDatum.getBusTrafficVolumeJN());
naturalTotal.setTrafficVolumeOfSmallTrucksHZ(naturalTotal.getTrafficVolumeOfSmallTrucksHZ() + dcTrafficVolumeDirectionDatum.getTrafficVolumeOfSmallTrucksHZ());
naturalTotal.setTrafficVolumeOfSmallTrucksJN(naturalTotal.getTrafficVolumeOfSmallTrucksJN() + dcTrafficVolumeDirectionDatum.getTrafficVolumeOfSmallTrucksJN());
naturalTotal.setMediumTruckTrafficVolumeHZ(naturalTotal.getMediumTruckTrafficVolumeHZ() + dcTrafficVolumeDirectionDatum.getMediumTruckTrafficVolumeHZ());
naturalTotal.setMediumTruckTrafficVolumeJN(naturalTotal.getMediumTruckTrafficVolumeJN() + dcTrafficVolumeDirectionDatum.getMediumTruckTrafficVolumeJN());
naturalTotal.setLargeTruckTrafficVolumeHZ(naturalTotal.getLargeTruckTrafficVolumeHZ() + dcTrafficVolumeDirectionDatum.getLargeTruckTrafficVolumeHZ());
naturalTotal.setLargeTruckTrafficVolumeJN(naturalTotal.getLargeTruckTrafficVolumeJN() + dcTrafficVolumeDirectionDatum.getLargeTruckTrafficVolumeJN());
naturalTotal.setExtraLargeTrucksTrafficVolumeHZ(naturalTotal.getExtraLargeTrucksTrafficVolumeHZ() + dcTrafficVolumeDirectionDatum.getExtraLargeTrucksTrafficVolumeHZ());
naturalTotal.setExtraLargeTrucksTrafficVolumeJN(naturalTotal.getExtraLargeTrucksTrafficVolumeJN() + dcTrafficVolumeDirectionDatum.getExtraLargeTrucksTrafficVolumeJN());
naturalTotal.setContainerTruckTrafficVolumeHZ(naturalTotal.getContainerTruckTrafficVolumeHZ() + dcTrafficVolumeDirectionDatum.getContainerTruckTrafficVolumeHZ());
naturalTotal.setContainerTruckTrafficVolumeJN(naturalTotal.getContainerTruckTrafficVolumeJN() + dcTrafficVolumeDirectionDatum.getContainerTruckTrafficVolumeJN());
naturalTotal.setMotorcycleTrafficVolumeHZ(naturalTotal.getMotorcycleTrafficVolumeHZ() + dcTrafficVolumeDirectionDatum.getMotorcycleTrafficVolumeHZ());
naturalTotal.setMotorcycleTrafficVolumeJN(naturalTotal.getMotorcycleTrafficVolumeJN() + dcTrafficVolumeDirectionDatum.getMotorcycleTrafficVolumeJN());
naturalTotal.setTractorTrafficVolumeHZ(naturalTotal.getTractorTrafficVolumeHZ() + dcTrafficVolumeDirectionDatum.getTractorTrafficVolumeHZ());
naturalTotal.setTractorTrafficVolumeJN(naturalTotal.getTractorTrafficVolumeJN() + dcTrafficVolumeDirectionDatum.getTractorTrafficVolumeJN());
naturalTotal.setTrafficVolumeHZ(naturalTotal.getTrafficVolumeHZ() + dcTrafficVolumeDirectionDatum.getTrafficVolumeHZ());
naturalTotal.setTrafficVolumeJN(naturalTotal.getTrafficVolumeJN() + dcTrafficVolumeDirectionDatum.getTrafficVolumeJN());
}
//折算值
DcTrafficVolumeDirectionData conversionValue = new DcTrafficVolumeDirectionData(0);
conversionValue.setTime("折算值");
conversionValue.setTrafficNumberOfInAndSmallHZ(naturalTotal.getTrafficNumberOfInAndSmallHZ());
conversionValue.setTrafficNumberOfInAndSmallJN(naturalTotal.getTrafficNumberOfInAndSmallJN());
conversionValue.setBusTrafficVolumeHZ((int) Math.round(naturalTotal.getBusTrafficVolumeHZ() * 1.5));
conversionValue.setBusTrafficVolumeJN((int) Math.round(naturalTotal.getBusTrafficVolumeJN() * 1.5));
conversionValue.setTrafficVolumeOfSmallTrucksHZ(naturalTotal.getTrafficVolumeOfSmallTrucksHZ());
conversionValue.setTrafficVolumeOfSmallTrucksJN(naturalTotal.getTrafficVolumeOfSmallTrucksJN());
conversionValue.setMediumTruckTrafficVolumeHZ((int) Math.round(naturalTotal.getMediumTruckTrafficVolumeHZ() * 1.5));
conversionValue.setMediumTruckTrafficVolumeJN((int) Math.round(naturalTotal.getMediumTruckTrafficVolumeJN() * 1.5));
conversionValue.setLargeTruckTrafficVolumeHZ(naturalTotal.getLargeTruckTrafficVolumeHZ() * 3);
conversionValue.setLargeTruckTrafficVolumeJN(naturalTotal.getLargeTruckTrafficVolumeJN() * 3);
conversionValue.setExtraLargeTrucksTrafficVolumeHZ(naturalTotal.getExtraLargeTrucksTrafficVolumeHZ() * 4);
conversionValue.setExtraLargeTrucksTrafficVolumeJN(naturalTotal.getExtraLargeTrucksTrafficVolumeJN() * 4);
conversionValue.setContainerTruckTrafficVolumeHZ(naturalTotal.getContainerTruckTrafficVolumeHZ() * 4);
conversionValue.setContainerTruckTrafficVolumeJN(naturalTotal.getContainerTruckTrafficVolumeJN() * 4);
conversionValue.setMotorcycleTrafficVolumeHZ(naturalTotal.getMotorcycleTrafficVolumeHZ());
conversionValue.setMotorcycleTrafficVolumeJN(naturalTotal.getMotorcycleTrafficVolumeJN());
conversionValue.setTractorTrafficVolumeHZ(naturalTotal.getTractorTrafficVolumeHZ());
conversionValue.setTractorTrafficVolumeJN(naturalTotal.getTractorTrafficVolumeJN());
Integer trafficVolumeHZ = conversionValue.getTrafficNumberOfInAndSmallHZ() + conversionValue.getBusTrafficVolumeHZ() +
conversionValue.getTrafficVolumeOfSmallTrucksHZ() + conversionValue.getMediumTruckTrafficVolumeHZ() +
conversionValue.getLargeTruckTrafficVolumeHZ() + conversionValue.getExtraLargeTrucksTrafficVolumeHZ() +
conversionValue.getContainerTruckTrafficVolumeHZ() + conversionValue.getMotorcycleTrafficVolumeHZ() +
conversionValue.getTractorTrafficVolumeHZ();
conversionValue.setTrafficVolumeHZ(trafficVolumeHZ);
Integer trafficVolumeJN = conversionValue.getTrafficNumberOfInAndSmallJN() + conversionValue.getBusTrafficVolumeJN() +
conversionValue.getTrafficVolumeOfSmallTrucksJN() + conversionValue.getMediumTruckTrafficVolumeJN() +
conversionValue.getLargeTruckTrafficVolumeJN() + conversionValue.getExtraLargeTrucksTrafficVolumeJN() +
conversionValue.getContainerTruckTrafficVolumeJN() + conversionValue.getMotorcycleTrafficVolumeJN() +
conversionValue.getTractorTrafficVolumeJN();
conversionValue.setTrafficVolumeJN(trafficVolumeJN);
//自然平均值
DcTrafficVolumeDirectionData naturalAvg = new DcTrafficVolumeDirectionData(0);
naturalAvg.setTime("自然平均值");
naturalAvg.setTrafficNumberOfInAndSmallHZ(naturalTotal.getTrafficNumberOfInAndSmallHZ() / result.size());
naturalAvg.setTrafficNumberOfInAndSmallJN(naturalTotal.getTrafficNumberOfInAndSmallJN() / result.size());
naturalAvg.setBusTrafficVolumeHZ(naturalTotal.getBusTrafficVolumeHZ() / result.size());
naturalAvg.setBusTrafficVolumeJN(naturalTotal.getBusTrafficVolumeJN() / result.size());
naturalAvg.setTrafficVolumeOfSmallTrucksHZ(naturalTotal.getTrafficVolumeOfSmallTrucksHZ() / result.size());
naturalAvg.setTrafficVolumeOfSmallTrucksJN(naturalTotal.getTrafficVolumeOfSmallTrucksJN() / result.size());
naturalAvg.setMediumTruckTrafficVolumeHZ(naturalTotal.getMediumTruckTrafficVolumeHZ() / result.size());
naturalAvg.setMediumTruckTrafficVolumeJN(naturalTotal.getMediumTruckTrafficVolumeJN() / result.size());
naturalAvg.setLargeTruckTrafficVolumeHZ(naturalTotal.getLargeTruckTrafficVolumeHZ() / result.size());
naturalAvg.setLargeTruckTrafficVolumeJN(naturalTotal.getLargeTruckTrafficVolumeJN() / result.size());
naturalAvg.setExtraLargeTrucksTrafficVolumeHZ(naturalTotal.getExtraLargeTrucksTrafficVolumeHZ() / result.size());
naturalAvg.setExtraLargeTrucksTrafficVolumeJN(naturalTotal.getExtraLargeTrucksTrafficVolumeJN() / result.size());
naturalAvg.setContainerTruckTrafficVolumeHZ(naturalTotal.getContainerTruckTrafficVolumeHZ() / result.size());
naturalAvg.setContainerTruckTrafficVolumeJN(naturalTotal.getContainerTruckTrafficVolumeJN() / result.size());
naturalAvg.setMotorcycleTrafficVolumeHZ(naturalTotal.getMotorcycleTrafficVolumeHZ() / result.size());
naturalAvg.setMotorcycleTrafficVolumeJN(naturalTotal.getMotorcycleTrafficVolumeJN() / result.size());
naturalAvg.setTractorTrafficVolumeHZ(naturalTotal.getTractorTrafficVolumeHZ() / result.size());
naturalAvg.setTractorTrafficVolumeJN(naturalTotal.getTractorTrafficVolumeJN() / result.size());
Integer naturalAvgTrafficVolumeHZ = naturalAvg.getTrafficNumberOfInAndSmallHZ() + naturalAvg.getBusTrafficVolumeHZ() +
naturalAvg.getTrafficVolumeOfSmallTrucksHZ() + naturalAvg.getMediumTruckTrafficVolumeHZ() +
naturalAvg.getLargeTruckTrafficVolumeHZ() + naturalAvg.getExtraLargeTrucksTrafficVolumeHZ() +
naturalAvg.getContainerTruckTrafficVolumeHZ() + naturalAvg.getMotorcycleTrafficVolumeHZ() +
naturalAvg.getTractorTrafficVolumeHZ();
naturalAvg.setTrafficVolumeHZ(naturalAvgTrafficVolumeHZ);
Integer naturalAvgTrafficVolumeJN = naturalAvg.getTrafficNumberOfInAndSmallJN() + naturalAvg.getBusTrafficVolumeJN() +
naturalAvg.getTrafficVolumeOfSmallTrucksJN() + naturalAvg.getMediumTruckTrafficVolumeJN() +
naturalAvg.getLargeTruckTrafficVolumeJN() + naturalAvg.getExtraLargeTrucksTrafficVolumeJN() +
naturalAvg.getContainerTruckTrafficVolumeJN() + naturalAvg.getMotorcycleTrafficVolumeJN() +
naturalAvg.getTractorTrafficVolumeJN();
naturalAvg.setTrafficVolumeJN(naturalAvgTrafficVolumeJN);
result = result.stream().sorted(Comparator.comparing(DcTrafficVolumeDirectionData::getTime)).collect(Collectors.toList());
result.add(naturalTotal);
result.add(conversionValue);
result.add(naturalAvg);
return AjaxResult.success(result);
} else if (dcTrafficSurveyDataQueryParams.getDirection().equals("2")){
//自然合计值
DcTrafficVolumeData naturalTotal = new DcTrafficVolumeData(0);
naturalTotal.setTime("自然合计值");
@ -337,12 +481,104 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi
dcTrafficVolumeData.add(conversionValue);
dcTrafficVolumeData.add(naturalAvg);
}
}
return AjaxResult.success(dcTrafficVolumeData);
} else {
//车速
List<DcTrafficSpeedData> dcTrafficSpeedData = dcTrafficSurveyDataMapper.selectSpeed(dcTrafficSurveyDataQueryParams);
if (dcTrafficSpeedData.size() > 0){
//判断是否区分方向
if (dcTrafficSurveyDataQueryParams.getDirection().equals("1")) {
List<DcTrafficSpeedDirectionData> result = new ArrayList<>();
//区分方向时将两个方向的数据合并为一条
Map<String, List<DcTrafficSpeedData>> group = dcTrafficSpeedData.stream().collect(Collectors.groupingBy(DcTrafficSpeedData::getTime));
for (List<DcTrafficSpeedData> value : group.values()) {
DcTrafficSpeedDirectionData dcTrafficSpeedDirectionData = new DcTrafficSpeedDirectionData(0);
dcTrafficSpeedDirectionData.setIotDeviceId(value.get(0).getIotDeviceId());
dcTrafficSpeedDirectionData.setTime(value.get(0).getTime());
for (DcTrafficSpeedData trafficSpeedData : value) {
if (trafficSpeedData.getDirection().equals("1")){
dcTrafficSpeedDirectionData.setInAndSmallAverageVehicleSpeedHZ(trafficSpeedData.getInAndSmallAverageVehicleSpeed());
dcTrafficSpeedDirectionData.setAverageSpeedOfBusHZ(trafficSpeedData.getAverageSpeedOfBus());
dcTrafficSpeedDirectionData.setSmallTrucksAverageVehicleSpeedHZ(trafficSpeedData.getSmallTrucksAverageVehicleSpeed());
dcTrafficSpeedDirectionData.setAverageSpeedOfMediumSizeTrucksHZ(trafficSpeedData.getAverageSpeedOfMediumSizeTrucks());
dcTrafficSpeedDirectionData.setAverageSpeedOfLargeTrucksHZ(trafficSpeedData.getAverageSpeedOfLargeTrucks());
dcTrafficSpeedDirectionData.setAverageSpeedOfExtraLargeTrucksHZ(trafficSpeedData.getAverageSpeedOfExtraLargeTrucks());
dcTrafficSpeedDirectionData.setAverageSpeedOfContainerTruckHZ(trafficSpeedData.getAverageSpeedOfContainerTruck());
dcTrafficSpeedDirectionData.setAverageSpeedOfMotorcycleHZ(trafficSpeedData.getAverageSpeedOfMotorcycle());
dcTrafficSpeedDirectionData.setAverageSpeedOfTractorHZ(trafficSpeedData.getAverageSpeedOfTractor());
dcTrafficSpeedDirectionData.setAvgSpeedHZ(trafficSpeedData.getAvgSpeed());
} else if (trafficSpeedData.getDirection().equals("3")){
dcTrafficSpeedDirectionData.setInAndSmallAverageVehicleSpeedJN(trafficSpeedData.getInAndSmallAverageVehicleSpeed());
dcTrafficSpeedDirectionData.setAverageSpeedOfBusJN(trafficSpeedData.getAverageSpeedOfBus());
dcTrafficSpeedDirectionData.setSmallTrucksAverageVehicleSpeedJN(trafficSpeedData.getSmallTrucksAverageVehicleSpeed());
dcTrafficSpeedDirectionData.setAverageSpeedOfMediumSizeTrucksJN(trafficSpeedData.getAverageSpeedOfMediumSizeTrucks());
dcTrafficSpeedDirectionData.setAverageSpeedOfLargeTrucksJN(trafficSpeedData.getAverageSpeedOfLargeTrucks());
dcTrafficSpeedDirectionData.setAverageSpeedOfExtraLargeTrucksJN(trafficSpeedData.getAverageSpeedOfExtraLargeTrucks());
dcTrafficSpeedDirectionData.setAverageSpeedOfContainerTruckJN(trafficSpeedData.getAverageSpeedOfContainerTruck());
dcTrafficSpeedDirectionData.setAverageSpeedOfMotorcycleJN(trafficSpeedData.getAverageSpeedOfMotorcycle());
dcTrafficSpeedDirectionData.setAverageSpeedOfTractorJN(trafficSpeedData.getAverageSpeedOfTractor());
dcTrafficSpeedDirectionData.setAvgSpeedJN(trafficSpeedData.getAvgSpeed());
}
}
result.add(dcTrafficSpeedDirectionData);
}
result = result.stream().sorted(Comparator.comparing(DcTrafficSpeedDirectionData::getTime)).collect(Collectors.toList());
DcTrafficSpeedDirectionData avgSpeed = new DcTrafficSpeedDirectionData(0);
avgSpeed.setTime("车速平均值");
for (DcTrafficSpeedDirectionData dcTrafficSpeedDatum : result) {
avgSpeed.setInAndSmallAverageVehicleSpeedHZ(avgSpeed.getInAndSmallAverageVehicleSpeedHZ() + dcTrafficSpeedDatum.getInAndSmallAverageVehicleSpeedHZ());
avgSpeed.setInAndSmallAverageVehicleSpeedJN(avgSpeed.getInAndSmallAverageVehicleSpeedJN() + dcTrafficSpeedDatum.getInAndSmallAverageVehicleSpeedJN());
avgSpeed.setAverageSpeedOfBusHZ(avgSpeed.getAverageSpeedOfBusHZ() + dcTrafficSpeedDatum.getAverageSpeedOfBusHZ());
avgSpeed.setAverageSpeedOfBusJN(avgSpeed.getAverageSpeedOfBusJN() + dcTrafficSpeedDatum.getAverageSpeedOfBusJN());
avgSpeed.setSmallTrucksAverageVehicleSpeedHZ(avgSpeed.getSmallTrucksAverageVehicleSpeedHZ() + dcTrafficSpeedDatum.getSmallTrucksAverageVehicleSpeedHZ());
avgSpeed.setSmallTrucksAverageVehicleSpeedJN(avgSpeed.getSmallTrucksAverageVehicleSpeedJN() + dcTrafficSpeedDatum.getSmallTrucksAverageVehicleSpeedJN());
avgSpeed.setAverageSpeedOfMediumSizeTrucksHZ(avgSpeed.getAverageSpeedOfMediumSizeTrucksHZ() + dcTrafficSpeedDatum.getAverageSpeedOfMediumSizeTrucksHZ());
avgSpeed.setAverageSpeedOfMediumSizeTrucksJN(avgSpeed.getAverageSpeedOfMediumSizeTrucksJN() + dcTrafficSpeedDatum.getAverageSpeedOfMediumSizeTrucksJN());
avgSpeed.setAverageSpeedOfLargeTrucksHZ(avgSpeed.getAverageSpeedOfLargeTrucksHZ() + dcTrafficSpeedDatum.getAverageSpeedOfLargeTrucksHZ());
avgSpeed.setAverageSpeedOfLargeTrucksJN(avgSpeed.getAverageSpeedOfLargeTrucksJN() + dcTrafficSpeedDatum.getAverageSpeedOfLargeTrucksJN());
avgSpeed.setAverageSpeedOfExtraLargeTrucksHZ(avgSpeed.getAverageSpeedOfExtraLargeTrucksHZ() + dcTrafficSpeedDatum.getAverageSpeedOfExtraLargeTrucksHZ());
avgSpeed.setAverageSpeedOfExtraLargeTrucksJN(avgSpeed.getAverageSpeedOfExtraLargeTrucksJN() + dcTrafficSpeedDatum.getAverageSpeedOfExtraLargeTrucksJN());
avgSpeed.setAverageSpeedOfContainerTruckHZ(avgSpeed.getAverageSpeedOfContainerTruckHZ() + dcTrafficSpeedDatum.getAverageSpeedOfContainerTruckHZ());
avgSpeed.setAverageSpeedOfContainerTruckJN(avgSpeed.getAverageSpeedOfContainerTruckJN() + dcTrafficSpeedDatum.getAverageSpeedOfContainerTruckJN());
avgSpeed.setAverageSpeedOfMotorcycleHZ(avgSpeed.getAverageSpeedOfMotorcycleHZ() + dcTrafficSpeedDatum.getAverageSpeedOfMotorcycleHZ());
avgSpeed.setAverageSpeedOfMotorcycleJN(avgSpeed.getAverageSpeedOfMotorcycleJN() + dcTrafficSpeedDatum.getAverageSpeedOfMotorcycleJN());
avgSpeed.setAverageSpeedOfTractorHZ(avgSpeed.getAverageSpeedOfTractorHZ() + dcTrafficSpeedDatum.getAverageSpeedOfTractorHZ());
avgSpeed.setAverageSpeedOfTractorJN(avgSpeed.getAverageSpeedOfTractorJN() + dcTrafficSpeedDatum.getAverageSpeedOfTractorJN());
avgSpeed.setAvgSpeedHZ(avgSpeed.getAvgSpeedHZ() + dcTrafficSpeedDatum.getAvgSpeedHZ());
avgSpeed.setAvgSpeedJN(avgSpeed.getAvgSpeedJN() + dcTrafficSpeedDatum.getAvgSpeedJN());
}
avgSpeed.setInAndSmallAverageVehicleSpeedHZ(avgSpeed.getInAndSmallAverageVehicleSpeedHZ() / result.size());
avgSpeed.setInAndSmallAverageVehicleSpeedJN(avgSpeed.getInAndSmallAverageVehicleSpeedJN() / result.size());
avgSpeed.setAverageSpeedOfBusHZ(avgSpeed.getAverageSpeedOfBusHZ() / result.size());
avgSpeed.setAverageSpeedOfBusJN(avgSpeed.getAverageSpeedOfBusJN() / result.size());
avgSpeed.setSmallTrucksAverageVehicleSpeedHZ(avgSpeed.getSmallTrucksAverageVehicleSpeedHZ() / result.size());
avgSpeed.setSmallTrucksAverageVehicleSpeedJN(avgSpeed.getSmallTrucksAverageVehicleSpeedJN() / result.size());
avgSpeed.setAverageSpeedOfMediumSizeTrucksHZ(avgSpeed.getAverageSpeedOfMediumSizeTrucksHZ() / result.size());
avgSpeed.setAverageSpeedOfMediumSizeTrucksJN(avgSpeed.getAverageSpeedOfMediumSizeTrucksJN() / result.size());
avgSpeed.setAverageSpeedOfLargeTrucksHZ(avgSpeed.getAverageSpeedOfLargeTrucksHZ() / result.size());
avgSpeed.setAverageSpeedOfLargeTrucksJN(avgSpeed.getAverageSpeedOfLargeTrucksJN() / result.size());
avgSpeed.setAverageSpeedOfExtraLargeTrucksHZ(avgSpeed.getAverageSpeedOfExtraLargeTrucksHZ() / result.size());
avgSpeed.setAverageSpeedOfExtraLargeTrucksJN(avgSpeed.getAverageSpeedOfExtraLargeTrucksJN() / result.size());
avgSpeed.setAverageSpeedOfContainerTruckHZ(avgSpeed.getAverageSpeedOfContainerTruckHZ() / result.size());
avgSpeed.setAverageSpeedOfContainerTruckJN(avgSpeed.getAverageSpeedOfContainerTruckJN() / result.size());
avgSpeed.setAverageSpeedOfMotorcycleHZ(avgSpeed.getAverageSpeedOfMotorcycleHZ() / result.size());
avgSpeed.setAverageSpeedOfMotorcycleJN(avgSpeed.getAverageSpeedOfMotorcycleJN() / result.size());
avgSpeed.setAverageSpeedOfTractorHZ(avgSpeed.getAverageSpeedOfTractorHZ() / result.size());
avgSpeed.setAverageSpeedOfTractorJN(avgSpeed.getAverageSpeedOfTractorJN() / result.size());
avgSpeed.setAvgSpeedHZ(avgSpeed.getAvgSpeedHZ() / result.size());
avgSpeed.setAvgSpeedJN(avgSpeed.getAvgSpeedJN() / result.size());
result.add(avgSpeed);
return AjaxResult.success(result);
} else {
DcTrafficSpeedData avgSpeed = new DcTrafficSpeedData(0);
avgSpeed.setTime("车速平均值");
for (DcTrafficSpeedData dcTrafficSpeedDatum : dcTrafficSpeedData) {
@ -370,6 +606,7 @@ public class DcTrafficSurveyDataServiceImpl implements IDcTrafficSurveyDataServi
avgSpeed.setAvgSpeed(avgSpeed.getAvgSpeed() / dcTrafficSpeedData.size());
dcTrafficSpeedData.add(avgSpeed);
}
}
return AjaxResult.success(dcTrafficSpeedData);
}
}

54
zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml

@ -5,7 +5,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.zc.business.mapper.DcGantryStatisticsDataMapper">
<resultMap type="map" id="countMap">
<result property="volume" column="total_traffic_volume"/>
<result property="name" column="interval_name"/>
<result property="name" column="facility_name"/>
<result property="totalPassengerFlow" column="total_passenger_flow"/>
<result property="typeSpecialVehicleFlow" column="type_special_vehicle_flow"/>
<result property="typeTruckFlow" column="type_truck_flow"/>
@ -204,9 +204,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="realTimeTrafficFlow" resultMap="countMap" resultType="map" >
SELECT
intervals.interval_name,
intervals.stake_make,
intervals.end_make,
ps.facility_code,
ps.facility_name,
COALESCE(SUM(dgsd.traffic_volume), 0) AS total_traffic_volume,
COALESCE(SUM(dgsd.type1_passenger_flow), 0) +
COALESCE(SUM(dgsd.type2_passenger_flow), 0) +
@ -226,39 +225,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
COALESCE(SUM(dgsd.type4_special_vehicle_flow), 0) +
COALESCE(SUM(dgsd.type5_special_vehicle_flow), 0) +
COALESCE(SUM(dgsd.type6_special_vehicle_flow), 0) AS type_special_vehicle_flow
FROM
(
SELECT 'K054+394' AS stake_make, 'K059+289' AS end_make, '殷家林枢纽' AS interval_name UNION ALL
SELECT 'K059+289', 'K072+847', '大学城立交' UNION ALL
SELECT 'K072+847', 'K083+835', '长清立交' UNION ALL
SELECT 'K083+835', 'K086+499', '松竹枢纽' UNION ALL
SELECT 'K086+499', 'K099+750', '孝里立交' UNION ALL
SELECT 'K099+750', 'K105+904', '平阴北立交' UNION ALL
SELECT 'K105+904', 'K117+878', '平阴立交' UNION ALL
SELECT 'K117+878', 'K126+233', '孔村枢纽' UNION ALL
SELECT 'K126+233', 'K133+588', '平阴南立交' UNION ALL
SELECT 'K133+588', 'K145+933', '魏雪枢纽' UNION ALL
SELECT 'K145+933', 'K155+652', '东平立交' UNION ALL
SELECT 'K155+652', 'K173+950', '东平湖枢纽' UNION ALL
SELECT 'K173+950', 'K179+396', '梁山东立交' UNION ALL
SELECT 'K179+396', 'K182+987', '梁山立交' UNION ALL
SELECT 'K182+987', 'K190+495', '信楼枢纽' UNION ALL
SELECT 'K190+495', 'K202+979', '嘉祥西立交'
)AS intervals
LEFT JOIN (
SELECT
facility_code,
stake_mark,
facility_name,
direction
FROM
dc_facility
WHERE
direction = #{direction}
) AS ps ON ps.stake_mark BETWEEN CONCAT(intervals.stake_make, '+0') AND CONCAT(intervals.end_make, '+0')
LEFT JOIN dc_gantry_statistics_data dgsd ON ps.facility_code = dgsd.gantry_code
AND
dc_facility ps
LEFT JOIN
dc_gantry_statistics_data dgsd ON ps.facility_code = dgsd.gantry_code
AND dgsd.period_type = #{periodType}
AND (
<if test="periodType == 1">
YEAR(dgsd.statistical_date) = #{startDate}
</if>
@ -268,11 +240,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="periodType == 4">
DATE(dgsd.statistical_date) = DATE(#{startDate})
</if>
AND dgsd.period_type =#{periodType}
)
WHERE
ps.direction = #{direction}
AND ps.facility_type = '10'
GROUP BY
intervals.interval_name,
intervals.stake_make,
intervals.end_make;
ps.facility_code,
ps.facility_name;
</select>

39
zc-business/src/main/resources/mapper/business/DcMeteorologicalDetectorDataMapper.xml

@ -200,27 +200,32 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectlistAll" parameterType="com.zc.business.domain.DcMeteorologicalDetectorData" resultMap="DcMeteorologicalDetectorDataResult">
SELECT
d.iot_device_id, d.stake_mark, d.direction, d.device_name, d.device_state,
m.iot_device_id,
m.device_name,
m.create_time,
m.rainfall, m.visibility_type, m.visibility, m.atmospheric_pressure,
m.temperature, m.humidity, m.wind_direction, m.wind_speed,
m.precipitation_type, m.wet_slippery_coefficient,
m.remote_road_surface_temperature, m.remote_road_surface_status,
m.rainfall,
m.visibility_type,
m.visibility,
m.atmospheric_pressure,
m.temperature,
m.humidity,
m.wind_direction,
m.wind_speed,
m.precipitation_type,
m.wet_slippery_coefficient,
m.remote_road_surface_temperature,
m.remote_road_surface_status,
m.water_film_ice_snow_value
FROM
dc_device d
LEFT JOIN
dc_meteorological_detector_data m
ON
d.iot_device_id = m.iot_device_id
AND m.create_time = (
SELECT MAX(create_time)
FROM dc_meteorological_detector_data m2
WHERE m2.iot_device_id = d.iot_device_id
)
WHERE
d.device_type = 3
ORDER BY d.stake_mark ASC;
JOIN (
SELECT
iot_device_id, MAX(create_time) AS max_create_time
FROM
dc_meteorological_detector_data
GROUP BY
iot_device_id
) latest ON m.iot_device_id = latest.iot_device_id AND m.create_time = latest.max_create_time;
</select>
<select id="selectDeviceNameList" parameterType="com.zc.business.domain.DcMeteorologicalDetectorData" resultMap="DcMeteorologicalDetectorDataResult">
SELECT

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

@ -61,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where DATE_FORMAT(`timestamp`,'%Y') = DATE_FORMAT(#{timestamp},'%Y')
GROUP BY iot_device_id,direction,times
</select>
<select id="selectTrafficVolume" resultType="com.zc.business.domain.DcTrafficVolumeData">
select
<choose>
@ -73,7 +74,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<when test="type != null and type == '3'.toString">
date_format(`timestamp`, '%Y-%m')
</when>
</choose> time,sum(traffic_volume) trafficVolume ,
</choose> time,direction,
sum(traffic_volume) trafficVolume ,
sum(traffic_number_of_in_and_small) trafficNumberOfInAndSmall,
sum(bus_traffic_volume) busTrafficVolume,
sum(traffic_volume_of_small_trucks) trafficVolumeOfSmallTrucks,
@ -97,19 +99,41 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null and type == '3'.toString">
and DATE_FORMAT(`timestamp`,'%Y') = DATE_FORMAT(#{date},'%Y')
</if>
<if test="direction != null and direction != ''">
and direction = #{direction}
</if>
</where>
GROUP BY time
<if test="direction != null and direction == '1'.toString">,direction</if>
</select>
<select id="selectSpeed" resultType="com.zc.business.domain.DcTrafficSpeedData">
select *,
round((t1.inAndSmallAverageVehicleSpeed + t1.averageSpeedOfBus + t1.smallTrucksAverageVehicleSpeed +
t1.averageSpeedOfMediumSizeTrucks + t1.averageSpeedOfLargeTrucks + t1.averageSpeedOfExtraLargeTrucks +
t1.averageSpeedOfContainerTruck + t1.averageSpeedOfMotorcycle + t1.averageSpeedOfTractor) / 9, 0) avgSpeed
ROUND(
(
t1.inAndSmallAverageVehicleSpeed +
t1.averageSpeedOfBus +
t1.smallTrucksAverageVehicleSpeed +
t1.averageSpeedOfMediumSizeTrucks +
t1.averageSpeedOfLargeTrucks +
t1.averageSpeedOfExtraLargeTrucks +
t1.averageSpeedOfContainerTruck +
t1.averageSpeedOfMotorcycle +
t1.averageSpeedOfTractor
) /
NULLIF(
CASE WHEN t1.inAndSmallAverageVehicleSpeed = 0 THEN 0 ELSE 1 END +
CASE WHEN t1.averageSpeedOfBus = 0 THEN 0 ELSE 1 END +
CASE WHEN t1.smallTrucksAverageVehicleSpeed = 0 THEN 0 ELSE 1 END +
CASE WHEN t1.averageSpeedOfMediumSizeTrucks = 0 THEN 0 ELSE 1 END +
CASE WHEN t1.averageSpeedOfLargeTrucks = 0 THEN 0 ELSE 1 END +
CASE WHEN t1.averageSpeedOfExtraLargeTrucks = 0 THEN 0 ELSE 1 END +
CASE WHEN t1.averageSpeedOfContainerTruck = 0 THEN 0 ELSE 1 END +
CASE WHEN t1.averageSpeedOfMotorcycle = 0 THEN 0 ELSE 1 END +
CASE WHEN t1.averageSpeedOfTractor = 0 THEN 0 ELSE 1 END,
0
)
,0) AS avgSpeed
from
(select
(select direction,
<choose>
<when test="type != null and type == '1'.toString">
date_format(`timestamp`, '%Y-%m-%d %H')
@ -121,15 +145,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
date_format(`timestamp`, '%Y-%m')
</when>
</choose> time,
round(avg(in_and_small_average_vehicle_speed),0) inAndSmallAverageVehicleSpeed,
round(avg(average_speed_of_bus),0) averageSpeedOfBus,
round(avg(small_trucks_average_vehicle_speed),0) smallTrucksAverageVehicleSpeed,
round(avg(average_speed_of_medium_size_trucks),0) averageSpeedOfMediumSizeTrucks,
round(avg(average_speed_of_large_trucks),0) averageSpeedOfLargeTrucks,
round(avg(average_speed_of_extra_large_trucks),0) averageSpeedOfExtraLargeTrucks,
round(avg(average_speed_of_container_truck),0) averageSpeedOfContainerTruck,
round(avg(average_speed_of_motorcycle),0) averageSpeedOfMotorcycle,
round(avg(average_speed_of_tractor),0) averageSpeedOfTractor
ROUND(IFNULL(AVG(NULLIF(in_and_small_average_vehicle_speed, 0)),0), 0) AS inAndSmallAverageVehicleSpeed,
ROUND(IFNULL(AVG(NULLIF(average_speed_of_bus, 0)),0), 0) AS averageSpeedOfBus,
ROUND(IFNULL(AVG(NULLIF(small_trucks_average_vehicle_speed, 0)),0), 0) AS smallTrucksAverageVehicleSpeed,
ROUND(IFNULL(AVG(NULLIF(average_speed_of_medium_size_trucks, 0)),0), 0) AS averageSpeedOfMediumSizeTrucks,
ROUND(IFNULL(AVG(NULLIF(average_speed_of_large_trucks, 0)),0), 0) AS averageSpeedOfLargeTrucks,
ROUND(IFNULL(AVG(NULLIF(average_speed_of_extra_large_trucks, 0)),0), 0) AS averageSpeedOfExtraLargeTrucks,
ROUND(IFNULL(AVG(NULLIF(average_speed_of_container_truck, 0)),0), 0) AS averageSpeedOfContainerTruck,
ROUND(IFNULL(AVG(NULLIF(average_speed_of_motorcycle, 0)),0), 0) AS averageSpeedOfMotorcycle,
ROUND(IFNULL(AVG(NULLIF(average_speed_of_tractor, 0)),0), 0) AS averageSpeedOfTractor
FROM `dc_traffic_survey_data`
<where>
<if test="iotDeviceId != null and iotDeviceId != ''">
@ -144,11 +168,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="type != null and type == '3'.toString">
and DATE_FORMAT(`timestamp`,'%Y') = DATE_FORMAT(#{date},'%Y')
</if>
<if test="direction != null and direction != ''">
and direction = #{direction}
</if>
</where>
GROUP BY time) t1
GROUP BY time
<if test="direction != null and direction == '1'.toString">,direction</if>
) t1
</select>
<insert id="insertDcTrafficSurveyData" parameterType="DcTrafficSurveyData" useGeneratedKeys="true" keyProperty="id">

Loading…
Cancel
Save