From ad774fea01ea67bcde09161bbf62d32ba1d4ac00 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Thu, 16 May 2024 17:38:10 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=BA=A4=E9=80=9A?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6-=E6=A0=B9=E6=8D=AE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E3=80=81=E5=8D=95=E4=B8=AA=E6=89=A7=E8=A1=8C=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E8=AE=BE=E5=A4=87=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/DcEmergencyPlansController.java | 9 +++++++++ .../domain/DcEventAnDcEmergencyPlans.java | 6 ++++++ .../service/DcEmergencyPlansService.java | 5 +++++ .../impl/DcEmergencyPlansServiceImpl.java | 18 ++++++++++++++++++ 4 files changed, 38 insertions(+) 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 3cfdf97f..96015b8e 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 @@ -82,6 +82,15 @@ public class DcEmergencyPlansController extends BaseController { return AjaxResult.success(dcEmergencyPlansList.get(0)); } + /** + * 交通事件-根据事件、单个执行操作筛选设备 + */ + @ApiOperation("交通事件-根据事件、单个执行操作筛选设备") + @PostMapping("/list/event/deviceList") + public AjaxResult selectDeviceListByEventDcExecuteAction(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { + return AjaxResult.success(dcEmergencyPlansService.selectDeviceListByEventDcExecuteAction(dcEventAnDcEmergencyPlans)); + } + /** * 交通事件-情报板确认回显原始模板 */ diff --git a/zc-business/src/main/java/com/zc/business/domain/DcEventAnDcEmergencyPlans.java b/zc-business/src/main/java/com/zc/business/domain/DcEventAnDcEmergencyPlans.java index 24d8ffb0..dd96dacd 100644 --- a/zc-business/src/main/java/com/zc/business/domain/DcEventAnDcEmergencyPlans.java +++ b/zc-business/src/main/java/com/zc/business/domain/DcEventAnDcEmergencyPlans.java @@ -37,6 +37,12 @@ public class DcEventAnDcEmergencyPlans { @ApiModelProperty("事件预案数据") private DcEmergencyPlans dcEmergencyPlans; + /** + * 单个执行操作数据 + */ + @ApiModelProperty("单个执行操作数据") + private DcExecuteAction dcExecuteAction; + /** * 情报板模板数据 */ 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 3e3e8c92..59fb69c8 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 @@ -44,6 +44,11 @@ public interface DcEmergencyPlansService { */ void dispositionDeviceContent(List list, DcEvent dcEvent); + /** + * 交通事件-根据事件、单个执行操作筛选设备 + */ + List selectDeviceListByEventDcExecuteAction(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans); + /** * 交通事件-情报板确认回显原始模板 */ 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 2b45a585..772160e4 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 @@ -185,6 +185,24 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { }); } + /** + * 交通事件-根据事件、单个执行操作筛选设备 + * @param dcEventAnDcEmergencyPlans + * @return + */ + @Override + public List selectDeviceListByEventDcExecuteAction(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { + // 事件桩号 + DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent(); + dcEvent.setStakeMark(dcEvent.getStakeMark().replace("K", "")); + String[] markArray = dcEvent.getStakeMark().split("\\+"); + if (markArray[1].length() < 3) { + // 不足三位 补零 + markArray[1] = String.format("%0" + 3 + "d", markArray[1]); + } + return ruleFiltering(dcEventAnDcEmergencyPlans.getDcExecuteAction(), markArray, dcEvent.getDirection()); + } + /** * 更改智能发布中的发布内容-计算公里数 */ From 68090045ddbd69180f6289640fe0940862873740 Mon Sep 17 00:00:00 2001 From: "Mr.Wang" Date: Thu, 16 May 2024 20:25:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=AE=A1=E6=8E=A7-=E7=A1=AE=E8=AE=A4=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E7=94=9F=E6=88=90=E5=86=85=E5=AE=B9=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DcEmergencyPlansController.java | 14 ++-- .../service/DcEmergencyPlansService.java | 5 ++ .../impl/DcEmergencyPlansServiceImpl.java | 72 ++++++++++++------- 3 files changed, 54 insertions(+), 37 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 96015b8e..6ad284ac 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 @@ -3,10 +3,7 @@ package com.zc.business.controller; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; -import com.zc.business.domain.DcEmergencyPlans; -import com.zc.business.domain.DcEvent; -import com.zc.business.domain.DcEventAnDcEmergencyPlans; -import com.zc.business.domain.DcWarning; +import com.zc.business.domain.*; import com.zc.business.service.DcEmergencyPlansService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -70,16 +67,13 @@ public class DcEmergencyPlansController extends BaseController { } /** - * 交通事件-切换智能发布生成内容 + * 设备管控-确认按钮生成内容 */ - @ApiOperation("交通事件-切换智能发布生成内容") + @ApiOperation("设备管控-确认按钮生成内容") // @PreAuthorize("@ss.hasPermi('business:plans:list')") @PostMapping("/list/event/emergencyPlans") public AjaxResult switchIntelligentPublishingToContent(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { - List dcEmergencyPlansList = new ArrayList<>(); - dcEmergencyPlansList.add(dcEventAnDcEmergencyPlans.getDcEmergencyPlans()); - dcEmergencyPlansService.dispositionDeviceContent(dcEmergencyPlansList,dcEventAnDcEmergencyPlans.getDcEvent()); - return AjaxResult.success(dcEmergencyPlansList.get(0)); + return AjaxResult.success(dcEmergencyPlansService.confirmButtonToGenerateContent(dcEventAnDcEmergencyPlans,dcEventAnDcEmergencyPlans.getDcEvent())); } /** 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 59fb69c8..0d41cf45 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 @@ -49,6 +49,11 @@ public interface DcEmergencyPlansService { */ List selectDeviceListByEventDcExecuteAction(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans); + /** + * 设备管控-确认按钮生成内容 + */ + DcExecuteAction confirmButtonToGenerateContent(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans, DcEvent dcEvent); + /** * 交通事件-情报板确认回显原始模板 */ 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 772160e4..6e87514f 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 @@ -37,6 +37,7 @@ import java.text.SimpleDateFormat; import java.util.*; import java.util.concurrent.CountDownLatch; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service @Slf4j @@ -169,17 +170,23 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { list.forEach(dcEmergencyPlans -> { List dcExecuteActions = dcEmergencyPlans.getDcExecuteAction(); dcExecuteActions.forEach(dcExecuteAction -> { + List deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection()); + String devices = deviceList.stream() + .map(DcDevice::getIotDeviceId) + .map(String::valueOf) + .collect(Collectors.joining(",")); + dcExecuteAction.setDeviceList(devices); JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.ROAD_SECTION_VOICE_BROADCASTING.getCode() && executeConfig.getString("operationType").equals("2")) { // 执行操作中智能发布语音广播 String content = intelligentPublishingOfInformation(dcEvent); - updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content,dcEvent.getDirection()); + updateIntelligentPublishingContent(dcExecuteAction,markArray,deviceList,content,dcEvent.getDirection()); } else if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode() && executeConfig.getString("operationType").equals("2")) { // 执行操作中智能发布情报板 String content = intelligentPublishingOfInformation(dcEvent); - updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content,dcEvent.getDirection()); + updateIntelligentPublishingContent(dcExecuteAction,markArray,deviceList,content,dcEvent.getDirection()); } }); }); @@ -203,15 +210,49 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { return ruleFiltering(dcEventAnDcEmergencyPlans.getDcExecuteAction(), markArray, dcEvent.getDirection()); } + /** + * 设备管控-确认按钮生成内容 + * @param dcEventAnDcEmergencyPlans + * @return + */ + @Override + public DcExecuteAction confirmButtonToGenerateContent(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans, DcEvent dcEvent) { + // 查询设备 + dcEvent.setStakeMark(dcEvent.getStakeMark().replace("K", "")); + String[] markArray = dcEvent.getStakeMark().split("\\+"); + if (markArray[1].length() < 3) { + // 不足三位 补零 + markArray[1] = String.format("%0" + 3 + "d", markArray[1]); + } + DcExecuteAction dcExecuteAction = dcEventAnDcEmergencyPlans.getDcExecuteAction(); + List dcDevices = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection()); + String devices = dcDevices.stream() + .map(DcDevice::getIotDeviceId) + .map(String::valueOf) + .collect(Collectors.joining(",")); + dcExecuteAction.setDeviceList(devices); + JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); + if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.ROAD_SECTION_VOICE_BROADCASTING.getCode() || + dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) { + // 修改执行操作数据内容 + if (executeConfig.getString("operationType").equals("2")) { + // 说明是智能发布 + String content = intelligentPublishingOfInformation(dcEvent); + updateIntelligentPublishingContent(dcExecuteAction,markArray,dcDevices,content,dcEvent.getDirection()); + } + } + return dcExecuteAction; + } + /** * 更改智能发布中的发布内容-计算公里数 */ public void updateIntelligentPublishingContent(DcExecuteAction dcExecuteAction, String[] markArray, - DcEvent dcEvent, + List deviceList, String content, String direction) { - List deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection()); +// List deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection()); JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig()); List> contentList = new ArrayList<>(); deviceList.forEach(dcDevice -> { @@ -638,29 +679,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { .forEach(dcExecuteAction -> { List dcDevices = ruleFiltering(dcExecuteAction, markArray, direction); -// // 此代码 是为了防止事件没有匹配到预案,但是还执行了设备控制,并且执行操作中带有智能发布 -// boolean isIdEmpty = ObjectUtils.isEmpty(dcEmergencyPlans.getId()); -// Set targetDeviceTypes = new HashSet<>(Arrays.asList( -// DeviceTypeEnum.ROAD_SECTION_VOICE_BROADCASTING.getCode(), -// DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode() -// )); -// boolean isTargetDeviceType = targetDeviceTypes.contains(dcExecuteAction.getDeviceType()); -// if (isIdEmpty && isTargetDeviceType) { -// String configJson = operationType.equals(1) ? dcExecuteAction.getExecuteConfig() : dcExecuteAction.getRecoverConfig(); -// JSONObject config = JSON.parseObject(configJson); -// if (config.getString("operationType").equals("2")) { -// DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent(); -// String content = intelligentPublishingOfInformation(dcEvent); -// updateIntelligentPublishingContent( -// dcExecuteAction, -// markArray, -// dcEvent, -// content, -// dcEvent.getDirection() -// ); -// } -// } - JSONObject otherConfig = operationType.equals(1)? JSON.parseObject(dcExecuteAction.getExecuteConfig()): JSON.parseObject(dcExecuteAction.getRecoverConfig()); try {