Browse Source

处理语音广播控制,播放错误,没有记录日志问题

develop
Mr.Wang 8 months ago
parent
commit
fcb26effde
  1. 247
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

247
zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

@ -96,7 +96,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
stringBuilder.append(","); stringBuilder.append(",");
stringBuilder.append(dcDevice.getDeviceName()); stringBuilder.append(dcDevice.getDeviceName());
}); });
dcEmergencyPlans1.setControllableDeviceName(stringBuilder.toString().replaceFirst(",","")); dcEmergencyPlans1.setControllableDeviceName(stringBuilder.toString().replaceFirst(",", ""));
}); });
return dcEmergencyPlansList; return dcEmergencyPlansList;
} }
@ -181,7 +181,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
list.forEach(dcEmergencyPlans -> { list.forEach(dcEmergencyPlans -> {
List<DcExecuteAction> dcExecuteActions = dcEmergencyPlans.getDcExecuteAction(); List<DcExecuteAction> dcExecuteActions = dcEmergencyPlans.getDcExecuteAction();
dcExecuteActions.forEach(dcExecuteAction -> { dcExecuteActions.forEach(dcExecuteAction -> {
handleConfigurationData(dcExecuteAction,dcEvent,markArray); handleConfigurationData(dcExecuteAction, dcEvent, markArray);
}); });
}); });
} }
@ -191,7 +191,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
*/ */
public void handleConfigurationData(DcExecuteAction dcExecuteAction, public void handleConfigurationData(DcExecuteAction dcExecuteAction,
DcEvent dcEvent, DcEvent dcEvent,
String[] markArray){ String[] markArray) {
List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection()); List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection());
String devices = deviceList.stream() String devices = deviceList.stream()
.map(DcDevice::getIotDeviceId) .map(DcDevice::getIotDeviceId)
@ -207,10 +207,10 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (executeConfig.getString("operationType").equals("2")) { if (executeConfig.getString("operationType").equals("2")) {
// 说明是智能发布 // 说明是智能发布
String content = intelligentPublishingOfInformation(dcEvent); String content = intelligentPublishingOfInformation(dcEvent);
updateIntelligentPublishingContent(dcExecuteAction,markArray,deviceList,content,dcEvent.getDirection()); updateIntelligentPublishingContent(dcExecuteAction, markArray, deviceList, content, dcEvent.getDirection());
}else { } else {
// 说明是自定义发布 // 说明是自定义发布
customPublishingDataFormatProcessing(deviceList,executeConfig,dcExecuteAction.getDeviceType()); customPublishingDataFormatProcessing(deviceList, executeConfig, dcExecuteAction.getDeviceType());
dcExecuteAction.setExecuteConfig(executeConfig.toJSONString()); dcExecuteAction.setExecuteConfig(executeConfig.toJSONString());
} }
} }
@ -218,53 +218,55 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) { if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) {
if (recoverConfig.getString("operationType").equals("1")) { if (recoverConfig.getString("operationType").equals("1")) {
// 说明是恢复操作中的自定义发布 (只有情报板会走) // 说明是恢复操作中的自定义发布 (只有情报板会走)
customPublishingDataFormatProcessing(deviceList,recoverConfig,dcExecuteAction.getDeviceType()); customPublishingDataFormatProcessing(deviceList, recoverConfig, dcExecuteAction.getDeviceType());
}else { } else {
recoverConfig.remove("contentList"); recoverConfig.remove("contentList");
} }
dcExecuteAction.setRecoverConfig(recoverConfig.toJSONString()); dcExecuteAction.setRecoverConfig(recoverConfig.toJSONString());
} }
} }
/** /**
* 自定义发布数据格式处理 * 自定义发布数据格式处理
*/ */
public void customPublishingDataFormatProcessing(List<DcDevice> deviceList, JSONObject otherConfig, int deviceType) { public void customPublishingDataFormatProcessing(List<DcDevice> deviceList, JSONObject otherConfig, int deviceType) {
List<Map<String,Object>> contentList = new ArrayList<>(); List<Map<String, Object>> contentList = new ArrayList<>();
if (!ObjectUtils.isEmpty(otherConfig.get("contentList"))) { if (!ObjectUtils.isEmpty(otherConfig.get("contentList"))) {
contentList.addAll((List<Map<String,Object>>) otherConfig.get("contentList")); contentList.addAll((List<Map<String, Object>>) otherConfig.get("contentList"));
contentList.removeIf(cont -> deviceList.stream().noneMatch(device -> device.getId().toString().equals(cont.get("dcDeviceId").toString()))); contentList.removeIf(cont -> deviceList.stream().noneMatch(device -> device.getId().toString().equals(cont.get("dcDeviceId").toString())));
deviceList.forEach(dcDevice -> { deviceList.forEach(dcDevice -> {
boolean filter = contentList.stream().anyMatch(content -> boolean filter = contentList.stream().anyMatch(content ->
content.get("dcDeviceId").toString().equals(dcDevice.getId().toString())); content.get("dcDeviceId").toString().equals(dcDevice.getId().toString()));
if (!filter) { if (!filter) {
handleContentList(dcDevice,deviceType,otherConfig,contentList); handleContentList(dcDevice, deviceType, otherConfig, contentList);
} }
}); });
}else { } else {
deviceList.forEach(dcDevice -> { deviceList.forEach(dcDevice -> {
handleContentList(dcDevice,deviceType,otherConfig,contentList); handleContentList(dcDevice, deviceType, otherConfig, contentList);
}); });
} }
otherConfig.put("contentList",contentList); otherConfig.put("contentList", contentList);
} }
public void handleContentList(DcDevice dcDevice, int deviceType, JSONObject otherConfig, List<Map<String,Object>> contentList) { public void handleContentList(DcDevice dcDevice, int deviceType, JSONObject otherConfig, List<Map<String, Object>> contentList) {
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("dcDeviceId",dcDevice.getId()); map.put("dcDeviceId", dcDevice.getId());
map.put("deviceName",dcDevice.getDeviceName()); map.put("deviceName", dcDevice.getDeviceName());
if (deviceType == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) { if (deviceType == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) {
JSONObject dcInfoBoardTemplate = JSON.parseObject(otherConfig.get("dcInfoBoardTemplate").toString()); JSONObject dcInfoBoardTemplate = JSON.parseObject(otherConfig.get("dcInfoBoardTemplate").toString());
dcInfoBoardTemplate.keySet().forEach(key -> map.put(key, dcInfoBoardTemplate.get(key))); dcInfoBoardTemplate.keySet().forEach(key -> map.put(key, dcInfoBoardTemplate.get(key)));
}else { } else {
// 语音广播 // 语音广播
map.put("content",otherConfig.get("content")); map.put("content", otherConfig.get("content"));
} }
contentList.add(map); contentList.add(map);
} }
/** /**
* 交通事件-根据事件单个执行操作筛选设备 * 交通事件-根据事件单个执行操作筛选设备
*
* @param dcEventAnDcEmergencyPlans * @param dcEventAnDcEmergencyPlans
* @return * @return
*/ */
@ -283,6 +285,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
/** /**
* 设备管控-确认按钮生成内容 * 设备管控-确认按钮生成内容
*
* @param dcEventAnDcEmergencyPlans * @param dcEventAnDcEmergencyPlans
* @return * @return
*/ */
@ -296,7 +299,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
markArray[1] = String.format("%0" + 3 + "d", markArray[1]); markArray[1] = String.format("%0" + 3 + "d", markArray[1]);
} }
DcExecuteAction dcExecuteAction = dcEventAnDcEmergencyPlans.getDcExecuteAction(); DcExecuteAction dcExecuteAction = dcEventAnDcEmergencyPlans.getDcExecuteAction();
handleConfigurationData(dcExecuteAction,dcEvent,markArray); handleConfigurationData(dcExecuteAction, dcEvent, markArray);
return dcExecuteAction; return dcExecuteAction;
} }
@ -310,11 +313,11 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
String direction) { String direction) {
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig());
List<Map<String,Object>> contentList = new ArrayList<>(); List<Map<String, Object>> contentList = new ArrayList<>();
deviceList.forEach(dcDevice -> { deviceList.forEach(dcDevice -> {
Map<String,Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("dcDeviceId",dcDevice.getId()); map.put("dcDeviceId", dcDevice.getId());
map.put("deviceName",dcDevice.getDeviceName()); map.put("deviceName", dcDevice.getDeviceName());
// 公里数 // 公里数
int kilometers = 0; int kilometers = 0;
// 米数 // 米数
@ -328,20 +331,20 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (direction.equals("菏泽方向") || direction.equals("1")) { if (direction.equals("菏泽方向") || direction.equals("1")) {
kilometers = Math.abs(Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0])); kilometers = Math.abs(Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0]));
meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]); meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]);
}else { } else {
kilometers = Math.abs(Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0])); kilometers = Math.abs(Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]));
meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]); meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]);
} }
double roundedDistance = Math.round((kilometers + meters / 1000.0) * 10.0) / 10.0; double roundedDistance = Math.round((kilometers + meters / 1000.0) * 10.0) / 10.0;
if (roundedDistance < 1) { if (roundedDistance < 1) {
map.put("content",content.replace("*",(int) (roundedDistance * 1000)+"米")); map.put("content", content.replace("*", (int) (roundedDistance * 1000) + "米"));
}else { } else {
if (roundedDistance % 1 == 0) { if (roundedDistance % 1 == 0) {
// 去除掉1.0公里的情况 // 去除掉1.0公里的情况
map.put("content",content.replace("*",(int)roundedDistance+"公里")); map.put("content", content.replace("*", (int) roundedDistance + "公里"));
}else { } else {
map.put("content",content.replace("*",roundedDistance+"公里")); map.put("content", content.replace("*", roundedDistance + "公里"));
} }
} }
@ -367,7 +370,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
} }
contentList.add(map); contentList.add(map);
}); });
executeConfig.put("contentList",contentList); executeConfig.put("contentList", contentList);
dcExecuteAction.setExecuteConfig(executeConfig.toJSONString()); dcExecuteAction.setExecuteConfig(executeConfig.toJSONString());
} }
@ -401,7 +404,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
dcDevices.forEach(dcDevice -> { dcDevices.forEach(dcDevice -> {
threadPoolTaskExecutor.execute(() -> { threadPoolTaskExecutor.execute(() -> {
try { try {
if (StringUtils.isNotEmpty(dcDevice.getIotDeviceId())){ if (StringUtils.isNotEmpty(dcDevice.getIotDeviceId())) {
AjaxResult ajaxResult = dcDeviceController.getDeviceRealtimeProperty(dcDevice.getIotDeviceId(), "3A", new HashMap<>()); AjaxResult ajaxResult = dcDeviceController.getDeviceRealtimeProperty(dcDevice.getIotDeviceId(), "3A", new HashMap<>());
if (ajaxResult.get("code").equals(200)) { if (ajaxResult.get("code").equals(200)) {
JSONObject properties = JSON.parseObject(JSON.parseObject(ajaxResult.get("data").toString()).get("3A").toString()); JSONObject properties = JSON.parseObject(JSON.parseObject(ajaxResult.get("data").toString()).get("3A").toString());
@ -498,7 +501,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (dcDevices.size() > 0) { if (dcDevices.size() > 0) {
if (dcExecuteAction.getNumber() > dcDevices.size()) { if (dcExecuteAction.getNumber() > dcDevices.size()) {
dcDevices = dcDevices.subList(0, dcDevices.size()); dcDevices = dcDevices.subList(0, dcDevices.size());
}else { } else {
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber()); dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber());
} }
@ -521,7 +524,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (dcDevices.size() > 0) { if (dcDevices.size() > 0) {
if (dcExecuteAction.getNumber() > dcDevices.size()) { if (dcExecuteAction.getNumber() > dcDevices.size()) {
dcDevices = dcDevices.subList(0, dcDevices.size()); dcDevices = dcDevices.subList(0, dcDevices.size());
}else { } else {
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber()); dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber());
} }
} }
@ -547,7 +550,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (dcDevices.size() > 0) { if (dcDevices.size() > 0) {
if (dcExecuteAction.getNumber() > dcDevices.size()) { if (dcExecuteAction.getNumber() > dcDevices.size()) {
dcDevices = dcDevices.subList(0, dcDevices.size()); dcDevices = dcDevices.subList(0, dcDevices.size());
}else { } else {
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber()); dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber());
} }
} }
@ -571,7 +574,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (dcDevices.size() > 0) { if (dcDevices.size() > 0) {
if (dcExecuteAction.getNumber() > dcDevices.size()) { if (dcExecuteAction.getNumber() > dcDevices.size()) {
dcDevices = dcDevices.subList(0, dcDevices.size()); dcDevices = dcDevices.subList(0, dcDevices.size());
}else { } else {
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber()); dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber());
} }
} }
@ -605,7 +608,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// 菏泽方向 桩号增大 设备桩号要小于事件桩号 // 菏泽方向 桩号增大 设备桩号要小于事件桩号
kilometers = Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0]); kilometers = Integer.parseInt(markArray[0]) - Integer.parseInt(deviceMarkArray[0]);
meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]); meters = Integer.parseInt(markArray[1]) - Integer.parseInt(deviceMarkArray[1]);
}else { } else {
// 济南方向 桩号减小 设备桩号要大于事件桩号 // 济南方向 桩号减小 设备桩号要大于事件桩号
kilometers = Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]); kilometers = Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]);
meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]); meters = Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]);
@ -636,6 +639,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
/** /**
* 根据事件id-查询预案事件关联表 * 根据事件id-查询预案事件关联表
*
* @param eventId 事件id * @param eventId 事件id
* @return * @return
*/ */
@ -648,6 +652,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
/** /**
* 根据id-查询预案事件关联表 * 根据id-查询预案事件关联表
*
* @param id id * @param id id
* @return * @return
*/ */
@ -702,7 +707,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
Integer facilityId = dcEventVehicleAccident.getFacilityId(); Integer facilityId = dcEventVehicleAccident.getFacilityId();
DcFacility facility = dcFacilityService.getFacility(facilityId.toString()); DcFacility facility = dcFacilityService.getFacility(facilityId.toString());
String facilityName = facility.getFacilityName(); String facilityName = facility.getFacilityName();
content = "前方*"+facilityName+"发生车辆故障"; content = "前方*" + facilityName + "发生车辆故障";
} }
} else if (eventType == EventTypeEnum.TRAFFIC_CONTROL.getCode()) { } else if (eventType == EventTypeEnum.TRAFFIC_CONTROL.getCode()) {
@ -754,8 +759,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
.forEach(dcExecuteAction -> { .forEach(dcExecuteAction -> {
List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, direction); List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, direction);
JSONObject otherConfig = operationType.equals(1)? JSONObject otherConfig = operationType.equals(1) ?
JSON.parseObject(dcExecuteAction.getExecuteConfig()): JSON.parseObject(dcExecuteAction.getRecoverConfig()); JSON.parseObject(dcExecuteAction.getExecuteConfig()) : JSON.parseObject(dcExecuteAction.getRecoverConfig());
try { try {
// 根据不通设备类型,执行不通的功能操作 // 根据不通设备类型,执行不通的功能操作
invokedFunction( invokedFunction(
@ -794,7 +799,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
eventPlanAssoc.setCreateTime(DateUtils.getNowDate()); eventPlanAssoc.setCreateTime(DateUtils.getNowDate());
eventPlanAssoc.setControl(JSON.toJSONString(dcEmergencyPlans.getDcExecuteAction())); eventPlanAssoc.setControl(JSON.toJSONString(dcEmergencyPlans.getDcExecuteAction()));
eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc); eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc);
resultObject.put("eventPlanAssocId",eventPlanAssoc.getId()); resultObject.put("eventPlanAssocId", eventPlanAssoc.getId());
DcEventProcess dcEventProcess = new DcEventProcess(); DcEventProcess dcEventProcess = new DcEventProcess();
dcEventProcess.setEventId(id); dcEventProcess.setEventId(id);
@ -804,7 +809,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
dcEventProcess.setContext("设备管控"); dcEventProcess.setContext("设备管控");
dcEventProcessService.insertDcEventProcess(dcEventProcess); dcEventProcessService.insertDcEventProcess(dcEventProcess);
resultObject.put("deviceOperationResult",resultArray); resultObject.put("deviceOperationResult", resultArray);
return resultObject; return resultObject;
} }
@ -825,21 +830,21 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
HashMap<String, Object> props = new HashMap<>(); HashMap<String, Object> props = new HashMap<>();
// 构造设备控制记录数据格式 // 构造设备控制记录数据格式
List<HashMap<String, List<Map<String,Object>>>> propsList = new ArrayList<>(); List<HashMap<String, List<Map<String, Object>>>> propsList = new ArrayList<>();
// 调用状态 0正常 1异常 // 调用状态 0正常 1异常
Integer status = 0; Integer status = 0;
HashMap<String, List<Map<String,Object>>> proDevice = new HashMap<>(); HashMap<String, List<Map<String, Object>>> proDevice = new HashMap<>();
// devices // devices
List<Map<String,Object>> dev = new ArrayList<>(); List<Map<String, Object>> dev = new ArrayList<>();
Map<String,Object> deviceMap = new HashMap<>(); Map<String, Object> deviceMap = new HashMap<>();
deviceMap.put("id",device.getId()); deviceMap.put("id", device.getId());
deviceMap.put("iotDeviceId",device.getIotDeviceId()); deviceMap.put("iotDeviceId", device.getIotDeviceId());
deviceMap.put("deviceType",device.getDeviceType()); deviceMap.put("deviceType", device.getDeviceType());
dev.add(deviceMap); dev.add(deviceMap);
proDevice.put("devices",dev); proDevice.put("devices", dev);
// functions // functions
List<Map<String,Object>> functionList = new ArrayList<>(); List<Map<String, Object>> functionList = new ArrayList<>();
remark.append("在"); remark.append("在");
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
@ -862,16 +867,16 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
String endTime = otherConfig.get("endTime").toString(); String endTime = otherConfig.get("endTime").toString();
props.put("startDisplayTime", startTime); props.put("startDisplayTime", startTime);
props.put("endDisplayTime", endTime); props.put("endDisplayTime", endTime);
result.put("content","自动:"+stateName+";时间范围:"+startTime+"-"+endTime); result.put("content", "自动:" + stateName + ";时间范围:" + startTime + "-" + endTime);
} else if (controlModel.equals("00")) { } else if (controlModel.equals("00")) {
result.put("content","手动:"+stateName); result.put("content", "手动:" + stateName);
}else { } else {
result.put("content","万年历:"+stateName); result.put("content", "万年历:" + stateName);
} }
result.put("device", device.getId()); result.put("device", device.getId());
result.put("deviceName",device.getDeviceName()); result.put("deviceName", device.getDeviceName());
processingDeviceParameters(functionId,functionList,props); processingDeviceParameters(functionId, functionList, props);
AjaxResult ajaxResult = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props); AjaxResult ajaxResult = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props);
// 将调用结果存入到 resultArray(操作结果) 中 // 将调用结果存入到 resultArray(操作结果) 中
@ -879,7 +884,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (ajaxResult.get("code").equals(200)) { if (ajaxResult.get("code").equals(200)) {
status = 0; status = 0;
remark.append("成功"); remark.append("成功");
}else { } else {
status = 1; status = 1;
remark.append("失败"); remark.append("失败");
} }
@ -887,26 +892,25 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
resultArray.add(result); resultArray.add(result);
} } else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) {
else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) {
if (operationType == 2 && otherConfig.getString("operationType").equals("2")) { if (operationType == 2 && otherConfig.getString("operationType").equals("2")) {
// 还原上次 恢复操作 // 还原上次 恢复操作
props.put("fileId", "10"); props.put("fileId", "10");
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B; functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B;
processingDeviceParameters(functionId,functionList,props); processingDeviceParameters(functionId, functionList, props);
AjaxResult ajaxResult1B = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props); AjaxResult ajaxResult1B = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props);
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("device", device.getId()); result.put("device", device.getId());
result.put("deviceName",device.getDeviceName()); result.put("deviceName", device.getDeviceName());
result.put("content","还原上次"); result.put("content", "还原上次");
result.put("result", ajaxResult1B); result.put("result", ajaxResult1B);
resultArray.add(result); resultArray.add(result);
if (ajaxResult1B.get("code").equals(200)) { if (ajaxResult1B.get("code").equals(200)) {
status = 0; status = 0;
remark.append("成功"); remark.append("成功");
}else { } else {
status = 1; status = 1;
remark.append("失败"); remark.append("失败");
} }
@ -922,26 +926,25 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (foundContent == null) { if (foundContent == null) {
// 说明没有匹配到设备 // 说明没有匹配到设备
JSONObject errorResult = new JSONObject(); JSONObject errorResult = new JSONObject();
errorResult.put("device",device.getId()); errorResult.put("device", device.getId());
errorResult.put("content","未匹配到对应的模板内容"); errorResult.put("content", "未匹配到对应的模板内容");
resultArray.add(errorResult); resultArray.add(errorResult);
status = 1; status = 1;
remark.append("失败"); remark.append("失败");
}else { } else {
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("dcInfoBoardTemplate",foundContent); jsonObject.put("dcInfoBoardTemplate", foundContent);
status = boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray, functionList); status = boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray, functionList);
if (status.equals(0)) { if (status.equals(0)) {
remark.append("成功"); remark.append("成功");
}else { } else {
remark.append("失败"); remark.append("失败");
} }
} }
} }
} } else if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING.toString())
else if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING.toString())
&& operationType.equals(1)) { && operationType.equals(1)) {
// 路段广播 // 路段广播
JSONObject params = new JSONObject(); JSONObject params = new JSONObject();
@ -958,14 +961,14 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (foundContent == null) { if (foundContent == null) {
// 说明没有匹配到设备 // 说明没有匹配到设备
JSONObject errorResult = new JSONObject(); JSONObject errorResult = new JSONObject();
errorResult.put("device",device.getId()); errorResult.put("device", device.getId());
errorResult.put("deviceName",device.getDeviceName()); errorResult.put("deviceName", device.getDeviceName());
errorResult.put("content","未匹配到对应的广播内容"); errorResult.put("content", "未匹配到对应的广播内容");
resultArray.add(errorResult); resultArray.add(errorResult);
} }
if (StringUtils.isEmpty(foundContent.getString("content"))) { if (StringUtils.isEmpty(foundContent.getString("content"))) {
params.put("text", "山东高速欢迎您"); params.put("text", "山东高速欢迎您");
}else { } else {
params.put("text", foundContent.getString("content")); params.put("text", foundContent.getString("content"));
} }
@ -977,34 +980,32 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("device", device.getId()); result.put("device", device.getId());
result.put("deviceName",device.getDeviceName()); result.put("deviceName", device.getDeviceName());
result.put("content",params.get("text")); result.put("content", params.get("text"));
processingDeviceParameters("A1",functionList,props); processingDeviceParameters("A1", functionList, props);
JSONObject returnResult = broadcastController.nearCamListDistance(params); JSONObject returnResult = broadcastController.nearCamListDistance(params);
result.put("result", returnResult); result.put("result", returnResult);
resultArray.add(result); resultArray.add(result);
if (Objects.equals(returnResult.getString("retCode"), "0")) {
if (returnResult.get("retCode").equals("0")) {
status = 0; status = 0;
remark.append("成功"); remark.append("成功");
}else { } else {
status = 1; status = 1;
remark.append("失败"); remark.append("失败");
} }
} } else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING.toString())) {
else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING.toString())) {
// 激光疲劳唤醒 // 激光疲劳唤醒
HashMap<String,Object> map = new HashMap<>(); HashMap<String, Object> map = new HashMap<>();
map.put("SET",otherConfig.get("operationType").toString()); map.put("SET", otherConfig.get("operationType").toString());
JSONObject resultTime = new JSONObject(); JSONObject resultTime = new JSONObject();
resultTime.put("device", device.getId()); resultTime.put("device", device.getId());
resultTime.put("deviceName",device.getDeviceName()); resultTime.put("deviceName", device.getDeviceName());
processingDeviceParameters("SETMD",functionList,map); processingDeviceParameters("SETMD", functionList, map);
AjaxResult ajaxResultState = dcDeviceController.getAjaxResult(iotDeviceId, "SETMD", map); AjaxResult ajaxResultState = dcDeviceController.getAjaxResult(iotDeviceId, "SETMD", map);
resultTime.put("resultState", ajaxResultState); resultTime.put("resultState", ajaxResultState);
@ -1015,9 +1016,9 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
HashMap<String, Object> propsTime = new HashMap<>(); HashMap<String, Object> propsTime = new HashMap<>();
propsTime.put("SET", operationDuration); propsTime.put("SET", operationDuration);
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_SETTM; functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_SETTM;
resultTime.put("content","状态:"+name+";操作时长"+otherConfig.get("operationDuration")+"分钟"); resultTime.put("content", "状态:" + name + ";操作时长" + otherConfig.get("operationDuration") + "分钟");
processingDeviceParameters(functionId,functionList,propsTime); processingDeviceParameters(functionId, functionList, propsTime);
AjaxResult ajaxResult = dcDeviceController.getAjaxResult(iotDeviceId, functionId, propsTime); AjaxResult ajaxResult = dcDeviceController.getAjaxResult(iotDeviceId, functionId, propsTime);
resultTime.put("result", ajaxResult); resultTime.put("result", ajaxResult);
@ -1026,15 +1027,15 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (ajaxResultState.get("code").equals(200) && ajaxResult.get("code").equals(200)) { if (ajaxResultState.get("code").equals(200) && ajaxResult.get("code").equals(200)) {
status = 0; status = 0;
remark.append("成功"); remark.append("成功");
}else { } else {
status = 1; status = 1;
remark.append("失败"); remark.append("失败");
} }
} }
proDevice.put("functions",functionList); proDevice.put("functions", functionList);
propsList.add(proDevice); propsList.add(proDevice);
insertEquipmentControlRecordTable(device,propsList,resultArray,status,remark.toString()); insertEquipmentControlRecordTable(device, propsList, resultArray, status, remark.toString());
} catch (HttpException | IOException e) { } catch (HttpException | IOException e) {
log.error(e.toString()); log.error(e.toString());
throw new RuntimeException(e); throw new RuntimeException(e);
@ -1047,12 +1048,12 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* 调用设备参数存储格式 * 调用设备参数存储格式
*/ */
public void processingDeviceParameters(String functionId, public void processingDeviceParameters(String functionId,
List<Map<String,Object>> functionList, List<Map<String, Object>> functionList,
Object props) { Object props) {
// 调用设备参数存储格式 // 调用设备参数存储格式
Map<String,Object> functionMap = new HashMap<>(); Map<String, Object> functionMap = new HashMap<>();
functionMap.put("functionId",functionId); functionMap.put("functionId", functionId);
functionMap.put("params",props); functionMap.put("params", props);
functionList.add(functionMap); functionList.add(functionMap);
} }
@ -1064,7 +1065,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
JSONObject otherConfig, JSONObject otherConfig,
DcDevice device, DcDevice device,
JSONArray resultArray, JSONArray resultArray,
List<Map<String,Object>> functionList List<Map<String, Object>> functionList
) throws HttpException, IOException { ) throws HttpException, IOException {
String functionId = ""; String functionId = "";
Integer status = 0; Integer status = 0;
@ -1075,7 +1076,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
props.put("fileName", "play011.lst"); props.put("fileName", "play011.lst");
props.put("size", "65535"); props.put("size", "65535");
processingDeviceParameters(functionId,functionList,props); processingDeviceParameters(functionId, functionList, props);
AjaxResult ajaxResult11 = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props); AjaxResult ajaxResult11 = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props);
if (ajaxResult11.get("code").equals(200)) { if (ajaxResult11.get("code").equals(200)) {
@ -1109,35 +1110,35 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
list.add(parameters); list.add(parameters);
props11.put("parameters", list); props11.put("parameters", list);
processingDeviceParameters(functionId,functionList,props11); processingDeviceParameters(functionId, functionList, props11);
AjaxResult ajaxResult13 = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props11); AjaxResult ajaxResult13 = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props11);
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
result.put("device", device.getId()); result.put("device", device.getId());
result.put("deviceName",device.getDeviceName()); result.put("deviceName", device.getDeviceName());
if (ajaxResult13.get("code").equals(200)) { if (ajaxResult13.get("code").equals(200)) {
HashMap<String, Object> props1B = new HashMap<>(); HashMap<String, Object> props1B = new HashMap<>();
// 3: 执行1B功能码 // 3: 执行1B功能码
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B; functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B;
props1B.put("fileId", "11"); props1B.put("fileId", "11");
processingDeviceParameters(functionId,functionList,props1B); processingDeviceParameters(functionId, functionList, props1B);
AjaxResult ajaxResult1B = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props1B); AjaxResult ajaxResult1B = dcDeviceController.getAjaxResult(iotDeviceId, functionId, props1B);
if (ajaxResult1B.get("code").equals(200)) { if (ajaxResult1B.get("code").equals(200)) {
status = 0; status = 0;
}else { } else {
status = 1; status = 1;
} }
result.put("content",dcInfoBoardTemplate.getContent()); result.put("content", dcInfoBoardTemplate.getContent());
result.put("result", ajaxResult1B); result.put("result", ajaxResult1B);
} else { } else {
result.put("content","发布失败"); result.put("content", "发布失败");
result.put("result", ajaxResult13); result.put("result", ajaxResult13);
status = 1; status = 1;
} }
resultArray.add(result); resultArray.add(result);
}else { } else {
resultArray.add(ajaxResult11); resultArray.add(ajaxResult11);
status = 1; status = 1;
} }
@ -1148,7 +1149,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* 设备控制记录表插入 * 设备控制记录表插入
*/ */
public void insertEquipmentControlRecordTable(DcDevice dcDevice, public void insertEquipmentControlRecordTable(DcDevice dcDevice,
List<HashMap<String, List<Map<String,Object>>>> propsList, List<HashMap<String, List<Map<String, Object>>>> propsList,
JSONArray resultList, JSONArray resultList,
Integer status, Integer status,
String remark) { String remark) {
@ -1318,35 +1319,33 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
JSONObject jsonObject = JSON.parseObject(executeConfig); JSONObject jsonObject = JSON.parseObject(executeConfig);
if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.DRIVING_GUIDANCE) { if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.DRIVING_GUIDANCE) {
// 行车诱导 // 行车诱导
config.put("controlModelName",jsonObject.get("controlModelName")); config.put("controlModelName", jsonObject.get("controlModelName"));
config.put("name",jsonObject.get("name")); config.put("name", jsonObject.get("name"));
if (jsonObject.get("controlModel").toString().equals("01")) { if (jsonObject.get("controlModel").toString().equals("01")) {
config.put("time",jsonObject.get("startTime").toString() +"-"+jsonObject.get("endTime").toString()); config.put("time", jsonObject.get("startTime").toString() + "-" + jsonObject.get("endTime").toString());
} }
}else if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.VARIABLE_INFORMATION_FLAG ) { } else if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.VARIABLE_INFORMATION_FLAG) {
// 情报板 // 情报板
if (jsonObject.getString("operationType").equals("1")) { if (jsonObject.getString("operationType").equals("1")) {
JSONObject dcInfoBoardTemplate = JSON.parseObject(jsonObject.get("dcInfoBoardTemplate").toString()) ; JSONObject dcInfoBoardTemplate = JSON.parseObject(jsonObject.get("dcInfoBoardTemplate").toString());
config.put("content",dcInfoBoardTemplate.get("content")); config.put("content", dcInfoBoardTemplate.get("content"));
}else { } else {
config.put("operationType","智能发布"); config.put("operationType", "智能发布");
} }
} } else if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING) {
else if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING) {
// 语音广播 // 语音广播
if (jsonObject.getString("operationType").equals("1")) { if (jsonObject.getString("operationType").equals("1")) {
config.put("content",jsonObject.get("content")); config.put("content", jsonObject.get("content"));
}else { } else {
config.put("operationType","智能发布"); config.put("operationType", "智能发布");
} }
} } else if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.LASER_FATIGUE_AWAKENING) {
else if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.LASER_FATIGUE_AWAKENING) {
// 激光疲劳唤醒 // 激光疲劳唤醒
config.put("name",jsonObject.get("name")); config.put("name", jsonObject.get("name"));
config.put("operationDuration",jsonObject.get("operationDuration")+"分钟"); config.put("operationDuration", jsonObject.get("operationDuration") + "分钟");
} }
return JSON.toJSONString(config); return JSON.toJSONString(config);
}) })

Loading…
Cancel
Save