Browse Source

修改设备管控相关接口

develop
Mr.Wang 6 months ago
parent
commit
e86220184f
  1. 99
      zc-business/src/main/java/com/zc/business/controller/DcEmergencyPlansController.java
  2. 198
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java

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

@ -29,29 +29,7 @@ public class DcEmergencyPlansController extends BaseController {
@Autowired
private DcEmergencyPlansService dcEmergencyPlansService;
/**
* 查询事件预案列表
*/
@ApiOperation("查询事件预案列表")
// @PreAuthorize("@ss.hasPermi('business:plans:list')")
@GetMapping("/list")
public TableDataInfo list(DcEmergencyPlans dcEmergencyPlans) {
startPage();
List<DcEmergencyPlans> list = dcEmergencyPlansService.selectDcEmergencyPlansList(dcEmergencyPlans);
return getDataTable(list);
}
/**
* 根据事件预案id查询事件预案列表
*/
@ApiOperation("根据事件预案id查询事件预案列表")
// @PreAuthorize("@ss.hasPermi('business:plans:list')")
@GetMapping("/list/{id}")
public AjaxResult list(@PathVariable @ApiParam(name = "id", value = "事件预案id", required = true) Integer id) {
DcEmergencyPlans dcEmergencyPlans = dcEmergencyPlansService.selectDcEmergencyPlans(id);
return AjaxResult.success(dcEmergencyPlans);
}
/**
* 交通事件-根据事件数据查询事件预案列表
@ -77,41 +55,37 @@ public class DcEmergencyPlansController extends BaseController {
}
/**
* 交通事件-根据事件单个执行操作筛选设备
* 交通事件确定
*/
@ApiOperation("交通事件-根据事件、单个执行操作筛选设备")
@PostMapping("/list/event/deviceList")
public AjaxResult selectDeviceListByEventDcExecuteAction(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.selectDeviceListByEventDcExecuteAction(dcEventAnDcEmergencyPlans));
@ApiOperation("交通事件确定")
@PreAuthorize("@ss.hasPermi('business:plans:edit')")
@PostMapping("/event/confirm")
public AjaxResult eventConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.executionEventConfirmation(dcEventAnDcEmergencyPlans));
}
/**
* 交通事件-情报板确认回显原始模板
* 查询事件预案列表
*/
@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')")
@GetMapping("/list")
public TableDataInfo list(DcEmergencyPlans dcEmergencyPlans) {
startPage();
List<DcEmergencyPlans> list = dcEmergencyPlansService.selectDcEmergencyPlansList(dcEmergencyPlans);
return getDataTable(list);
}
/**
* 交通事件-情报板自动生成文字
* 根据事件预案id查询事件预案列表
*/
// @ApiOperation("交通事件-情报板自动生成文字")
@PostMapping("/event/automatic")
public AjaxResult eventAutomaticGeneration(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.eventAutomaticGeneration(dcEventAnDcEmergencyPlans));
}
@ApiOperation("根据事件预案id查询事件预案列表")
// @PreAuthorize("@ss.hasPermi('business:plans:list')")
@GetMapping("/list/{id}")
public AjaxResult list(@PathVariable @ApiParam(name = "id", value = "事件预案id", required = true) Integer id) {
/**
* 交通事件确定
*/
@ApiOperation("交通事件确定")
@PreAuthorize("@ss.hasPermi('business:plans:edit')")
@PostMapping("/event/confirm")
public AjaxResult eventConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.executionEventConfirmation(dcEventAnDcEmergencyPlans));
DcEmergencyPlans dcEmergencyPlans = dcEmergencyPlansService.selectDcEmergencyPlans(id);
return AjaxResult.success(dcEmergencyPlans);
}
/**
@ -161,4 +135,35 @@ public class DcEmergencyPlansController extends BaseController {
public AjaxResult update(@PathVariable String[] ids) {
return toAjax(dcEmergencyPlansService.deleteDcEmergencyPlans(ids));
}
/*************************************** 以下是暂时不用,但未来可能会用的接口 ***************************/
/**
* 交通事件-情报板自动生成文字
*/
// @ApiOperation("交通事件-情报板自动生成文字")
@PostMapping("/event/automatic")
public AjaxResult eventAutomaticGeneration(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.eventAutomaticGeneration(dcEventAnDcEmergencyPlans));
}
/**
* 交通事件-情报板确认回显原始模板
*/
// @ApiOperation("交通事件-情报板确认回显原始模板")
// @PreAuthorize("@ss.hasPermi('business:plans:list')")
@PostMapping("/event/board/confirm")
public AjaxResult eventBoardConfirm(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.eventBoardConfirm(dcEventAnDcEmergencyPlans));
}
/**
* 交通事件-根据事件单个执行操作筛选设备
*/
// @ApiOperation("交通事件-根据事件、单个执行操作筛选设备")
@PostMapping("/list/event/deviceList")
public AjaxResult selectDeviceListByEventDcExecuteAction(@RequestBody DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) {
return AjaxResult.success(dcEmergencyPlansService.selectDeviceListByEventDcExecuteAction(dcEventAnDcEmergencyPlans));
}
}

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

