Browse Source

修改事件确认、根据事件查询预案内容等接口

develop
Mr.Wang 8 months ago
parent
commit
8ef4cfb354
  1. 15
      zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java
  2. 44
      zc-business/src/main/java/com/zc/business/enums/EventSubclassEnum.java
  3. 19
      zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java
  4. 224
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java
  5. 2
      zc-business/src/main/resources/mapper/business/EventPlanAssocMapper.xml

15
zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java

@ -63,13 +63,14 @@ public class DcEmergencyPlansController extends BaseController {
public AjaxResult listByEventType(@RequestBody DcEvent dcEvent) { public AjaxResult listByEventType(@RequestBody DcEvent dcEvent) {
List<DcEmergencyPlans> dcEmergencyPlansList = dcEmergencyPlansService.selectDcEmergencyPlansByEventType(dcEvent); List<DcEmergencyPlans> dcEmergencyPlansList = dcEmergencyPlansService.selectDcEmergencyPlansByEventType(dcEvent);
dcEmergencyPlansService.dispositionDeviceContent(dcEmergencyPlansList,dcEvent);
return AjaxResult.success(dcEmergencyPlansList); return AjaxResult.success(dcEmergencyPlansList);
} }
/** /**
* 感知事件-根据事件数据查询事件预案列表 * 感知事件-根据事件数据查询事件预案列表
*/ */
@ApiOperation("感知事件-根据事件数据查询事件预案列表") // @ApiOperation("感知事件-根据事件数据查询事件预案列表")
@PreAuthorize("@ss.hasPermi('business:plans:list')") @PreAuthorize("@ss.hasPermi('business:plans:list')")
@PostMapping("/list/warning/type") @PostMapping("/list/warning/type")
public AjaxResult listByEventType(@RequestBody DcWarning dcWarning) { public AjaxResult listByEventType(@RequestBody DcWarning dcWarning) {
@ -91,7 +92,7 @@ public class DcEmergencyPlansController extends BaseController {
/** /**
* 感知事件-情报板确认回显原始模板 * 感知事件-情报板确认回显原始模板
*/ */
@ApiOperation("感知事件-情报板确认回显原始模板") // @ApiOperation("感知事件-情报板确认回显原始模板")
@PreAuthorize("@ss.hasPermi('business:plans:list')") @PreAuthorize("@ss.hasPermi('business:plans:list')")
@PostMapping("/warning/board/confirm") @PostMapping("/warning/board/confirm")
public AjaxResult warningBoardConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { public AjaxResult warningBoardConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
@ -101,7 +102,7 @@ public class DcEmergencyPlansController extends BaseController {
/** /**
* 感知事件-情报板自动生成文字 * 感知事件-情报板自动生成文字
*/ */
@ApiOperation("感知事件-情报板自动生成文字") // @ApiOperation("感知事件-情报板自动生成文字")
@PostMapping("/warning/automatic") @PostMapping("/warning/automatic")
public AjaxResult warningAutomaticGeneration(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { public AjaxResult warningAutomaticGeneration(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.warningAutomaticGeneration(dcEventAnDcEmergencyPlans)); return AjaxResult.success(dcEmergencyPlansService.warningAutomaticGeneration(dcEventAnDcEmergencyPlans));
@ -110,7 +111,7 @@ public class DcEmergencyPlansController extends BaseController {
/** /**
* 交通事件-情报板自动生成文字 * 交通事件-情报板自动生成文字
*/ */
@ApiOperation("交通事件-情报板自动生成文字") // @ApiOperation("交通事件-情报板自动生成文字")
@PostMapping("/event/automatic") @PostMapping("/event/automatic")
public AjaxResult eventAutomaticGeneration(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { public AjaxResult eventAutomaticGeneration(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.eventAutomaticGeneration(dcEventAnDcEmergencyPlans)); return AjaxResult.success(dcEmergencyPlansService.eventAutomaticGeneration(dcEventAnDcEmergencyPlans));
@ -138,7 +139,7 @@ public class DcEmergencyPlansController extends BaseController {
/** /**
* 感知事件确定 * 感知事件确定
*/ */
@ApiOperation("感知事件确认") // @ApiOperation("感知事件确认")
@PreAuthorize("@ss.hasPermi('business:plans:edit')") @PreAuthorize("@ss.hasPermi('business:plans:edit')")
@PostMapping("/warning/confirm") @PostMapping("/warning/confirm")
public AjaxResult warningConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { public AjaxResult warningConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
@ -149,7 +150,7 @@ public class DcEmergencyPlansController extends BaseController {
* 新增事件预案 * 新增事件预案
*/ */
@ApiOperation("新增预案") @ApiOperation("新增预案")
// @PreAuthorize("@ss.hasPermi('business:plans:add')") @PreAuthorize("@ss.hasPermi('business:plans:add')")
@PostMapping @PostMapping
public AjaxResult add(@RequestBody DcEmergencyPlans dcEmergencyPlans) { public AjaxResult add(@RequestBody DcEmergencyPlans dcEmergencyPlans) {
return toAjax(dcEmergencyPlansService.insertDcEmergencyPlans(dcEmergencyPlans)); return toAjax(dcEmergencyPlansService.insertDcEmergencyPlans(dcEmergencyPlans));
@ -159,7 +160,7 @@ public class DcEmergencyPlansController extends BaseController {
* 修改事件预案 * 修改事件预案
*/ */
@ApiOperation("修改预案") @ApiOperation("修改预案")
// @PreAuthorize("@ss.hasPermi('business:plans:edit')") @PreAuthorize("@ss.hasPermi('business:plans:edit')")
@PutMapping @PutMapping
public AjaxResult update(@RequestBody DcEmergencyPlans dcEmergencyPlans) { public AjaxResult update(@RequestBody DcEmergencyPlans dcEmergencyPlans) {
return toAjax(dcEmergencyPlansService.updateDcEmergencyPlans(dcEmergencyPlans)); return toAjax(dcEmergencyPlansService.updateDcEmergencyPlans(dcEmergencyPlans));

44
zc-business/src/main/java/com/zc/business/enums/EventSubclassEnum.java

@ -5,28 +5,28 @@ package com.zc.business.enums;
* @author wangjiabao * @author wangjiabao
*/ */
public enum EventSubclassEnum { public enum EventSubclassEnum {
REAR_END_COLLISION("1-1", "追尾","前方发生追尾 注意避让"), REAR_END_COLLISION("1-1", "追尾","前方*发生追尾 注意避让"),
ROLLOVER("1-2", "侧翻","前方发生侧翻 注意避让"), ROLLOVER("1-2", "侧翻","前方*发生侧翻 注意避让"),
COLLISION_WITH_GUARDRAIL("1-3", "撞护栏","前方车撞击护栏注意避让"), COLLISION_WITH_GUARDRAIL("1-3", "撞护栏","前方*车撞击护栏注意避让"),
NATURAL("1-4", "自然","前方发生自然现象请注意"), NATURAL("1-4", "自然","前方*发生自然现象请注意"),
OTHER_ACCIDENTS("1-5", "其他事故","前方发生事故谨慎驾驶"), OTHER_ACCIDENTS("1-5", "其他事故","前方*发生事故谨慎驾驶"),
VEHICLE_MALFUNCTION("2-1", "车辆故障","前方发生故障注意避让"), VEHICLE_MALFUNCTION("2-1", "车辆故障","前方*发生故障注意避让"),
ROAD_CONGESTION("4-1", "道路拥堵","前方道路拥堵"), ROAD_CONGESTION("4-1", "道路拥堵","前方*道路拥堵"),
OVERPASS_CONGESTION("4-2", "立交拥堵","前方立交拥堵"), OVERPASS_CONGESTION("4-2", "立交拥堵","前方*立交拥堵"),
TOLL_STATION_CONGESTION("4-3", "收费站拥堵","前方收费站拥堵"), TOLL_STATION_CONGESTION("4-3", "收费站拥堵","前方*收费站拥堵"),
SERVICE_AREA_CONGESTION("4-4", "服务区拥堵","前方服务区拥堵"), SERVICE_AREA_CONGESTION("4-4", "服务区拥堵","前方*服务区拥堵"),
PEDESTRIAN("5-1", "行人","有行人穿行请注意"), PEDESTRIAN("5-1", "行人","前方*有行人穿行请注意"),
NON_MOTOR_VEHICLES("5-2", "非机动车","有非机动车上路请注意"), NON_MOTOR_VEHICLES("5-2", "非机动车","前方*有非机动车上路请注意"),
MOTORCYCLE("5-3", "摩托车","有摩托车上路请注意"), MOTORCYCLE("5-3", "摩托车","前方*有摩托车上路请注意"),
OTHER("5-4", "其他","有非法上路车辆"), OTHER("5-4", "其他","前方*有非法上路车辆"),
SMOKE("6-1", "烟雾","烟雾道路请注意驾驶"), SMOKE("6-1", "烟雾","前方*烟雾道路请注意驾驶"),
FALLEN_TREES("6-2", "倒伏树木","有倒伏树木请注意"), FALLEN_TREES("6-2", "倒伏树木","前方*有倒伏树木请注意"),
SCATTERED_MATERIALS("6-3", "洒落物","有洒落物请注意"), SCATTERED_MATERIALS("6-3", "洒落物","前方*有洒落物请注意"),
ANIMAL("6-4", "动物","有动物请注意"), ANIMAL("6-4", "动物","前方*有动物请注意"),
OTHER_OBSTACLES("6-5", "其他障碍","有不明障碍请注意"), OTHER_OBSTACLES("6-5", "其他障碍","前方*有不明障碍请注意"),
CLOSED_OR_SUSPENDED_OPERATIONS("8-1", "封闭、暂停营业","服务区封闭、暂停营业"), CLOSED_OR_SUSPENDED_OPERATIONS("8-1", "封闭、暂停营业","前方*服务区封闭、暂停营业"),
SHUTDOWN_OF_IMPORTANT_FACILITIES("8-2", "重要设施停用","服务区重要设施停用"), SHUTDOWN_OF_IMPORTANT_FACILITIES("8-2", "重要设施停用","前方*服务区重要设施停用"),
OTHER_ABNORMALITIES_IN_THE_SERVICE_AREA("8-3", "服务区其他异常","服务区设备停用"), OTHER_ABNORMALITIES_IN_THE_SERVICE_AREA("8-3", "服务区其他异常","前方*服务区设备停用"),
RAIN("10-1", "雨","雨天请谨慎驾驶"), RAIN("10-1", "雨","雨天请谨慎驾驶"),
SNOW("10-2", "雪","雪天路滑请谨慎驾驶"), SNOW("10-2", "雪","雪天路滑请谨慎驾驶"),
HEAVY_FOG("10-3", "大雾","大雾天气请谨慎驾驶"), HEAVY_FOG("10-3", "大雾","大雾天气请谨慎驾驶"),

19
zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java

@ -1,6 +1,6 @@
package com.zc.business.service; package com.zc.business.service;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject;
import com.zc.business.domain.*; import com.zc.business.domain.*;
import java.util.List; import java.util.List;
@ -39,6 +39,11 @@ public interface DcEmergencyPlansService {
*/ */
List<DcEmergencyPlans> selectDcEmergencyPlansByEventType(DcEvent event); List<DcEmergencyPlans> selectDcEmergencyPlansByEventType(DcEvent event);
/**
* 处置设备智能发布的内容
*/
void dispositionDeviceContent(List<DcEmergencyPlans> list, DcEvent dcEvent);
/** /**
* 感知事件-根据事件类型查询事件预案 * 感知事件-根据事件类型查询事件预案
* *
@ -63,7 +68,7 @@ public interface DcEmergencyPlansService {
* @param dcEventAnDcEmergencyPlans 事件数据 事件预案数据 * @param dcEventAnDcEmergencyPlans 事件数据 事件预案数据
* @return 结果 * @return 结果
*/ */
JSONArray executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans); JSONObject executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans);
/** /**
* 根据事件id-查询预案事件关联表 * 根据事件id-查询预案事件关联表
@ -79,7 +84,7 @@ public interface DcEmergencyPlansService {
* @param dcEventAnDcEmergencyPlans 事件数据 事件预案数据 * @param dcEventAnDcEmergencyPlans 事件数据 事件预案数据
* @return 结果 * @return 结果
*/ */
JSONArray executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans); JSONObject executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans);
/** /**
* 感知事件-情报板自动生成 * 感知事件-情报板自动生成
@ -111,14 +116,6 @@ public interface DcEmergencyPlansService {
*/ */
int updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans); int updateDcEmergencyPlans(DcEmergencyPlans dcEmergencyPlans);
/**
* 批量修改事件预案
*
* @param dcEmergencyPlansList 事件预案
* @return 结果
*/
int updateBatchDcEmergencyPlans(List<DcEmergencyPlans> dcEmergencyPlansList);
/** /**
* 批量删除事件预案 * 批量删除事件预案
* *

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

@ -20,6 +20,7 @@ import com.zc.business.mapper.EventPlanAssocMapper;
import com.zc.business.service.DcEmergencyPlansService; import com.zc.business.service.DcEmergencyPlansService;
import com.zc.business.service.DcExecuteActionService; import com.zc.business.service.DcExecuteActionService;
import com.zc.business.service.IDcDeviceService; import com.zc.business.service.IDcDeviceService;
import com.zc.business.service.IDcFacilityService;
import com.zc.common.core.httpclient.exception.HttpException; import com.zc.common.core.httpclient.exception.HttpException;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@ -50,6 +51,9 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
@Resource @Resource
private EventPlanAssocMapper eventPlanAssocMapper; private EventPlanAssocMapper eventPlanAssocMapper;
@Resource
private IDcFacilityService dcFacilityService;
@Resource @Resource
private ThreadPoolTaskExecutor threadPoolTaskExecutor; private ThreadPoolTaskExecutor threadPoolTaskExecutor;
@ -110,8 +114,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
return dcEmergencyPlansList.stream() return dcEmergencyPlansList.stream()
.filter(dcEmergencyPlans -> { .filter(dcEmergencyPlans -> {
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); String triggerMechanism = dcEmergencyPlans.getTriggerMechanism();
// JSONObject triggerJson = JSONObject.parseObject(triggerMechanism);
// String eventSubclass = triggerJson.get("eventSubclass").toString();
return triggerMechanism.equals(event.getSubclass()); return triggerMechanism.equals(event.getSubclass());
}) })
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -120,8 +122,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
return dcEmergencyPlansList.stream() return dcEmergencyPlansList.stream()
.filter(dcEmergencyPlans -> { .filter(dcEmergencyPlans -> {
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); String triggerMechanism = dcEmergencyPlans.getTriggerMechanism();
// JSONObject triggerJson = JSONObject.parseObject(triggerMechanism);
// String locationType = triggerJson.get("locationType").toString();
DcEventVehicleAccident dcEventVehicleAccident = event.getDcEventVehicleAccident(); DcEventVehicleAccident dcEventVehicleAccident = event.getDcEventVehicleAccident();
String eventLocationType = dcEventVehicleAccident.getLocationType().toString(); String eventLocationType = dcEventVehicleAccident.getLocationType().toString();
return triggerMechanism.equals(eventLocationType); return triggerMechanism.equals(eventLocationType);
@ -132,9 +132,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
return dcEmergencyPlansList.stream() return dcEmergencyPlansList.stream()
.filter(dcEmergencyPlans -> { .filter(dcEmergencyPlans -> {
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); String triggerMechanism = dcEmergencyPlans.getTriggerMechanism();
// JSONObject triggerJson = JSONObject.parseObject(triggerMechanism);
// 分类
// Integer classify = Integer.parseInt(triggerJson.get("classify").toString());
// 事件--交通管制数据 // 事件--交通管制数据
DcEventTrafficControl dcEventTrafficControl = event.getDcEventTrafficControl(); DcEventTrafficControl dcEventTrafficControl = event.getDcEventTrafficControl();
Integer eventClassify = Integer.parseInt(dcEventTrafficControl.getClassify().toString()); Integer eventClassify = Integer.parseInt(dcEventTrafficControl.getClassify().toString());
@ -148,6 +145,94 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
} }
/**
* 处置设备智能发布的内容
*/
@Override
public void dispositionDeviceContent(List<DcEmergencyPlans> list, 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]);
}
// 情报板 语音广播
list.forEach(dcEmergencyPlans -> {
List<DcExecuteAction> dcExecuteActions = dcEmergencyPlans.getDcExecuteAction();
dcExecuteActions.forEach(dcExecuteAction -> {
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig());
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.ROAD_SECTION_VOICE_BROADCASTING.getCode()
&& executeConfig.get("operationType").equals("2")) {
// 执行操作中智能发布语音广播
String content = intelligentPublishingOfInformation(dcEvent);
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content);
} else if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()
&& executeConfig.get("operationType").equals("2")) {
// 执行操作中智能发布情报板
String content = intelligentPublishingOfInformation(dcEvent);
updateIntelligentPublishingContent(dcExecuteAction,markArray,dcEvent,content);
}
});
});
}
/**
* 更改智能发布中的发布内容-计算公里数
*/
public void updateIntelligentPublishingContent(DcExecuteAction dcExecuteAction, String[] markArray, DcEvent dcEvent,String content) {
List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection());
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig());
List<Map<String,Object>> contentList = new ArrayList<>();
deviceList.forEach(dcDevice -> {
Map<String,Object> map = new HashMap<>();
map.put("dcDeviceId",dcDevice.getId());
map.put("deviceName",dcDevice.getDeviceName());
// 公里数
int kilometers = 0;
// 米数
int meters = 0;
dcDevice.setStakeMark(dcDevice.getStakeMark().replace("K", ""));
String[] deviceMarkArray = dcDevice.getStakeMark().split("\\+");
if (deviceMarkArray[1].length() < 3) {
// 不足三位 补零
deviceMarkArray[1] = String.format("%0" + 3 + "d", deviceMarkArray[1]);
}
kilometers = Math.abs(Integer.parseInt(deviceMarkArray[0]) - Integer.parseInt(markArray[0]));
meters = Math.abs(Integer.parseInt(deviceMarkArray[1]) - Integer.parseInt(markArray[1]));
double roundedDistance = Math.round((kilometers + meters / 1000.0) * 10.0) / 10.0;
if (roundedDistance < 1) {
map.put("content",content.replace("*",(int) (roundedDistance * 1000)+"米"));
}else {
map.put("content",content.replace("*",roundedDistance+"公里"));
}
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) {
// 情报板
// stopTime
map.put("stopTime", "50");
// inScreenMode
map.put("inScreenMode", "1");
// fontSpacing
map.put("fontSpacing", "0");
// fontColor
map.put("fontColor", "ffff00");
// fontType
map.put("fontType", "1");
// fontSize
map.put("fontSize", "36");
// screenSize 768*64 宽度和高度
map.put("screenSize", "768*64");
// formatStyle
map.put("formatStyle", "2");
}
contentList.add(map);
});
executeConfig.put("contentList",contentList);
dcExecuteAction.setExecuteConfig(executeConfig.toJSONString());
}
/** /**
* 感知事件 - 根据事件类型查询事件预案 * 感知事件 - 根据事件类型查询事件预案
* *
@ -196,8 +281,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
markArray[1] = String.format("%0" + 3 + "d", markArray[1]); markArray[1] = String.format("%0" + 3 + "d", markArray[1]);
} }
DcExecuteAction executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction(); DcExecuteAction executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction();
Integer operationType = dcEventAnDcEmergencyPlans.getOperationType(); List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction);
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction, operationType);
return getBoardTemplate(dcDevices); return getBoardTemplate(dcDevices);
} }
@ -218,8 +302,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
markArray[1] = String.format("%0" + 3 + "d", markArray[1]); markArray[1] = String.format("%0" + 3 + "d", markArray[1]);
} }
DcExecuteAction executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction(); DcExecuteAction executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction();
Integer operationType = dcEventAnDcEmergencyPlans.getOperationType(); List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction);
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction, operationType);
return getBoardTemplate(dcDevices); return getBoardTemplate(dcDevices);
} }
@ -289,12 +372,9 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* @param direction * @param direction
* @return * @return
*/ */
public List<DcDevice> ruleFiltering(DcExecuteAction dcExecuteAction, String[] markArray, String direction, Integer operationType) { public List<DcDevice> ruleFiltering(DcExecuteAction dcExecuteAction, String[] markArray, String direction) {
Integer searchRule = dcExecuteAction.getSearchRule(); Integer searchRule = dcExecuteAction.getSearchRule();
// 区分执行操作还是恢复操作
JSONObject otherConfig = operationType.equals(1)?
JSON.parseObject(dcExecuteAction.getExecuteConfig()): JSON.parseObject(dcExecuteAction.getRecoverConfig());
List<String> start = new ArrayList<>(); List<String> start = new ArrayList<>();
List<String> end = new ArrayList<>(); List<String> end = new ArrayList<>();
// 设备列表 // 设备列表
@ -306,7 +386,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// 指定设备资源 // 指定设备资源
// 根据设备id,获取设备集合 // 根据设备id,获取设备集合
LambdaQueryWrapper<DcDevice> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DcDevice> queryWrapper = new LambdaQueryWrapper<>();
List<String> deviceList = (List<String>) otherConfig.get("deviceList"); String[] deviceList = dcExecuteAction.getDeviceList().split(",");
queryWrapper.in(DcDevice::getIotDeviceId, deviceList); queryWrapper.in(DcDevice::getIotDeviceId, deviceList);
dcDevices = dcDeviceService.list(queryWrapper); dcDevices = dcDeviceService.list(queryWrapper);
} else if (searchRule.equals(2)) { } else if (searchRule.equals(2)) {
@ -418,7 +498,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public JSONArray executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { public JSONObject executionEventConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
// 获取事件数据 // 获取事件数据
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent(); DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent();
// 方向 // 方向
@ -478,8 +558,17 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
@Override @Override
public DcInfoBoardTemplate eventAutomaticGeneration(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { public DcInfoBoardTemplate eventAutomaticGeneration(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
// 根据交通事件的事件类型,生成相应的情报板内容 // 根据交通事件的事件类型,生成相应的情报板内容
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent();
DcInfoBoardTemplate dcInfoBoardTemplate = dcEventAnDcEmergencyPlans.getDcInfoBoardTemplate(); DcInfoBoardTemplate dcInfoBoardTemplate = dcEventAnDcEmergencyPlans.getDcInfoBoardTemplate();
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent();
dcInfoBoardTemplate.setContent(intelligentPublishingOfInformation(dcEvent));
return dcInfoBoardTemplate;
}
/**
* 智能发布信息匹配
*/
public String intelligentPublishingOfInformation(DcEvent dcEvent) {
String content = "请注意前方危险";
int eventType = Integer.parseInt(dcEvent.getEventType().toString()); int eventType = Integer.parseInt(dcEvent.getEventType().toString());
if (eventType == EventTypeEnum.ABNORMAL_WEATHER.getCode() || if (eventType == EventTypeEnum.ABNORMAL_WEATHER.getCode() ||
eventType == EventTypeEnum.TRAFFIC_ACCIDENT.getCode() || eventType == EventTypeEnum.TRAFFIC_ACCIDENT.getCode() ||
@ -488,42 +577,41 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
eventType == EventTypeEnum.SERVICE_AREA_ABNORMALITY.getCode() || eventType == EventTypeEnum.SERVICE_AREA_ABNORMALITY.getCode() ||
eventType == EventTypeEnum.ROADBLOCK_CLEARANCE.getCode()) { eventType == EventTypeEnum.ROADBLOCK_CLEARANCE.getCode()) {
String content = Arrays.stream(EventSubclassEnum.values()) content = Arrays.stream(EventSubclassEnum.values())
.filter(eventSubclassEnum -> eventSubclassEnum.getCode().equals(dcEvent.getSubclass())) .filter(eventSubclassEnum -> eventSubclassEnum.getCode().equals(dcEvent.getSubclass()))
.findFirst() .findFirst()
.map(EventSubclassEnum::getText) .map(EventSubclassEnum::getText)
.orElse("请注意前方危险"); .orElse("请注意前方危险");
dcInfoBoardTemplate.setContent(content);
} else if (eventType == EventTypeEnum.VEHICLE_MALFUNCTION.getCode()) { } else if (eventType == EventTypeEnum.VEHICLE_MALFUNCTION.getCode()) {
// 车辆故障 // 车辆故障
DcEventVehicleAccident dcEventVehicleAccident = dcEvent.getDcEventVehicleAccident(); DcEventVehicleAccident dcEventVehicleAccident = dcEvent.getDcEventVehicleAccident();
int locationType = Integer.parseInt(dcEventVehicleAccident.getLocationType().toString()); int locationType = Integer.parseInt(dcEventVehicleAccident.getLocationType().toString());
// 路广设施id
Integer facilityId = dcEventVehicleAccident.getFacilityId();
DcFacility facility = dcFacilityService.getFacility(facilityId.toString());
String facilityName = facility.getFacilityName();
if (locationType == 1) { if (locationType == 1) {
dcInfoBoardTemplate.setContent("高速主线发生车辆故障"); content = "前方*高速主线发生车辆故障";
} else if (locationType == 2) { } else if (locationType == 2 || locationType == 3 || locationType == 4) {
dcInfoBoardTemplate.setContent("服务区发生车辆故障"); // 服务区、立交、收费站
} else if (locationType == 3) { content = "前方*"+facilityName+"发生车辆故障";
dcInfoBoardTemplate.setContent("立交桥发生车辆故障");
} else if (locationType == 4) {
dcInfoBoardTemplate.setContent("收费站发生车辆故障");
} }
} else if (eventType == EventTypeEnum.TRAFFIC_CONTROL.getCode()) { } else if (eventType == EventTypeEnum.TRAFFIC_CONTROL.getCode()) {
// 交通管制 // 交通管制
DcEventTrafficControl dcEventTrafficControl = dcEvent.getDcEventTrafficControl(); DcEventTrafficControl dcEventTrafficControl = dcEvent.getDcEventTrafficControl();
int classify = Integer.parseInt(dcEventTrafficControl.getClassify().toString()); int classify = Integer.parseInt(dcEventTrafficControl.getClassify().toString());
String content = Arrays.stream(ClassifyEnum.values()) content = Arrays.stream(ClassifyEnum.values())
.filter(eventSubclassEnum -> eventSubclassEnum.getCode() == classify) .filter(eventSubclassEnum -> eventSubclassEnum.getCode() == classify)
.findFirst() .findFirst()
.map(ClassifyEnum::getText) .map(ClassifyEnum::getText)
.orElse("前方存在限行或关闭"); .orElse("前方*存在限行或关闭");
dcInfoBoardTemplate.setContent(content);
} else { } else {
// 施工建设 // 施工建设
dcInfoBoardTemplate.setContent("前方施工请注意驾驶"); content = "前方*施工请注意驾驶";
} }
return dcInfoBoardTemplate; return content;
} }
/** /**
@ -533,7 +621,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* @return * @return
*/ */
@Override @Override
public JSONArray executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { public JSONObject executionWarningConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
// 获取事件数据 // 获取事件数据
DcWarning dcWarning = dcEventAnDcEmergencyPlans.getDcWarning(); DcWarning dcWarning = dcEventAnDcEmergencyPlans.getDcWarning();
@ -550,7 +638,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
* @param dcEventAnDcEmergencyPlans 事件数据 事件预案数据 * @param dcEventAnDcEmergencyPlans 事件数据 事件预案数据
* @return * @return
*/ */
public JSONArray executionConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans, public JSONObject executionConfirmation(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans,
String stakeMark, String stakeMark,
String direction, String direction,
String id) { String id) {
@ -574,7 +662,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
//获取事件预案中的操作配置 //获取事件预案中的操作配置
dcEmergencyPlans.getDcExecuteAction() dcEmergencyPlans.getDcExecuteAction()
.forEach(dcExecuteAction -> { .forEach(dcExecuteAction -> {
List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, direction, operationType); List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, direction);
JSONObject otherConfig = operationType.equals(1)? JSONObject otherConfig = operationType.equals(1)?
JSON.parseObject(dcExecuteAction.getExecuteConfig()): JSON.parseObject(dcExecuteAction.getRecoverConfig()); JSON.parseObject(dcExecuteAction.getExecuteConfig()): JSON.parseObject(dcExecuteAction.getRecoverConfig());
try { try {
@ -600,23 +688,26 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
}); });
// 创建一个 预案事件关联对象 // 创建一个 预案事件关联对象
EventPlanAssoc eventPlanAssoc = new EventPlanAssoc(); EventPlanAssoc eventPlanAssoc = new EventPlanAssoc();
JSONObject resultObject = new JSONObject();
// 事件编号 // 事件编号
eventPlanAssoc.setEventId(id); eventPlanAssoc.setEventId(id);
EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc); EventPlanAssoc selectEventPlanAssoc = eventPlanAssocMapper.selectByEventId(eventPlanAssoc);
// 区分是执行操作 还是 恢复操作 // 区分是执行操作 还是 恢复操作
if (dcEventAnDcEmergencyPlans.getOperationType().equals(1) && StringUtils.isEmpty(selectEventPlanAssoc.getId())) { if (dcEventAnDcEmergencyPlans.getOperationType().equals(1) && selectEventPlanAssoc == null) {
// 首次执行操作 // 首次执行操作
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());
eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc); int eventPlanAssocId = eventPlanAssocMapper.insertEventPlanAssoc(eventPlanAssoc);
resultObject.put("eventPlanAssocId",eventPlanAssocId);
} }
else if (StringUtils.isNotEmpty(selectEventPlanAssoc.getId()) && dcEventAnDcEmergencyPlans.getOperationType().equals(1)) { else if (StringUtils.isNotEmpty(selectEventPlanAssoc.getId()) && dcEventAnDcEmergencyPlans.getOperationType().equals(1)) {
// 多次执行操作 // 多次执行操作
selectEventPlanAssoc.setExecutingControlResult(resultArray.toJSONString()); selectEventPlanAssoc.setExecutingControlResult(resultArray.toJSONString());
selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate()); selectEventPlanAssoc.setUpdateTime(DateUtils.getNowDate());
eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc); eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc);
resultObject.put("eventPlanAssocId",selectEventPlanAssoc.getId());
} }
else { else {
// 恢复操作 未执行的事件不能进行恢复操作 // 恢复操作 未执行的事件不能进行恢复操作
@ -624,8 +715,10 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(";", "")); selectEventPlanAssoc.setRecoveredControlDevice(deviceIds.toString().replaceFirst(";", ""));
selectEventPlanAssoc.setRecoveredControlResult(resultArray.toJSONString()); selectEventPlanAssoc.setRecoveredControlResult(resultArray.toJSONString());
eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc); eventPlanAssocMapper.updateEventPlanAssoc(selectEventPlanAssoc);
resultObject.put("eventPlanAssocId",selectEventPlanAssoc.getId());
} }
return resultArray; resultObject.put("deviceOperationResult",resultArray);
return resultObject;
} }
/** /**
@ -635,7 +728,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
List<DcDevice> dcDevices, List<DcDevice> dcDevices,
JSONObject otherConfig, JSONObject otherConfig,
JSONArray resultArray) { JSONArray resultArray) {
CountDownLatch latch = new CountDownLatch(dcDevices.size());
for (DcDevice device : dcDevices) { for (DcDevice device : dcDevices) {
@ -673,7 +766,28 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) { else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) {
if (operationType == 1) { if (operationType == 1) {
// 情报板发布全流程 // 情报板发布全流程
if (otherConfig.get("operationType").equals("2")) {
JSONArray contentList = JSON.parseArray(otherConfig.get("contentList").toString());
JSONObject foundContent = contentList.stream()
.map(content -> JSON.parseObject(content.toString()))
.filter(jsonObject ->
Integer.parseInt(jsonObject.get("dcDeviceId").toString()) == device.getId())
.findFirst()
.orElse(null);
if (foundContent == null) {
// 说明没有匹配到设备
JSONObject errorResult = new JSONObject();
errorResult.put("device",device.getId());
errorResult.put("errorMessage","未匹配到对应的模板内容");
resultArray.add(errorResult);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("dcInfoBoardTemplate",foundContent);
boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray);
}else {
boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray); boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray);
}
} else { } else {
// 恢复操作 // 恢复操作
if (otherConfig.get("operationType").equals("2")) { if (otherConfig.get("operationType").equals("2")) {
@ -702,7 +816,26 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
params.put("name", "task-event"); params.put("name", "task-event");
params.put("outVVol", "8"); params.put("outVVol", "8");
params.put("priority", "1"); params.put("priority", "1");
if (otherConfig.get("operationType").equals("2")) {
// 智能发布
JSONArray contentList = JSON.parseArray(otherConfig.get("contentList").toString());
JSONObject foundContent = contentList.stream()
.map(content -> JSON.parseObject(content.toString()))
.filter(jsonObject ->
Integer.parseInt(jsonObject.get("dcDeviceId").toString()) == device.getId())
.findFirst()
.orElse(null);
if (foundContent == null) {
// 说明没有匹配到设备
JSONObject errorResult = new JSONObject();
errorResult.put("device",device.getId());
errorResult.put("errorMessage","未匹配到对应的广播内容");
resultArray.add(errorResult);
}
params.put("text", foundContent.get("content"));
}else {
params.put("text", otherConfig.get("content")); params.put("text", otherConfig.get("content"));
}
params.put("repeatTimes", "3"); params.put("repeatTimes", "3");
params.put("functionType", "startPaTts"); params.put("functionType", "startPaTts");
JSONArray termList = new JSONArray(); JSONArray termList = new JSONArray();
@ -743,10 +876,18 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
} catch (HttpException | IOException e) { } catch (HttpException | IOException e) {
log.error(e.toString()); log.error(e.toString());
throw new RuntimeException(e); throw new RuntimeException(e);
} finally {
latch.countDown(); // 确保在异常情况下也能减少CountDownLatch计数
} }
}); });
} }
try {
latch.await(); // 等待所有线程执行完毕
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
} }
/** /**
@ -889,11 +1030,6 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
return dcExecuteActionService.updateDcExecuteActionBatch(dcExecuteActionList); return dcExecuteActionService.updateDcExecuteActionBatch(dcExecuteActionList);
} }
@Override
public int updateBatchDcEmergencyPlans(List<DcEmergencyPlans> dcEmergencyPlansList) {
return 0;
}
/** /**
* 批量删除事件预案 * 批量删除事件预案
* *

2
zc-business/src/main/resources/mapper/business/EventPlanAssocMapper.xml

@ -4,7 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zc.business.mapper.EventPlanAssocMapper"> <mapper namespace="com.zc.business.mapper.EventPlanAssocMapper">
<insert id="insertEventPlanAssoc" parameterType="EventPlanAssoc"> <insert id="insertEventPlanAssoc" parameterType="EventPlanAssoc" useGeneratedKeys="true" keyProperty="id">
insert into event_plan_assoc insert into event_plan_assoc
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="eventId != null and eventId != ''">event_id,</if> <if test="eventId != null and eventId != ''">event_id,</if>

Loading…
Cancel
Save