|
|
@ -21,6 +21,8 @@ import com.zc.business.service.DcEmergencyPlansService; |
|
|
|
import com.zc.business.service.DcExecuteActionService; |
|
|
|
import com.zc.business.service.IDcDeviceService; |
|
|
|
import com.zc.common.core.httpclient.exception.HttpException; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
@ -31,6 +33,7 @@ import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@Service |
|
|
|
@Slf4j |
|
|
|
public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
|
|
|
|
@Resource |
|
|
@ -46,6 +49,9 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
@Resource |
|
|
|
private EventPlanAssocMapper eventPlanAssocMapper; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查询事件预案 |
|
|
@ -103,7 +109,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
JSONObject triggerJson = JSONObject.parseObject(triggerMechanism); |
|
|
|
String locationType = triggerJson.get("locationType").toString(); |
|
|
|
DcEventVehicleAccident dcEventVehicleAccident = event.getDcEventVehicleAccident(); |
|
|
|
String eventLocationType =dcEventVehicleAccident.getLocationType().toString(); |
|
|
|
String eventLocationType = dcEventVehicleAccident.getLocationType().toString(); |
|
|
|
return locationType.equals(eventLocationType); |
|
|
|
}) |
|
|
|
.collect(Collectors.toList()); |
|
|
@ -141,7 +147,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
|
|
|
|
int warningType = Integer.parseInt(dcWarning.getWarningType().toString()); |
|
|
|
|
|
|
|
if (warningType == WarningTypeEnum.UNUSUAL_WEATHER.getCode()) { |
|
|
|
if (warningType == WarningTypeEnum.UNUSUAL_WEATHER.getCode()) { |
|
|
|
return dcEmergencyPlansList.stream() |
|
|
|
.filter(dcEmergencyPlans -> { |
|
|
|
String triggerMechanism = dcEmergencyPlans.getTriggerMechanism(); |
|
|
@ -163,13 +169,13 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
* 交通事件-情报板确认回显原始模板 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String,List<DcInfoBoardTemplate>> eventBoardConfirm(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { |
|
|
|
public Map<String, List<DcInfoBoardTemplate>> eventBoardConfirm(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { |
|
|
|
// 获取事件数据
|
|
|
|
DcEvent dcEvent = dcEventAnDcEmergencyPlans.getDcEvent(); |
|
|
|
// 方向
|
|
|
|
String direction = dcEvent.getDirection(); |
|
|
|
// 事件桩号
|
|
|
|
dcEvent.setStakeMark(dcEvent.getStakeMark().replace("K","")); |
|
|
|
dcEvent.setStakeMark(dcEvent.getStakeMark().replace("K", "")); |
|
|
|
String[] markArray = dcEvent.getStakeMark().split("\\+"); |
|
|
|
if (markArray[1].length() < 3) { |
|
|
|
// 不足三位 补零
|
|
|
@ -184,13 +190,13 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
* 感知事件-情报板确认回显原始模板 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Map<String,List<DcInfoBoardTemplate>> warningBoardConfirm(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { |
|
|
|
public Map<String, List<DcInfoBoardTemplate>> warningBoardConfirm(DcEventAnDcEmergencyPlans dcEventAnDcEmergencyPlans) { |
|
|
|
// 获取事件数据
|
|
|
|
DcWarning dcWarning = dcEventAnDcEmergencyPlans.getDcWarning(); |
|
|
|
// 方向
|
|
|
|
String direction = dcWarning.getDirection(); |
|
|
|
// 事件桩号
|
|
|
|
dcWarning.setStakeMark(dcWarning.getStakeMark().replace("K","")); |
|
|
|
dcWarning.setStakeMark(dcWarning.getStakeMark().replace("K", "")); |
|
|
|
String[] markArray = dcWarning.getStakeMark().split("\\+"); |
|
|
|
if (markArray[1].length() < 3) { |
|
|
|
// 不足三位 补零
|
|
|
@ -204,48 +210,50 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
/** |
|
|
|
* 情报板设备执行3A功能,获取模板 |
|
|
|
*/ |
|
|
|
public Map<String,List<DcInfoBoardTemplate>> getBoardTemplate(List<DcDevice> dcDevices) { |
|
|
|
Map<String,List<DcInfoBoardTemplate>> map = new HashMap<>(); |
|
|
|
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); |
|
|
|
threadPoolTaskExecutor.execute(() -> { |
|
|
|
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(); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
return map; |
|
|
@ -253,12 +261,13 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 执行操作中的规则筛选 |
|
|
|
* |
|
|
|
* @param dcExecuteAction |
|
|
|
* @param markArray |
|
|
|
* @param direction |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public List<DcDevice> ruleFiltering(DcExecuteAction dcExecuteAction,String[] markArray,String direction){ |
|
|
|
public List<DcDevice> ruleFiltering(DcExecuteAction dcExecuteAction, String[] markArray, String direction) { |
|
|
|
|
|
|
|
Integer searchRule = dcExecuteAction.getSearchRule(); |
|
|
|
List<String> start = new ArrayList<>(); |
|
|
@ -273,11 +282,10 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
// 根据设备id,获取设备集合
|
|
|
|
LambdaQueryWrapper<DcDevice> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
JSONObject otherConfig = JSON.parseObject(dcExecuteAction.getOtherConfig()); |
|
|
|
List<String> deviceList = (List<String>)otherConfig.get("deviceList"); |
|
|
|
List<String> deviceList = (List<String>) otherConfig.get("deviceList"); |
|
|
|
queryWrapper.in(DcDevice::getIotDeviceId, deviceList); |
|
|
|
dcDevices = dcDeviceService.list(queryWrapper); |
|
|
|
} |
|
|
|
else if (searchRule.equals(2)) { |
|
|
|
} else if (searchRule.equals(2)) { |
|
|
|
|
|
|
|
// 事件上游最近
|
|
|
|
if (direction.equals("1")) { |
|
|
@ -296,7 +304,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
} |
|
|
|
}); |
|
|
|
if (dcDevices.size() > 0) { |
|
|
|
dcDevices = dcDevices.subList(0 , dcExecuteAction.getNumber()); |
|
|
|
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber()); |
|
|
|
} |
|
|
|
} else { |
|
|
|
// 下行 取最小的几个
|
|
|
@ -318,8 +326,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else if (searchRule.equals(3)) { |
|
|
|
} else if (searchRule.equals(3)) { |
|
|
|
// 事件下游最近
|
|
|
|
if (direction.equals("1")) { |
|
|
|
// 上行 取最大的几个
|
|
|
@ -360,8 +367,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
dcDevices = dcDevices.subList(0, dcExecuteAction.getNumber()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
} else { |
|
|
|
// 最近公里数
|
|
|
|
Integer kilometers = Integer.parseInt(markArray[0].replaceAll("K", "")); |
|
|
|
// 根据事件桩号、公里数 计算出 桩号范围
|
|
|
@ -395,11 +401,12 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
String direction = dcEvent.getDirection(); |
|
|
|
// 事件编号
|
|
|
|
String id = dcEvent.getId(); |
|
|
|
return executionConfirmation(dcEventAnDcEmergencyPlans,dcEvent.getStakeMark(),direction,id); |
|
|
|
return executionConfirmation(dcEventAnDcEmergencyPlans, dcEvent.getStakeMark(), direction, id); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 感知事件-情报板自动生成 |
|
|
|
* |
|
|
|
* @param dcEventAnDcEmergencyPlans |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -411,17 +418,17 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
Integer warningType = dcWarning.getWarningType(); |
|
|
|
if (warningType.equals(WarningTypeEnum.TRAFFIC_JAM.getCode())) { |
|
|
|
// 交通拥堵
|
|
|
|
dcInfoBoardTemplate.setContent("前方"+WarningTypeEnum.TRAFFIC_JAM.getInfo()+"请谨慎驾驶"); |
|
|
|
}else if (warningType.equals(WarningTypeEnum.NON_MOTOR_VEHICLE.getCode())) { |
|
|
|
dcInfoBoardTemplate.setContent("前方出现"+WarningTypeEnum.NON_MOTOR_VEHICLE.getInfo()+"请注意避让"); |
|
|
|
}else if (warningType.equals(WarningTypeEnum.PEDESTRIAN.getCode())) { |
|
|
|
dcInfoBoardTemplate.setContent("前方出现"+WarningTypeEnum.PEDESTRIAN.getInfo()+"请注意避让"); |
|
|
|
}else if (warningType.equals(WarningTypeEnum.FIREWORKS.getCode())) { |
|
|
|
dcInfoBoardTemplate.setContent("前方出现"+WarningTypeEnum.FIREWORKS.getInfo()+"请注意避让"); |
|
|
|
}else if (warningType.equals(WarningTypeEnum.OUTFALL.getCode())) { |
|
|
|
dcInfoBoardTemplate.setContent("前方出现"+WarningTypeEnum.OUTFALL.getInfo()+"请注意避让"); |
|
|
|
dcInfoBoardTemplate.setContent("前方" + WarningTypeEnum.TRAFFIC_JAM.getInfo() + "请谨慎驾驶"); |
|
|
|
} else if (warningType.equals(WarningTypeEnum.NON_MOTOR_VEHICLE.getCode())) { |
|
|
|
dcInfoBoardTemplate.setContent("前方出现" + WarningTypeEnum.NON_MOTOR_VEHICLE.getInfo() + "请注意避让"); |
|
|
|
} else if (warningType.equals(WarningTypeEnum.PEDESTRIAN.getCode())) { |
|
|
|
dcInfoBoardTemplate.setContent("前方出现" + WarningTypeEnum.PEDESTRIAN.getInfo() + "请注意避让"); |
|
|
|
} else if (warningType.equals(WarningTypeEnum.FIREWORKS.getCode())) { |
|
|
|
dcInfoBoardTemplate.setContent("前方出现" + WarningTypeEnum.FIREWORKS.getInfo() + "请注意避让"); |
|
|
|
} else if (warningType.equals(WarningTypeEnum.OUTFALL.getCode())) { |
|
|
|
dcInfoBoardTemplate.setContent("前方出现" + WarningTypeEnum.OUTFALL.getInfo() + "请注意避让"); |
|
|
|
} else if (warningType.equals(WarningTypeEnum.VEHICLE_CONVERSE_RUNNING.getCode())) { |
|
|
|
dcInfoBoardTemplate.setContent("前方出现"+WarningTypeEnum.OUTFALL.getInfo()+"请注意避让"); |
|
|
|
dcInfoBoardTemplate.setContent("前方出现" + WarningTypeEnum.OUTFALL.getInfo() + "请注意避让"); |
|
|
|
} |
|
|
|
|
|
|
|
return dcInfoBoardTemplate; |
|
|
@ -429,6 +436,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 交通事件-情报板自动生成 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
@ -475,7 +483,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
.orElse("前方存在限行或关闭"); |
|
|
|
dcInfoBoardTemplate.setContent(content); |
|
|
|
|
|
|
|
}else { |
|
|
|
} else { |
|
|
|
// 施工建设
|
|
|
|
dcInfoBoardTemplate.setContent("前方施工请注意驾驶"); |
|
|
|
} |
|
|
@ -484,6 +492,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
|
|
|
|
/** |
|
|
|
* 感知事件确认 |
|
|
|
* |
|
|
|
* @param dcEventAnDcEmergencyPlans 事件数据 和 事件预案数据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -496,11 +505,12 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
String direction = dcWarning.getDirection(); |
|
|
|
// 事件编号
|
|
|
|
String id = dcWarning.getId(); |
|
|
|
return executionConfirmation(dcEventAnDcEmergencyPlans,dcWarning.getStakeMark(),direction,id); |
|
|
|
return executionConfirmation(dcEventAnDcEmergencyPlans, dcWarning.getStakeMark(), direction, id); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 事件确认 |
|
|
|
* |
|
|
|
* @param dcEventAnDcEmergencyPlans 事件数据 和 事件预案数据 |
|
|
|
* @return |
|
|
|
*/ |
|
|
@ -513,7 +523,7 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
// 存储所有设备的执行结果
|
|
|
|
JSONArray resultArray = new JSONArray(); |
|
|
|
// 事件桩号
|
|
|
|
stakeMark = stakeMark.replace("K",""); |
|
|
|
stakeMark = stakeMark.replace("K", ""); |
|
|
|
String[] markArray = stakeMark.split("\\+"); |
|
|
|
if (markArray[1].length() < 3) { |
|
|
|
// 不足三位 补零
|
|
|
@ -575,156 +585,175 @@ public class DcEmergencyPlansServiceImpl implements DcEmergencyPlansService { |
|
|
|
/** |
|
|
|
* 根据不通设备类型,执行不通的功能操作 |
|
|
|
*/ |
|
|
|
public void invokedFunction( |
|
|
|
Integer operationType, |
|
|
|
public void invokedFunction(Integer operationType, |
|
|
|
List<DcDevice> dcDevices, |
|
|
|
JSONObject otherConfig, |
|
|
|
JSONArray resultArray) throws HttpException, IOException { |
|
|
|
String iotDeviceId = ""; |
|
|
|
String functionId = ""; |
|
|
|
JSONArray resultArray) { |
|
|
|
|
|
|
|
|
|
|
|
for (DcDevice device : dcDevices) { |
|
|
|
iotDeviceId = device.getIotDeviceId(); |
|
|
|
HashMap<String, Object> props = new HashMap<>(); |
|
|
|
|
|
|
|
if (device.getDeviceType().equals(DeviceTypeConstants.DRIVING_GUIDANCE)) { |
|
|
|
// 行车诱导
|
|
|
|
functionId = DeviceFunctionIdConstants.DRIVING_GUIDANCE; |
|
|
|
// 控制模式 1-手动 2-自动 3-万年历
|
|
|
|
String controlModel = otherConfig.get("controlModel").toString(); |
|
|
|
props.put("onWorkStatus", otherConfig.get("state").toString()); |
|
|
|
props.put("inWorkStatus", otherConfig.get("state").toString()); |
|
|
|
if (controlModel.equals("1")) { |
|
|
|
props.put("mode", "00"); |
|
|
|
} else if (controlModel.equals("2")) { |
|
|
|
String startTime = otherConfig.get("startTime").toString(); |
|
|
|
String endTime = otherConfig.get("endTime").toString(); |
|
|
|
props.put("mode", "01"); |
|
|
|
props.put("startDisplayTime", startTime); |
|
|
|
props.put("endDisplayTime", endTime); |
|
|
|
} else { |
|
|
|
props.put("mode", "02"); |
|
|
|
} |
|
|
|
|
|
|
|
AjaxResult ajaxResult = dcDeviceController.invokedFunction(iotDeviceId, functionId, props); |
|
|
|
// 将调用结果存入到 resultArray(操作结果) 中
|
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", ajaxResult); |
|
|
|
resultArray.add(result); |
|
|
|
threadPoolTaskExecutor.execute(() -> { |
|
|
|
String iotDeviceId = ""; |
|
|
|
String functionId = ""; |
|
|
|
iotDeviceId = device.getIotDeviceId(); |
|
|
|
HashMap<String, Object> props = new HashMap<>(); |
|
|
|
try { |
|
|
|
if (device.getDeviceType().equals(DeviceTypeConstants.DRIVING_GUIDANCE)) { |
|
|
|
// 行车诱导
|
|
|
|
functionId = DeviceFunctionIdConstants.DRIVING_GUIDANCE; |
|
|
|
// 控制模式 1-手动 2-自动 3-万年历
|
|
|
|
String controlModel = otherConfig.get("controlModel").toString(); |
|
|
|
props.put("onWorkStatus", otherConfig.get("state").toString()); |
|
|
|
props.put("inWorkStatus", otherConfig.get("state").toString()); |
|
|
|
if (controlModel.equals("1")) { |
|
|
|
props.put("mode", "00"); |
|
|
|
} else if (controlModel.equals("2")) { |
|
|
|
String startTime = otherConfig.get("startTime").toString(); |
|
|
|
String endTime = otherConfig.get("endTime").toString(); |
|
|
|
props.put("mode", "01"); |
|
|
|
props.put("startDisplayTime", startTime); |
|
|
|
props.put("endDisplayTime", endTime); |
|
|
|
} else { |
|
|
|
props.put("mode", "02"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG)) { |
|
|
|
if (operationType == 1) { |
|
|
|
// 执行操作
|
|
|
|
// 可变信息标志 分三步
|
|
|
|
// 1:执行11功能码
|
|
|
|
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_11; |
|
|
|
props.put("fileName","play011.lst"); |
|
|
|
props.put("size","65535"); |
|
|
|
AjaxResult ajaxResult11 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props); |
|
|
|
if (ajaxResult11.get("code").equals(200)) { |
|
|
|
// 2:执行13功能码
|
|
|
|
HashMap<String, Object> props11 = new HashMap<>(); |
|
|
|
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_13; |
|
|
|
List<Map<String,String>> list = new ArrayList<>(); |
|
|
|
Map<String,String> parameters = new HashMap<>(); |
|
|
|
DcInfoBoardTemplate dcInfoBoardTemplate = JSON.parseObject( |
|
|
|
JSON.toJSONString(otherConfig.get("dcInfoBoardTemplate")), |
|
|
|
DcInfoBoardTemplate.class); |
|
|
|
// stopTime
|
|
|
|
parameters.put("STAY",dcInfoBoardTemplate.getStopTime()); |
|
|
|
// inScreenMode
|
|
|
|
parameters.put("ACTION",dcInfoBoardTemplate.getInScreenMode()); |
|
|
|
// fontSpacing
|
|
|
|
parameters.put("SPEED",dcInfoBoardTemplate.getFontSpacing()); |
|
|
|
// fontColor
|
|
|
|
parameters.put("COLOR",dcInfoBoardTemplate.getFontColor()); |
|
|
|
// fontType
|
|
|
|
parameters.put("FONT",dcInfoBoardTemplate.getFontType()); |
|
|
|
// fontSize
|
|
|
|
parameters.put("FONT_SIZE",dcInfoBoardTemplate.getFontSize()); |
|
|
|
// content
|
|
|
|
parameters.put("CONTENT",dcInfoBoardTemplate.getContent()); |
|
|
|
// screenSize 768*64 宽度和高度
|
|
|
|
parameters.put("width",dcInfoBoardTemplate.getScreenSize().split("\\*")[0]); |
|
|
|
parameters.put("height",dcInfoBoardTemplate.getScreenSize().split("\\*")[1]); |
|
|
|
// formatStyle
|
|
|
|
parameters.put("formatStyle",dcInfoBoardTemplate.getFormatStyle()); |
|
|
|
list.add(parameters); |
|
|
|
props11.put("parameters",list); |
|
|
|
AjaxResult ajaxResult13 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props11); |
|
|
|
AjaxResult ajaxResult = dcDeviceController.invokedFunction(iotDeviceId, functionId, props); |
|
|
|
// 将调用结果存入到 resultArray(操作结果) 中
|
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
if (ajaxResult13.get("code").equals(200)) { |
|
|
|
HashMap<String, Object> props1B = new HashMap<>(); |
|
|
|
// 3: 执行1B功能码
|
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", ajaxResult); |
|
|
|
resultArray.add(result); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
else if (device.getDeviceType().equals(DeviceTypeConstants.VARIABLE_INFORMATION_FLAG)) { |
|
|
|
if (operationType == 1) { |
|
|
|
|
|
|
|
// 执行操作
|
|
|
|
// 可变信息标志 分三步
|
|
|
|
// 1:执行11功能码
|
|
|
|
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_11; |
|
|
|
props.put("fileName", "play011.lst"); |
|
|
|
props.put("size", "65535"); |
|
|
|
AjaxResult ajaxResult11; |
|
|
|
ajaxResult11 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props); |
|
|
|
if (ajaxResult11.get("code").equals(200)) { |
|
|
|
// 2:执行13功能码
|
|
|
|
HashMap<String, Object> props11 = new HashMap<>(); |
|
|
|
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_13; |
|
|
|
List<Map<String, String>> list = new ArrayList<>(); |
|
|
|
Map<String, String> parameters = new HashMap<>(); |
|
|
|
DcInfoBoardTemplate dcInfoBoardTemplate = JSON.parseObject( |
|
|
|
JSON.toJSONString(otherConfig.get("dcInfoBoardTemplate")), |
|
|
|
DcInfoBoardTemplate.class); |
|
|
|
// stopTime
|
|
|
|
parameters.put("STAY", dcInfoBoardTemplate.getStopTime()); |
|
|
|
// inScreenMode
|
|
|
|
parameters.put("ACTION", dcInfoBoardTemplate.getInScreenMode()); |
|
|
|
// fontSpacing
|
|
|
|
parameters.put("SPEED", dcInfoBoardTemplate.getFontSpacing()); |
|
|
|
// fontColor
|
|
|
|
parameters.put("COLOR", dcInfoBoardTemplate.getFontColor()); |
|
|
|
// fontType
|
|
|
|
parameters.put("FONT", dcInfoBoardTemplate.getFontType()); |
|
|
|
// fontSize
|
|
|
|
parameters.put("FONT_SIZE", dcInfoBoardTemplate.getFontSize()); |
|
|
|
// content
|
|
|
|
parameters.put("CONTENT", dcInfoBoardTemplate.getContent()); |
|
|
|
// screenSize 768*64 宽度和高度
|
|
|
|
parameters.put("width", dcInfoBoardTemplate.getScreenSize().split("\\*")[0]); |
|
|
|
parameters.put("height", dcInfoBoardTemplate.getScreenSize().split("\\*")[1]); |
|
|
|
// formatStyle
|
|
|
|
parameters.put("formatStyle", dcInfoBoardTemplate.getFormatStyle()); |
|
|
|
list.add(parameters); |
|
|
|
props11.put("parameters", list); |
|
|
|
AjaxResult ajaxResult13 = null; |
|
|
|
ajaxResult13 = dcDeviceController.invokedFunction(iotDeviceId, functionId, props11); |
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
if (ajaxResult13.get("code").equals(200)) { |
|
|
|
HashMap<String, Object> props1B = new HashMap<>(); |
|
|
|
// 3: 执行1B功能码
|
|
|
|
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B; |
|
|
|
props1B.put("fileId", "11"); |
|
|
|
AjaxResult ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props1B); |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", ajaxResult1B); |
|
|
|
resultArray.add(result); |
|
|
|
|
|
|
|
} else { |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", ajaxResult13); |
|
|
|
resultArray.add(result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
// 恢复操作
|
|
|
|
props.put("fileId", "10"); |
|
|
|
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_1B; |
|
|
|
props1B.put("fileId","11"); |
|
|
|
AjaxResult ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props1B); |
|
|
|
AjaxResult ajaxResult1B; |
|
|
|
|
|
|
|
ajaxResult1B = dcDeviceController.invokedFunction(iotDeviceId, functionId, props); |
|
|
|
|
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", ajaxResult1B); |
|
|
|
resultArray.add(result); |
|
|
|
}else { |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", ajaxResult13); |
|
|
|
resultArray.add(result); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
// 恢复操作
|
|
|
|
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("result", ajaxResult1B); |
|
|
|
resultArray.add(result); |
|
|
|
} |
|
|
|
else if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) { |
|
|
|
// 路段广播
|
|
|
|
JSONObject params = new JSONObject(); |
|
|
|
params.put("name", "task-event"); |
|
|
|
params.put("outVVol", "8"); |
|
|
|
params.put("priority", "1"); |
|
|
|
params.put("text", otherConfig.get("content")); |
|
|
|
params.put("repeatTimes", "3"); |
|
|
|
params.put("functionType", "startPaTts"); |
|
|
|
JSONArray termList = new JSONArray(); |
|
|
|
termList.add(JSON.parseObject(device.getOtherConfig())); |
|
|
|
params.put("termList", termList); |
|
|
|
|
|
|
|
JSONObject returnResult = broadcastController.nearCamListDistance(params); |
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", returnResult); |
|
|
|
resultArray.add(result); |
|
|
|
|
|
|
|
} |
|
|
|
else if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) { |
|
|
|
// 路段广播
|
|
|
|
JSONObject params = new JSONObject(); |
|
|
|
params.put("name","task-event"); |
|
|
|
params.put("outVVol","8"); |
|
|
|
params.put("priority","1"); |
|
|
|
params.put("text",otherConfig.get("content")); |
|
|
|
params.put("repeatTimes","3"); |
|
|
|
params.put("functionType","startPaTts"); |
|
|
|
JSONArray termList = new JSONArray(); |
|
|
|
termList.add(JSON.parseObject(device.getOtherConfig())); |
|
|
|
params.put("termList",termList); |
|
|
|
JSONObject returnResult =broadcastController.nearCamListDistance(params); |
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", returnResult); |
|
|
|
resultArray.add(result); |
|
|
|
} |
|
|
|
else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING)) { |
|
|
|
// 激光疲劳唤醒
|
|
|
|
functionId = otherConfig.get("state").toString(); |
|
|
|
|
|
|
|
AjaxResult ajaxResultState = dcDeviceController.invokedFunction(iotDeviceId, functionId, new HashMap<>()); |
|
|
|
// 将调用结果存入到 resultArray(操作结果) 中
|
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", ajaxResultState); |
|
|
|
resultArray.add(result); |
|
|
|
// 操作时长
|
|
|
|
String operationDuration = "SETTM" + otherConfig.get("operationDuration").toString(); |
|
|
|
AjaxResult ajaxResult = dcDeviceController.invokedFunction(iotDeviceId, operationDuration, new HashMap<>()); |
|
|
|
JSONObject resultTime = new JSONObject(); |
|
|
|
resultTime.put("device", device.getId()); |
|
|
|
resultTime.put("result", ajaxResult); |
|
|
|
resultArray.add(resultTime); |
|
|
|
} else { |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else if (device.getDeviceType().equals(DeviceTypeConstants.LASER_FATIGUE_AWAKENING)) { |
|
|
|
// 激光疲劳唤醒
|
|
|
|
functionId = otherConfig.get("state").toString(); |
|
|
|
|
|
|
|
AjaxResult ajaxResultState = dcDeviceController.invokedFunction(iotDeviceId, functionId, new HashMap<>()); |
|
|
|
JSONObject result = new JSONObject(); |
|
|
|
result.put("device", device.getId()); |
|
|
|
result.put("result", ajaxResultState); |
|
|
|
resultArray.add(result); |
|
|
|
|
|
|
|
// 操作时长
|
|
|
|
String operationDuration = "SETTM" + otherConfig.get("operationDuration").toString(); |
|
|
|
HashMap<String, Object> propsTime = new HashMap<>(); |
|
|
|
propsTime.put("SET", operationDuration); |
|
|
|
functionId = DeviceFunctionIdConstants.VARIABLE_INFORMATION_FLAG_SETTM; |
|
|
|
|
|
|
|
AjaxResult ajaxResult = dcDeviceController.invokedFunction(iotDeviceId, functionId, propsTime); |
|
|
|
JSONObject resultTime = new JSONObject(); |
|
|
|
resultTime.put("device", device.getId()); |
|
|
|
resultTime.put("result", ajaxResult); |
|
|
|
resultArray.add(resultTime); |
|
|
|
|
|
|
|
} |
|
|
|
} catch (HttpException | IOException e) { |
|
|
|
log.error(e.toString()); |
|
|
|
throw new RuntimeException(e); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|