diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java index 7e59ea01..53c23e79 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java +++ b/zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java @@ -197,7 +197,7 @@ public class DcEventServiceImpl extends ServiceImpl impl dcEvent.setStakeMark(extracted(facilityId)); } //桩号校验 - if (!com.ruoyi.common.utils.StakeMarkUtils.checkStakeMark(dcEvent.getStakeMark())){ + if (!com.ruoyi.common.utils.StakeMarkUtils.checkStakeMark(dcEvent.getStakeMark())) { return -1; } @@ -232,9 +232,11 @@ public class DcEventServiceImpl extends ServiceImpl impl break; //交通管制 case 3: + //交通管制事件 不做 首因关联 + if (dcEvent.getDcEventTrafficControl() != null) { if (dcEventId == null) {//非首页进入 - if (dcEvent.getDcEventTrafficControl().getFacilityIds() ==null ) { + if (dcEvent.getDcEventTrafficControl().getFacilityIds() == null) { dcEvent.getDcEventTrafficControl().setId(uuid); int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl()); break; @@ -248,19 +250,23 @@ public class DcEventServiceImpl extends ServiceImpl impl //查询事件 DcEvent dcEvent2 = dcEventMapper.selectDcEventById(dcEventId); //判断事件 关联事件id是否为空 - if (dcEvent2.getLinkId()==null){ + if (dcEvent2.getLinkId() == null) { DcEvent dcEvent1 = new DcEvent(); dcEvent1.setId(dcEventId);//事件id - dcEvent1.setEventNature(1l);//首发事件 - dcEvent1.setLinkId(uuid);//关联管制事件id - dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 - }else { + if (dcEvent2.getEventType() != 3) { + dcEvent1.setEventNature(1l);//首发事件 + dcEvent1.setLinkId(uuid);//关联管制事件id + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + } + } else { DcEvent dcEvent1 = new DcEvent(); dcEvent1.setId(dcEventId);//事件id - dcEvent1.setEventNature(1l);//首发事件 - dcEvent1.setLinkId(dcEvent2.getLinkId()+","+uuid);//关联管制事件id - dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + if (dcEvent2.getEventType() != 3) { + dcEvent1.setEventNature(1l);//首发事件 + dcEvent1.setLinkId(dcEvent2.getLinkId() + "," + uuid);//关联管制事件id + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + } } @@ -270,11 +276,16 @@ public class DcEventServiceImpl extends ServiceImpl impl if (dcEvent.getDcEventTrafficControl().getFacilityIds().length == 1) {//facilityIds==1 说明只选择了一个收费站 if (dcEventId != null && !dcEventId.equals("")) {//不等于空 事件处置页面 修改 + DcEvent dcEvent2 = dcEventMapper.selectDcEventById(dcEventId); + DcEvent dcEvent1 = new DcEvent(); dcEvent1.setId(dcEventId);//事件id - dcEvent1.setEventNature(1l);//首发事件 - dcEvent1.setLinkId(uuid);//关联管制事件id - dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + if (dcEvent2.getEventType() != 3) { + dcEvent1.setEventNature(1l);//首发事件 + dcEvent1.setLinkId(dcEvent2.getLinkId()+","+uuid);//关联管制事件id + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + + } dcEvent.getDcEventTrafficControl().setId(uuid); dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id @@ -292,10 +303,14 @@ public class DcEventServiceImpl extends ServiceImpl impl } else if (dcEvent.getDcEventTrafficControl().getFacilityIds().length > 1) {//facilityIds1=1 说明只选择了多个收费站 if (dcEventId != null) {//不等于空 事件处置页面 修改 + DcEvent dcEvent2 = dcEventMapper.selectDcEventById(dcEventId); + dcEventMapper.deleteDcEventById(uuid);//删除添加的事件主类 DcEvent dcEvent1 = new DcEvent(); dcEvent1.setId(dcEventId);//事件id - dcEvent1.setEventNature(1l);//首发事件 + + dcEvent1.setEventNature(1l);//首发事件 + Map map = new HashMap<>(); for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { //设置事件Id UUID无下划线格式32 String facilityUUID = IdUtils.fastSimpleUUID(); @@ -312,8 +327,13 @@ public class DcEventServiceImpl extends ServiceImpl impl a++; } String linkId2 = sb2.toString(); - dcEvent1.setLinkId(linkId2);//关联管制事件id - dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + dcEvent1.setLinkId(dcEvent2.getLinkId()+","+linkId2);//关联管制事件id + + if (dcEvent2.getEventType() != 3) { + dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质 + } + + for (int i = 0; i < dcEvent.getDcEventTrafficControl().getFacilityIds().length; i++) { dcEvent.getDcEventTrafficControl().setId(map.get("facilityId" + i));//交通管制事件id dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[i]);//取出数组字段赋值 设施id @@ -409,6 +429,7 @@ public class DcEventServiceImpl extends ServiceImpl impl } + break; //交通拥堵 case 4: @@ -524,7 +545,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventAccident() != null) { }*/ - DcEventAccident dcEventAccident =new DcEventAccident(); + DcEventAccident dcEventAccident = new DcEventAccident(); dcEvent.setDcEventAccident(dcEventAccident); dcEvent.getDcEventAccident().setId(uuid); dcEvent.getDcEventAccident().setReporterName("视频AI"); @@ -537,7 +558,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventVehicleAccident() != null) { }*/ - DcEventVehicleAccident dcEventVehicleAccident =new DcEventVehicleAccident(); + DcEventVehicleAccident dcEventVehicleAccident = new DcEventVehicleAccident(); dcEvent.setDcEventVehicleAccident(dcEventVehicleAccident); dcEvent.getDcEventVehicleAccident().setReporterName("视频AI"); dcEvent.getDcEventVehicleAccident().setReporterPhoneNumber("96659"); @@ -550,7 +571,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventTrafficControl() != null) { } */ - DcEventTrafficControl dcEventTrafficControl =new DcEventTrafficControl(); + DcEventTrafficControl dcEventTrafficControl = new DcEventTrafficControl(); dcEvent.setDcEventTrafficControl(dcEventTrafficControl); dcEvent.getDcEventTrafficControl().setControlType(1L);//限行 dcEvent.getDcEventTrafficControl().setControlCause(2L);//交通事故 @@ -562,7 +583,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventTrafficCongestion() != null) { }*/ - DcEventTrafficCongestion dcEventTrafficCongestion =new DcEventTrafficCongestion(); + DcEventTrafficCongestion dcEventTrafficCongestion = new DcEventTrafficCongestion(); dcEvent.setDcEventTrafficCongestion(dcEventTrafficCongestion); dcEvent.getDcEventTrafficCongestion().setId(uuid); dcEvent.getDcEventTrafficCongestion().setCongestionMileage(0F);//拥堵里程(公里) @@ -581,7 +602,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventConstruction() != null) { }*/ - DcEventConstruction dcEventConstruction =new DcEventConstruction(); + DcEventConstruction dcEventConstruction = new DcEventConstruction(); dcEvent.setDcEventConstruction(dcEventConstruction); dcEvent.getDcEventConstruction().setId(uuid); dcEvent.getDcEventConstruction().setControlMode(1l);//封闭 @@ -592,7 +613,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /* if (dcEvent.getDcEventServiceArea() != null) { }*/ - DcEventServiceArea dcEventServiceArea =new DcEventServiceArea(); + DcEventServiceArea dcEventServiceArea = new DcEventServiceArea(); dcEvent.setDcEventServiceArea(dcEventServiceArea); dcEvent.getDcEventServiceArea().setId(uuid); int i3 = dcEventServiceAreaMapper.insertDcEventServiceArea(dcEvent.getDcEventServiceArea()); @@ -604,7 +625,7 @@ public class DcEventServiceImpl extends ServiceImpl impl case 10: /* if (dcEvent.getDcEventAbnormalWeather() != null) { }*/ - DcEventAbnormalWeather dcEventAbnormalWeather =new DcEventAbnormalWeather(); + DcEventAbnormalWeather dcEventAbnormalWeather = new DcEventAbnormalWeather(); dcEvent.setDcEventAbnormalWeather(dcEventAbnormalWeather); dcEvent.getDcEventAbnormalWeather().setId(uuid); dcEvent.getDcEventAbnormalWeather().setWeatherSituation("1-1");//雨雾 @@ -798,7 +819,7 @@ public class DcEventServiceImpl extends ServiceImpl impl int i7 = dcEventMapper.updateDcEvent(dcEvent); if (i7 > 0) { String context = comparisonInfo(oldEvent, dcEvent); - if (context.length() > 0){ + if (context.length() > 0) { //事件处置流程记录 DcEventProcess dcEventProcess = new DcEventProcess(); dcEventProcess.setEventId(dcEvent.getId()); @@ -1146,11 +1167,11 @@ public class DcEventServiceImpl extends ServiceImpl impl dcEventProcessService.insertDcEventProcess(dcEventProcess); //插入调度默认数据 - ArrayList> hashMaps = new ArrayList<>(); + ArrayList> hashMaps = new ArrayList<>(); String stakeMark = dcEvent.getStakeMark();//传入桩号 List> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称 - for (HashMap map:mapList){ - if (org.apache.commons.lang3.StringUtils.isBlank(map.get("stakeMark").toString())){ + for (HashMap map : mapList) { + if (org.apache.commons.lang3.StringUtils.isBlank(map.get("stakeMark").toString())) { continue; } Long sectionId = (Long) map.get("id");//机构的id @@ -1158,15 +1179,16 @@ public class DcEventServiceImpl extends ServiceImpl impl com.zc.business.utils.StakeMarkUtils stakeMarkUtils = new StakeMarkUtils(); Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMarkNew);//机构本身的米数 Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMark);//传入的桩号米数 - Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值 - map.put("difference",difference/1000.0);//米转公里加入到map - map.put("id",sectionId); + Integer difference = Math.abs(afferentStakeMark - itselfStakeMark); //计算距离绝对值 + map.put("difference", difference / 1000.0);//米转公里加入到map + map.put("id", sectionId); hashMaps.add(map); } List> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> { - return (Double) map.get("difference"); })).collect(Collectors.toList()); + return (Double) map.get("difference"); + })).collect(Collectors.toList()); HashMap hashMap = dcWarningMapper.selectDcDispatch(id);//查询事件是否已经有转的调度记录 - if (!sortedHashMaps.isEmpty()&&hashMap==null) { + if (!sortedHashMaps.isEmpty() && hashMap == null) { HashMap map = sortedHashMaps.get(0); Long sortId = (Long) map.get("id");//取出最近的机构id if (sortId != null) { @@ -1180,7 +1202,7 @@ public class DcEventServiceImpl extends ServiceImpl impl dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录 Long dispatchId = dcDispatch.getId();//信息记录id List> employeesMap = dcWarningMapper.selectOrganizationEmployees(sortId);//人员map - if (employeesMap != null&&employeesMap.size()>0) { + if (employeesMap != null && employeesMap.size() > 0) { // 生成一个随机索引,范围在0到列表长度减1之间 int randomIndex = ThreadLocalRandom.current().nextInt(employeesMap.size()); HashMap randomEmployee = employeesMap.get(randomIndex); @@ -1191,7 +1213,7 @@ public class DcEventServiceImpl extends ServiceImpl impl dcWarningMapper.insertDispatchResource(dcDispatchResource); } List> vehiclesMap = dcWarningMapper.selectVehicles(sortId);//车辆map - if (vehiclesMap != null&&vehiclesMap.size()>0) { + if (vehiclesMap != null && vehiclesMap.size() > 0) { // 生成一个随机索引,范围在0到列表长度减1之间 int randomIndex = ThreadLocalRandom.current().nextInt(vehiclesMap.size()); HashMap randomEmployee = employeesMap.get(randomIndex); @@ -1250,10 +1272,10 @@ public class DcEventServiceImpl extends ServiceImpl impl } else if ("direction".equals(result.getRightPath())) { if (("1".equals(result.getRight()) || "上行".equals(result.getRight()) || "菏泽方向".equals(result.getRight())) - && ("1".equals(result.getLeft()) || "上行".equals(result.getLeft()) || "菏泽方向".equals(result.getLeft()))){ + && ("1".equals(result.getLeft()) || "上行".equals(result.getLeft()) || "菏泽方向".equals(result.getLeft()))) { continue; - } else if(("3".equals(result.getRight()) || "下行".equals(result.getRight()) || "济南方向".equals(result.getRight())) - && ("3".equals(result.getLeft()) || "下行".equals(result.getLeft()) || "济南方向".equals(result.getLeft()))){ + } else if (("3".equals(result.getRight()) || "下行".equals(result.getRight()) || "济南方向".equals(result.getRight())) + && ("3".equals(result.getLeft()) || "下行".equals(result.getLeft()) || "济南方向".equals(result.getLeft()))) { continue; } @@ -1779,6 +1801,7 @@ public class DcEventServiceImpl extends ServiceImpl impl /** * 调度记录 + * * @param dcEvent * @return */ @@ -1787,7 +1810,7 @@ public class DcEventServiceImpl extends ServiceImpl impl dcEvent.setEventState(2l); List dcEvents = dcEventMapper.dispatchRecordEventList(dcEvent); for (DcEvent event : dcEvents) { - List dcEventProcess= dcEventProcessService.selectDcEventProcessByEventId(event.getId()); + List dcEventProcess = dcEventProcessService.selectDcEventProcessByEventId(event.getId()); event.setDcEventProcessList(dcEventProcess); } @@ -1819,29 +1842,28 @@ public class DcEventServiceImpl extends ServiceImpl impl } /** + * @param eventId + * @return com.ruoyi.common.core.domain.AjaxResult * @Description 查询关联事件 - * * @author liuwenge * @date 2024/5/30 14:29 - * @param eventId - * @return com.ruoyi.common.core.domain.AjaxResult */ @Override - public AjaxResult getLinkEvent(String eventId){ + public AjaxResult getLinkEvent(String eventId) { - List> result = new ArrayList<>(); + List> result = new ArrayList<>(); DcEvent dcEvent = dcEventMapper.selectDcEventById(eventId); - if (StringUtils.isNotEmpty(dcEvent.getLinkId())){ - Map item = new HashMap<>(); - item.put("eventId",eventId); - item.put("eventNature",dcEvent.getEventNature()); + if (StringUtils.isNotEmpty(dcEvent.getLinkId())) { + Map item = new HashMap<>(); + item.put("eventId", eventId); + item.put("eventNature", dcEvent.getEventNature()); result.add(item); String[] linkIds = dcEvent.getLinkId().split(","); for (String linkId : linkIds) { item = new HashMap<>(); - item.put("eventId",linkId); - item.put("eventNature",2); + item.put("eventId", linkId); + item.put("eventNature", 2); result.add(item); } } diff --git a/zc-business/src/main/resources/mapper/business/DcEventMapper.xml b/zc-business/src/main/resources/mapper/business/DcEventMapper.xml index 86a50871..38faaef3 100644 --- a/zc-business/src/main/resources/mapper/business/DcEventMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEventMapper.xml @@ -816,12 +816,12 @@ and dept_id = #{deptId} + and id = #{id} and stake_mark BETWEEN #{stakeMark} and #{endStakeMark} and direction = #{direction} and user_id = #{userId} - and start_time BETWEEN #{startTime} and #{endTime} - and estimated_end_time = #{estimatedEndTime} + and end_time BETWEEN #{startTime} and #{endTime} and event_level = #{eventLevel} and event_type = #{eventType} and event_subclass = #{eventSubclass}