Browse Source

Merge branch 'develop' of http://39.106.31.193:9211/mengff/jihe-dc into develop

develop
xiepufeng 8 months ago
parent
commit
d795547621
  1. 5
      zc-business/src/main/java/com/zc/business/constant/DeviceFunctionIdConstants.java
  2. 42
      zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java
  3. 15
      zc-business/src/main/java/com/zc/business/controller/DcMYSQLJob.java
  4. 7
      zc-business/src/main/java/com/zc/business/controller/DcMYSQLUtil.java
  5. 431
      zc-business/src/main/java/com/zc/business/service/impl/DcEmergencyPlansServiceImpl.java
  6. 2
      zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSectionDataServiceImpl.java

5
zc-business/src/main/java/com/zc/business/constant/DeviceFunctionIdConstants.java

@ -28,4 +28,9 @@ public class DeviceFunctionIdConstants {
* 可变信息标志 1B 功能码
*/
public static final String VARIABLE_INFORMATION_FLAG_1B = "1B";
/**
* 激光疲劳唤醒 SETTM 功能码
*/
public static final String VARIABLE_INFORMATION_FLAG_SETTM = "SETTM";
}

42
zc-business/src/main/java/com/zc/business/controller/DcDeviceController.java

@ -1,12 +1,15 @@
package com.zc.business.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.zc.business.constant.DeviceTypeConstants;
import com.zc.business.domain.DcDevice;
import com.zc.business.request.DeviceGetPropertiesOperateRequest;
import com.zc.business.service.IDcDeviceService;
@ -25,9 +28,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 设备Controller
@ -45,6 +46,9 @@ public class DcDeviceController extends BaseController {
@Value("${iot.address}")
private String iotAddress;
@Resource
private BroadcastController broadcastController;
//*********************************设备增删改查******************************************
/**
@ -368,16 +372,28 @@ public class DcDeviceController extends BaseController {
@ApiOperation("批量设备功能调用")
@PostMapping("/batchFunctions")
public AjaxResult batchInvokedFunction(@RequestBody Map<String, Object> props) throws HttpException, IOException, InterruptedException {
OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(props);
Response response // 请求响应
= okHttp
.url(iotAddress + "/api/iot/device/batchFunctions") // 请求地址
.data(requestParams)
.post(); // 请求方法
return JSON.parseObject(response.body().string(), AjaxResult.class);
List<DcDevice> devices = (List<DcDevice>) props.get("devices");
JSONArray functions = (JSONArray) props.get("functions");
JSONArray resultArray = new JSONArray();
for (DcDevice device : devices) {
String iotDeviceId = device.getIotDeviceId();
for (Object function : functions) {
JSONObject functionJSONObject = JSONObject.parseObject(String.valueOf(function));
String functionId = functionJSONObject.getString("functionId");
JSONObject jsonObject = functionJSONObject.getJSONObject("params");
HashMap<String, Object> params = jsonObject.toJavaObject(new TypeReference<HashMap<String, Object>>() {
});
JSONObject result = new JSONObject();
result.put("device", device.getId());
if (device.getDeviceType().equals(DeviceTypeConstants.ROAD_SECTION_VOICE_BROADCASTING)) {
result.put("result", broadcastController.nearCamListDistance(jsonObject));
} else {
result.put("result", invokedFunction(iotDeviceId, functionId, params));
}
resultArray.add(result);
}
}
return AjaxResult.success(resultArray);
}
/**

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

@ -2,7 +2,6 @@ package com.zc.business.controller;
import com.ruoyi.common.config.RuoYiConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.env.Environment;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@ -20,7 +19,7 @@ import java.util.Date;
@Component
@Slf4j
public class DcMYSQLJob {
private final Environment environment;
//private final Environment environment;
private static final String IP = "10.0.81.202";
@ -30,12 +29,12 @@ public class DcMYSQLJob {
private static final String PASSWORD = "mysql123!@#";
public DcMYSQLJob(Environment environment) {
this.environment = environment;
}
//public DcMYSQLJob(Environment environment) {
// this.environment = environment;
//}
@Scheduled(cron = "0 0 22 * * ?")
//@Scheduled(cron = "0 25 * * * ?")
//@Scheduled(cron = "0 10 * * * ?")
public void backupAthena() throws IOException {
String url = "jdbc:mysql://10.0.81.202:3306/athena?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true";
@ -43,7 +42,7 @@ public class DcMYSQLJob {
}
@Scheduled(cron = "0 30 22 * * ?")
//@Scheduled(cron = "0 27 * * * ?")
//@Scheduled(cron = "0 20 * * * ?")
public void backupJiHeDC() throws IOException {
// 数据库配置信息
String url = "jdbc:mysql://10.0.81.202:3306/jihe-dc?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true";
@ -52,7 +51,7 @@ public class DcMYSQLJob {
}
@Scheduled(cron = "0 0 23 * * ?")
//@Scheduled(cron = "0 56 * * * ?")
//@Scheduled(cron = "0 30 * * * ?")
public void backupJiHeDCPro() throws IOException {
// 数据库配置信息
String url = "jdbc:mysql://10.0.81.202:3306/jihe-dc-pro?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&serverTimezone=GMT%2B8&allowPublicKeyRetrieval=true";

7
zc-business/src/main/java/com/zc/business/controller/DcMYSQLUtil.java

@ -16,11 +16,14 @@ public class DcMYSQLUtil {
*/
public static void backup(String host, String port, String userName, String password, String dbName, File file) {
String cmd = "mysqldump --single-transaction " + " -h" + host + " -P" + port + " -u" + userName + " -p" + password + " --databases --skip-extended-insert " + dbName + " > " + file.getPath();
String cmd = "";
String os = System.getProperties().getProperty("os.name");
if (os.contains("Windows")) {
// Windows 需要加上 cmd /c
cmd = "cmd /c " + cmd;
cmd = "cmd /c mysqldump --single-transaction " + " -h" + host + " -P" + port + " -u" + userName + " -p" + password + " --databases --skip-extended-insert " + dbName + " > " + file.getPath();
} else {
// Linux 需要加上 /usr/local/mysql/bin/
cmd = "bash -c /usr/local/mysql/bin/mysqldump --single-transaction " + " -h" + host + " -P" + port + " -u" + userName + " -p'" + password + "' --databases --skip-extended-insert " + dbName + " > " + file.getPath();
}
System.out.printf("cmd命令为:%s%n", cmd);
try {

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

@ -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);
}
});
}
}

2
zc-business/src/main/java/com/zc/business/service/impl/DcTrafficSectionDataServiceImpl.java

@ -122,7 +122,7 @@ public class DcTrafficSectionDataServiceImpl
/**
* 定义每小时第20分钟执行的任务用于清除过期缓存数据并将缓存中的数据整合后保存至数据库
*/
@Scheduled(cron = "0 20 * * * ?") // 每小时的20分整点执行该任务
// @Scheduled(cron = "0 20 * * * ?") // 每小时的20分整点执行该任务
public void performHourlyCleanupAndPersist() {
// 清除已过期的缓存数据
DailyTrafficStatisticsCache.clearExpiredData();

Loading…
Cancel
Save