Browse Source

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

develop
wangsixiang 5 months ago
parent
commit
891a535af2
  1. 23
      zc-business/src/main/java/com/zc/business/controller/DcTrafficStatisticsController.java
  2. 36
      zc-business/src/main/java/com/zc/business/domain/ComprehensiveIndexQuery.java
  3. 25
      zc-business/src/main/java/com/zc/business/domain/MdDevice.java
  4. 2
      zc-business/src/main/java/com/zc/business/enums/ValueConverter.java
  5. 2
      zc-business/src/main/java/com/zc/business/mapper/DcGantryMetricsStatisticsDataMapper.java
  6. 3
      zc-business/src/main/java/com/zc/business/service/IDcGantryMetricsStatisticsDataService.java
  7. 24
      zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java
  8. 69
      zc-business/src/main/resources/mapper/business/DcGantryMetricsStatisticsDataMapper.xml
  9. 6
      zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

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

@ -1,9 +1,12 @@
package com.zc.business.controller;
import com.alibaba.fastjson.JSONArray;
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.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.zc.business.domain.*;
import com.zc.business.request.DcTrafficMetricsDataRequest;
import com.zc.business.request.DcTrafficSectionDataRequest;
@ -14,6 +17,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@ -248,8 +252,25 @@ public AjaxResult realTimeTrafficFlow(String startDate, String direction,String
// 将查询结果封装为成功响应并返回
return AjaxResult.success(map);
}
@ApiOperation("综合指标查询")
@GetMapping("/history/comprehensiveIndexQuery")
public TableDataInfo comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery){
startPage();
List<ComprehensiveIndexQuery> mapList = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery);
// 将查询结果封装为成功响应并返回
return getDataTable(mapList);
}
@ApiOperation("导出综合指标")
//@PreAuthorize("@ss.hasPermi('system:event:export')")
@Log(title = "导出综合指标", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, @RequestBody ComprehensiveIndexQuery comprehensiveIndexQuery)
{
List<ComprehensiveIndexQuery> list = dcGantryMetricsStatisticsDataService.comprehensiveIndexQuery(comprehensiveIndexQuery);
ExcelUtil<ComprehensiveIndexQuery> util = new ExcelUtil<ComprehensiveIndexQuery>(ComprehensiveIndexQuery.class);
util.exportExcel(response, list, "事件信息数据");
}
/**
* 获取门架指标统计数据

36
zc-business/src/main/java/com/zc/business/domain/ComprehensiveIndexQuery.java

@ -0,0 +1,36 @@
package com.zc.business.domain;
import com.ruoyi.common.annotation.Excel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
/**
*
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ComprehensiveIndexQuery {
@Excel(name = "路段名称")
private String intervalName;
private String stakeMake;
private String endMake;
private String facilityCode;
private String facilityName;
private String direction;
@Excel(name = "饱和度")
private Float saturationRate;
@Excel(name = "交通组成特征指数(大车占比", readConverterExp = "1=低,2=中,3=高")
private Integer trafficCompositionRate;
@Excel(name = "统计时间", dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date statisticalDate;
@Excel(name = "拥堵度", readConverterExp = "1=畅通,2=基本畅通,3=轻度拥堵 ,4=中度拥堵,5=重度拥堵")
private Integer crowdingRate;
private Integer periodType;
private String startDate;
}

25
zc-business/src/main/java/com/zc/business/domain/MdDevice.java

@ -56,6 +56,20 @@ public class MdDevice
@Excel(name = "设备类型")
private String typeCode;
/** 设备子类型
1-1 高清网络枪型固定摄像机
1-2 高清网络球形摄像机
1-3 桥下高清网络球形摄像机
1-4 360°全景摄像机
1-5 180°全景摄像机
2-1 门架式可变信息标志
2-2 站前可变信息标志
2-3 雨棚可变信息标志
2-4 站前悬臂式可变信息标志
*/
@Excel(name = "设备子类型")
private String childTypeCode;
/** 设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等 */
@Excel(name = "设施归属类型(0:默认1: 道路沿线2:桥梁3: 隧道4:收费广场5: 收费站6: 服务区等 ")
private String facilitiesType;
@ -265,6 +279,14 @@ public class MdDevice
this.deletionTime = deletionTime;
}
public String getChildTypeCode() {
return childTypeCode;
}
public void setChildTypeCode(String childTypeCode) {
this.childTypeCode = childTypeCode;
}
@Override
public String toString() {
return new ToStringBuilder(this)
@ -298,7 +320,8 @@ public class MdDevice
this.devName = dcDevice.getDeviceName();
this.stakeNum = dcDevice.getStakeMark();
this.direction = dcDevice.getDirection();
this.typeCode = dcDevice.getDeviceType().toString();
this.typeCode = dcDevice.getDeviceType();
this.childTypeCode = dcDevice.getChildType();
if (StringUtils.isNotEmpty(dcDevice.getFacilitiesType())){
this.facilitiesType = dcDevice.getFacilitiesType();
}

2
zc-business/src/main/java/com/zc/business/enums/ValueConverter.java

@ -198,7 +198,7 @@ public class ValueConverter {
// eventLabel.put("isPerceived","是否感知事件");
eventLabel.put("lang","影响车道");
eventLabel.put("roadName","高速名称");
eventLabel.put("eventTitle","时间标题");
eventLabel.put("eventTitle","事件标题");
eventLabel.put("remark","备注");
eventLabel.put("dcEventAbnormalWeather.weatherSituation","天气情况");
eventLabel.put("dcEventAbnormalWeather.emergencyLevel","紧急级别");

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

@ -1,6 +1,7 @@
package com.zc.business.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zc.business.domain.ComprehensiveIndexQuery;
import com.zc.business.domain.DcGantryMetricsStatisticsData;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -35,4 +36,5 @@ public interface DcGantryMetricsStatisticsDataMapper extends BaseMapper<DcGantry
List<Map<String, Object>> sectionTrafficIndexAnalysis(@Param("startDate") String startDate, @Param("direction") String direction,@Param("periodType") String periodType);
List<Map<String, Object>> radarMapOfTrafficIndicators(@Param("startDate") String startDate, @Param("direction") String direction,@Param("periodType") String periodType);
List<ComprehensiveIndexQuery> comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery);
}

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

