diff --git a/zc-business/pom.xml b/zc-business/pom.xml
index d612ab2e..ce688960 100644
--- a/zc-business/pom.xml
+++ b/zc-business/pom.xml
@@ -21,6 +21,13 @@
org.eclipse.paho.client.mqttv3
1.2.2
+
+
+ com.hikvision.ga
+ artemis-http-client
+ 1.1.12.RELEASE
+
+
commons-net
diff --git a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java
index d5086948..81d51e11 100644
--- a/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java
+++ b/zc-business/src/main/java/com/zc/business/controller/DcWarningController.java
@@ -238,5 +238,16 @@ public class DcWarningController extends BaseController
return toAjax(dcWarningService.falseAlarmResolution(dcWarning));
}
+ /**
+ * 获取雷达事件视频
+ *
+ *
+ */
+ @GetMapping("/video/{id}")
+ public AjaxResult getRadarIncidentVideo(@PathVariable("id") String id)throws Exception{
+
+ return AjaxResult.success(dcWarningService.getRadarIncidentVideo(id));
+ }
+
}
diff --git a/zc-business/src/main/java/com/zc/business/controller/VideoController.java b/zc-business/src/main/java/com/zc/business/controller/VideoController.java
index 4da078c9..2df09ac8 100644
--- a/zc-business/src/main/java/com/zc/business/controller/VideoController.java
+++ b/zc-business/src/main/java/com/zc/business/controller/VideoController.java
@@ -699,6 +699,43 @@ public class VideoController extends BaseController {
return getJsonResult(response,okHttp);
}
+ /**
+ * 获取视频流信息
+ * camId string 相机编号
+ * startTime Date 相机开始时间 yyyy-MM-dd HH:mm:ss
+ * duration 是Int 下载时长/分钟 不能超过五分钟
+ */
+ @ApiOperation("下载相机录像")
+ @GetMapping(value = "/downloadCameraVideo")
+ public JSONObject downloadCameraVideo( String camId,String startTime,int duration) throws HttpException, IOException {
+ JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo"));
+
+
+ OkHttp okHttp = new OkHttp();
+
+ RequestParams requestParams = new RequestParams();
+ requestParams.put("camId", camId);
+ requestParams.put("startTime", startTime);
+ requestParams.put("duration", duration);
+
+ Map header = new HashMap<>();
+
+ if (VideoController.TOKEN == null) {
+ getToken();
+ }
+
+ header.put("Authorization", TOKEN);
+
+ Response response // 请求响应
+ = okHttp
+ .headers(header)
+ .url(cameraInfo.getString("URL") + UniversalEnum.DOWNLOAD_CAMERA_VIDEO.getValue()) // 请求地址
+ .data(requestParams) // 请求参数
+ .get(); // 请求方法
+
+ return getJsonResult(response,okHttp);
+
+ }
public void getToken() throws HttpException, IOException {
diff --git a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java
index 1666d78a..a379baa0 100644
--- a/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java
+++ b/zc-business/src/main/java/com/zc/business/enums/UniversalEnum.java
@@ -1732,6 +1732,10 @@ public enum UniversalEnum {
// 获取视频流信息 /videoInfo/api/externalVideoStreaming
GET_VIDEO_STREAM_INFORMATION(0, "/videoInfo/api/externalVideoStreaming"),
+ //下载相机录像
+ DOWNLOAD_CAMERA_VIDEO(0,"/videoInfo/api/downloadVideotape"),
+//雷达关联监控点查询接口
+RADAR_ASSOCIATED_MONITORING_POINT_QUERY_INTERFACE(0,"/api/radar/v1/selectRelateByPage"),
// 云平台控制 /videoInfo/api/PTZControl
CLOUD_PLATFORM_CONTROL(0, "/videoInfo/api/PTZControl"),
diff --git a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java
index a89cc77e..69c2ecca 100644
--- a/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java
+++ b/zc-business/src/main/java/com/zc/business/message/device/handler/DeviceMessageHandler.java
@@ -317,12 +317,12 @@ public class DeviceMessageHandler {
}
dcWarning.setLane(String.valueOf(relatedLaneNo));
- String title = direction + WarningSubclassEnum.getDecorateInfo(warningSubclass);
+ String title = direction+UniversalEnum.BLANK_SPACE.getValue() + WarningSubclassEnum.getDecorateInfo(warningSubclass);
// 标题
dcWarning.setWarningTitle(title);
SimpleDateFormat sdf = new SimpleDateFormat(UniversalEnum.CHINESE_CHARACTER_TIME_FORMAT.getValue());
String formattedDate = sdf.format(new Date());
- dcWarning.setRemark(formattedDate + UniversalEnum.BLANK_SPACE.getValue() + title);
+ dcWarning.setRemark(formattedDate + UniversalEnum.BLANK_SPACE.getValue() +data.getString("stakeMark")+UniversalEnum.BLANK_SPACE.getValue()+ title);
// 影响车道
// 物联设备id
diff --git a/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java b/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java
index f4d8576f..efb350d5 100644
--- a/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java
+++ b/zc-business/src/main/java/com/zc/business/service/IDcWarningService.java
@@ -108,4 +108,8 @@ public interface IDcWarningService
public Integer insertDispatch(DcDispatch dcDispatch);
//误报解除
public Integer falseAlarmResolution(DcWarning dcWarning);
+ /**
+ * 获取雷达事件视频
+ */
+ String getRadarIncidentVideo(String id)throws Exception;
}
diff --git a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
index a51c25e4..28aab3ca 100644
--- a/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
+++ b/zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java
@@ -2,13 +2,17 @@ package com.zc.business.service.impl;
import com.alibaba.fastjson.JSON;
-import com.google.gson.JsonObject;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.hikvision.artemis.sdk.ArtemisHttpUtil;
+import com.hikvision.artemis.sdk.config.ArtemisConfig;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.service.ISysConfigService;
+import com.zc.business.controller.VideoController;
import com.zc.business.domain.*;
import com.zc.business.enums.UniversalEnum;
import com.zc.business.enums.ValueConverter;
@@ -22,7 +26,6 @@ import com.zc.business.service.IDcWarningService;
import com.zc.business.utils.StakeMarkUtils;
import com.zc.common.core.httpclient.OkHttp;
import com.zc.common.core.httpclient.exception.HttpException;
-import com.zc.common.core.httpclient.request.RequestParams;
import com.zc.common.core.websocket.WebSocketService;
import com.zc.common.core.websocket.constant.WebSocketEvent;
import okhttp3.Response;
@@ -35,10 +38,15 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.IOException;
+import java.time.Duration;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.time.temporal.ChronoUnit;
import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
+
/**
* 预警信息Service业务层处理
*
@@ -46,8 +54,7 @@ import java.util.stream.Collectors;
* @date 2024-01-26
*/
@Service
-public class DcWarningServiceImpl implements IDcWarningService
-{
+public class DcWarningServiceImpl implements IDcWarningService {
@Autowired
private DcWarningMapper dcWarningMapper;
//事件
@@ -63,6 +70,8 @@ public class DcWarningServiceImpl implements IDcWarningService
private DcProcessConfigMapper dcProcessConfigMapper;
@Autowired
private ISysConfigService configService;
+ @Autowired
+ private VideoController videoController;
@Resource
private RedisCache redisCache;
private final String HAPPEN = UniversalEnum.TAKE_PLACE.getValue();
@@ -71,9 +80,11 @@ public class DcWarningServiceImpl implements IDcWarningService
private static final String WARNINGSTRATEGY = UniversalEnum.WARNING_STRATEGY.getValue();//redis策略缓存的key
private static final String WARNINGDATA = UniversalEnum.WARNING_DATA.getValue();//redis事件缓存的key
//private static String JUDGE = "1"; //自定义判断参数,1为满足0为不满足
+ private static final String ARTEMIS_PATH = "/artemis";
/**
* 感知事件数据统计
+ *
* @return
*/
@Override
@@ -88,8 +99,7 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 预警信息
*/
@Override
- public HashMap selectDcWarningById(String id)
- {
+ public HashMap selectDcWarningById(String id) {
return dcWarningMapper.selectDcWarningById(id);
}
@@ -100,8 +110,7 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 预警信息
*/
@Override
- public HashMap selectAlarmById(String id)
- {
+ public HashMap selectAlarmById(String id) {
return dcWarningMapper.selectAlarmById(id);
}
@@ -112,10 +121,10 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 预警信息
*/
@Override
- public List> selectDcWarningList(DcWarning dcWarning)
- {
+ public List> selectDcWarningList(DcWarning dcWarning) {
return dcWarningMapper.selectDcWarningList(dcWarning);
}
+
//导出
@Override
public List export(DcWarning dcWarning) {
@@ -129,24 +138,23 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 结果
*/
@Override
- public int insertDcWarning(DcWarning dcWarning)
- {
+ public int insertDcWarning(DcWarning dcWarning) {
dcWarning.setCreateTime(DateUtils.getNowDate());
//设置事件Id UUID无下划线格式32
String uuid = IdUtils.fastSimpleUUID();
dcWarning.setId(uuid);
- if (StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getWarningSource()==null||dcWarning.getWarningType()==null||
- StringUtils.isBlank(dcWarning.getWarningSubclass())||StringUtils.isBlank(dcWarning.getDirection())){
+ if (StringUtils.isBlank(dcWarning.getStakeMark()) || dcWarning.getWarningSource() == null || dcWarning.getWarningType() == null ||
+ StringUtils.isBlank(dcWarning.getWarningSubclass()) || StringUtils.isBlank(dcWarning.getDirection())) {
return UniversalEnum.ZERO.getNumber();
}
- String redisKye=dcWarning.getWarningSource().toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//配置数据的key 事件源+事件类型+策略
+ String redisKye = dcWarning.getWarningSource().toString() + dcWarning.getWarningType().toString() + dcWarning.getWarningSubclass();//配置数据的key 事件源+事件类型+策略
Map redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//获取缓存全部的配置数据
- if (redisWarningStrategy==null||redisWarningStrategy.size()==UniversalEnum.ZERO.getNumber()){//如果缓存为空,查询数据重新加入缓存
+ if (redisWarningStrategy == null || redisWarningStrategy.size() == UniversalEnum.ZERO.getNumber()) {//如果缓存为空,查询数据重新加入缓存
Map redisMap = new HashMap<>();
List dcWaringStrategies = dcWarningMapper.selectDcWaringStrategyList();//数据库全部配置数据
for (DcWaringStrategy waringStrategy : dcWaringStrategies) {
String key = waringStrategy.getWarningSource().toString() + waringStrategy.getWarningType().toString()
- + waringStrategy.getWarningSubclass()+waringStrategy.getStrategy().toString();//redis配置数据key
+ + waringStrategy.getWarningSubclass() + waringStrategy.getStrategy().toString();//redis配置数据key
JSONObject jsonObject = new JSONObject();
jsonObject.put("strategy", waringStrategy.getStrategy());//策略模式
jsonObject.put("strategyTime", waringStrategy.getStrategyTime());//模式时长,单位为分钟
@@ -156,32 +164,32 @@ public class DcWarningServiceImpl implements IDcWarningService
redisCache.setCacheMap(WARNINGSTRATEGY, redisMap);//数据库配置数据加入缓存中
redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//缓存数据为空重新加入到缓存在取出缓存的配置
}
- String key=dcWarning.getStakeMark()+dcWarning.getDirection()+dcWarning.getWarningSource().
- toString()+dcWarning.getWarningType().toString()+dcWarning.getWarningSubclass();//key,redis存储事件的key(桩号+方向+事件源+类型)
+ String key = dcWarning.getStakeMark() + dcWarning.getDirection() + dcWarning.getWarningSource().
+ toString() + dcWarning.getWarningType().toString() + dcWarning.getWarningSubclass();//key,redis存储事件的key(桩号+方向+事件源+类型)
String dataId = redisCache.getCacheObject(WARNINGDATA + key);//查看redis是否存在数据(id的值)
- HashMap redisValueTwo = redisWarningStrategy.get(redisKye+UniversalEnum.TWO.getValue());//查看传入的事件类型是否配置策略2(延迟策略)
- if (redisValueTwo!=null){ //执行策略2,
+ HashMap redisValueTwo = redisWarningStrategy.get(redisKye + UniversalEnum.TWO.getValue());//查看传入的事件类型是否配置策略2(延迟策略)
+ if (redisValueTwo != null) { //执行策略2,
String strategyTime = redisValueTwo.get("strategyTime").toString();//策略时长
dcWarning.setEndTime(DateUtils.getObtainDateAfter(Integer.parseInt(strategyTime)));//注入过期时间
- if (dataId==null){//如果不存在直接加入数据库,加入缓存,配置对应的缓存过期时间以及数据库过期时间
+ if (dataId == null) {//如果不存在直接加入数据库,加入缓存,配置对应的缓存过期时间以及数据库过期时间
int insertDcWarning = dcWarningMapper.insertDcWarning(dcWarning);//加入数据库
- //事件推送至 Websocket
+ //事件推送至 Websocket
extracted(dcWarning);
- if (insertDcWarning==UniversalEnum.ZERO.getNumber()){
+ if (insertDcWarning == UniversalEnum.ZERO.getNumber()) {
return UniversalEnum.ZERO.getNumber();
}
String id = dcWarning.getId();//取出加入后的id作为value
- redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
+ redisCache.setCacheObject(WARNINGDATA + key, id, Integer.parseInt(strategyTime), TimeUnit.MINUTES);//加入缓存并设置延迟时间(单位分钟)
return UniversalEnum.ONE.getNumber();//结束
}
//redis存在数据,取出redis的id找对对应事件的配置,合成事件配置,重新定义延迟时间
HashMap map = dcWarningMapper.selectDcWarningById(dataId);
- if (map==null||(map.get("warningState")!=null&&map.get("warningState").toString().equals(UniversalEnum.FOUR.getValue()))){//redis中有id但是数据库中没有这条数据,或则数据库中有数据但是状态不为结束,那就删除这条redis数据,新数据加入到数据库,并加入到redis
- redisCache.deleteObject(WARNINGDATA+key);
+ if (map == null || (map.get("warningState") != null && map.get("warningState").toString().equals(UniversalEnum.FOUR.getValue()))) {//redis中有id但是数据库中没有这条数据,或则数据库中有数据但是状态不为结束,那就删除这条redis数据,新数据加入到数据库,并加入到redis
+ redisCache.deleteObject(WARNINGDATA + key);
String id = dcWarning.getId();
- redisCache.setCacheObject(WARNINGDATA+key,id,Integer.parseInt(strategyTime),TimeUnit.MINUTES);
+ redisCache.setCacheObject(WARNINGDATA + key, id, Integer.parseInt(strategyTime), TimeUnit.MINUTES);
int i = dcWarningMapper.insertDcWarning(dcWarning);
//事件推送至 Websocket
@@ -189,13 +197,13 @@ public class DcWarningServiceImpl implements IDcWarningService
return i;
}
- String otherConfig=UniversalEnum.EMPTY_STRING.getValue();
- if (map.get("otherConfig")!=null){
+ String otherConfig = UniversalEnum.EMPTY_STRING.getValue();
+ if (map.get("otherConfig") != null) {
otherConfig = map.get("otherConfig").toString(); //取出原id的配置信息
}
String otherConfigString = dcWarning.getOtherConfig();//新增的配置信息
- if (StringUtils.isBlank(otherConfig)&&StringUtils.isBlank(otherConfigString)){//数据为空不新增,直接走规则
- redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
+ if (StringUtils.isBlank(otherConfig) && StringUtils.isBlank(otherConfigString)) {//数据为空不新增,直接走规则
+ redisCache.setCacheObject(WARNINGDATA + key, dataId, Integer.parseInt(strategyTime), TimeUnit.MINUTES);//重新设置延迟时间
return 1;//修改数据库配置
}
JSONObject jsonObjectOne = new JSONObject(otherConfig);//原始数据库数据
@@ -208,15 +216,15 @@ public class DcWarningServiceImpl implements IDcWarningService
if (jsonObjectOne != null && jsonObjectOne.has("videoList")) {//验证视频是否存在
picturesArrayVideo = jsonObjectOne.getJSONArray("videoList");
}
- if (picturesArrayVideo!=null||picturesArrayPic!=null) {
- boolean a =false;
+ if (picturesArrayVideo != null || picturesArrayPic != null) {
+ boolean a = false;
if (picturesArrayVideo != null) {
int videoListLength = jsonObjectOne.getJSONArray("pictures").length();//已经存在数据库的视频的长度
if (videoListLength >= UniversalEnum.TEN.getNumber() && jsonObjectTwo.get("videoList") != null) {
JSONArray videoList = jsonObjectOne.getJSONArray("videoList");
videoList.put(videoListLength - UniversalEnum.ONE.getNumber(), jsonObjectTwo.getJSONArray("videoList").getString(UniversalEnum.ZERO.getNumber()));
jsonObjectOne.put("videoList", videoList);
- a=true;
+ a = true;
}
}
if (picturesArrayPic != null) {
@@ -225,30 +233,30 @@ public class DcWarningServiceImpl implements IDcWarningService
JSONArray pictures = jsonObjectOne.getJSONArray("pictures");//获取图片数组
pictures.put(picturesLength - UniversalEnum.ONE.getNumber(), jsonObjectTwo.getJSONArray("pictures").getString(UniversalEnum.ZERO.getNumber())); //替换第十个元素
jsonObjectOne.put("pictures", pictures);//更新 jsonObjectOne中的pictures 数组
- a=true;
+ a = true;
}
}
- if (a==true){
+ if (a == true) {
redisCache.setCacheObject(WARNINGDATA + key, dataId, Integer.parseInt(strategyTime), TimeUnit.MINUTES);//重新设置延迟时间
return dcWarningMapper.updateOtherConfig(dataId, jsonObjectOne.toString(), dcWarning.getEndTime());//修改数据库配置
}
}
DcWarningServiceImpl dcWarningService = new DcWarningServiceImpl();//合成工具类
JSONObject jsonObject = dcWarningService.mergeJsonObjects(jsonObjectOne, jsonObjectTwo);
- if (jsonObject==null){ //没有进行合成或则合成后的数据为null
- redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
- if (jsonObjectOne!=null) {
+ if (jsonObject == null) { //没有进行合成或则合成后的数据为null
+ redisCache.setCacheObject(WARNINGDATA + key, dataId, Integer.parseInt(strategyTime), TimeUnit.MINUTES);//重新设置延迟时间
+ if (jsonObjectOne != null) {
return dcWarningMapper.updateOtherConfig(dataId, jsonObjectOne.toString(), dcWarning.getEndTime());//修改数据库配置
- }else if (jsonObjectTwo!=null){
+ } else if (jsonObjectTwo != null) {
return dcWarningMapper.updateOtherConfig(dataId, jsonObjectTwo.toString(), dcWarning.getEndTime());//修改数据库配置
- }else {
+ } else {
return dcWarningMapper.updateOtherConfig(dataId, "", dcWarning.getEndTime());//修改数据库配置
}
}
- redisCache.setCacheObject(WARNINGDATA+key,dataId,Integer.parseInt(strategyTime),TimeUnit.MINUTES);//重新设置延迟时间
- return dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString(),dcWarning.getEndTime());//修改数据库配置
+ redisCache.setCacheObject(WARNINGDATA + key, dataId, Integer.parseInt(strategyTime), TimeUnit.MINUTES);//重新设置延迟时间
+ return dcWarningMapper.updateOtherConfig(dataId, jsonObject.toString(), dcWarning.getEndTime());//修改数据库配置
}
- if (redisValueTwo==null){ //如果传进来的事件未配置策略,在这里出入默认的过去时间值
+ if (redisValueTwo == null) { //如果传进来的事件未配置策略,在这里出入默认的过去时间值
dcWarning.setEndTime(DateUtils.getObtainDateAfter(UniversalEnum.SIXTY.getNumber()));//注入过期时间(默认值为60分钟)
}
//事件推送至 Websocket
@@ -259,34 +267,35 @@ public class DcWarningServiceImpl implements IDcWarningService
/**
* 事件推送至 Websocket
+ *
* @param dcWarning
*/
private void extracted(DcWarning dcWarning) {
String direction = UniversalEnum.EMPTY_STRING.getValue();// 方向
String EventSubclass = UniversalEnum.EMPTY_STRING.getValue();// 事件类型
if (dcWarning.getDirection().equals(UniversalEnum.ONE.getValue())) {
- direction=UniversalEnum.DIRECTION_OF_HEZE.getValue();
- }else {
- direction=UniversalEnum.DIRECTION_OF_JINAN.getValue();
+ direction = UniversalEnum.DIRECTION_OF_HEZE.getValue();
+ } else {
+ direction = UniversalEnum.DIRECTION_OF_JINAN.getValue();
}
for (WarningSubclassEnum eventSubclass : WarningSubclassEnum.values()) {
if (eventSubclass.getCode().equals(dcWarning.getWarningSubclass())) {
- EventSubclass=eventSubclass.getInfo();
+ EventSubclass = eventSubclass.getInfo();
break;
}
}
- Map contentMap = new HashMap<>();
+ Map contentMap = new HashMap<>();
if (dcWarning.getWarningSource() == 7) {
- String remark = dcWarning.getRemark();
- String[] split = remark.split(" ");
- String s = split[split.length - 1];
- contentMap.put("content",s);
- }else {
- String content= direction+UniversalEnum.BLANK_SPACE.getValue() + dcWarning.getStakeMark()+UniversalEnum.BLANK_SPACE.getValue()+HAPPEN+EventSubclass+EVENT ;
- contentMap.put("content",content);
+ String remark = dcWarning.getRemark();
+ String[] split = remark.split(" ");
+ String s = split[split.length - 1];
+ contentMap.put("content", s);
+ } else {
+ String content = direction + UniversalEnum.BLANK_SPACE.getValue() + dcWarning.getStakeMark() + UniversalEnum.BLANK_SPACE.getValue() + HAPPEN + EventSubclass + EVENT;
+ contentMap.put("content", content);
}
- contentMap.put("event",dcWarning);
+ contentMap.put("event", dcWarning);
WebSocketService.broadcast(WebSocketEvent.WARNING, contentMap); //推送事件消息 0不是感知事件
dcEventService.getCountNum();
}
@@ -460,14 +469,14 @@ public class DcWarningServiceImpl implements IDcWarningService
// }
// return dcWarningMapper.insertDcWarning(dcWarning);//如果没有配置策略直接加入数据库;
// }
- private JSONObject mergeJsonObjects(JSONObject jsonObjectOne, JSONObject jsonObjectTwo){
- if(jsonObjectOne!=null&&jsonObjectTwo==null){
+ private JSONObject mergeJsonObjects(JSONObject jsonObjectOne, JSONObject jsonObjectTwo) {
+ if (jsonObjectOne != null && jsonObjectTwo == null) {
return jsonObjectOne; //两个存在一个为空返回不为空的
}
- if (jsonObjectOne==null&&jsonObjectTwo!=null){
+ if (jsonObjectOne == null && jsonObjectTwo != null) {
return jsonObjectTwo;//两个存在一个为空返回不为空的
}
- if(jsonObjectOne==null&&jsonObjectTwo==null){
+ if (jsonObjectOne == null && jsonObjectTwo == null) {
return new JSONObject();//两个都为空返回空json
}
// 合并videoList
@@ -496,6 +505,7 @@ public class DcWarningServiceImpl implements IDcWarningService
}
return jsonObjectOne;
}
+
/**
* 修改预警信息
*
@@ -503,8 +513,7 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 结果
*/
@Override
- public int updateDcWarning(DcWarning dcWarning)
- {
+ public int updateDcWarning(DcWarning dcWarning) {
dcWarning.setUpdateTime(DateUtils.getNowDate());
return dcWarningMapper.updateDcWarning(dcWarning);
}
@@ -516,8 +525,7 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 结果
*/
@Override
- public int deleteDcWarningByIds(String id)
- {
+ public int deleteDcWarningByIds(String id) {
return dcWarningMapper.deleteDcWarningByIds(id);
}
@@ -528,27 +536,27 @@ public class DcWarningServiceImpl implements IDcWarningService
* @return 结果
*/
@Override
- public int deleteDcWarningById(Integer id)
- {
+ public int deleteDcWarningById(Integer id) {
return dcWarningMapper.deleteDcWarningById(id);
}
+
//感知事件转交通事件(感知事件状态改为处置中,把感知事件的数据整理新增到交通事件)
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult updateWarningConvert(DcWarning dcWarning) {
- if (dcWarning==null||dcWarning.getId()==null|| dcWarning.getStakeMark()==null||
- StringUtils.isBlank(dcWarning.getStakeMark())||dcWarning.getDirection()==null||
+ if (dcWarning == null || dcWarning.getId() == null || dcWarning.getStakeMark() == null ||
+ StringUtils.isBlank(dcWarning.getStakeMark()) || dcWarning.getDirection() == null ||
StringUtils.isBlank(dcWarning.getDirection()) ||
- dcWarning.getWarningType()==null|| dcWarning.getWarningSource()==null){
+ dcWarning.getWarningType() == null || dcWarning.getWarningSource() == null) {
return AjaxResult.error(UniversalEnum.PARAMETER_ERROR.getValue());
}
- if (UniversalEnum.SIX.getValue().equals(dcWarning.getWarningSource().toString())){
+ if (UniversalEnum.SIX.getValue().equals(dcWarning.getWarningSource().toString())) {
return AjaxResult.error("非机预警无需转换");
}
- ArrayList> hashMaps = new ArrayList<>();
+ ArrayList> hashMaps = new ArrayList<>();
dcWarning.setUserId(SecurityUtils.getUserId());
int updateState = dcWarningMapper.updateState(dcWarning);//感知事件状态改变为已完成
- if (updateState==UniversalEnum.ZERO.getNumber()){
+ if (updateState == UniversalEnum.ZERO.getNumber()) {
return AjaxResult.error(UniversalEnum.OPERATION_FAILURE.getValue());
}
String stakeMark = dcWarning.getStakeMark();
@@ -559,16 +567,16 @@ public class DcWarningServiceImpl implements IDcWarningService
dcEvent.setDeptId(dcWarning.getDeptId());//部门
dcEvent.setOccurrenceTime(dcWarning.getWarningTime());//预警时间
Integer warningType = dcWarning.getWarningType();//事件主类
- if (dcWarning.getWarningLevel()!=null) {
+ if (dcWarning.getWarningLevel() != null) {
dcEvent.setEventLevel(dcWarning.getWarningLevel().longValue());//事件等级
}
- if (dcWarning.getWarningSource()!=null) {
+ if (dcWarning.getWarningSource() != null) {
dcEvent.setEventSource((long) ValueConverter.convertValueSource(dcWarning.getWarningSource()));//事件来源
}
- if (warningType!=null) {
+ if (warningType != null) {
dcEvent.setEventType((long) ValueConverter.convertValueHost(dcWarning.getWarningType()));//事件主类
}
- if (dcWarning.getWarningSubclass()!=null) {
+ if (dcWarning.getWarningSubclass() != null) {
dcEvent.setEventSubclass(ValueConverter.convertValueSon(dcWarning.getWarningSubclass()));//事件子类
}
// if (dcWarning.getWarningSubclass()!=null&&(warningType==UniversalEnum.SEVEN.getNumber())){
@@ -586,14 +594,14 @@ public class DcWarningServiceImpl implements IDcWarningService
dcEvent.setUserId(SecurityUtils.getUserId());//处置人员
dcEvent.setRoadId(Long.valueOf(UniversalEnum.ONE.getNumber()));//高速公路(济菏高速)
int insertDcEvent = dcEventService.insertDcEventWarning(dcEvent);
- if (insertDcEvent==UniversalEnum.ZERO.getNumber()){
+ if (insertDcEvent == UniversalEnum.ZERO.getNumber()) {
return AjaxResult.error(UniversalEnum.OPERATION_FAILURE.getValue());
}
//推送待处理数量
dcEventService.getCountNum();
//扫码报警小程序
- if(dcWarning.getWarningSource() == 5){
+ if (dcWarning.getWarningSource() == 5) {
HashMap warningInfo = dcWarningMapper.selectDcWarningById(dcWarning.getId());
com.alibaba.fastjson.JSONObject otherConfig = com.alibaba.fastjson.JSONObject.parseObject(warningInfo.get("otherConfig").toString());
String alarmId = otherConfig.getString("id");
@@ -624,38 +632,37 @@ public class DcWarningServiceImpl implements IDcWarningService
@Override
public int deleteDcWarningByStringId(DcWarning dcWarning) {
- return dcWarningMapper.deleteDcWarningByStringId(dcWarning);
+ return dcWarningMapper.deleteDcWarningByStringId(dcWarning);
}
+
@Override
- public List> selectDcWarningoTherConfig(DcWarning dcWarning)
- {
+ public List> selectDcWarningoTherConfig(DcWarning dcWarning) {
return dcWarningMapper.selectDcWarningoTherConfig(dcWarning);
}
/**
+ * @param dcWarningBatchConvert
+ * @return com.ruoyi.common.core.domain.AjaxResult
* @Description 感知事件批量转换
- *
* @author liuwenge
* @date 2024/3/16 16:36
- * @param dcWarningBatchConvert
- * @return com.ruoyi.common.core.domain.AjaxResult
*/
@Override
@Transactional
- public AjaxResult batchConvert(DcWarningBatchConvert dcWarningBatchConvert){
+ public AjaxResult batchConvert(DcWarningBatchConvert dcWarningBatchConvert) {
- if (StringUtils.isBlank(dcWarningBatchConvert.getType())){
+ if (StringUtils.isBlank(dcWarningBatchConvert.getType())) {
return AjaxResult.error(UniversalEnum.THE_OPERATION_TYPE_CANNOT_BE_EMPTY.getValue());
}
List dcWarningList = dcWarningBatchConvert.getWarningList();
- if (dcWarningList != null && dcWarningList.size() > UniversalEnum.ZERO.getNumber()){
+ if (dcWarningList != null && dcWarningList.size() > UniversalEnum.ZERO.getNumber()) {
//误报,批量删除
- if (UniversalEnum.ZERO.getValue().equals(dcWarningBatchConvert.getType())){
+ if (UniversalEnum.ZERO.getValue().equals(dcWarningBatchConvert.getType())) {
dcWarningMapper.batchDelete(dcWarningList);
} else {
- //确认,批量转换为事件
+ //确认,批量转换为事件
List dcEventList = new ArrayList<>();
for (DcWarning dcWarning : dcWarningList) {
if (dcWarning == null || dcWarning.getId() == null || StringUtils.isBlank(dcWarning.getStakeMark()) ||
@@ -694,7 +701,7 @@ public class DcWarningServiceImpl implements IDcWarningService
}
//批量更改感知事件状态
- dcWarningMapper.batchUpdateState(SecurityUtils.getUserId(),dcWarningList);
+ dcWarningMapper.batchUpdateState(SecurityUtils.getUserId(), dcWarningList);
//批量插入事件表
dcEventService.batchInsertDcEventWarning(dcEventList);
}
@@ -710,7 +717,7 @@ public class DcWarningServiceImpl implements IDcWarningService
@Override
public Integer updateEndSection() {
List dcWarnings = dcWarningMapper.selectEndSection();//全部应该结束事件的id
- if (dcWarnings.size()==UniversalEnum.ZERO.getNumber()){
+ if (dcWarnings.size() == UniversalEnum.ZERO.getNumber()) {
return UniversalEnum.ONE.getNumber();
}
Integer i = dcWarningMapper.updateEndSection(dcWarnings);
@@ -726,131 +733,135 @@ public class DcWarningServiceImpl implements IDcWarningService
public AjaxResult commandAndDispatch(DcWarning dcWarning) {
Map mapAll = new HashMap<>();
HashMap dcDispatch = dcWarningMapper.selectDcDispatch(dcWarning.getId());//查询是否存在调度记录
- if (dcDispatch==null){
- mapAll.put("existence",UniversalEnum.ZERO.getNumber());
+ if (dcDispatch == null) {
+ mapAll.put("existence", UniversalEnum.ZERO.getNumber());
return AjaxResult.success(mapAll);
}
//逻辑,调用全部的机构信息,计算传入的桩号与机构桩号的距离作为排序使用,使用机构的id调出车辆,人员,值班等信息
List> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
- ArrayList> hashMaps = new ArrayList<>();
+ ArrayList> hashMaps = new ArrayList<>();
- for (HashMap map:mapList){
- if (StringUtils.isBlank(map.get("stakeMark").toString())){
+ for (HashMap map : mapList) {
+ if (StringUtils.isBlank(map.get("stakeMark").toString())) {
continue;
}
String stakeMark = map.get("stakeMark").toString();
StakeMarkUtils stakeMarkUtils = new StakeMarkUtils();
Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMark);//桩号本身的米数
Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(dcWarning.getStakeMark());//传入的桩号米数
- Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值
- map.put("difference",difference/1000.0);//米转公里加入到map
- Long id =Long.parseLong(map.get("id").toString());//机构的id,用户获取人员、值班、车辆等信息
- List> employeesMap = dcWarningMapper.selectEmployeesDispatch(id,dcWarning.getId());//人员map
- List> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id,dcWarning.getId());//车辆map
- map.put("employeesMap",employeesMap);
- map.put("vehiclesMap",vehiclesMap);
+ Integer difference = Math.abs(afferentStakeMark - itselfStakeMark); //计算距离绝对值
+ map.put("difference", difference / 1000.0);//米转公里加入到map
+ Long id = Long.parseLong(map.get("id").toString());//机构的id,用户获取人员、值班、车辆等信息
+ List> employeesMap = dcWarningMapper.selectEmployeesDispatch(id, dcWarning.getId());//人员map
+ List> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id, dcWarning.getId());//车辆map
+ map.put("employeesMap", employeesMap);
+ map.put("vehiclesMap", vehiclesMap);
hashMaps.add(map);
}
List> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> {
- return (Double) map.get("difference"); })).collect(Collectors.toList());
- mapAll.put("listData",sortedHashMaps);
+ return (Double) map.get("difference");
+ })).collect(Collectors.toList());
+ mapAll.put("listData", sortedHashMaps);
if (!sortedHashMaps.isEmpty()) {
HashMap map = sortedHashMaps.get(UniversalEnum.ZERO.getNumber());
Long id = Long.parseLong(map.get("id").toString());//取出最近的机构id
//todo 交警
DcTrafficPolice dcTrafficPolice = dcTrafficPoliceService.selectEvent(dcWarning.getStakeMark());
- mapAll.put("trafficPolice",dcTrafficPolice);
+ mapAll.put("trafficPolice", dcTrafficPolice);
}
- mapAll.put("dispatchId",dcDispatch.get("id"));
- mapAll.put("existence",UniversalEnum.ONE.getNumber());
+ mapAll.put("dispatchId", dcDispatch.get("id"));
+ mapAll.put("existence", UniversalEnum.ONE.getNumber());
HashMap map = dcWarningMapper.selectDcDispatch(dcWarning.getId());//获取机构id与资源id
- if (map!=null){
+ if (map != null) {
HashMap