Browse Source

事件确认代码补全

develop
Mr.Wang 12 months ago
parent
commit
a62fdd18f8
  1. 108
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

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

@ -299,7 +299,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
//获取事件预案中的 执行操作配置 //获取事件预案中的 执行操作配置
dcEmergencyPlans.getDcExecuteAction().stream() dcEmergencyPlans.getDcExecuteAction()
.forEach(dcExecuteAction -> { .forEach(dcExecuteAction -> {
Integer searchRule = dcExecuteAction.getSearchRule(); Integer searchRule = dcExecuteAction.getSearchRule();
List<String> start = new ArrayList<>(); List<String> start = new ArrayList<>();
@ -314,10 +314,11 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// 根据设备id,获取设备集合 // 根据设备id,获取设备集合
LambdaQueryWrapper<DcDevice> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DcDevice> queryWrapper = new LambdaQueryWrapper<>();
JSONObject otherConfig = JSON.parseObject(dcExecuteAction.getOtherConfig()); JSONObject otherConfig = JSON.parseObject(dcExecuteAction.getOtherConfig());
JSONArray deviceList = JSONArray.parseArray(otherConfig.get("deviceList").toString()); List<String> deviceList = (List<String>)otherConfig.get("deviceList");
queryWrapper.in(DcDevice::getId, deviceList); queryWrapper.in(DcDevice::getIotDeviceId, deviceList);
dcDevices = dcDeviceService.list(queryWrapper); dcDevices = dcDeviceService.list(queryWrapper);
} else if (searchRule.equals(2)) { }
else if (searchRule.equals(2)) {
// 事件上游最近 // 事件上游最近
if (direction.equals("1")) { if (direction.equals("1")) {
@ -348,7 +349,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// Collections.sort(dcDevices, comparator); // Collections.sort(dcDevices, comparator);
// // 对dcDevices进行降序排序 // // 对dcDevices进行降序排序
// Collections.sort(dcDevices, comparator.reversed()); // Collections.sort(dcDevices, comparator.reversed());
} else if (searchRule.equals(3)) { }
else if (searchRule.equals(3)) {
// 事件下游最近 // 事件下游最近
if (direction.equals("1")) { if (direction.equals("1")) {
// 上行 取最大的几个 // 上行 取最大的几个
@ -372,7 +374,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter); dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
dcDevices = dcDevices.subList(dcDevices.size() - dcExecuteAction.getNumber(), dcDevices.size()); dcDevices = dcDevices.subList(dcDevices.size() - dcExecuteAction.getNumber(), dcDevices.size());
} }
} else { }
else {
// 最近公里数 // 最近公里数
Integer kilometers = Integer.parseInt(markArray[0].replaceAll("K", "")); Integer kilometers = Integer.parseInt(markArray[0].replaceAll("K", ""));
// 根据事件桩号、公里数 计算出 桩号范围 // 根据事件桩号、公里数 计算出 桩号范围
@ -388,20 +391,21 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter); dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
} }
String deviceId = dcDevices.stream()
.map(DcDevice::getId)
.map(String::valueOf)
.collect(Collectors.joining(","));
// 存储设备id 到 deviceIds 中
deviceIds.append(",");
deviceIds.append(deviceId);
try { try {
// 根据不通设备类型,执行不通的功能操作 // 根据不通设备类型,执行不通的功能操作
invokedFunction( invokedFunction(
dcDevices, dcDevices,
JSON.parseObject(dcExecuteAction.getOtherConfig()), JSON.parseObject(dcExecuteAction.getOtherConfig()),
resultArray); resultArray);
// 记录操作过的设备id
String deviceId = dcDevices.stream()
.map(DcDevice::getId)
.map(String::valueOf)
.collect(Collectors.joining(","));
// 存储设备id 到 deviceIds 中
deviceIds.append(";");
deviceIds.append(deviceId);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -416,14 +420,14 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
if (dcEventAnDcEmergencyPlans.getOperationType().equals(1)) { if (dcEventAnDcEmergencyPlans.getOperationType().equals(1)) {
// 事件预案编号 // 事件预案编号
eventPlanAssoc.setEmergencyPlansId(dcEmergencyPlans.getId()); eventPlanAssoc.setEmergencyPlansId(dcEmergencyPlans.getId());
eventPlanAssoc.setExecutingControlDevice(deviceIds.toString().replaceFirst(",", "")); eventPlanAssoc.setExecutingControlDevice(deviceIds.toString().replaceFirst(";", ""));
eventPlanAssoc.setExecutingControlResult(resultArray.toJSONString()); eventPlanAssoc.setExecutingControlResult(resultArray.toJSONString());
eventPlanAssoc.setCreateTime(DateUtils.getNowDate()); eventPlanAssoc.setCreateTime(DateUtils.getNowDate());
return eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc); return eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc);
} else { } else {
EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc); EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc);
selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate()); selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate());
selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(",", "")); selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(";", ""));
selectEventPlanAssoc.setRecoveredControlResult(resultArray.toJSONString()); selectEventPlanAssoc.setRecoveredControlResult(resultArray.toJSONString());
return eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc); return eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc);
} }
@ -432,7 +436,10 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
/** /**
* 根据不通设备类型执行不通的功能操作 * 根据不通设备类型执行不通的功能操作
*/ */
public void invokedFunction(List<DcDevice> dcDevices, JSONObject otherConfig, JSONArray resultArray) throws HttpException, IOException { public void invokedFunction(
List<DcDevice> dcDevices,
JSONObject otherConfig,
JSONArray resultArray) throws HttpException, IOException {
String iotDeviceId = ""; String iotDeviceId = "";
String functionId = ""; String functionId = "";
@ -461,22 +468,71 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
props.put("mode", "02"); props.put("mode", "02");
} }
AjaxResult ajaxResult = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
// 将调用结果存入到 resultArray(操作结果) 中
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("result", ajaxResult);
resultArray.add(result);
} }
else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG)) { else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG)) {
// 可变信息标志 // 可变信息标志 分三步
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG; // 1:执行11功能码
// props.put("") functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_11;
props.put("fileName","play011.lst");
props.put("size","65535");
AjaxResult ajaxResult11 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
if (ajaxResult11.get("code").equals(200)) {
// 2:执行13功能码
HashMap<String, Object> props11 = new HashMap<>();
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_13;
Map<String,String> parameters = new HashMap<>();
// stopTime
parameters.put("STAY",otherConfig.get("STAY").toString());
// inScreenMode
parameters.put("ACTION",otherConfig.get("ACTION").toString());
// fontSpacing
parameters.put("SPEED",otherConfig.get("SPEED").toString());
// fontColor
parameters.put("COLOR",otherConfig.get("COLOR").toString());
// fontType
parameters.put("FONT",otherConfig.get("FONT").toString());
// fontSize
parameters.put("FONT_SIZE",otherConfig.get("FONT_SIZE").toString());
// content
parameters.put("CONTENT",otherConfig.get("CONTENT").toString());
// screenSize 768*64 宽度和高度
parameters.put("width",otherConfig.get("width").toString());
parameters.put("height",otherConfig.get("height").toString());
// formatStyle
parameters.put("formatStyle",otherConfig.get("formatStyle").toString());
props11.put("parameters",parameters);
AjaxResult ajaxResult13 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props11);
JSONObject result = new JSONObject();
if (ajaxResult13.get("code").equals(200)) {
HashMap<String, Object> props1B = new HashMap<>();
// 3: 执行1B功能码
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B;
props1B.put("fileId","11");
AjaxResult ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props1B);
result.put("device", device.getId());
result.put("result", ajaxResult1B);
resultArray.add(result);
}else {
result.put("device", device.getId());
result.put("result", ajaxResult13);
resultArray.add(result);
}
}
} }
else { else {
break; break;
} }
AjaxResult ajaxResult = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
// 将调用结果存入到 resultArray(操作结果) 中
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("result", ajaxResult);
resultArray.add(result);
} }
} }

Loading…
Cancel
Save