|
|
@ -20,6 +20,7 @@ import com.zc.business.mapper.EventPlanAssocMapper; |
|
|
|
import com.zc.business.service.DcEmergencyPlansService; |
|
|
|
import com.zc.business.service.DcExecuteActionService; |
|
|
|
import com.zc.business.service.IDcDeviceService; |
|
|
|
import com.zc.business.service.IDcFacilityService; |
|
|
|
import com.zc.common.core.httpclient.exception.HttpException; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
|
|
@ -50,6 +51,9 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
@Resource |
|
|
|
private EventPlanAssocMapper eventPlanAssocMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private IDcFacilityService dcFacilityService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
|
|
|
|
|
|
@ -110,8 +114,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
return dcEmergencyPlansList.stream() |
|
|
|
.filter(dcEmergencyPlans -> { |
|
|
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
|
|
|
// JSONObject triggerJson = JSONObject.parseObject(triggerMechanism);
|
|
|
|
// String eventSubclass = triggerJson.get("eventSubclass").toString();
|
|
|
|
return triggerMechanism.equals(event.getSubclass()); |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
@ -120,8 +122,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
return dcEmergencyPlansList.stream() |
|
|
|
.filter(dcEmergencyPlans -> { |
|
|
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
|
|
|
// JSONObject triggerJson = JSONObject.parseObject(triggerMechanism);
|
|
|
|
// String locationType = triggerJson.get("locationType").toString();
|
|
|
|
DcEventVehicleAccident dcEventVehicleAccident = event.getDcEventVehicleAccident(); |
|
|
|
String eventLocationType = dcEventVehicleAccident.getLocationType().toString(); |
|
|
|
return triggerMechanism.equals(eventLocationType); |
|
|
@ -132,9 +132,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
return dcEmergencyPlansList.stream() |
|
|
|
.filter(dcEmergencyPlans -> { |
|
|
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
|
|
|
// JSONObject triggerJson = JSONObject.parseObject(triggerMechanism);
|
|
|
|
// 分类
|
|
|
|
// Integer classify = Integer.parseInt(triggerJson.get("classify").toString());
|
|
|
|
// 事件--交通管制数据
|
|
|
|
DcEventTrafficControl dcEventTrafficControl = event.getDcEventTrafficControl(); |
|
|
|
Integer eventClassify = Integer.parseInt(dcEventTrafficControl.getClassify().toString()); |
|
|
@ -148,6 +145,110 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处置设备智能发布的内容 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void dispositionDeviceContent(List<DcEmergencyPlans> list, DcEvent dcEvent) { |
|
|
|
// 事件桩号
|
|
|
|
dcEvent.setStakeMark(dcEvent.getStakeMark().replace("K", "")); |
|
|
|
String[] markArray = dcEvent.getStakeMark().split("\\+"); |
|
|
|
if (markArray[1].length() < 3) { |
|
|
|
// 不足三位 补零
|
|
|
|
markArray[1] = String.format("%0" + 3 + "d", markArray[1]); |
|
|
|
} |
|
|
|
|
|
|
|
// 情报板 语音广播
|
|
|
|
list.forEach(dcEmergencyPlans -> { |
|
|
|
List<DcExecuteAction> dcExecuteActions = dcEmergencyPlans.getDcExecuteAction(); |
|
|
|
dcExecuteActions.forEach(dcExecuteAction -> { |
|
|
|
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); |
|
|
|
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.ROAD_SECTION_VOICE_BROADCASTING.getCode() |
|
|
|
&& executeConfig.get("operationType").equals("2")) { |
|
|
|
// 执行操作中智能发布语音广播
|
|
|
|
String content = intelligentPublishingOfInformation(dcEvent); |
|
|
|
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content,dcEvent.getDirection()); |
|
|
|
} else if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode() |
|
|
|
&& executeConfig.get("operationType").equals("2")) { |
|
|
|
// 执行操作中智能发布情报板
|
|
|
|
String content = intelligentPublishingOfInformation(dcEvent); |
|
|
|
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content,dcEvent.getDirection()); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 更改智能发布中的发布内容-计算公里数 |
|
|
|
*/ |
|
|
|
public void updateIntelligentPublishingContent(DcExecuteAction dcExecuteAction, |
|
|
|
String[] markArray, |
|
|
|
DcEvent dcEvent, |
|
|
|
String content, |
|
|
|
String direction) { |
|
|
|
List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection()); |
|
|
|
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); |
|
|
|
List<Map<String,Object>> contentList = new ArrayList<>(); |
|
|
|
deviceList.forEach(dcDevice -> { |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("dcDeviceId",dcDevice.getId()); |
|
|
|
map.put("deviceName",dcDevice.getDeviceName()); |
|
|
|
// 公里数
|
|
|
|
int kilometers = 0; |
|
|
|
// 米数
|
|
|
|
int meters = 0; |
|
|
|
dcDevice.setStakeMark(dcDevice.getStakeMark().replace("K", "")); |
|
|
|
String[] deviceMarkArray = dcDevice.getStakeMark().split("\\+"); |
|
|
|
if (deviceMarkArray[1].length() < 3) { |
|
|
|
// 不足三位 补零
|
|
|
|
deviceMarkArray[1] = String.format("%0" + 3 + "d", deviceMarkArray[1]); |
|
|
|
} |
|
|
|
if (direction.equals("菏泽方向") || direction.equals("1")) { |
|
|
|
kilometers = Math.abs(Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0])); |
|
|
|
meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]); |
|
|
|
}else { |
|
|
|
kilometers = Math.abs(Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0])); |
|
|
|
meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]); |
|
|
|
} |
|
|
|
|
|
|
|
double roundedDistance = Math.round((kilometers + meters / 1000.0) * 10.0) / 10.0; |
|
|
|
if (roundedDistance < 1) { |
|
|
|
map.put("content",content.replace("*",(int) (roundedDistance * 1000)+"米")); |
|
|
|
}else { |
|
|
|
if (roundedDistance % 1 == 0) { |
|
|
|
// 去除掉1.0公里的情况
|
|
|
|
map.put("content",content.replace("*",(int)roundedDistance+"公里")); |
|
|
|
}else { |
|
|
|
map.put("content",content.replace("*",roundedDistance+"公里")); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) { |
|
|
|
// 情报板
|
|
|
|
// stopTime
|
|
|
|
map.put("stopTime", "50"); |
|
|
|
// inScreenMode
|
|
|
|
map.put("inScreenMode", "1"); |
|
|
|
// fontSpacing
|
|
|
|
map.put("fontSpacing", "0"); |
|
|
|
// fontColor
|
|
|
|
map.put("fontColor", "ffff00"); |
|
|
|
// fontType
|
|
|
|
map.put("fontType", "1"); |
|
|
|
// fontSize
|
|
|
|
map.put("fontSize", "36"); |
|
|
|
// screenSize 768*64 宽度和高度
|
|
|
|
map.put("screenSize", "768*64"); |
|
|
|
// formatStyle
|
|
|
|
map.put("formatStyle", "2"); |
|
|
|
} |
|
|
|
contentList.add(map); |
|
|
|
}); |
|
|
|
executeConfig.put("contentList",contentList); |
|
|
|
dcExecuteAction.setExecuteConfig(executeConfig.toJSONString()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 感知事件 - 根据事件类型查询事件预案 |
|
|
|
* |
|
|
@ -196,8 +297,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
markArray[1] = String.format("%0" + 3 + "d", markArray[1]); |
|
|
|
} |
|
|
|
DcExecuteAction executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction(); |
|
|
|
Integer operationType = dcEventAnDcEmergencyPlans.getOperationType(); |
|
|
|
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction, operationType); |
|
|
|
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction); |
|
|
|
return getBoardTemplate(dcDevices); |
|
|
|
} |
|
|
|
|
|
|
@ -218,8 +318,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
markArray[1] = String.format("%0" + 3 + "d", markArray[1]); |
|
|
|
} |
|
|
|
DcExecuteAction executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction(); |
|
|
|
Integer operationType = dcEventAnDcEmergencyPlans.getOperationType(); |
|
|
|
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction, operationType); |
|
|
|
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction); |
|
|
|
return getBoardTemplate(dcDevices); |
|
|
|
} |
|
|
|
|
|
|
@ -289,12 +388,9 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
* @param direction |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<DcDevice> ruleFiltering(DcExecuteAction dcExecuteAction, String[] markArray, String direction, Integer operationType) { |
|
|
|
public List<DcDevice> ruleFiltering(DcExecuteAction dcExecuteAction, String[] markArray, String direction) { |
|
|
|
|
|
|
|
Integer searchRule = dcExecuteAction.getSearchRule(); |
|
|
|
// 区分执行操作还是恢复操作
|
|
|
|
JSONObject otherConfig = operationType.equals(1)? |
|
|
|
JSON.parseObject(dcExecuteAction.getExecuteConfig()): JSON.parseObject(dcExecuteAction.getRecoverConfig()); |
|
|
|
List<String> start = new ArrayList<>(); |
|
|
|
List<String> end = new ArrayList<>(); |
|
|
|
// 设备列表
|
|
|
@ -306,13 +402,13 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
// 指定设备资源
|
|
|
|
// 根据设备id,获取设备集合
|
|
|
|
LambdaQueryWrapper<DcDevice> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
List<String> deviceList = (List<String>) otherConfig.get("deviceList"); |
|
|
|
String[] deviceList = dcExecuteAction.getDeviceList().split(","); |
|
|
|
queryWrapper.in(DcDevice::getIotDeviceId, deviceList); |
|
|
|
dcDevices = dcDeviceService.list(queryWrapper); |
|
|
|
} else if (searchRule.equals(2)) { |
|
|
|
|
|
|
|
// 事件上游最近
|
|
|
|
if (direction.equals("菏泽方向")) { |
|
|
|
if (direction.equals("菏泽方向") || direction.equals("1")) { |
|
|
|
// 上行 取最大的几个
|
|
|
|
start.add("55"); |
|
|
|
start.add("379"); |
|
|
@ -351,8 +447,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
} |
|
|
|
|
|
|
|
} else if (searchRule.equals(3)) { |
|
|
|
// 事件下游最近
|
|
|
|
if (direction.equals("菏泽方向")) { |
|
|
|
// 事件下游最近 没有这个类型
|
|
|
|
if (direction.equals("菏泽方向") || direction.equals("1")) { |
|
|
|
// 上行 取最大的几个
|
|
|
|
start.add(markArray[0]); |
|
|
|
start.add(markArray[1]); |
|
|
@ -406,8 +502,29 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
// 根据桩号范围,查询附近设备
|
|
|
|
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter); |
|
|
|
} |
|
|
|
|
|
|
|
return dcDevices; |
|
|
|
//将0公里和负数的设备去掉
|
|
|
|
return dcDevices.stream() |
|
|
|
.filter(device -> { |
|
|
|
device.setStakeMark(device.getStakeMark().replace("K", "")); |
|
|
|
String[] deviceMarkArray = device.getStakeMark().split("\\+"); |
|
|
|
if (deviceMarkArray[1].length() < 3) { |
|
|
|
deviceMarkArray[1] = String.format("%0" + 3 + "d", deviceMarkArray[1]); |
|
|
|
} |
|
|
|
int kilometers = 0; |
|
|
|
int meters = 0; |
|
|
|
if (direction.equals("菏泽方向") || direction.equals("1")) { |
|
|
|
// 菏泽方向 桩号增大 设备桩号要小于事件桩号
|
|
|
|
kilometers = Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0]); |
|
|
|
meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]); |
|
|
|
}else { |
|
|
|
// 济南方向 桩号减小 设备桩号要大于事件桩号
|
|
|
|
kilometers = Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]); |
|
|
|
meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]); |
|
|
|
} |
|
|
|
double roundedDistance = Math.round((kilometers + meters / 1000.0) * 10.0) / 10.0; |
|
|
|
return kilometers >= 0 && roundedDistance > 0; |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -418,7 +535,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public JSONArray executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { |
|
|
|
public JSONObject executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { |
|
|
|
// 获取事件数据
|
|
|
|
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent(); |
|
|
|
// 方向
|
|
|
@ -478,8 +595,17 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
@Override |
|
|
|
public DcInfoBoardTemplate eventAutomaticGeneration(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { |
|
|
|
// 根据交通事件的事件类型,生成相应的情报板内容
|
|
|
|
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent(); |
|
|
|
DcInfoBoardTemplate dcInfoBoardTemplate = dcEventAnDcEmergencyPlans.getDcInfoBoardTemplate(); |
|
|
|
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent(); |
|
|
|
dcInfoBoardTemplate.setContent(intelligentPublishingOfInformation(dcEvent)); |
|
|
|
return dcInfoBoardTemplate; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 智能发布信息匹配 |
|
|
|
*/ |
|
|
|
public String intelligentPublishingOfInformation(DcEvent dcEvent) { |
|
|
|
String content = "请注意前方危险"; |
|
|
|
int eventType = Integer.parseInt(dcEvent.getEventType().toString()); |
|
|
|
if (eventType == EventTypeEnum.ABNORMAL_WEATHER.getCode() || |
|
|
|
eventType == EventTypeEnum.TRAFFIC_ACCIDENT.getCode() || |
|
|
@ -488,42 +614,41 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
eventType == EventTypeEnum.SERVICE_AREA_ABNORMALITY.getCode() || |
|
|
|
eventType == EventTypeEnum.ROADBLOCK_CLEARANCE.getCode()) { |
|
|
|
|
|
|
|
String content = Arrays.stream(EventSubclassEnum.values()) |
|
|
|
content = Arrays.stream(EventSubclassEnum.values()) |
|
|
|
.filter(eventSubclassEnum -> eventSubclassEnum.getCode().equals(dcEvent.getSubclass())) |
|
|
|
.findFirst() |
|
|
|
.map(EventSubclassEnum::getText) |
|
|
|
.orElse("请注意前方危险"); |
|
|
|
dcInfoBoardTemplate.setContent(content); |
|
|
|
} else if (eventType == EventTypeEnum.VEHICLE_MALFUNCTION.getCode()) { |
|
|
|
// 车辆故障
|
|
|
|
DcEventVehicleAccident dcEventVehicleAccident = dcEvent.getDcEventVehicleAccident(); |
|
|
|
int locationType = Integer.parseInt(dcEventVehicleAccident.getLocationType().toString()); |
|
|
|
// 路广设施id
|
|
|
|
Integer facilityId = dcEventVehicleAccident.getFacilityId(); |
|
|
|
DcFacility facility = dcFacilityService.getFacility(facilityId.toString()); |
|
|
|
String facilityName = facility.getFacilityName(); |
|
|
|
if (locationType == 1) { |
|
|
|
dcInfoBoardTemplate.setContent("高速主线发生车辆故障"); |
|
|
|
} else if (locationType == 2) { |
|
|
|
dcInfoBoardTemplate.setContent("服务区发生车辆故障"); |
|
|
|
} else if (locationType == 3) { |
|
|
|
dcInfoBoardTemplate.setContent("立交桥发生车辆故障"); |
|
|
|
} else if (locationType == 4) { |
|
|
|
dcInfoBoardTemplate.setContent("收费站发生车辆故障"); |
|
|
|
content = "前方*高速主线发生车辆故障"; |
|
|
|
} else if (locationType == 2 || locationType == 3 || locationType == 4) { |
|
|
|
// 服务区、立交、收费站
|
|
|
|
content = "前方*"+facilityName+"发生车辆故障"; |
|
|
|
} |
|
|
|
|
|
|
|
} else if (eventType == EventTypeEnum.TRAFFIC_CONTROL.getCode()) { |
|
|
|
// 交通管制
|
|
|
|
DcEventTrafficControl dcEventTrafficControl = dcEvent.getDcEventTrafficControl(); |
|
|
|
int classify = Integer.parseInt(dcEventTrafficControl.getClassify().toString()); |
|
|
|
String content = Arrays.stream(ClassifyEnum.values()) |
|
|
|
content = Arrays.stream(ClassifyEnum.values()) |
|
|
|
.filter(eventSubclassEnum -> eventSubclassEnum.getCode() == classify) |
|
|
|
.findFirst() |
|
|
|
.map(ClassifyEnum::getText) |
|
|
|
.orElse("前方存在限行或关闭"); |
|
|
|
dcInfoBoardTemplate.setContent(content); |
|
|
|
.orElse("前方*存在限行或关闭"); |
|
|
|
|
|
|
|
} else { |
|
|
|
// 施工建设
|
|
|
|
dcInfoBoardTemplate.setContent("前方施工请注意驾驶"); |
|
|
|
content = "前方*施工请注意驾驶"; |
|
|
|
} |
|
|
|
return dcInfoBoardTemplate; |
|
|
|
return content; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -533,7 +658,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public JSONArray executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { |
|
|
|
public JSONObject executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { |
|
|
|
// 获取事件数据
|
|
|
|
DcWarning dcWarning = dcEventAnDcEmergencyPlans.getDcWarning(); |
|
|
|
|
|
|
@ -550,7 +675,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
* @param dcEventAnDcEmergencyPlans 事件数据 和 事件预案数据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public JSONArray executionConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans, |
|
|
|
public JSONObject executionConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans, |
|
|
|
String stakeMark, |
|
|
|
String direction, |
|
|
|
String id) { |
|
|
@ -574,7 +699,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
//获取事件预案中的操作配置
|
|
|
|
dcEmergencyPlans.getDcExecuteAction() |
|
|
|
.forEach(dcExecuteAction -> { |
|
|
|
List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, direction, operationType); |
|
|
|
List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, direction); |
|
|
|
JSONObject otherConfig = operationType.equals(1)? |
|
|
|
JSON.parseObject(dcExecuteAction.getExecuteConfig()): JSON.parseObject(dcExecuteAction.getRecoverConfig()); |
|
|
|
try { |
|
|
@ -600,23 +725,26 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
}); |
|
|
|
// 创建一个 预案事件关联对象
|
|
|
|
EventPlanAssoc eventPlanAssoc = new EventPlanAssoc(); |
|
|
|
JSONObject resultObject = new JSONObject(); |
|
|
|
// 事件编号
|
|
|
|
eventPlanAssoc.setEventId(id); |
|
|
|
EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc); |
|
|
|
// 区分是执行操作 还是 恢复操作
|
|
|
|
if (dcEventAnDcEmergencyPlans.getOperationType().equals(1) && StringUtils.isEmpty(selectEventPlanAssoc.getId())) { |
|
|
|
if (dcEventAnDcEmergencyPlans.getOperationType().equals(1) && selectEventPlanAssoc == null) { |
|
|
|
// 首次执行操作
|
|
|
|
eventPlanAssoc.setEmergencyPlansId(dcEmergencyPlans.getId()); |
|
|
|
eventPlanAssoc.setExecutingControlDevice(deviceIds.toString().replaceFirst(";", "")); |
|
|
|
eventPlanAssoc.setExecutingControlResult(resultArray.toJSONString()); |
|
|
|
eventPlanAssoc.setCreateTime(DateUtils.getNowDate()); |
|
|
|
eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc); |
|
|
|
int eventPlanAssocId = eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc); |
|
|
|
resultObject.put("eventPlanAssocId",eventPlanAssocId); |
|
|
|
} |
|
|
|
else if (StringUtils.isNotEmpty(selectEventPlanAssoc.getId()) && dcEventAnDcEmergencyPlans.getOperationType().equals(1)) { |
|
|
|
// 多次执行操作
|
|
|
|
selectEventPlanAssoc.setExecutingControlResult(resultArray.toJSONString()); |
|
|
|
selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate()); |
|
|
|
eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc); |
|
|
|
resultObject.put("eventPlanAssocId",selectEventPlanAssoc.getId()); |
|
|
|
} |
|
|
|
else { |
|
|
|
// 恢复操作 未执行的事件不能进行恢复操作
|
|
|
@ -624,8 +752,10 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(";", "")); |
|
|
|
selectEventPlanAssoc.setRecoveredControlResult(resultArray.toJSONString()); |
|
|
|
eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc); |
|
|
|
resultObject.put("eventPlanAssocId",selectEventPlanAssoc.getId()); |
|
|
|
} |
|
|
|
return resultArray; |
|
|
|
resultObject.put("deviceOperationResult",resultArray); |
|
|
|
return resultObject; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -635,7 +765,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
List<DcDevice> dcDevices, |
|
|
|
JSONObject otherConfig, |
|
|
|
JSONArray resultArray) { |
|
|
|
|
|
|
|
CountDownLatch latch = new CountDownLatch(dcDevices.size()); |
|
|
|
|
|
|
|
for (DcDevice device : dcDevices) { |
|
|
|
|
|
|
@ -673,7 +803,28 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) { |
|
|
|
if (operationType == 1) { |
|
|
|
// 情报板发布全流程
|
|
|
|
boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray); |
|
|
|
if (otherConfig.get("operationType").equals("2")) { |
|
|
|
JSONArray contentList = JSON.parseArray(otherConfig.get("contentList").toString()); |
|
|
|
JSONObject foundContent = contentList.stream() |
|
|
|
.map(content -> JSON.parseObject(content.toString())) |
|
|
|
.filter(jsonObject -> |
|
|
|
Integer.parseInt(jsonObject.get("dcDeviceId").toString()) == device.getId()) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
|
if (foundContent == null) { |
|
|
|
// 说明没有匹配到设备
|
|
|
|
JSONObject errorResult = new JSONObject(); |
|
|
|
errorResult.put("device",device.getId()); |
|
|
|
errorResult.put("errorMessage","未匹配到对应的模板内容"); |
|
|
|
resultArray.add(errorResult); |
|
|
|
} |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.put("dcInfoBoardTemplate",foundContent); |
|
|
|
boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray); |
|
|
|
}else { |
|
|
|
boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
// 恢复操作
|
|
|
|
if (otherConfig.get("operationType").equals("2")) { |
|
|
@ -702,7 +853,26 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
params.put("name", "task-event"); |
|
|
|
params.put("outVVol", "8"); |
|
|
|
params.put("priority", "1"); |
|
|
|
params.put("text", otherConfig.get("content")); |
|
|
|
if (otherConfig.get("operationType").equals("2")) { |
|
|
|
// 智能发布
|
|
|
|
JSONArray contentList = JSON.parseArray(otherConfig.get("contentList").toString()); |
|
|
|
JSONObject foundContent = contentList.stream() |
|
|
|
.map(content -> JSON.parseObject(content.toString())) |
|
|
|
.filter(jsonObject -> |
|
|
|
Integer.parseInt(jsonObject.get("dcDeviceId").toString()) == device.getId()) |
|
|
|
.findFirst() |
|
|
|
.orElse(null); |
|
|
|
if (foundContent == null) { |
|
|
|
// 说明没有匹配到设备
|
|
|
|
JSONObject errorResult = new JSONObject(); |
|
|
|
errorResult.put("device",device.getId()); |
|
|
|
errorResult.put("errorMessage","未匹配到对应的广播内容"); |
|
|
|
resultArray.add(errorResult); |
|
|
|
} |
|
|
|
params.put("text", foundContent.get("content")); |
|
|
|
}else { |
|
|
|
params.put("text", otherConfig.get("content")); |
|
|
|
} |
|
|
|
params.put("repeatTimes", "3"); |
|
|
|
params.put("functionType", "startPaTts"); |
|
|
|
JSONArray termList = new JSONArray(); |
|
|
@ -743,10 +913,18 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
} catch (HttpException | IOException e) { |
|
|
|
log.error(e.toString()); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} finally { |
|
|
|
latch.countDown(); // 确保在异常情况下也能减少CountDownLatch计数
|
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
latch.await(); // 等待所有线程执行完毕
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -889,11 +1067,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
return dcExecuteActionService.updateDcExecuteActionBatch(dcExecuteActionList); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public int updateBatchDcEmergencyPlans(List<DcEmergencyPlans> dcEmergencyPlansList) { |
|
|
|
return 0; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 批量删除事件预案 |
|
|
|
* |
|
|
|