From a9820f478b39c2a1f8dc252e9de4f8407ab00c74 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Mon, 8 Apr 2024 18:37:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=84=E6=A1=88=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcEmergencyPlansController.java | 8 ++-- .../zc/business/domain/DcEmergencyPlans.java | 6 --- .../zc/business/domain/DcExecuteAction.java | 18 ++++----- .../impl/DcEmergencyPlansServiceImpl.java | 37 ++++++++++--------- .../business/DcEmergencyPlansMapper.xml | 24 +++++------- .../mapper/business/DcExecuteActionMapper.xml | 28 +++++++------- 6 files changed, 56 insertions(+), 65 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 d6b84c89..f260969a 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 @@ -34,7 +34,7 @@ public class DcEmergencyPlansController extends BaseController { * 查询事件预案列表 */ @ApiOperation("查询事件预案列表") - @PreAuthorize("@ss.hasPermi('business:plans:list')") +// @PreAuthorize("@ss.hasPermi('business:plans:list')") @GetMapping("/list") public TableDataInfo list(DcEmergencyPlans dcEmergencyPlans) { startPage(); @@ -46,7 +46,7 @@ public class DcEmergencyPlansController extends BaseController { * 根据事件预案id查询事件预案列表 */ @ApiOperation("根据事件预案id查询事件预案列表") - @PreAuthorize("@ss.hasPermi('business:plans:list')") +// @PreAuthorize("@ss.hasPermi('business:plans:list')") @GetMapping("/list/{id}") public AjaxResult list(@PathVariable @ApiParam(name = "id", value = "事件预案id", required = true) Integer id) { @@ -149,7 +149,7 @@ public class DcEmergencyPlansController extends BaseController { * 新增事件预案 */ @ApiOperation("新增预案") - @PreAuthorize("@ss.hasPermi('business:plans:add')") +// @PreAuthorize("@ss.hasPermi('business:plans:add')") @PostMapping public AjaxResult add(@RequestBody DcEmergencyPlans dcEmergencyPlans) { return toAjax(dcEmergencyPlansService.insertDcEmergencyPlans(dcEmergencyPlans)); @@ -159,7 +159,7 @@ public class DcEmergencyPlansController extends BaseController { * 修改事件预案 */ @ApiOperation("修改预案") - @PreAuthorize("@ss.hasPermi('business:plans:edit')") +// @PreAuthorize("@ss.hasPermi('business:plans:edit')") @PutMapping public AjaxResult update(@RequestBody DcEmergencyPlans dcEmergencyPlans) { return toAjax(dcEmergencyPlansService.updateDcEmergencyPlans(dcEmergencyPlans)); diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEmergencyPlans.java b/zc-business/src/main/java/com/zc/business/domain/DcEmergencyPlans.java index a7bcad9e..67fc4156 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEmergencyPlans.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcEmergencyPlans.java @@ -81,12 +81,6 @@ public class DcEmergencyPlans { @ApiModelProperty("控制指令") private String controlCommand; - /** - * 事件分类 - */ - @ApiModelProperty("事件分类") - private int eventCategory; - /** * 执行操作列表 */ diff --git a/zc-business/src/main/java/com/zc/business/domain/DcExecuteAction.java b/zc-business/src/main/java/com/zc/business/domain/DcExecuteAction.java index 1ef52211..c43224bd 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcExecuteAction.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcExecuteAction.java @@ -39,12 +39,6 @@ public class DcExecuteAction{ @ApiModelProperty("设备类型") private int deviceType; - /** - * 操作类型 - */ - @ApiModelProperty("操作类型") - private int actionType; - @ApiModelProperty("创建时间") private Date createTime; @ApiModelProperty("修改时间") @@ -69,10 +63,16 @@ public class DcExecuteAction{ private String deviceList; /** - * 其他配置 + * 执行操作配置 + */ + @ApiModelProperty("执行操作配置") + private String executeConfig; + + /** + * 恢复操作配置 */ - @ApiModelProperty("其他配置") - private String otherConfig; + @ApiModelProperty("恢复操作配置") + private String recoverConfig; 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 e837c5ea..c373152e 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 @@ -301,7 +301,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { // 指定设备资源 // 根据设备id,获取设备集合 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); - JSONObject otherConfig = JSON.parseObject(dcExecuteAction.getOtherConfig()); + JSONObject otherConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); List deviceList = (List) otherConfig.get("deviceList"); queryWrapper.in(DcDevice::getIotDeviceId, deviceList); dcDevices = dcDeviceService.list(queryWrapper); @@ -576,7 +576,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { invokedFunction( dcEventAnDcEmergencyPlans.getOperationType(), dcDevices, - JSON.parseObject(dcExecuteAction.getOtherConfig()), + JSON.parseObject(dcExecuteAction.getExecuteConfig()), resultArray); // 记录操作过的设备id @@ -828,7 +828,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { dcEmergencyPlansMapper.updateDcEmergencyPlans(dcEmergencyPlans); // 修改执行操作表数据 dcExecuteActionList.forEach(dcExecuteAction -> dcExecuteAction.setUpdateTime(DateUtils.getNowDate())); - // 过滤出删除掉的执行操作和恢复操作 + // 过滤出删除掉的操作 String dcExecuteActionId = dcExecuteActionList.stream() .filter(dcExecuteAction -> dcExecuteAction.getId() != null) .map(DcExecuteAction::getEmergencyPlansId) @@ -839,17 +839,16 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { .filter(dcExecuteAction -> dcExecuteAction.getId() != null) .map(DcExecuteAction::getId) .collect(Collectors.toList()); - // 查询出事件预案关联的执行操作和恢复操作 + // 查询出事件预案关联的操作 List dcExecuteActionIdList = dcExecuteActionService.selectDcExecuteActionByEmergencyPlansId(dcExecuteActionId); List commonIds = new ArrayList<>(ids); commonIds.retainAll(dcExecuteActionIdList); - // 删除后的执行操作id和恢复操作id + // 删除后的操作id List idsNotInDcExecuteActionIdList = new ArrayList<>(dcExecuteActionIdList); idsNotInDcExecuteActionIdList.removeAll(commonIds); - // 根据执行操作id和恢复操作id,进行删除操作 + // 根据操作id,进行删除操作 if (idsNotInDcExecuteActionIdList.size() > 0) { - System.out.println("存在需要删除的数据"); dcExecuteActionService.deleteDcExecuteAction(idsNotInDcExecuteActionIdList); } @@ -907,14 +906,10 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { * 数据处理 */ public static List dataProcessing(DcEmergencyPlans dcEmergencyPlans) { - // 过滤出执行操作数据 - List dcExecuteActionOperationList = dcEmergencyPlans.getDcExecuteAction() - .stream() - .filter(dcExecuteAction -> dcExecuteAction.getActionType() == 1) - .collect(Collectors.toList()); + List dcExecuteActionList = dcEmergencyPlans.getDcExecuteAction(); // 设备类型 数据处理 - String deviceType = dcExecuteActionOperationList.stream() + String deviceType = dcExecuteActionList.stream() .map(DcExecuteAction::getDeviceType) .distinct() .map(type -> Arrays.stream(DeviceTypeEnum.values()) @@ -926,7 +921,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { .collect(Collectors.joining(",")); dcEmergencyPlans.setDeviceType(deviceType); // 可控设备 数据处理 - List dcExecuteActionNewList = dcExecuteActionOperationList.stream() + List dcExecuteActionNewList = dcExecuteActionList.stream() .filter(dcExecuteAction -> dcExecuteAction.getSearchRule() == 1) .collect(Collectors.toList()); String controllableDevice = dcExecuteActionNewList.stream() @@ -934,11 +929,12 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { .collect(Collectors.joining("、")); dcEmergencyPlans.setControllableDevice(controllableDevice); // 控制指令 数据处理 - List otherConfigList = dcExecuteActionOperationList.stream() + List otherConfigList = dcExecuteActionList.stream() .map(dcExecuteAction -> { JSONObject config = new JSONObject(); - String otherConfig = dcExecuteAction.getOtherConfig(); - JSONObject jsonObject = JSON.parseObject(otherConfig); + // 执行操作配置 + String executeConfig = dcExecuteAction.getExecuteConfig(); + JSONObject jsonObject = JSON.parseObject(executeConfig); if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.DRIVING_GUIDANCE) { // 行车诱导 config.put("controlModelName",jsonObject.get("controlModelName")); @@ -950,7 +946,12 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { }else if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.VARIABLE_INFORMATION_FLAG || dcExecuteAction.getDeviceType() == DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING) { // 情报板/语音广播 - config.put("content",jsonObject.get("content")); + if (jsonObject.get("operationType").equals("1")) { + config.put("content",jsonObject.get("content")); + }else { + config.put("operationType","智能发布"); + } + } else if (dcExecuteAction.getDeviceType() == DeviceTypeConstants.LASER_FATIGUE_AWAKENING) { // 激光疲劳唤醒 diff --git a/zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml b/zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml index a1e7e6f5..bb15469d 100644 --- a/zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcEmergencyPlansMapper.xml @@ -15,18 +15,17 @@ - - - + + @@ -43,7 +42,6 @@ triggering_condition, controllable_device, control_command, - event_category, #{planName}, @@ -55,7 +53,6 @@ #{triggeringCondition}, #{controllableDevice}, #{controlCommand}, - #{eventCategory}, @@ -68,8 +65,7 @@ device_type = #{deviceType}, triggering_condition = #{triggeringCondition}, controllable_device = #{controllableDevice}, - control_command = #{controlCommand}, - event_category = #{eventCategory} + control_command = #{controlCommand} where id = #{id} @@ -90,16 +86,16 @@ t1.triggering_condition, t1.controllable_device, t1.control_command, - t1.event_category, t2.id as action_id, t2.emergency_plans_id as action_emergency_plans_id, t2.device_type as action_device_type, - t2.action_type as action_action_type, t2.create_time as action_create_time, + t2.update_time as action_update_time, t2.search_rule as action_search_rule, t2.`number` as action_number, t2.device_list as action_device_list, - t2.other_config as action_other_config + t2.execute_config as action_execute_config, + t2.recover_config as action_recover_config from dc_emergency_plans t1 left join dc_execute_action t2 on t1.id = t2.emergency_plans_id @@ -115,13 +111,11 @@ t1.device_type, t1.triggering_condition, t1.controllable_device, - t1.control_command, - t1.event_category + t1.control_command from dc_emergency_plans t1 and plan_name like concat('%', #{planName}, '%') and event_type = #{eventType} - and event_category = #{eventCategory} order by t1.id desc @@ -133,12 +127,12 @@ diff --git a/zc-business/src/main/resources/mapper/business/DcExecuteActionMapper.xml b/zc-business/src/main/resources/mapper/business/DcExecuteActionMapper.xml index 2d975ec5..98c710ce 100644 --- a/zc-business/src/main/resources/mapper/business/DcExecuteActionMapper.xml +++ b/zc-business/src/main/resources/mapper/business/DcExecuteActionMapper.xml @@ -10,24 +10,26 @@ (emergency_plans_id, device_type, - action_type, create_time, search_rule, `number`, device_list, - other_config + execute_config, + recover_config ) values - (#{item.emergencyPlansId}, + ( + #{item.emergencyPlansId}, #{item.deviceType}, - #{item.actionType}, #{item.createTime}, #{item.searchRule}, #{item.number}, #{item.deviceList}, - #{item.otherConfig}) + #{item.executeConfig}, + #{item.recoverConfig} + ) @@ -47,12 +49,6 @@ then #{item.deviceType} - - - when id=#{item.id} - then #{item.actionType} - - when id=#{item.id} @@ -77,10 +73,16 @@ then #{item.deviceList} - + + + when id=#{item.id} + then #{item.executeConfig} + + + when id=#{item.id} - then #{item.otherConfig} + then #{item.recoverConfig}