Browse Source

管制事件( 关联管制) 事件

develop
王兴琳 10 months ago
parent
commit
953e14f940
  1. 102
      zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java
  2. 4
      zc-business/src/main/resources/mapper/business/DcEventMapper.xml

102
zc-business/src/main/java/com/zc/business/service/impl/DcEventServiceImpl.java

@ -197,7 +197,7 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> 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,20 +250,24 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
//查询事件
DcEvent dcEvent2 = dcEventMapper.selectDcEventById(dcEventId);
//判断事件 关联事件id是否为空
if (dcEvent2.getLinkId()==null){
if (dcEvent2.getLinkId() == null) {
DcEvent dcEvent1 = new DcEvent();
dcEvent1.setId(dcEventId);//事件id
if (dcEvent2.getEventType() != 3) {
dcEvent1.setEventNature(1l);//首发事件
dcEvent1.setLinkId(uuid);//关联管制事件id
dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质
}else {
}
} else {
DcEvent dcEvent1 = new DcEvent();
dcEvent1.setId(dcEventId);//事件id
if (dcEvent2.getEventType() != 3) {
dcEvent1.setEventNature(1l);//首发事件
dcEvent1.setLinkId(dcEvent2.getLinkId()+","+uuid);//关联管制事件id
dcEvent1.setLinkId(dcEvent2.getLinkId() + "," + uuid);//关联管制事件id
dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质
}
}
break;
@ -270,12 +276,17 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> 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
if (dcEvent2.getEventType() != 3) {
dcEvent1.setEventNature(1l);//首发事件
dcEvent1.setLinkId(uuid);//关联管制事件id
dcEvent1.setLinkId(dcEvent2.getLinkId()+","+uuid);//关联管制事件id
dcEventMapper.updateDcEventLinkId(dcEvent1);//修改事件性质
}
dcEvent.getDcEventTrafficControl().setId(uuid);
dcEvent.getDcEventTrafficControl().setFacilityId(dcEvent.getDcEventTrafficControl().getFacilityIds()[0]);//取出数组字段赋值 设施id
int i6 = dcEventTrafficControlMapper.insertDcEventTrafficControl(dcEvent.getDcEventTrafficControl());//
@ -292,10 +303,14 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> 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);//首发事件
Map<String, String> 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<DcEventMapper, DcEvent> impl
a++;
}
String linkId2 = sb2.toString();
dcEvent1.setLinkId(linkId2);//关联管制事件id
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<DcEventMapper, DcEvent> impl
}
break;
//交通拥堵
case 4:
@ -524,7 +545,7 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> impl
dcEventProcessService.insertDcEventProcess(dcEventProcess);
//插入调度默认数据
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>();
ArrayList<HashMap<String, Object>> hashMaps = new ArrayList<>();
String stakeMark = dcEvent.getStakeMark();//传入桩号
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
for (HashMap<String,Object> map:mapList){
if (org.apache.commons.lang3.StringUtils.isBlank(map.get("stakeMark").toString())){
for (HashMap<String, Object> 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<DcEventMapper, DcEvent> 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<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> {
return (Double) map.get("difference"); })).collect(Collectors.toList());
return (Double) map.get("difference");
})).collect(Collectors.toList());
HashMap<String, Object> hashMap = dcWarningMapper.selectDcDispatch(id);//查询事件是否已经有转的调度记录
if (!sortedHashMaps.isEmpty()&&hashMap==null) {
if (!sortedHashMaps.isEmpty() && hashMap == null) {
HashMap<String, Object> map = sortedHashMaps.get(0);
Long sortId = (Long) map.get("id");//取出最近的机构id
if (sortId != null) {
@ -1180,7 +1202,7 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
Long dispatchId = dcDispatch.getId();//信息记录id
List<HashMap<String, Object>> 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<String, Object> randomEmployee = employeesMap.get(randomIndex);
@ -1191,7 +1213,7 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
dcWarningMapper.insertDispatchResource(dcDispatchResource);
}
List<HashMap<String, Object>> 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<String, Object> randomEmployee = employeesMap.get(randomIndex);
@ -1250,10 +1272,10 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> 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<DcEventMapper, DcEvent> impl
/**
* 调度记录
*
* @param dcEvent
* @return
*/
@ -1787,7 +1810,7 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> impl
dcEvent.setEventState(2l);
List<DcEvent> dcEvents = dcEventMapper.dispatchRecordEventList(dcEvent);
for (DcEvent event : dcEvents) {
List<DcEventProcess> dcEventProcess= dcEventProcessService.selectDcEventProcessByEventId(event.getId());
List<DcEventProcess> dcEventProcess = dcEventProcessService.selectDcEventProcessByEventId(event.getId());
event.setDcEventProcessList(dcEventProcess);
}
@ -1819,29 +1842,28 @@ public class DcEventServiceImpl extends ServiceImpl<DcEventMapper, DcEvent> 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<Map<String,Object>> result = new ArrayList<>();
List<Map<String, Object>> result = new ArrayList<>();
DcEvent dcEvent = dcEventMapper.selectDcEventById(eventId);
if (StringUtils.isNotEmpty(dcEvent.getLinkId())){
Map<String,Object> item = new HashMap<>();
item.put("eventId",eventId);
item.put("eventNature",dcEvent.getEventNature());
if (StringUtils.isNotEmpty(dcEvent.getLinkId())) {
Map<String, Object> 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);
}
}

4
zc-business/src/main/resources/mapper/business/DcEventMapper.xml

@ -816,12 +816,12 @@
<include refid="selectDcEventVo"/>
<where>
<if test="deptId != null ">and dept_id = #{deptId}</if>
<if test="id != null ">and id = #{id}</if>
<if test="stakeMark != null and stakeMark != ''">and stake_mark BETWEEN #{stakeMark} and #{endStakeMark}
</if>
<if test="direction != null and direction != ''">and direction = #{direction}</if>
<if test="userId != null ">and user_id = #{userId}</if>
<if test="startTime != null ">and start_time BETWEEN #{startTime} and #{endTime}</if>
<if test="estimatedEndTime != null ">and estimated_end_time = #{estimatedEndTime}</if>
<if test="endTime != null ">and end_time BETWEEN #{startTime} and #{endTime}</if>
<if test="eventLevel != null ">and event_level = #{eventLevel}</if>
<if test="eventType != null ">and event_type = #{eventType}</if>
<if test="eventSubclass != null and eventSubclass != ''">and event_subclass = #{eventSubclass}</if>

Loading…
Cancel
Save