From b07864492dcaf227bbaa5fa7ac465e6b593ec9a4 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Tue, 26 Mar 2024 17:37:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=8B=E4=BB=B6=E7=A1=AE?= =?UTF-8?q?=E8=AE=A4=E4=BB=A3=E7=A0=81=20=E5=A2=9E=E5=8A=A0=E6=A0=B9?= =?UTF-8?q?=E6=8D=AE=E4=BA=8B=E4=BB=B6id-=E6=9F=A5=E8=AF=A2=E9=A2=84?= =?UTF-8?q?=E6=A1=88=E4=BA=8B=E4=BB=B6=E5=85=B3=E8=81=94=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcEmergencyPlansController.java | 9 +++++ .../service/DcEmergencyPlansService.java | 8 ++++ .../impl/DcEmergencyPlansServiceImpl.java | 37 ++++++++++++++----- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java b/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java index 1163548e..d6b84c89 100644 --- a/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java +++ b/zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java @@ -126,6 +126,15 @@ public class DcEmergencyPlansController extends BaseController { return AjaxResult.success(dcEmergencyPlansService.executionEventConfirmation(dcEventAnDcEmergencyPlans)); } + /** + * 根据事件id-查询预案事件关联表 + */ + @ApiOperation("根据事件id-查询预案事件关联表") + @GetMapping("/event/assoc/{id}") + public AjaxResult eventConfirm(@PathVariable("id") String id) { + return AjaxResult.success(dcEmergencyPlansService.selectEventPlanAssocByEventId(id)); + } + /** * 感知事件确定 */ diff --git a/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java b/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java index 2ecea0a2..de8faf8e 100644 --- a/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java +++ b/zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java @@ -65,6 +65,14 @@ public interface DcEmergencyPlansService { */ JSONArray executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans); + /** + * 根据事件id-查询预案事件关联表 + * + * @param eventId 事件id + * @return 结果 + */ + EventPlanAssoc selectEventPlanAssocByEventId(String eventId); + /** * 感知事件确定 * 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 7f0a614a..e837c5ea 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 @@ -424,6 +424,18 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { return executionConfirmation(dcEventAnDcEmergencyPlans, dcEvent.getStakeMark(), direction, id); } + /** + * 根据事件id-查询预案事件关联表 + * @param eventId 事件id + * @return + */ + @Override + public EventPlanAssoc selectEventPlanAssocByEventId(String eventId) { + EventPlanAssoc eventPlanAssoc = new EventPlanAssoc(); + eventPlanAssoc.setEventId(eventId); + return eventPlanAssocMapper.selectByEventId(eventPlanAssoc); + } + /** * 感知事件-情报板自动生成 * @@ -584,17 +596,24 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { EventPlanAssoc eventPlanAssoc = new EventPlanAssoc(); // 事件编号 eventPlanAssoc.setEventId(id); - + EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc); // 区分是执行操作 还是 恢复操作 - if (dcEventAnDcEmergencyPlans.getOperationType().equals(1)) { - // 事件预案编号 + if (dcEventAnDcEmergencyPlans.getOperationType().equals(1) && StringUtils.isEmpty(selectEventPlanAssoc.getId())) { + // 首次执行操作 eventPlanAssoc.setEmergencyPlansId(dcEmergencyPlans.getId()); eventPlanAssoc.setExecutingControlDevice(deviceIds.toString().replaceFirst(";", "")); eventPlanAssoc.setExecutingControlResult(resultArray.toJSONString()); eventPlanAssoc.setCreateTime(DateUtils.getNowDate()); eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc); - } else { - EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc); + } + else if (StringUtils.isNotEmpty(selectEventPlanAssoc.getId()) && dcEventAnDcEmergencyPlans.getOperationType().equals(1)) { + // 多次执行操作 + selectEventPlanAssoc.setExecutingControlResult(resultArray.toJSONString()); + selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate()); + eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc); + } + else { + // 恢复操作 未执行的事件不能进行恢复操作 selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate()); selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(";", "")); selectEventPlanAssoc.setRecoveredControlResult(resultArray.toJSONString()); @@ -620,7 +639,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { iotDeviceId = device.getIotDeviceId(); HashMap props = new HashMap<>(); try { - if (device.getDeviceType().equals(DeviceTypeConstants.DRIVING_GUIDANCE)) { + if (device.getDeviceType().equals(DeviceTypeConstants.DRIVING_GUIDANCE.toString())) { // 行车诱导 functionId = DeviceFunctionIdConstants.DRIVING_GUIDANCE; // 控制模式 1-手动 2-自动 3-万年历 @@ -645,7 +664,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } - else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG)) { + else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) { if (operationType == 1) { // 执行操作 @@ -721,7 +740,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } } - else if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) { + else if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING.toString())) { // 路段广播 JSONObject params = new JSONObject(); params.put("name", "task-event"); @@ -742,7 +761,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { } - else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING)) { + else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING.toString())) { // 激光疲劳唤醒 functionId = otherConfig.get("state").toString();