Browse Source

增加事件确认弹框中,执行操作获取情报板播放内容

develop
Mr.Wang 1 year ago
parent
commit
950bbf27e0
  1. 20
      zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java
  2. 8
      zc-business/src/main/java/com/zc/business/domain/DcEmergencyPlans.java
  3. 11
      zc-business/src/main/java/com/zc/business/service/DcEmergencyPlansService.java
  4. 313
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

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

@ -78,6 +78,26 @@ public class DcEmergencyPlansController extends BaseController {
return AjaxResult.success(dcEmergencyPlansList);
}
/**
* 交通事件-情报板确认回显原始模板
*/
@ApiOperation("交通事件-情报板确认回显原始模板")
@PreAuthorize("@ss.hasPermi('business:plans:list')")
@PostMapping("/event/board/confirm")
public AjaxResult eventBoardConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.eventBoardConfirm(dcEventAnDcEmergencyPlans));
}
/**
* 感知事件-情报板确认回显原始模板
*/
@ApiOperation("感知事件-情报板确认回显原始模板")
@PreAuthorize("@ss.hasPermi('business:plans:list')")
@PostMapping("/warning/board/confirm")
public AjaxResult warningBoardConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.warningBoardConfirm(dcEventAnDcEmergencyPlans));
}
/**
* 感知事件-情报板自动生成文字
*/

8
zc-business/src/main/java/com/zc/business/domain/DcEmergencyPlans.java

@ -81,11 +81,17 @@ public class DcEmergencyPlans {
@ApiModelProperty("事件分类")
private int eventCategory;
/**
* 执行操作列表
*/
@ApiModelProperty("执行操作列表")
private List<DcExecuteAction> dcExecuteAction;
/**
* 执行操作
*/
@ApiModelProperty("执行操作")
private List<DcExecuteAction> dcExecuteAction;
private DcExecuteAction executeAction;
}

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

