diff --git a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java index 48cbd239..c910fde3 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java @@ -31,6 +31,7 @@ import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; /** @@ -76,6 +77,45 @@ public class DcWarningController extends BaseController return getDataTable(list); } + /** + * + */ + @ApiOperation("查询视频审核事件类型") + // @PreAuthorize("@ss.hasPermi('business:warning:list')") + @PostMapping("/videoReviewEventTypeList") + public AjaxResult videoReviewEventType(@RequestBody DcWarning dcWarning) + { + Map list = dcWarningService.selectVideoReviewEventTypeList(dcWarning); + return AjaxResult.success(list); + } @ApiOperation("查询视频审核路段分布") + // @PreAuthorize("@ss.hasPermi('business:warning:list')") + @GetMapping("/videoReviewSectionDistribution") + public AjaxResult videoReviewSectionDistribution(DcWarning dcWarning) + { + return AjaxResult.success(dcWarningService.selectVideoReviewSectionDistribution(dcWarning)) ; + } + @ApiOperation("查询视频审核事件源分布") + // @PreAuthorize("@ss.hasPermi('business:warning:list')") + @GetMapping("/videoReviewEventSource") + public AjaxResult videoReviewEventSource(DcWarning dcWarning) + { + return AjaxResult.success(dcWarningService.videoReviewEventSource(dcWarning)) ; + } + @ApiOperation("查询视频") + // @PreAuthorize("@ss.hasPermi('business:warning:list')") + @GetMapping("/videoReviewEventSourceList") + public TableDataInfo videoReviewEventSourceList(DcWarning dcWarning) + { + startPage(); + return getDataTable(dcWarningService.videoReviewEventSourceList(dcWarning)) ; + } + @ApiOperation("查询视频审核事件时间") + // @PreAuthorize("@ss.hasPermi('business:warning:list')") + @GetMapping("/videoReviewEventTime") + public AjaxResult videoReviewEventTime(DcWarning dcWarning) + { + return AjaxResult.success(dcWarningService.videoReviewEventTime(dcWarning)) ; + } /** * 导出预警信息列表 */ 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 1d951f43..094b8bc6 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 @@ -1,6 +1,9 @@ package com.zc.business.domain; +import java.util.Arrays; import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModelProperty; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -45,8 +48,18 @@ public class DcWarning extends BaseEntity private Long userId; /** 信息来源:1-视频AI2-雷达识别3-锥桶4-护栏碰撞5-扫码报警6-非机预警,7-气象监测器,8-边坡监测,9-桥梁监测 */ - @Excel(name = "信息来源", readConverterExp = "1=视频AI,2=雷达识别,3=锥桶,4=护栏碰撞,5=扫码报警,6=非机预警,7=气象监测器,8=边坡监测,9-桥梁监测") + @Excel(name = "信息来源数组", readConverterExp = "1=视频AI,2=雷达识别,3=锥桶,4=护栏碰撞,5=扫码报警,6=非机预警,7=气象监测器,8=边坡监测,9-桥梁监测") private Integer warningSource; + @TableField(exist = false) + private Integer[] warningSourceArray; + + public Integer[] getWarningSourceArray() { + return warningSourceArray; + } + + public void setWarningSourceArray(Integer[] warningSourceArray) { + this.warningSourceArray = warningSourceArray; + } /** 预警级别 */ private Integer warningLevel; diff --git a/zc-business/src/main/java/com/zc/business/enums/StakeMarkRange.java b/zc-business/src/main/java/com/zc/business/enums/StakeMarkRange.java index 53dd890a..23202177 100644 --- a/zc-business/src/main/java/com/zc/business/enums/StakeMarkRange.java +++ b/zc-business/src/main/java/com/zc/business/enums/StakeMarkRange.java @@ -12,12 +12,15 @@ public enum StakeMarkRange { SIX(99750, 105904, 6,"平阴北立交"), SEVEN(105904, 117878,7, "平阴立交"), EIGHT(117878, 126233,8, "孔村枢纽"), - NINE(126233, 145933, 9,"平阴南立交"), - TEN(145933, 155652, 10,"东平立交"), - DONGPING_LAKE_HUB(155652,173950,11,"东平湖枢纽"), - LIANGSHANDONG_INTERCHANGE(173950,179396,12,"梁山东立交"), - LIANGSHAN_INTERCHANGE(179396,190495,13,"梁山立交"), - JIAXIANG_WEST_INTERCHANGE(190495,202979,14,"嘉祥西立交"); + NINE(126233, 133588, 9,"平阴南立交"), + WEIXUE_JUNCTION(133588, 145933, 10,"魏雪枢纽"), + + TEN(145933, 155652, 11,"东平立交"), + DONGPING_LAKE_HUB(155652,173950,12,"东平湖枢纽"), + LIANGSHANDONG_INTERCHANGE(173950,179396,13,"梁山东立交"), + LIANGSHAN_INTERCHANGE(179396,182978,14,"梁山立交"), + XINLOU_JUNCTION(182978,190495,15,"信楼枢纽"), + JIAXIANG_WEST_INTERCHANGE(190495,202979,16,"嘉祥西立交"); private final int stakeMark; private final int endMark; diff --git a/zc-business/src/main/java/com/zc/business/enums/WarningSubclassEnum.java b/zc-business/src/main/java/com/zc/business/enums/WarningSubclassEnum.java index 0941f143..f8eedbaf 100644 --- a/zc-business/src/main/java/com/zc/business/enums/WarningSubclassEnum.java +++ b/zc-business/src/main/java/com/zc/business/enums/WarningSubclassEnum.java @@ -33,8 +33,8 @@ public enum WarningSubclassEnum { TURNROUND("5-3", "掉头", "发生掉头"), SPEED("5-4", "超速", "发生超速"), LOW_SPEED("5-5", "低速", "发生低速"), - ILLEGALLANECHANGE("5-5", "违规变道", "发生违规变道"), - FAILURE_TO_MAINTAIN_A_SAFE_DISTANCE("5-5", "未保持安全距离", "发生未保持安全距离"), + ILLEGALLANECHANGE("5-6", "违规变道", "发生违规变道"), + FAILURE_TO_MAINTAIN_A_SAFE_DISTANCE("5-7", "未保持安全距离", "发生未保持安全距离"), FIREWORKS("6-1", "烟火", "发生烟火"), FIRE_HAZARD("6-2", "火灾", "发生火灾"), STUMBLING_BLOCK("6-3", "障碍物", "发生障碍物"), @@ -52,7 +52,7 @@ public enum WarningSubclassEnum { LOW_VISIBILITY("8-9", "道路能见度低", "发生异常天气"), ROAD_FOG("8-10", "道路团雾", "发生异常天气"), COLLISION_ONLY("9-1", "只碰撞不倾斜", "发生护栏碰撞"), - TILTED_WITHOUT_COLLISION("9-1", "只倾斜无碰撞", "发生护栏碰撞"), + TILTED_WITHOUT_COLLISION("9-2", "只倾斜无碰撞", "发生护栏碰撞"), COLLISION_AND_TILTED("9-3", "碰撞后倾斜", "发生护栏碰撞"), UNKNOWN("10-1", "未知", "发生未知交通事故"), SINGLE_VEHICLE_ACCIDENT("10-2", "单车事故", "发生单车事故"), diff --git a/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java b/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java index 8b81e686..0a9f2afb 100644 --- a/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java +++ b/zc-business/src/main/java/com/zc/business/mapper/DcWarningMapper.java @@ -165,4 +165,10 @@ public interface DcWarningMapper //首页气象预警列表 public List selectStakeWarningTable(); + + List selectVideoReviewEventTypeList(DcWarning dcWarning); + //数据集合 + List selectVideoEventList(DcWarning dcWarning); + + List selectVideoReviewEventTimeList(DcWarning dcWarning); } diff --git a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java index 69c2ecca..8a95802d 100644 --- a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java +++ b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java @@ -312,9 +312,9 @@ public class DeviceMessageHandler { } - if(relatedLaneNo==UniversalEnum.ONE.getNumber() || relatedLaneNo==UniversalEnum.SIX.getNumber()){ + /* if(relatedLaneNo==UniversalEnum.ONE.getNumber() || relatedLaneNo==UniversalEnum.EIGHT.getNumber()){ relatedLaneNo=UniversalEnum.ZERO.getNumber(); - } + }*/ dcWarning.setLane(String.valueOf(relatedLaneNo)); String title = direction+UniversalEnum.BLANK_SPACE.getValue() + WarningSubclassEnum.getDecorateInfo(warningSubclass); diff --git a/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java b/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java index cc066546..c20ed8d1 100644 --- a/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java +++ b/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java @@ -2,6 +2,7 @@ package com.zc.business.service; import java.util.HashMap; import java.util.List; +import java.util.Map; import com.ruoyi.common.core.domain.AjaxResult; import com.zc.business.domain.DcDispatch; @@ -116,4 +117,14 @@ public interface IDcWarningService //首页气象预警列表 public List selectStakeWarningTable(); +//视频审核事件类型列表 +Map selectVideoReviewEventTypeList(DcWarning dcWarning); +//视频审核事件分布列表 +Map selectVideoReviewSectionDistribution(DcWarning dcWarning); +//视频审核事件来源列表 + Map videoReviewEventSource(DcWarning dcWarning); + + List videoReviewEventSourceList(DcWarning dcWarning); + + Map videoReviewEventTime(DcWarning dcWarning); } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java index 075f19cc..0b5caf67 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcTrafficStatisticsServiceImpl.java @@ -932,7 +932,7 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi // 初始化计数器和描述映射 Map flowCounts = new HashMap<>(); Map descriptions = new HashMap<>(); - for (int i = UniversalEnum.ONE.getNumber(); i <= UniversalEnum.FOURTEEN.getNumber(); i++) { + for (int i = UniversalEnum.ONE.getNumber(); i <= 16; i++) { flowCounts.put(i, UniversalEnum.ZERO.getNumber()); descriptions.put(i, UniversalEnum.EMPTY_STRING.getValue()); } @@ -1190,11 +1190,12 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi double fixedLon = firstLon; // Los Angeles的经度 // System.out.println("Lon Angeles的纬度"+fixedLon); - // 根据距离固定点的远近排序 - // Collections.sort(locations, Comparator.comparingDouble(location -> haversineDistance(fixedLat, fixedLon, location.latitude, location.longitude))); // 按照经度升序排序坐标数组 Collections.sort(locations, Comparator.comparingDouble(location ->location.getLongitude())); - + // 参考点设定为第一个点 + Location referencePoint = locations.get(0); + // 根据距离固定点的远近排序 + Collections.sort(locations, Comparator.comparingDouble(loc -> haversine(referencePoint, loc))); // 将排序后的坐标重新格式化为原始的字符串格式 StringBuilder sortedLngLatsBuilder = new StringBuilder(); // 输出排序后的地点及其距离 @@ -1263,6 +1264,10 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi return new JSONArray(); } } + private static double toRadians(double degrees) { + return degrees * Math.PI / 180; + } + private String stakeMarkKilometre(String stakeMark) { // 使用正则表达式匹配+号前的数字 @@ -1596,5 +1601,22 @@ public class DcTrafficStatisticsServiceImpl implements IDcTrafficStatisticsServi double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return R * c; } + private static double haversine(Location loc1, Location loc2) { + final int R = 6371; // 地球半径,单位为公里 + double lat1 = toRadians(loc1.getLatitude()); + double lat2 = toRadians(loc2.getLatitude()); + double lon1 = toRadians(loc1.getLongitude()); + double lon2 = toRadians(loc2.getLongitude()); + + double dLat = lat2 - lat1; + double dLon = lon2 - lon1; + + double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + + Math.cos(lat1) * Math.cos(lat2) * + Math.sin(dLon / 2) * Math.sin(dLon / 2); + double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); + + return R * c; // 返回的是两地点间的距离,单位为公里 + } } diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java index db385398..d56bb1cc 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java @@ -14,9 +14,7 @@ import com.ruoyi.common.utils.uuid.IdUtils; import com.ruoyi.system.service.ISysConfigService; import com.zc.business.controller.VideoController; import com.zc.business.domain.*; -import com.zc.business.enums.UniversalEnum; -import com.zc.business.enums.ValueConverter; -import com.zc.business.enums.WarningSubclassEnum; +import com.zc.business.enums.*; import com.zc.business.mapper.*; import com.zc.business.service.IDcEventService; import com.zc.business.service.IDcTrafficPoliceService; @@ -41,6 +39,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.io.IOException; +import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.LocalDate; @@ -51,6 +50,8 @@ import java.time.temporal.ChronoUnit; import java.util.*; import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; /** @@ -140,12 +141,12 @@ public class DcWarningServiceImpl implements IDcWarningService { //导出 @Override public List export(DcWarning dcWarning) { - if (com.ruoyi.common.utils.StringUtils.isNotEmpty(dcWarning.getStartStakeMark())){ + if (com.ruoyi.common.utils.StringUtils.isNotEmpty(dcWarning.getStartStakeMark())) { String startStakeMark = com.ruoyi.common.utils.StakeMarkUtils.formatMetre(dcWarning.getStartStakeMark()); dcWarning.setStartStakeMark(startStakeMark); } - if (com.ruoyi.common.utils.StringUtils.isNotEmpty(dcWarning.getEndStakeMark())){ + if (com.ruoyi.common.utils.StringUtils.isNotEmpty(dcWarning.getEndStakeMark())) { String endStakeMark = com.ruoyi.common.utils.StakeMarkUtils.formatMetre(dcWarning.getEndStakeMark()); dcWarning.setEndStakeMark(endStakeMark); } @@ -170,8 +171,8 @@ public class DcWarningServiceImpl implements IDcWarningService { return UniversalEnum.ZERO.getNumber(); } //目前护栏碰撞触发的事件,有关应急车道的先进行过滤掉,后续可能会放开 - if ("4".equals(dcWarning.getWarningSource().toString())&&("4-7".equals(dcWarning.getWarningSubclass())|| - "4-8".equals(dcWarning.getWarningSubclass()))){ + if ("4".equals(dcWarning.getWarningSource().toString()) && ("4-7".equals(dcWarning.getWarningSubclass()) || + "4-8".equals(dcWarning.getWarningSubclass()))) { return 1; } String redisKye = dcWarning.getWarningSource().toString() + dcWarning.getWarningType().toString() + dcWarning.getWarningSubclass();//配置数据的key 事件源+事件类型+策略 @@ -290,7 +291,7 @@ public class DcWarningServiceImpl implements IDcWarningService { int i = dcWarningMapper.insertDcWarning(dcWarning);//如果没有配置策略直接加入数据库; //扫码报警提前插入处置记录 - if (dcWarning.getWarningSource() == 5){ + if (dcWarning.getWarningSource() == 5) { DcEventProcess dcEventProcess = new DcEventProcess(); dcEventProcess.setEventId(uuid); dcEventProcess.setSource(2); @@ -348,9 +349,9 @@ public class DcWarningServiceImpl implements IDcWarningService { contentMap.put("content", content); } contentMap.put("event", dcWarning); - if (dcWarning.getWarningSource()==UniversalEnum.FIVE.getNumber()){ + if (dcWarning.getWarningSource() == UniversalEnum.FIVE.getNumber()) { WebSocketService.broadcast(UniversalEnum.TWO.getValue(), contentMap); //推送事件消息 2是扫码报警 - }else { + } else { WebSocketService.broadcast(WebSocketEvent.WARNING, contentMap); //推送事件消息 1感知事件 } @@ -611,7 +612,7 @@ public class DcWarningServiceImpl implements IDcWarningService { return AjaxResult.error("非机预警无需转换"); } String selectEventId = dcWarningMapper.selectEventId(dcWarning.getId());//验证转换的对象是否已经在事件表中存在 - if (StringUtils.isNotBlank(selectEventId)){ + if (StringUtils.isNotBlank(selectEventId)) { return AjaxResult.success(); } ArrayList> hashMaps = new ArrayList<>(); @@ -670,7 +671,7 @@ public class DcWarningServiceImpl implements IDcWarningService { try { dealWarning(alarmId); //扫码报警接警反馈 - addCodeScanningProcess(alarmId,"济菏运管中心接警"); + addCodeScanningProcess(alarmId, "济菏运管中心接警"); } catch (IOException | HttpException e) { e.printStackTrace(); } @@ -694,7 +695,7 @@ public class DcWarningServiceImpl implements IDcWarningService { } //扫码报警 处置记录 - public AjaxResult addCodeScanningProcess(String alarmId,String content) throws IOException, HttpException { + public AjaxResult addCodeScanningProcess(String alarmId, String content) throws IOException, HttpException { String url = configService.selectConfigByKey("alarmCode"); url = url + "/warning/addProcess"; @@ -1035,28 +1036,28 @@ public class DcWarningServiceImpl implements IDcWarningService { List employeesList = employeesMapper.selectEmployeesByIds(ids); List wxUserIds = new ArrayList<>(); for (DcEmployees dcEmployees : employeesList) { - if (StringUtils.isNotBlank(dcEmployees.getWxUserId())){ + if (StringUtils.isNotBlank(dcEmployees.getWxUserId())) { wxUserIds.add(dcEmployees.getWxUserId()); } else { String wxUserId = qywxUtil.getUserIdByMobile(dcEmployees.getContactNumber()); - if (StringUtils.isNotBlank(wxUserId)){ + if (StringUtils.isNotBlank(wxUserId)) { dcEmployees.setWxUserId(wxUserId); employeesMapper.updateDcEmployees(dcEmployees); wxUserIds.add(wxUserId); } } } - qywxUtil.sendMessageByWxUserId(wxUserIds,message); + qywxUtil.sendMessageByWxUserId(wxUserIds, message); //扫码报警 处置记录 HashMap warningInfo = dcWarningMapper.selectDcWarningById(eventId); - if (warningInfo != null && Objects.nonNull(warningInfo.get("warningSource")) && "5".equals(warningInfo.get("warningSource").toString())){ + if (warningInfo != null && Objects.nonNull(warningInfo.get("warningSource")) && "5".equals(warningInfo.get("warningSource").toString())) { com.alibaba.fastjson.JSONObject otherConfig = com.alibaba.fastjson.JSONObject.parseObject(warningInfo.get("otherConfig").toString()); String alarmId = otherConfig.getString("id"); if (StringUtils.isNotBlank(alarmId)) { try { //扫码报警接警反馈 - addCodeScanningProcess(alarmId,"调度路管人员现场处置"); + addCodeScanningProcess(alarmId, "调度路管人员现场处置"); } catch (IOException | HttpException e) { e.printStackTrace(); } @@ -1197,18 +1198,18 @@ public class DcWarningServiceImpl implements IDcWarningService { dcEventProcessService.insertDcEventProcess(dcEventProcess); //给路管人员发送企业微信 - map.put("eventId",dcDispatchEventId.getEventId()); + map.put("eventId", dcDispatchEventId.getEventId()); sendQYWXMessage(map); //扫码报警 处置记录 HashMap warningInfo = dcWarningMapper.selectDcWarningById(dcDispatchEventId.getEventId()); - if (warningInfo != null && Objects.nonNull(warningInfo.get("warningSource")) && "5".equals(warningInfo.get("warningSource").toString())){ + if (warningInfo != null && Objects.nonNull(warningInfo.get("warningSource")) && "5".equals(warningInfo.get("warningSource").toString())) { com.alibaba.fastjson.JSONObject otherConfig = com.alibaba.fastjson.JSONObject.parseObject(warningInfo.get("otherConfig").toString()); String alarmId = otherConfig.getString("id"); if (StringUtils.isNotBlank(alarmId)) { try { //扫码报警接警反馈 - addCodeScanningProcess(alarmId,"调度路管人员现场处置"); + addCodeScanningProcess(alarmId, "调度路管人员现场处置"); } catch (IOException | HttpException e) { e.printStackTrace(); } @@ -1219,7 +1220,7 @@ public class DcWarningServiceImpl implements IDcWarningService { } //给路管人员发送企业微信 - private void sendQYWXMessage(HashMap map){ + private void sendQYWXMessage(HashMap map) { String eventId = map.get("eventId").toString(); DcEvent dcEvent = dcEventMapper.selectDcEventById(eventId); SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -1254,20 +1255,21 @@ public class DcWarningServiceImpl implements IDcWarningService { List employeesList = employeesMapper.selectEmployeesByIds(ids); List wxUserIds = new ArrayList<>(); for (DcEmployees dcEmployees : employeesList) { - if (StringUtils.isNotBlank(dcEmployees.getWxUserId())){ + if (StringUtils.isNotBlank(dcEmployees.getWxUserId())) { wxUserIds.add(dcEmployees.getWxUserId()); } else { String wxUserId = qywxUtil.getUserIdByMobile(dcEmployees.getContactNumber()); - if (StringUtils.isNotBlank(wxUserId)){ + if (StringUtils.isNotBlank(wxUserId)) { dcEmployees.setWxUserId(wxUserId); employeesMapper.updateDcEmployees(dcEmployees); wxUserIds.add(wxUserId); } } } - qywxUtil.sendMessageByWxUserId(wxUserIds,message); + qywxUtil.sendMessageByWxUserId(wxUserIds, message); } + //误报解除 @Override public Integer falseAlarmResolution(DcWarning dcWarning) { @@ -1312,7 +1314,7 @@ public class DcWarningServiceImpl implements IDcWarningService { JsonNode roocallPostApiGetRegionstNode = objectMapper.readTree(callPostApiGetRegions); JsonNode jsonNode = roocallPostApiGetRegionstNode.get("data"); JsonNode jsonNodelist = jsonNode.get("list"); - if (jsonNodelist.isEmpty()){ + if (jsonNodelist.isEmpty()) { return ""; } @@ -1330,7 +1332,7 @@ public class DcWarningServiceImpl implements IDcWarningService { String fileUrl = data.get("fileUrl").textValue(); return fileUrl; - }else { + } else { return ""; } @@ -1400,4 +1402,247 @@ public class DcWarningServiceImpl implements IDcWarningService { public List selectStakeWarningTable() { return dcWarningMapper.selectStakeWarningTable(); } + + @Override + public Map selectVideoReviewEventTypeList(DcWarning dcWarning) { + dcWarning.setAuditFlag(UniversalEnum.ONE.getNumber()); + List dcWarningsOne = dcWarningMapper.selectVideoReviewEventTypeList(dcWarning); + dcWarning.setAuditFlag(UniversalEnum.TWO.getNumber()); + List dcWarningsTwo = dcWarningMapper.selectVideoReviewEventTypeList(dcWarning); + + // 使用枚举类来定义类型映射 + Map warningTypeMap = Arrays.stream(WarningTypeEnum.values()) + .collect(Collectors.toMap(WarningTypeEnum::getCode, WarningTypeEnum::getInfo)); + + // 统计 dcWarningsOne 每种类型的数量 + Map typeCountOne = dcWarningsOne.stream() + .collect(Collectors.groupingBy(DcWarning::getWarningType, Collectors.counting())); + + // 统计 dcWarningsTwo 每种类型的数量 + Map typeCountTwo = dcWarningsTwo.stream() + .collect(Collectors.groupingBy(DcWarning::getWarningType, Collectors.counting())); + + // 初始化结果集 + Map result = new LinkedHashMap<>(); + DecimalFormat decimalFormat = new DecimalFormat("0"); + + // 遍历所有类型,计算数量和百分比 + warningTypeMap.forEach((type, getWarningSource) -> { + long countOne = typeCountOne.getOrDefault(type, 0L); + long countTwo = typeCountTwo.getOrDefault(type, 0L); + + // 计算总数量 + long totalCount = countOne + countTwo; + // 计算百分比并格式化 + double percentageOne = totalCount == 0 ? 0 : ((double) countOne / totalCount) * 100; + double percentageTwo = totalCount == 0 ? 0 : ((double) countTwo / totalCount) * 100; + + String formattedPercentageOne = decimalFormat.format(percentageOne); + String formattedPercentageTwo = decimalFormat.format(percentageTwo); + + // 只保留有非零数量的类型 + if (countOne > 0 || countTwo > 0) { + // 存储结果 + Map typeResult = new LinkedHashMap<>(); + typeResult.put("AuditFlag1_Count", countOne); + typeResult.put("AuditFlag2_Count", countTwo); + typeResult.put("AuditFlag1_Percentage", formattedPercentageOne+"%"); + typeResult.put("AuditFlag2_Percentage", formattedPercentageTwo+"%"); + + result.put(getWarningSource, typeResult); + } + /* // 存储结果 + Map typeResult = new LinkedHashMap<>(); + typeResult.put("AuditFlag1_Count", countOne); + typeResult.put("AuditFlag2_Count", countTwo); + typeResult.put("AuditFlag1_Percentage", formattedPercentageOne); + typeResult.put("AuditFlag2_Percentage", formattedPercentageTwo); + result.put(getWarningSource, typeResult); + */ + }); + + return result; } + +//视频复核路段 + @Override + public Map selectVideoReviewSectionDistribution(DcWarning dcWarning) { + dcWarning.setAuditFlag(UniversalEnum.ONE.getNumber()); + List dcWarningsOne = dcWarningMapper.selectVideoReviewEventTypeList(dcWarning); + + dcWarning.setAuditFlag(UniversalEnum.TWO.getNumber()); + List dcWarningsTwo = dcWarningMapper.selectVideoReviewEventTypeList(dcWarning); + Map eventOne = stakeMarkCount(dcWarningsOne); + + Map eventTwo = stakeMarkCount(dcWarningsTwo); + + // 转换为百分比 + Map eventOnePercents = convertToPercentage(eventOne, eventTwo); + Map eventTwoPercents = convertToPercentage(eventTwo, eventOne); + + // 提取所有的 key 并排序 + Set allKeys = new TreeSet<>((key1, key2) -> { + int start1 = extractStartKm(key1); + int start2 = extractStartKm(key2); + return Integer.compare(start1, start2); + }); + allKeys.addAll(eventOne.keySet()); + allKeys.addAll(eventTwo.keySet()); + + // 使用 LinkedHashMap 来保持插入顺序 + Map finalData = new LinkedHashMap<>(); + + for (String key : allKeys) { + Map segmentData = new HashMap<>(); + segmentData.put("AuditFlag1_Count", eventOne.getOrDefault(key, 0)); + segmentData.put("AuditFlag2_Count", eventTwo.getOrDefault(key, 0)); + segmentData.put("AuditFlag1_Percentage", eventOnePercents.getOrDefault(key, "0%")); + segmentData.put("AuditFlag2_Percentage", eventTwoPercents.getOrDefault(key, "0%")); + + finalData.put(key, segmentData); + } + + return finalData; + } +//视频复核事件来源 + @Override + public Map videoReviewEventSource(DcWarning dcWarning) { + dcWarning.setAuditFlag(UniversalEnum.ONE.getNumber()); + List dcWarningsOne = dcWarningMapper.selectVideoReviewEventTypeList(dcWarning); + dcWarning.setAuditFlag(UniversalEnum.TWO.getNumber()); + List dcWarningsTwo = dcWarningMapper.selectVideoReviewEventTypeList(dcWarning); + + // 使用枚举类来定义类型映射 + Map warningTypeMap = Arrays.stream(WarningSourceEnum.values()) + .collect(Collectors.toMap(WarningSourceEnum::getCode, WarningSourceEnum::getDescription)); + + // 统计 dcWarningsOne 每种类型的数量 + Map typeCountOne = dcWarningsOne.stream() + .collect(Collectors.groupingBy(DcWarning::getWarningType, Collectors.counting())); + + // 统计 dcWarningsTwo 每种类型的数量 + Map typeCountTwo = dcWarningsTwo.stream() + .collect(Collectors.groupingBy(DcWarning::getWarningType, Collectors.counting())); + + // 初始化结果集 + Map result = new LinkedHashMap<>(); + DecimalFormat decimalFormat = new DecimalFormat("0"); + + // 遍历所有类型,计算数量和百分比 + warningTypeMap.forEach((type, warningType) -> { + long countOne = typeCountOne.getOrDefault(type, 0L); + long countTwo = typeCountTwo.getOrDefault(type, 0L); + + // 计算总数量 + long totalCount = countOne + countTwo; + // 计算百分比并格式化 + double percentageOne = totalCount == 0 ? 0 : ((double) countOne / totalCount) * 100; + double percentageTwo = totalCount == 0 ? 0 : ((double) countTwo / totalCount) * 100; + + String formattedPercentageOne = decimalFormat.format(percentageOne); + String formattedPercentageTwo = decimalFormat.format(percentageTwo); + + // 只保留有非零数量的类型 + if (countOne > 0 || countTwo > 0) { + // 存储结果 + Map typeResult = new LinkedHashMap<>(); + typeResult.put("AuditFlag1_Count", countOne); + typeResult.put("AuditFlag2_Count", countTwo); + typeResult.put("AuditFlag1_Percentage", formattedPercentageOne+"%"); + typeResult.put("AuditFlag2_Percentage", formattedPercentageTwo+"%"); + + result.put(warningType, typeResult); + } + /* // 存储结果 + Map typeResult = new LinkedHashMap<>(); + typeResult.put("AuditFlag1_Count", countOne); + typeResult.put("AuditFlag2_Count", countTwo); + typeResult.put("AuditFlag1_Percentage", formattedPercentageOne); + typeResult.put("AuditFlag2_Percentage", formattedPercentageTwo); + result.put(warningType, typeResult); + */ + }); + + return result; + } + + @Override + public List videoReviewEventSourceList(DcWarning dcWarning) { + return dcWarningMapper.selectVideoEventList(dcWarning); + } +//时间分布 + @Override + public Map videoReviewEventTime(DcWarning dcWarning) { + dcWarning.setAuditFlag(UniversalEnum.ONE.getNumber()); + List dcWarningsOne = dcWarningMapper.selectVideoReviewEventTimeList(dcWarning); + dcWarning.setAuditFlag(UniversalEnum.TWO.getNumber()); + List dcWarningsTwo = dcWarningMapper.selectVideoReviewEventTimeList(dcWarning); + + return null; + } + + public Map stakeMarkCount(List dcWarnings){ + Map groupCountMap = new HashMap<>(); + for (DcWarning dcWarning : dcWarnings) { + + String kmStr = dcWarning.getStakeMark(); + if (org.apache.commons.lang3.StringUtils.isBlank(kmStr)) { + continue; + } + String patternStr = "^K\\d+(\\+\\d+)?$"; + Pattern pattern = Pattern.compile(patternStr); + Matcher matcher = pattern.matcher(kmStr); + if (!matcher.matches()) { + continue; + } + int km = Integer.parseInt(kmStr.replaceAll("^K", "").split("\\+")[0]); // 假设+后面还有其他内容,我们只取+前面的部分 + // 计算分组startKm,确保是5的倍数且不大于km + int startKm = ((km / 10) * 10) + (km % 10 >= 5 ? 10 : 0); + startKm = startKm - startKm % 5; // 确保startKm是5的倍数 + if (startKm%5==0){ + if ((startKm / 5) % 2 == 0) { + startKm -= 5; + } + } + // 计算分组endKm,找到比startKm大、最接近的、以5结尾的数 + int endKm = startKm + 10; + while (endKm % 5 != 0) { + endKm++; + } + // 构造分组key + String groupKey = "K" + startKm + "-" + "K" + endKm; + if (groupCountMap.get(groupKey)==null){ //事件还为存入map + groupCountMap.putIfAbsent(groupKey, UniversalEnum.ONE.getNumber());//事件类型不存在存1 + }else { + Integer currentSum = groupCountMap.get(groupKey); + groupCountMap.put(groupKey, currentSum +1 ); + } + } + return groupCountMap; + } + // 提取 "Kxx-xxx" 格式中的起始公里数 + private int extractStartKm(String key) { + String[] parts = key.split("-"); + if (parts.length == 2 && parts[0].matches("K\\d+")) { + return Integer.parseInt(parts[0].substring(1)); + } + throw new IllegalArgumentException("Invalid stake mark format: " + key); + } + public Map convertToPercentage(Map countMap1, Map countMap2) { + Map percentageMap = new HashMap<>(); + DecimalFormat df = new DecimalFormat("0"); + + for (String key : countMap1.keySet()) { + int count1 = countMap1.get(key); + int count2 = countMap2.getOrDefault(key, 0); + int totalCount = count1 + count2; + + if (totalCount > 0) { + double percentage = (double) count1 / totalCount * 100; + percentageMap.put(key, df.format(percentage) + "%"); + } else { + percentageMap.put(key, "0%"); + } + } + return percentageMap; + }} diff --git a/zc-business/src/main/resources/mapper/business/DcGantryMetricsStatisticsDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcGantryMetricsStatisticsDataMapper.xml index 47dfaaf6..6fcde1e0 100644 --- a/zc-business/src/main/resources/mapper/business/DcGantryMetricsStatisticsDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcGantryMetricsStatisticsDataMapper.xml @@ -180,11 +180,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 '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', 'K190+495', '梁山立交-嘉祥西立交' UNION ALL + SELECT 'K179+396', 'K182+987', '梁山立交-信楼枢纽' UNION ALL + SELECT 'K182+987', 'K190+495', '信楼枢纽-嘉祥西立交' UNION ALL SELECT 'K190+495', 'K202+979', '嘉祥西立交-王官屯枢纽' ) AS i JOIN dc_facility AS ps diff --git a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml index 020b218a..19622a37 100644 --- a/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcGantryStatisticsDataMapper.xml @@ -204,59 +204,61 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" @@ -325,12 +327,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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 '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', 'K190+495', '梁山立交-嘉祥西立交' UNION ALL - SELECT 'K190+495', 'K202+979', '嘉祥西立交' + SELECT 'K179+396', 'K182+987', '梁山立交-信楼枢纽' UNION ALL + SELECT 'K182+987', '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') @@ -350,81 +354,86 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + +