From 59bda7d6e939fe10ea69604147fd8d83ba9d63de Mon Sep 17 00:00:00 2001 From: xiepufeng <1072271977@qq.com> Date: Thu, 21 Mar 2024 17:47:30 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=96=AD=E9=9D=A2=E4=BA=A4=E9=80=9A?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=B7=BB=E5=8A=A0=E5=A4=A7=E5=9E=8B=E8=BD=A6?= =?UTF-8?q?=E8=BD=A6=E6=B5=81=E9=87=8F=E5=AD=97=E6=AE=B5=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/domain/DcTrafficSectionData.java | 5 +++ .../impl/DcTrafficSectionDataServiceImpl.java | 39 ++++++++++++++++--- .../handler/RealtimeTrafficStatistics.java | 9 ++++- .../business/DcTrafficSectionDataMapper.xml | 3 ++ 4 files changed, 50 insertions(+), 6 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSectionData.java b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSectionData.java index 5bc3adaa..3444312b 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcTrafficSectionData.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcTrafficSectionData.java @@ -29,6 +29,11 @@ public class DcTrafficSectionData { */ private Integer trafficVolume; + /** + * 大型车车流量 + */ + private Integer largeTrafficVolume; + /** * 平均速度 */ diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSectionDataServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSectionDataServiceImpl.java index 5be5983d..57b703a3 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSectionDataServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSectionDataServiceImpl.java @@ -369,8 +369,11 @@ public class DcTrafficSectionDataServiceImpl initializeTrafficSectionData(upwardData, dcDevice, reportTime, LaneDirection.UPWARD); initializeTrafficSectionData(downwardData, dcDevice, reportTime, LaneDirection.DOWNWARD); - // 初始化上行和下行的车流量和累计平均速度 + // 初始化上行和下行的车流量 int upwardTrafficVolume = 0, downwardTrafficVolume = 0; + // 初始化上行和下行的累计大车流量 + int upwardLargeTrafficVolume = 0, downwardLargeTrafficVolume = 0; + // 初始化上行和下行的累计平均速度 double upwardCumulativeAverageSpeed = 0.0, downwardCumulativeAverageSpeed = 0.0; // 遍历车道信息,计算上行和下行的车流量和累计平均速度 @@ -383,20 +386,23 @@ public class DcTrafficSectionDataServiceImpl // 根据车道方向累加车流量和累计平均速度 int totalTrafficFlow = laneData.getInteger("totalTrafficFlow"); - double cumulativeAverageSpeed = calculateCumulativeAverageSpeed(laneData); + int cumulativeAverageSpeed = calculateCumulativeAverageSpeed(laneData); + int cumulativeLargeTrafficVolume = calculateCumulativeLargeTrafficVolume(laneData); if (isDownward) { downwardTrafficVolume += totalTrafficFlow; downwardCumulativeAverageSpeed += cumulativeAverageSpeed; + downwardLargeTrafficVolume += cumulativeLargeTrafficVolume; } else { upwardTrafficVolume += totalTrafficFlow; upwardCumulativeAverageSpeed += cumulativeAverageSpeed; + upwardLargeTrafficVolume += cumulativeLargeTrafficVolume; } } // 设置上行和下行的车流量和累计平均速度 - setUpTrafficSectionData(upwardData, upwardTrafficVolume, upwardCumulativeAverageSpeed); - setUpTrafficSectionData(downwardData, downwardTrafficVolume, downwardCumulativeAverageSpeed); + setTrafficSectionData(upwardData, upwardTrafficVolume, upwardCumulativeAverageSpeed, upwardLargeTrafficVolume); + setTrafficSectionData(downwardData, downwardTrafficVolume, downwardCumulativeAverageSpeed, downwardLargeTrafficVolume); // 将上行和下行的交通段数据放入结果映射中 resultMap.put(LaneDirection.UPWARD, upwardData); @@ -437,9 +443,11 @@ public class DcTrafficSectionDataServiceImpl * @param data 交通路段数据对象,用于存储交通路段的相关信息。 * @param trafficVolume 该路段的交通量,单位通常为车辆数。 * @param cumulativeAverageSpeed 该路段的累积平均速度,单位通常为千米/小时。 + * @param largeTrafficVolume 大型车交通量。 */ - private void setUpTrafficSectionData(DcTrafficSectionData data, int trafficVolume, double cumulativeAverageSpeed) { + private void setTrafficSectionData(DcTrafficSectionData data, int trafficVolume, double cumulativeAverageSpeed, int largeTrafficVolume) { data.setTrafficVolume(trafficVolume); // 设置交通量 + data.setLargeTrafficVolume(largeTrafficVolume); // 设置大车流量 data.setAverageSpeed(0); if (trafficVolume != 0) { // 当交通量不为0时,计算并设置平均速度 data.setAverageSpeed((int) Math.round(cumulativeAverageSpeed / trafficVolume)); // 平均速度 = 累积平均速度 / 交通量 @@ -475,6 +483,27 @@ public class DcTrafficSectionDataServiceImpl laneData.getInteger("motorcycleTrafficVolume") * laneData.getInteger("averageSpeedOfMotorcycle"); } + /** + * 计算累积大型交通流量。 + * 该方法用于根据给定的车道数据,计算出特定类型的车辆(包括公共汽车、中型货车、大型货车、特大型货车和集装箱车)的交通量总和。 + * + * @param laneData 包含车道交通量数据的JSONObject对象。该对象应包含以下键: + * - "busTrafficVolume":公共汽车交通量 + * - "mediumTruckTrafficVolume":中型货车交通量 + * - "largeTruckTrafficVolume":大型货车交通量 + * - "extraLargeTrucksTrafficVolume":特大型货车交通量 + * - "containerTruckTrafficVolume":集装箱车交通量 + * @return 返回各种类型大型车辆交通量的总和,类型为int。 + */ + private int calculateCumulativeLargeTrafficVolume(JSONObject laneData) { + // 计算各种类型大型车辆的交通量总和 + return laneData.getInteger("busTrafficVolume") + + laneData.getInteger("mediumTruckTrafficVolume") + + laneData.getInteger("largeTruckTrafficVolume") + + laneData.getInteger("extraLargeTrucksTrafficVolume") + + laneData.getInteger("containerTruckTrafficVolume"); + } + /** * 将缓存中的数据统计后保存至数据库。 */ diff --git a/zc-business/src/main/java/com/zc/business/statistics/handler/RealtimeTrafficStatistics.java b/zc-business/src/main/java/com/zc/business/statistics/handler/RealtimeTrafficStatistics.java index e122cc0e..802e709e 100644 --- a/zc-business/src/main/java/com/zc/business/statistics/handler/RealtimeTrafficStatistics.java +++ b/zc-business/src/main/java/com/zc/business/statistics/handler/RealtimeTrafficStatistics.java @@ -26,14 +26,19 @@ public class RealtimeTrafficStatistics { // 创建一个汇总统计用的对象 DcTrafficSectionData aggregatedData = new DcTrafficSectionData(); - // 初始化车流量总和和计算平均车速所需的分子部分 + // 初始化车流量总和 int trafficVolume = 0; + // 初始化最大车流量 + int largeTrafficVolume = 0; + // 初始化计算平均车速所需的分子部分 double numerator = 0; // 遍历原始数据列表,累加车流量并计算平均车速 for (DcTrafficSectionData data: dataCollection) { // 累加车流量 trafficVolume += data.getTrafficVolume(); + // 累加最大车流量 + largeTrafficVolume += data.getLargeTrafficVolume(); // 计算分子部分 numerator += data.getAverageSpeed() * data.getTrafficVolume(); } @@ -62,6 +67,8 @@ public class RealtimeTrafficStatistics { aggregatedData.setStatisticalDate(firstDcTrafficSectionData.getStatisticalDate(), trafficDataPeriodType); // 车流量 aggregatedData.setTrafficVolume(trafficVolume); + // 大型车车流量 + aggregatedData.setLargeTrafficVolume(largeTrafficVolume); // 更新或插入操作 aggregatedData.setUpdateTime(DateUtils.getNowDate()); // 生成主键 diff --git a/zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml index 1fe5c30f..f52c76d1 100644 --- a/zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcTrafficSectionDataMapper.xml @@ -11,6 +11,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ( id, traffic_volume, + large_traffic_volume, average_speed, device_id, statistical_date, @@ -23,6 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ( #{id}, #{trafficVolume}, + #{largeTrafficVolume}, #{averageSpeed}, #{deviceId}, #{statisticalDate}, @@ -32,6 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" NOW()) ON DUPLICATE KEY UPDATE traffic_volume = VALUES(traffic_volume), + large_traffic_volume = VALUES(large_traffic_volume), average_speed = VALUES(average_speed), device_id = VALUES(device_id), statistical_date = VALUES(statistical_date), From 854b85a73739e239d82f1454b7d1181608248186 Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Thu, 21 Mar 2024 17:51:40 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=84=9F=E7=9F=A5=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/zc/business/domain/DcWarning.java | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcWarning.java b/zc-business/src/main/java/com/zc/business/domain/DcWarning.java index 3c9376a5..46e5b6d9 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcWarning.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcWarning.java @@ -26,15 +26,14 @@ public class DcWarning extends BaseEntity private String stakeMark; /** 方向:1-上行2-中3-下行 */ - @Excel(name = "方向: 1-上行 2-中 3-下行") + @Excel(name = "方向",readConverterExp = "1=菏泽方向,3=济南方向,2=双向") private String direction; /** 所属部门 */ - @Excel(name = "所属部门") private Long deptId; /** 警情状态:1-上报2-已完成3-已终止4-自动结束 */ - @Excel(name = "警情状态: 1-上报 2-已完成 3-已终止 4-自动结束") + @Excel(name = "警情状态",readConverterExp = "1=上报,2=已完成,3=已终止,4=自动结束") private Integer warningState; /** 预警时间 */ @@ -43,23 +42,22 @@ public class DcWarning extends BaseEntity private Date warningTime; /** 处理人员 */ - @Excel(name = "处理人员") private Long userId; /** 信息来源:1-视频AI2-雷达识别3-锥桶4-护栏碰撞5-扫码报警6-非机预警 */ - @Excel(name = "信息来源: 1-视频AI 2-雷达识别 3-锥桶 4-护栏碰撞 5-扫码报警 6-非机预警") + @Excel(name = "信息来源", readConverterExp = "1=视频AI,2=雷达识别,3=锥桶,4=护栏碰撞,5=扫码报警,6=非机预警") private Integer warningSource; /** 预警级别 */ - @Excel(name = "预警级别") private Integer warningLevel; /** 事件主类:1-交通拥堵2-行人3-非机动车4-停车5-倒车/逆行6-烟火7-撒落物8-异常天气9-护栏碰撞 */ - @Excel(name = "事件主类: 1-交通拥堵 2-行人 3-非机动车 4-停车 5-倒车/逆行 6-烟火 7-撒落物 8-异常天气 9-护栏碰撞") + @Excel(name = "事件主类", + readConverterExp = "1=交通拥堵,2=行人,3=非机动车,4=停车,5=违规驾驶,6=路障,7=道路施工,8=异常天气,9=护栏碰撞,10=交通事故,11=车辆故障,99=其它") private Integer warningType; /** 事件子类:1-1 拥堵1-2 缓行 */ - @Excel(name = "事件子类: 1-1 拥堵 1-2 缓行 2-1 普通行人") + @Excel(name = "事件子类", readConverterExp =" 1-1=拥堵, 1=2 缓行,2=1 普通行人,2=2 工作人员,3=1 摩托车,3=2 自行车 ,3=3 三轮车,4=1 非工程车,4=2=工程车,4=3 主路有车,4=4 匝道有车,4=5 车辆故障(弃用),4=6 交通事故(弃用) ,4=7 应急车道被占用 ,4=8 车离开应急车道 ,4=9 其他,4=10 未知车辆 ,5=1 倒车/逆行 ,5=2 压线,5=3 掉头,5=4 超速,5=5 低速,5=6 违规变道,5=7 未保持安全距离 ,6=1 烟火,6=2 火灾,6=3 障碍物,6=4 抛洒物,7=1 道路施工,8=1 雨 ,8=2 冰雹 ,8=3 风 ,8=4 雾 ,8=5 高温 ,8=6 积水 ,8=7 路面湿滑 ,8=8 路面结冰 ,8=9 道路能见度低 ,8=10 道路团雾 ,9=1 只碰撞不倾斜 ,9=2 只倾斜无碰撞 ,9=3 碰撞后倾斜,10=1 未知,10=2 单车事故,10=3 多车事故,11=1 车辆抛锚,11=2 车辆炸胎(有备胎),11=2 车辆炸胎(无备胎),99=1 其它") private String warningSubclass; /** 事件标题 */ @@ -69,10 +67,9 @@ public class DcWarning extends BaseEntity /** $column.columnComment */ - @Excel(name = "其它配置", readConverterExp = "$column.readConverterExp()") private String otherConfig; /** 车道0-应急 1-行1 2-行2 3-行3 4-行4 */ - @Excel(name = "车道0-应急 1-行1 2-行2 3-行3 4-行4") + @Excel(name = "车道",readConverterExp="0=应急,1=行1,2=行2,3=行3,4=行4") private String lane; /** 所属辖区路段名称 */ @@ -91,7 +88,6 @@ public class DcWarning extends BaseEntity //@Excel(name = "车辆类型") private String vehicleType; /** 持续时长 */ - @Excel(name = "持续时长(秒)") private int duration; @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8") @@ -103,10 +99,8 @@ public class DcWarning extends BaseEntity private String quarter; //事件原因 - @Excel(name = "事件原因") private String eventCause; //完结时间 - @Excel(name = "完结时间") @JsonFormat(pattern = "yyyy-MM-dd",timezone="GMT+8") private Date endTime; //操作员 From 3f2cf48239bc6ef17255c3beb355a9bad301ed9b Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Thu, 21 Mar 2024 17:58:10 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=84=9F=E7=9F=A5=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zc-business/src/main/java/com/zc/business/domain/DcWarning.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcWarning.java b/zc-business/src/main/java/com/zc/business/domain/DcWarning.java index 46e5b6d9..836e9ef5 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcWarning.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcWarning.java @@ -57,7 +57,7 @@ public class DcWarning extends BaseEntity private Integer warningType; /** 事件子类:1-1 拥堵1-2 缓行 */ - @Excel(name = "事件子类", readConverterExp =" 1-1=拥堵, 1=2 缓行,2=1 普通行人,2=2 工作人员,3=1 摩托车,3=2 自行车 ,3=3 三轮车,4=1 非工程车,4=2=工程车,4=3 主路有车,4=4 匝道有车,4=5 车辆故障(弃用),4=6 交通事故(弃用) ,4=7 应急车道被占用 ,4=8 车离开应急车道 ,4=9 其他,4=10 未知车辆 ,5=1 倒车/逆行 ,5=2 压线,5=3 掉头,5=4 超速,5=5 低速,5=6 违规变道,5=7 未保持安全距离 ,6=1 烟火,6=2 火灾,6=3 障碍物,6=4 抛洒物,7=1 道路施工,8=1 雨 ,8=2 冰雹 ,8=3 风 ,8=4 雾 ,8=5 高温 ,8=6 积水 ,8=7 路面湿滑 ,8=8 路面结冰 ,8=9 道路能见度低 ,8=10 道路团雾 ,9=1 只碰撞不倾斜 ,9=2 只倾斜无碰撞 ,9=3 碰撞后倾斜,10=1 未知,10=2 单车事故,10=3 多车事故,11=1 车辆抛锚,11=2 车辆炸胎(有备胎),11=2 车辆炸胎(无备胎),99=1 其它") + @Excel(name = "事件子类", readConverterExp ="1-1=拥堵,1=2缓行,2=1普通行人,2=2工作人员,3=1摩托车,3=2自行车,3=3三轮车,4=1非工程车,4=2=工程车,4=3主路有车,4=4匝道有车,4=5车辆故障(弃用),4=6交通事故(弃用),4=7应急车道被占用,4=8车离开应急车道,4=9其他,4=10未知车辆,5=1倒车/逆行,5=2压线,5=3掉头,5=4超速,5=5低速,5=6违规变道,5=7未保持安全距离,6=1烟火,6=2火灾,6=3障碍物,6=4抛洒物,7=1道路施工,8=1雨,8=2冰雹,8=3风,8=4雾,8=5高温,8=6积水,8=7路面湿滑,8=8路面结冰,8=9道路能见度低,8=10道路团雾,9=1只碰撞不倾斜,9=2只倾斜无碰撞,9=3碰撞后倾斜,10=1未知,10=2单车事故,10=3多车事故,11=1车辆抛锚,11=2车辆炸胎(有备胎),11=2车辆炸胎(无备胎),99=1其它") private String warningSubclass; /** 事件标题 */ From fc1461e10d4a146151e9d59a26f3581959c90ce5 Mon Sep 17 00:00:00 2001 From: wangsixiang <2970484253@qq.com> Date: Thu, 21 Mar 2024 18:08:30 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=84=9F=E7=9F=A5=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/zc/business/domain/DcWarning.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/domain/DcWarning.java b/zc-business/src/main/java/com/zc/business/domain/DcWarning.java index 836e9ef5..4746bcc3 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcWarning.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcWarning.java @@ -52,20 +52,17 @@ public class DcWarning extends BaseEntity private Integer warningLevel; /** 事件主类:1-交通拥堵2-行人3-非机动车4-停车5-倒车/逆行6-烟火7-撒落物8-异常天气9-护栏碰撞 */ - @Excel(name = "事件主类", - readConverterExp = "1=交通拥堵,2=行人,3=非机动车,4=停车,5=违规驾驶,6=路障,7=道路施工,8=异常天气,9=护栏碰撞,10=交通事故,11=车辆故障,99=其它") + @Excel(name = "事件主类", readConverterExp = "1=交通拥堵,2=行人,3=非机动车,4=停车,5=违规驾驶,6=路障,7=道路施工,8=异常天气,9=护栏碰撞,10=交通事故,11=车辆故障,99=其它") private Integer warningType; /** 事件子类:1-1 拥堵1-2 缓行 */ - @Excel(name = "事件子类", readConverterExp ="1-1=拥堵,1=2缓行,2=1普通行人,2=2工作人员,3=1摩托车,3=2自行车,3=3三轮车,4=1非工程车,4=2=工程车,4=3主路有车,4=4匝道有车,4=5车辆故障(弃用),4=6交通事故(弃用),4=7应急车道被占用,4=8车离开应急车道,4=9其他,4=10未知车辆,5=1倒车/逆行,5=2压线,5=3掉头,5=4超速,5=5低速,5=6违规变道,5=7未保持安全距离,6=1烟火,6=2火灾,6=3障碍物,6=4抛洒物,7=1道路施工,8=1雨,8=2冰雹,8=3风,8=4雾,8=5高温,8=6积水,8=7路面湿滑,8=8路面结冰,8=9道路能见度低,8=10道路团雾,9=1只碰撞不倾斜,9=2只倾斜无碰撞,9=3碰撞后倾斜,10=1未知,10=2单车事故,10=3多车事故,11=1车辆抛锚,11=2车辆炸胎(有备胎),11=2车辆炸胎(无备胎),99=1其它") + @Excel(name = "事件子类", readConverterExp ="1-1-拥堵,1-2=缓行,2-1=普通行人,2-2=工作人员,3-1=摩托车,3-2=自行车,3-3=三轮车,4-1=非工程车,4-2=工程车,4-3=主路有车,4-4=匝道有车,4-5=车辆故障(弃用),4-6=交通事故(弃用),4-7=应急车道被占用,4-8=车离开应急车道,4-9=其他,4-10=未知车辆,5-1=倒车/逆行,5-2=压线,5-3=掉头,5-4=超速,5-5=低速,5-6=违规变道,5-7=未保持安全距离,6-1=烟火,6-2=火灾,6-3=障碍物,6-4=抛洒物,7-1=道路施工,8-1=雨,8-2=冰雹,8-3=风,8-4=雾,8-5=高温,8-6=积水,8-7=路面湿滑,8-8=路面结冰,8-9=道路能见度低,8-10=道路团雾,9-1=只碰撞不倾斜,9-2=只倾斜无碰撞,9-3=碰撞后倾斜,10-1=未知,10-2单车事故,10-3=多车事故,11-1=车辆抛锚,11-2=车辆炸胎(有备胎),11-2=车辆炸胎(无备胎),99-1=其它") private String warningSubclass; /** 事件标题 */ @Excel(name = "事件标题") private String warningTitle; - - /** $column.columnComment */ private String otherConfig; /** 车道0-应急 1-行1 2-行2 3-行3 4-行4 */