@ -3,6 +3,7 @@ package com.zc.business.service;
import com.zc.business.domain.*;
import java.util.List;
import java.util.Map;
/**
* 事件预案Service接口
@ -45,6 +46,16 @@ public interface DcEmergencyPlansService {
*/
List<DcEmergencyPlans> selectDcEmergencyPlansByWarningType(DcWarning dcWarning);
/**
* 交通事件-情报板确认回显原始模板
*/
Map<String,List<DcInfoBoardTemplate>> eventBoardConfirm(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans);
/**
* 感知事件-情报板确认回显原始模板
*/
Map<String,List<DcInfoBoardTemplate>> warningBoardConfirm(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans);
/**
* 交通事件确定
*

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

@ -8,6 +8,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.zc.business.constant.DeviceFunctionIdConstants;
import com.zc.business.constant.DeviceTypeConstants;
import com.zc.business.controller.BroadcastController;
@ -158,6 +159,227 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
}
}
/**
* 交通事件-情报板确认回显原始模板
*/
@Override
public Map<String,List<DcInfoBoardTemplate>> eventBoardConfirm(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
// 获取事件数据
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent();
// 方向
String direction = dcEvent.getDirection();
// 事件桩号
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 executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction();
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction);
return getBoardTemplate(dcDevices);
}
/**
* 感知事件-情报板确认回显原始模板
*/
@Override
public Map<String,List<DcInfoBoardTemplate>> warningBoardConfirm(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
// 获取事件数据
DcWarning dcWarning = dcEventAnDcEmergencyPlans.getDcWarning();
// 方向
String direction = dcWarning.getDirection();
// 事件桩号
dcWarning.setStakeMark(dcWarning.getStakeMark().replace("K",""));
String[] markArray = dcWarning.getStakeMark().split("\\+");
if (markArray[1].length() < 3) {
// 不足三位 补零
markArray[1] = String.format("%0" + 3 + "d", markArray[1]);
}
DcExecuteAction executeAction = dcEventAnDcEmergencyPlans.getDcEmergencyPlans().getExecuteAction();
List<DcDevice> dcDevices = ruleFiltering(executeAction, markArray, direction);
return getBoardTemplate(dcDevices);
}
/**
* 情报板设备执行3A功能,获取模板
*/
public Map<String,List<DcInfoBoardTemplate>> getBoardTemplate(List<DcDevice> dcDevices) {
Map<String,List<DcInfoBoardTemplate>> map = new HashMap<>();
dcDevices.forEach(dcDevice -> {
try {
if (StringUtils.isEmpty(dcDevice.getIotDeviceId())) {
return;
}
AjaxResult ajaxResult = dcDeviceController.getDeviceRealtimeProperty(dcDevice.getIotDeviceId(), "3A", new HashMap<>());
if (ajaxResult.get("code").equals(200)) {
JSONObject properties = JSON.parseObject(JSON.parseObject(ajaxResult.get("data").toString()).get("3A").toString());
JSONArray contentArray = JSONArray.parseArray(properties.get("content").toString());
List<DcInfoBoardTemplate> list = new ArrayList<>();
contentArray.forEach(content -> {
DcInfoBoardTemplate dcInfoBoardTemplate = new DcInfoBoardTemplate();
JSONObject jsonObject = JSON.parseObject(content.toString());
String displayAreaWidth = jsonObject.get("displayAreaWidth").toString();
String displayAreaHeight = jsonObject.get("displayAreaHeight").toString();
// 内容
dcInfoBoardTemplate.setContent(jsonObject.get("textContent").toString());
// 前景颜色
dcInfoBoardTemplate.setFontColor(jsonObject.get("foregroundColor").toString());
// 屏幕尺寸
dcInfoBoardTemplate.setScreenSize(displayAreaWidth+"*"+displayAreaHeight);
// 字号
dcInfoBoardTemplate.setFontSize(jsonObject.get("fontSize").toString());
// 字体风格
dcInfoBoardTemplate.setFontType(jsonObject.get("fontStyle").toString());
// 字距
dcInfoBoardTemplate.setFontSpacing(jsonObject.get("fontSpacing").toString());
// 停留时间
dcInfoBoardTemplate.setStopTime(jsonObject.get("residenceTime").toString());
// 入屏方式
dcInfoBoardTemplate.setInScreenMode(jsonObject.get("screenEntryMethod").toString());
// 水平对齐
dcInfoBoardTemplate.setFormatStyle(jsonObject.get("horizontalAlignment").toString());
list.add(dcInfoBoardTemplate);
});
map.put(dcDevice.getDeviceName(),list);
}
} catch (Exception e) {
e.printStackTrace();
}
});
return map;
}
/**
* 执行操作中的规则筛选
* @param dcExecuteAction
* @param markArray
* @param direction
* @return
*/
public List<DcDevice> ruleFiltering(DcExecuteAction dcExecuteAction,String[] markArray,String direction){
Integer searchRule = dcExecuteAction.getSearchRule();
List<String> start = new ArrayList<>();
List<String> end = new ArrayList<>();
// 设备列表
List<DcDevice> dcDevices = new ArrayList<>();
Map<String, Object> parameter = new HashMap<>();
parameter.put("deviceType", dcExecuteAction.getDeviceType());
// 根据不同的检索规则条件 获取设备
if (searchRule.equals(1)) {
// 指定设备资源
// 根据设备id,获取设备集合
LambdaQueryWrapper<DcDevice> queryWrapper = new LambdaQueryWrapper<>();
JSONObject otherConfig = JSON.parseObject(dcExecuteAction.getOtherConfig());
List<String> deviceList = (List<String>)otherConfig.get("deviceList");
queryWrapper.in(DcDevice::getIotDeviceId, deviceList);
dcDevices = dcDeviceService.list(queryWrapper);
}
else if (searchRule.equals(2)) {
// 事件上游最近
if (direction.equals("1")) {
// 上行 取最大的几个
start.add("55");
start.add("379");
end.add(markArray[0]);
end.add(markArray[1]);
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
Collections.sort(dcDevices, new Comparator<DcDevice>() {
@Override
public int compare(DcDevice o1, DcDevice o2) {
return o2.getStakeMark().compareTo(o1.getStakeMark());
}
});
if (dcDevices.size() > 0) {
dcDevices = dcDevices.subList(0 , dcExecuteAction.getNumber());
}
} else {
// 下行 取最小的几个
start.add(markArray[0]);
start.add(markArray[1]);
end.add("208");
end.add("154");
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
Collections.sort(dcDevices, new Comparator<DcDevice>() {
@Override
public int compare(DcDevice o1, DcDevice o2) {
return o1.getStakeMark().compareTo(o2.getStakeMark());
}
});
if (dcDevices.size() > 0) {
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber());
}
}
}
else if (searchRule.equals(3)) {
// 事件下游最近
if (direction.equals("1")) {
// 上行 取最大的几个
start.add(markArray[0]);
start.add(markArray[1]);
end.add("208");
end.add("154");
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
Collections.sort(dcDevices, new Comparator<DcDevice>() {
@Override
public int compare(DcDevice o1, DcDevice o2) {
return o1.getStakeMark().compareTo(o2.getStakeMark());
}
});
if (dcDevices.size() > 0) {
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber());
}
} else {
// 下行 取最小的几个
start.add("55");
start.add("379");
end.add(markArray[0]);
end.add(markArray[1]);
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
Collections.sort(dcDevices, new Comparator<DcDevice>() {
@Override
public int compare(DcDevice o1, DcDevice o2) {
return o2.getStakeMark().compareTo(o1.getStakeMark());
}
});
// 需要对查出的设备,按照桩号进行排序从小到大
if (dcDevices.size() > 0) {
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber());
}
}
}
else {
// 最近公里数
Integer kilometers = Integer.parseInt(markArray[0].replaceAll("K", ""));
// 根据事件桩号、公里数 计算出 桩号范围
start.add(String.valueOf(kilometers - dcExecuteAction.getNumber()));
start.add(markArray[1]);
end.add(String.valueOf(kilometers + dcExecuteAction.getNumber()));
end.add(markArray[1]);
// 构造查询条件
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
parameter.put("deviceType", dcExecuteAction.getDeviceType());
// 根据桩号范围,查询附近设备
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
}
return dcDevices;
}
/**
* 交通事件确定
@ -291,6 +513,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
// 存储所有设备的执行结果
JSONArray resultArray = new JSONArray();
// 事件桩号
stakeMark = stakeMark.replace("K","");
String[] markArray = stakeMark.split("\\+");
if (markArray[1].length() < 3) {
// 不足三位 补零
@ -304,95 +527,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
//获取事件预案中的 执行操作配置
dcEmergencyPlans.getDcExecuteAction()
.forEach(dcExecuteAction -> {
Integer searchRule = dcExecuteAction.getSearchRule();
List<String> start = new ArrayList<>();
List<String> end = new ArrayList<>();
// 设备列表
List<DcDevice> dcDevices = new ArrayList<>();
Map<String, Object> parameter = new HashMap<>();
parameter.put("deviceType", dcExecuteAction.getDeviceType());
// 根据不同的检索规则条件 获取设备
if (searchRule.equals(1)) {
// 指定设备资源
// 根据设备id,获取设备集合
LambdaQueryWrapper<DcDevice> queryWrapper = new LambdaQueryWrapper<>();
JSONObject otherConfig = JSON.parseObject(dcExecuteAction.getOtherConfig());
List<String> deviceList = (List<String>)otherConfig.get("deviceList");
queryWrapper.in(DcDevice::getIotDeviceId, deviceList);
dcDevices = dcDeviceService.list(queryWrapper);
}
else if (searchRule.equals(2)) {
// 事件上游最近
if (direction.equals("1")) {
// 上行 取最大的几个
start.add("55");
start.add("378.7");
end.add(markArray[0]);
end.add(markArray[1]);
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
dcDevices = dcDevices.subList(dcDevices.size() - dcExecuteAction.getNumber(), dcDevices.size());
} else {
// 下行 取最小的几个
start.add(markArray[0]);
start.add(markArray[1]);
end.add("208");
end.add("153.4");
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber());
}
// // 定义Comparator来比较DcDevice对象的stakeMark字段
// Comparator<DcDevice> comparator = Comparator.comparing(DcDevice::getStakeMark);
// // 对dcDevices进行升序排序
// Collections.sort(dcDevices, comparator);
// // 对dcDevices进行降序排序
// Collections.sort(dcDevices, comparator.reversed());
}
else if (searchRule.equals(3)) {
// 事件下游最近
if (direction.equals("1")) {
// 上行 取最大的几个
start.add(markArray[0]);
start.add(markArray[1]);
end.add("208");
end.add("153.4");
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber());
} else {
// 下行 取最小的几个
start.add("55");
start.add("378.7");
end.add(markArray[0]);
end.add(markArray[1]);
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
dcDevices = dcDevices.subList(dcDevices.size() - dcExecuteAction.getNumber(), dcDevices.size());
}
}
else {
// 最近公里数
Integer kilometers = Integer.parseInt(markArray[0].replaceAll("K", ""));
// 根据事件桩号、公里数 计算出 桩号范围
start.add(String.valueOf(kilometers - dcExecuteAction.getNumber()));
start.add(markArray[1]);
end.add(String.valueOf(kilometers + dcExecuteAction.getNumber()));
end.add(markArray[1]);
// 构造查询条件
parameter.put("startStakeMark", start);
parameter.put("endStakeMark", end);
parameter.put("deviceType", dcExecuteAction.getDeviceType());
// 根据桩号范围,查询附近设备
dcDevices = dcDeviceService.devicePileNumberQueryDevice(parameter);
}
List<DcDevice> dcDevices = ruleFiltering(dcExecuteAction, markArray, direction);
try {
// 根据不通设备类型,执行不通的功能操作

Loading…
Cancel
Save