From a62fdd18f8310220e2623f2dcbe171fa2805db46 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Thu, 7 Mar 2024 08:47:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8B=E4=BB=B6=E7=A1=AE=E8=AE=A4=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E8=A1=A5=E5=85=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DcEmergencyPlansServiceImpl.java | 108 +++++++++++++----- 1 file changed, 82 insertions(+), 26 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java index bdbc39fd..29a55557 100644 --- a/zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java +++ b/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 -> { Integer searchRule = dcExecuteAction.getSearchRule(); List start = new ArrayList<>(); @@ -314,10 +314,11 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { // 根据设备id,获取设备集合 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); JSONObject otherConfig = JSON.parseObject(dcExecuteAction.getOtherConfig()); - JSONArray deviceList = JSONArray.parseArray(otherConfig.get("deviceList").toString()); - queryWrapper.in(DcDevice::getId, deviceList); + List deviceList = (List)otherConfig.get("deviceList"); + queryWrapper.in(DcDevice::getIotDeviceId, deviceList); dcDevices = dcDeviceService.list(queryWrapper); - } else if (searchRule.equals(2)) { + } + else if (searchRule.equals(2)) { // 事件上游最近 if (direction.equals("1")) { @@ -348,7 +349,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { // Collections.sort(dcDevices, comparator); // // 对dcDevices进行降序排序 // Collections.sort(dcDevices, comparator.reversed()); - } else if (searchRule.equals(3)) { + } + else if (searchRule.equals(3)) { // 事件下游最近 if (direction.equals("1")) { // 上行 取最大的几个 @@ -372,7 +374,8 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter); dcDevices = dcDevices.subList(dcDevices.size() - dcExecuteAction.getNumber(), dcDevices.size()); } - } else { + } + else { // 最近公里数 Integer kilometers = Integer.parseInt(markArray[0].replaceAll("K", "")); // 根据事件桩号、公里数 计算出 桩号范围 @@ -388,20 +391,21 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { 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 { // 根据不通设备类型,执行不通的功能操作 invokedFunction( dcDevices, JSON.parseObject(dcExecuteAction.getOtherConfig()), 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) { e.printStackTrace(); } @@ -416,14 +420,14 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { if (dcEventAnDcEmergencyPlans.getOperationType().equals(1)) { // 事件预案编号 eventPlanAssoc.setEmergencyPlansId(dcEmergencyPlans.getId()); - eventPlanAssoc.setExecutingControlDevice(deviceIds.toString().replaceFirst(",", "")); + eventPlanAssoc.setExecutingControlDevice(deviceIds.toString().replaceFirst(";", "")); eventPlanAssoc.setExecutingControlResult(resultArray.toJSONString()); eventPlanAssoc.setCreateTime(DateUtils.getNowDate()); return eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc); } else { EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc); selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate()); - selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(",", "")); + selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(";", "")); selectEventPlanAssoc.setRecoveredControlResult(resultArray.toJSONString()); return eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc); } @@ -432,7 +436,10 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { /** * 根据不通设备类型,执行不通的功能操作 */ - public void invokedFunction(List dcDevices, JSONObject otherConfig, JSONArray resultArray) throws HttpException, IOException { + public void invokedFunction( + List dcDevices, + JSONObject otherConfig, + JSONArray resultArray) throws HttpException, IOException { String iotDeviceId = ""; String functionId = ""; @@ -461,22 +468,71 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { 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)) { - // 可变信息标志 - functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG; -// props.put("") + // 可变信息标志 分三步 + // 1:执行11功能码 + 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 props11 = new HashMap<>(); + functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_13; + Map 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 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 { 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); + } }