|
|
@ -170,28 +170,71 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
list.forEach(dcEmergencyPlans -> { |
|
|
|
List<DcExecuteAction> dcExecuteActions = dcEmergencyPlans.getDcExecuteAction(); |
|
|
|
dcExecuteActions.forEach(dcExecuteAction -> { |
|
|
|
List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection()); |
|
|
|
String devices = deviceList.stream() |
|
|
|
.map(DcDevice::getIotDeviceId) |
|
|
|
.map(String::valueOf) |
|
|
|
.collect(Collectors.joining(",")); |
|
|
|
dcExecuteAction.setDeviceList(devices); |
|
|
|
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); |
|
|
|
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.ROAD_SECTION_VOICE_BROADCASTING.getCode() |
|
|
|
&& executeConfig.getString("operationType").equals("2")) { |
|
|
|
// 执行操作中智能发布语音广播
|
|
|
|
String content = intelligentPublishingOfInformation(dcEvent); |
|
|
|
updateIntelligentPublishingContent(dcExecuteAction,markArray,deviceList,content,dcEvent.getDirection()); |
|
|
|
} else if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode() |
|
|
|
&& executeConfig.getString("operationType").equals("2")) { |
|
|
|
// 执行操作中智能发布情报板
|
|
|
|
String content = intelligentPublishingOfInformation(dcEvent); |
|
|
|
updateIntelligentPublishingContent(dcExecuteAction,markArray,deviceList,content,dcEvent.getDirection()); |
|
|
|
} |
|
|
|
handleConfigurationData(dcExecuteAction,dcEvent,markArray); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 处理executeConfig和recoverConfig中的配置数据 |
|
|
|
*/ |
|
|
|
public void handleConfigurationData(DcExecuteAction dcExecuteAction, |
|
|
|
DcEvent dcEvent, |
|
|
|
String[] markArray){ |
|
|
|
List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection()); |
|
|
|
String devices = deviceList.stream() |
|
|
|
.map(DcDevice::getIotDeviceId) |
|
|
|
.filter(java.util.Objects::nonNull) |
|
|
|
.collect(Collectors.joining(",")); |
|
|
|
dcExecuteAction.setDeviceList(devices); |
|
|
|
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); |
|
|
|
JSONObject recoverConfig = JSON.parseObject(dcExecuteAction.getRecoverConfig()); |
|
|
|
|
|
|
|
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.ROAD_SECTION_VOICE_BROADCASTING.getCode() || |
|
|
|
dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) { |
|
|
|
// 修改执行操作数据内容
|
|
|
|
if (executeConfig.getString("operationType").equals("2")) { |
|
|
|
// 说明是智能发布
|
|
|
|
String content = intelligentPublishingOfInformation(dcEvent); |
|
|
|
updateIntelligentPublishingContent(dcExecuteAction,markArray,deviceList,content,dcEvent.getDirection()); |
|
|
|
}else { |
|
|
|
// 说明是自定义发布
|
|
|
|
customPublishingDataFormatProcessing(deviceList,executeConfig,dcExecuteAction.getDeviceType()); |
|
|
|
dcExecuteAction.setExecuteConfig(executeConfig.toJSONString()); |
|
|
|
} |
|
|
|
} |
|
|
|
// 语音广播没有恢复操作
|
|
|
|
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) { |
|
|
|
if (recoverConfig.getString("operationType").equals("1")) { |
|
|
|
// 说明是恢复操作中的自定义发布 (只有情报板会走)
|
|
|
|
customPublishingDataFormatProcessing(deviceList,recoverConfig,dcExecuteAction.getDeviceType()); |
|
|
|
}else { |
|
|
|
recoverConfig.remove("contentList"); |
|
|
|
} |
|
|
|
dcExecuteAction.setRecoverConfig(recoverConfig.toJSONString()); |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
* 自定义发布数据格式处理 |
|
|
|
*/ |
|
|
|
public void customPublishingDataFormatProcessing(List<DcDevice> deviceList, JSONObject otherConfig, int deviceType) { |
|
|
|
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()); |
|
|
|
if (deviceType == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) { |
|
|
|
JSONObject dcInfoBoardTemplate = JSON.parseObject(otherConfig.get("dcInfoBoardTemplate").toString()); |
|
|
|
dcInfoBoardTemplate.keySet().forEach(key -> map.put(key, dcInfoBoardTemplate.get(key))); |
|
|
|
}else { |
|
|
|
// 语音广播
|
|
|
|
map.put("content",otherConfig.get("content")); |
|
|
|
} |
|
|
|
contentList.add(map); |
|
|
|
}); |
|
|
|
otherConfig.put("contentList",contentList); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 交通事件-根据事件、单个执行操作筛选设备 |
|
|
|
* @param dcEventAnDcEmergencyPlans |
|
|
@ -225,22 +268,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
markArray[1] = String.format("%0" + 3 + "d", markArray[1]); |
|
|
|
} |
|
|
|
DcExecuteAction dcExecuteAction = dcEventAnDcEmergencyPlans.getDcExecuteAction(); |
|
|
|
List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection()); |
|
|
|
String devices = dcDevices.stream() |
|
|
|
.map(DcDevice::getIotDeviceId) |
|
|
|
.map(String::valueOf) |
|
|
|
.collect(Collectors.joining(",")); |
|
|
|
dcExecuteAction.setDeviceList(devices); |
|
|
|
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); |
|
|
|
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.ROAD_SECTION_VOICE_BROADCASTING.getCode() || |
|
|
|
dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) { |
|
|
|
// 修改执行操作数据内容
|
|
|
|
if (executeConfig.getString("operationType").equals("2")) { |
|
|
|
// 说明是智能发布
|
|
|
|
String content = intelligentPublishingOfInformation(dcEvent); |
|
|
|
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcDevices,content,dcEvent.getDirection()); |
|
|
|
} |
|
|
|
} |
|
|
|
handleConfigurationData(dcExecuteAction,dcEvent,markArray); |
|
|
|
return dcExecuteAction; |
|
|
|
} |
|
|
|
|
|
|
@ -252,7 +280,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
List<DcDevice> deviceList, |
|
|
|
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 -> { |
|
|
@ -779,48 +807,38 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
|
|
|
|
} |
|
|
|
else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) { |
|
|
|
if (operationType == 1) { |
|
|
|
if (operationType == 2 && otherConfig.getString("operationType").equals("2")) { |
|
|
|
// 还原上次 恢复操作
|
|
|
|
props.put("fileId", "10"); |
|
|
|
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B; |
|
|
|
AjaxResult ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props); |
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("deviceName",device.getDeviceName()); |
|
|
|
result.put("content","还原上次"); |
|
|
|
result.put("result", ajaxResult1B); |
|
|
|
resultArray.add(result); |
|
|
|
} else { |
|
|
|
// 情报板发布全流程
|
|
|
|
if (otherConfig.getString("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); |
|
|
|
} |
|
|
|
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); |
|
|
|
}else { |
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
jsonObject.put("dcInfoBoardTemplate",foundContent); |
|
|
|
boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray); |
|
|
|
}else { |
|
|
|
boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
// 恢复操作
|
|
|
|
if (otherConfig.getString("operationType").equals("2")) { |
|
|
|
// 还原上次
|
|
|
|
props.put("fileId", "10"); |
|
|
|
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B; |
|
|
|
|
|
|
|
AjaxResult ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props); |
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("deviceName",device.getDeviceName()); |
|
|
|
result.put("content","还原上次"); |
|
|
|
result.put("result", ajaxResult1B); |
|
|
|
resultArray.add(result); |
|
|
|
}else { |
|
|
|
// 播放自定义
|
|
|
|
boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -831,27 +849,27 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
params.put("name", "task-event"); |
|
|
|
params.put("outVVol", "8"); |
|
|
|
params.put("priority", "1"); |
|
|
|
if (otherConfig.getString("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("deviceName",device.getDeviceName()); |
|
|
|
errorResult.put("errorMessage","未匹配到对应的广播内容"); |
|
|
|
resultArray.add(errorResult); |
|
|
|
} |
|
|
|
params.put("text", foundContent.get("content")); |
|
|
|
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("deviceName",device.getDeviceName()); |
|
|
|
errorResult.put("errorMessage","未匹配到对应的广播内容"); |
|
|
|
resultArray.add(errorResult); |
|
|
|
} |
|
|
|
if (StringUtils.isEmpty(foundContent.getString("content"))) { |
|
|
|
params.put("text", "山东高速欢迎您"); |
|
|
|
}else { |
|
|
|
params.put("text", otherConfig.get("content")); |
|
|
|
params.put("text", foundContent.getString("content")); |
|
|
|
} |
|
|
|
|
|
|
|
params.put("repeatTimes", "3"); |
|
|
|
params.put("functionType", "startPaTts"); |
|
|
|
JSONArray termList = new JSONArray(); |
|
|
|