@ -170,28 +170,71 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
list.forEach(dcEmergencyPlans -> {
List<DcExecuteAction> dcExecuteActions = dcEmergencyPlans.getDcExecuteAction();
dcExecuteActions.forEach(dcExecuteAction -> {
List<DcDevice> 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,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,deviceList,content,dcEvent.getDirection());
}
handleConfigurationData(dcExecuteAction,dcEvent,markArray);
});
});
}
/**
* 处理executeConfig和recoverConfig中的配置数据
*/
public void handleConfigurationData(DcExecuteAction dcExecuteAction,
DcEvent dcEvent,
String[] markArray){
List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection());
String devices = deviceList.stream()
.map(DcDevice::getIotDeviceId)
.filter(java.util.Objects::nonNull)
.collect(Collectors.joining(","));
dcExecuteAction.setDeviceList(devices);
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig());
JSONObject recoverConfig = JSON.parseObject(dcExecuteAction.getRecoverConfig());
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,deviceList,content,dcEvent.getDirection());
}else {
// 说明是自定义发布
customPublishingDataFormatProcessing(deviceList,executeConfig,dcExecuteAction.getDeviceType());
dcExecuteAction.setExecuteConfig(executeConfig.toJSONString());
}
}
// 语音广播没有恢复操作
if (dcExecuteAction.getDeviceType() == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) {
if (recoverConfig.getString("operationType").equals("1")) {
// 说明是恢复操作中的自定义发布 (只有情报板会走)
customPublishingDataFormatProcessing(deviceList,recoverConfig,dcExecuteAction.getDeviceType());
}else {
recoverConfig.remove("contentList");
}
dcExecuteAction.setRecoverConfig(recoverConfig.toJSONString());
}
}
/**
* 自定义发布数据格式处理
*/
public void customPublishingDataFormatProcessing(List<DcDevice> deviceList, JSONObject otherConfig, int deviceType) {
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());
if (deviceType == DeviceTypeEnum.VARIABLE_INFORMATION_FLAG.getCode()) {
JSONObject dcInfoBoardTemplate = JSON.parseObject(otherConfig.get("dcInfoBoardTemplate").toString());
dcInfoBoardTemplate.keySet().forEach(key -> map.put(key, dcInfoBoardTemplate.get(key)));
}else {
// 语音广播
map.put("content",otherConfig.get("content"));
}
contentList.add(map);
});
otherConfig.put("contentList",contentList);
}
/**
* 交通事件-根据事件单个执行操作筛选设备
* @param dcEventAnDcEmergencyPlans
@ -225,22 +268,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
markArray[1] = String.format("%0" + 3 + "d", markArray[1]);
}
DcExecuteAction dcExecuteAction = dcEventAnDcEmergencyPlans.getDcExecuteAction();
List<DcDevice> 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());
}
}
handleConfigurationData(dcExecuteAction,dcEvent,markArray);
return dcExecuteAction;
}
@ -252,7 +280,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
List<DcDevice> deviceList,
String content,
String direction) {
// List<DcDevice> deviceList = ruleFiltering(dcExecuteAction, markArray, dcEvent.getDirection());
JSONObject executeConfig = JSON.parseObject(dcExecuteAction.getExecuteConfig());
List<Map<String,Object>> contentList = new ArrayList<>();
deviceList.forEach(dcDevice -> {
@ -779,48 +807,38 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
}
else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG.toString())) {
if (operationType == 1) {
if (operationType == 2 && otherConfig.getString("operationType").equals("2")) {
// 还原上次 恢复操作
props.put("fileId", "10");
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B;
AjaxResult ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName",device.getDeviceName());
result.put("content","还原上次");
result.put("result", ajaxResult1B);
resultArray.add(result);
} else {
// 情报板发布全流程
if (otherConfig.getString("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);
}
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);
}else {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dcInfoBoardTemplate",foundContent);
boardReleaseProcess(props, iotDeviceId, jsonObject, device, resultArray);
}else {
boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray);
}
} else {
// 恢复操作
if (otherConfig.getString("operationType").equals("2")) {
// 还原上次
props.put("fileId", "10");
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B;
AjaxResult ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props);
JSONObject result = new JSONObject();
result.put("device", device.getId());
result.put("deviceName",device.getDeviceName());
result.put("content","还原上次");
result.put("result", ajaxResult1B);
resultArray.add(result);
}else {
// 播放自定义
boardReleaseProcess(props, iotDeviceId, otherConfig, device, resultArray);
}
}
}
@ -831,27 +849,27 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService {
params.put("name", "task-event");
params.put("outVVol", "8");
params.put("priority", "1");
if (otherConfig.getString("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("deviceName",device.getDeviceName());
errorResult.put("errorMessage","未匹配到对应的广播内容");
resultArray.add(errorResult);
}
params.put("text", foundContent.get("content"));
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("deviceName",device.getDeviceName());
errorResult.put("errorMessage","未匹配到对应的广播内容");
resultArray.add(errorResult);
}
if (StringUtils.isEmpty(foundContent.getString("content"))) {
params.put("text", "山东高速欢迎您");
}else {
params.put("text", otherConfig.get("content"));
params.put("text", foundContent.getString("content"));
}
params.put("repeatTimes", "3");
params.put("functionType", "startPaTts");
JSONArray termList = new JSONArray();

Loading…
Cancel
Save