@ -1,6 +1,7 @@
package com.zc.business.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zc.business.domain.ComprehensiveIndexQuery;
import com.zc.business.domain.DcGantryMetricsStatisticsData;
import com.zc.business.domain.DcGantryMetricsStatisticsData;
import com.zc.business.domain.DcGantryMetricsStatisticsData;
@ -46,4 +47,6 @@ public interface IDcGantryMetricsStatisticsDataService extends IService<DcGantry
List<Map<String, Object>> passIndicatorTimeDistribution(String startDate, String direction, String periodType);
Map<String, Object> radarMapOfTrafficIndicators(String startDate, String direction, String periodType);
List<ComprehensiveIndexQuery> comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery);
}

24
zc-business/src/main/java/com/zc/business/service/impl/IDcGantryMetricsStatisticsDataServiceImpl.java

@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.exception.ServiceException;
import com.zc.business.domain.ComprehensiveIndexQuery;
import com.zc.business.domain.DcGantryMetricsStatisticsData;
import com.zc.business.enums.ChannelCongestionLevelEnum;
import com.zc.business.enums.StakeMarkRange;
@ -307,7 +308,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl
double avgSaturationRate = count > 0 ? sumSaturationRate / count : 0;
// 格式化保留4位小数
String formattedAvgSaturationRate = String.format("%.4f", avgSaturationRate);
Double formattedAvgSaturationRate = Double.valueOf(String.format("%.4f", avgSaturationRate));
Map<String, Object> map = new HashMap<>();
map.put("groupTime", groupId);
map.put("Id", id);
@ -317,7 +318,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl
mapTime.add(map);
}
// 输出结果
/* // 输出结果
result.forEach((date, data) -> {
System.out.println("统计日期:" + date);
data.forEach(entry -> {
@ -325,7 +326,7 @@ public class IDcGantryMetricsStatisticsDataServiceImpl
System.out.println(key + ": " + value);
});
});
});
});*/
return mapTime;
}
@ -341,7 +342,12 @@ public class IDcGantryMetricsStatisticsDataServiceImpl
public Map<String, Object> radarMapOfTrafficIndicators(String startDate, String direction, String periodType) {
List<Map<String, Object>> mapOne = gantryMetricsStatisticsDataMapper.radarMapOfTrafficIndicators(startDate, direction, periodType);
if (mapOne.isEmpty()) {
return null;
Map<String, Object> map = new HashMap<>();
map.put("crowdingRate", 0);
map.put("trafficCompositionRate", 0);
map.put("saturationRate", 0);
return map;
}
// 计算crowdingRate和trafficCompositionRate的众数,以及saturationRate的平均值
int[] rates = {0, 0}; // 用于存储众数,第一个元素为crowdingRate众数,第二个为trafficCompositionRate众数
@ -367,14 +373,20 @@ public class IDcGantryMetricsStatisticsDataServiceImpl
double avgSaturationRate = count > 0 ? sumSaturationRate / count : 0;
// 格式化保留4位小数
String formattedAvgSaturationRate = String.format("%.4f", avgSaturationRate);
Double formattedAvgSaturationRate = Double.valueOf(String.format("%.4f", avgSaturationRate));
Map<String, Object> map = new HashMap<>();
map.put("crowdingRate", rates[0]);
map.put("crowdingRate", rates[0]);
map.put("trafficCompositionRate", rates[1]);
map.put("saturationRate", formattedAvgSaturationRate);
return map;
}
@Override
public List<ComprehensiveIndexQuery> comprehensiveIndexQuery(ComprehensiveIndexQuery comprehensiveIndexQuery) {
return gantryMetricsStatisticsDataMapper.comprehensiveIndexQuery(comprehensiveIndexQuery);
}
private static int findMaxCountKey(Map<Integer, Integer> counts) {
// 初始化一个 Pair 类型来存储当前的最大计数及对应的键

69
zc-business/src/main/resources/mapper/business/DcGantryMetricsStatisticsDataMapper.xml

@ -14,6 +14,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="saturationRate" column="saturation_rate"/>
<result property="statisticalDate" column="statistical_date"/>
</resultMap>
<resultMap type="com.zc.business.domain.ComprehensiveIndexQuery" id="ComprehensiveIndexQuery" >
<result property="facilityName" column="facility_name"/>
<result property="intervalName" column="interval_name"/>
<result property="direction" column="direction"/>
<result property="stakeMake" column="stake_make"/>
<result property="trafficCompositionRate" column="traffic_composition_rate"/>
<result property="facilityName" column="facility_name"/>
<result property="saturationRate" column="saturation_rate"/>
<result property="statisticalDate" column="statistical_date"/>
<result property="crowdingRate" column="crowding_rate"/>
<result property="facilityCode" column="facility_code"/>
</resultMap>
<!-- 插入或更新门架指标数据 -->
<insert id="insertOrUpdate" parameterType="com.zc.business.domain.DcGantryMetricsStatisticsData">
INSERT INTO
@ -145,5 +157,62 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND fa.direction = #{direction}
AND dg.period_type = #{periodType}
</select>
<select id="comprehensiveIndexQuery" resultMap="ComprehensiveIndexQuery" parameterType="com.zc.business.domain.ComprehensiveIndexQuery" >
SELECT
i.interval_name,
i.stake_make ,
i.end_make,
ps.facility_code ,
ps.facility_name ,
ps.direction ,
dgsd.saturation_rate as saturation_rate,
dgsd.traffic_composition_rate as traffic_composition_rate,
dgsd.statistical_date as statistical_date,
dgsd.crowding_rate
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', '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', 'K190+495', '梁山立交-嘉祥西立交' UNION ALL
SELECT 'K190+495', 'K202+979', '嘉祥西立交-王官屯枢纽'
) AS i
JOIN dc_facility AS ps
ON ps.stake_mark BETWEEN CONCAT(i.stake_make, '+0') AND CONCAT(i.end_make, '+0')
<if test="direction !=null">
AND ps.direction = #{direction}
</if>
<if test="intervalName !=null">
AND i.interval_name=#{intervalName}
</if>
JOIN dc_gantry_metrics_statistics_data AS dgsd
ON ps.facility_code = dgsd.gantry_code
AND
<if test="periodType == 1">
YEAR(dgsd.statistical_date) = #{startDate}
</if>
<if test="periodType == 3">
DATE_FORMAT(dgsd.statistical_date, '%Y-%m') = #{startDate}
</if>
<if test="periodType == 4">
DATE(dgsd.statistical_date) = DATE(#{startDate})
</if>
<if test="periodType == 5">
DATE(dgsd.statistical_date) = DATE(#{startDate})
</if>
AND dgsd.period_type = #{periodType}
ORDER BY
dgsd.statistical_date DESC
</select>
</mapper>

6
zc-business/src/main/resources/mapper/business/MiddleDatabaseMapper.xml

@ -130,6 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stakeNum != null">stake_num,</if>
<if test="direction != null">direction,</if>
<if test="typeCode != null">type_code,</if>
<if test="childTypeCode != null">child_type_code,</if>
<if test="facilitiesType != null">facilities_type,</if>
<if test="devStatus != null">dev_status,</if>
<if test="opmaManagerId != null">opma_manager_id,</if>
@ -151,6 +152,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stakeNum != null">#{stakeNum},</if>
<if test="direction != null">#{direction},</if>
<if test="typeCode != null">#{typeCode},</if>
<if test="childTypeCode != null">#{childTypeCode},</if>
<if test="facilitiesType != null">#{facilitiesType},</if>
<if test="devStatus != null">#{devStatus},</if>
<if test="opmaManagerId != null">#{opmaManagerId},</if>
@ -178,6 +180,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mdDevice.stakeNum != null">stake_num,</if>
<if test="mdDevice.direction != null">direction,</if>
<if test="mdDevice.typeCode != null">type_code,</if>
<if test="mdDevice.childTypeCode != null">child_type_code,</if>
<if test="mdDevice.facilitiesType != null">facilities_type,</if>
<if test="mdDevice.devStatus != null">dev_status,</if>
<if test="mdDevice.opmaManagerId != null">opma_manager_id,</if>
@ -199,6 +202,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mdDevice.stakeNum != null">#{mdDevice.stakeNum},</if>
<if test="mdDevice.direction != null">#{mdDevice.direction},</if>
<if test="mdDevice.typeCode != null">#{mdDevice.typeCode},</if>
<if test="mdDevice.childTypeCode != null">#{mdDevice.childTypeCode},</if>
<if test="mdDevice.facilitiesType != null">#{mdDevice.facilitiesType},</if>
<if test="mdDevice.devStatus != null">#{mdDevice.devStatus},</if>
<if test="mdDevice.opmaManagerId != null">#{mdDevice.opmaManagerId},</if>
@ -220,6 +224,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="mdDevice.stakeNum != null">stake_num = #{mdDevice.stakeNum},</if>
<if test="mdDevice.direction != null">direction = #{mdDevice.direction},</if>
<if test="mdDevice.typeCode != null">type_code = #{mdDevice.typeCode},</if>
<if test="mdDevice.childTypeCode != null">child_type_code = #{mdDevice.childTypeCode},</if>
<if test="mdDevice.facilitiesType != null">facilities_type = #{mdDevice.facilitiesType},</if>
<if test="mdDevice.devStatus != null">dev_status = #{mdDevice.devStatus},</if>
<if test="mdDevice.opmaManagerId != null">opma_manager_id = #{mdDevice.opmaManagerId},</if>
@ -333,6 +338,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="stakeNum != null">stake_num = #{stakeNum},</if>
<if test="direction != null">direction = #{direction},</if>
<if test="typeCode != null">type_code = #{typeCode},</if>
<if test="childTypeCode != null">child_type_code = #{childTypeCode},</if>
<if test="facilitiesType != null">facilities_type = #{facilitiesType},</if>
<if test="devStatus != null">dev_status = #{devStatus},</if>
<if test="opmaManagerId != null">opma_manager_id = #{opmaManagerId},</if>

Loading…
Cancel
Save