|
|
@ -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<String, Object> selectDcWarningById(String id) |
|
|
|
{ |
|
|
|
public HashMap<String, Object> selectDcWarningById(String id) { |
|
|
|
return dcWarningMapper.selectDcWarningById(id); |
|
|
|
} |
|
|
|
|
|
|
@ -100,8 +110,7 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
* @return 预警信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public HashMap<String, Object> selectAlarmById(String id) |
|
|
|
{ |
|
|
|
public HashMap<String, Object> selectAlarmById(String id) { |
|
|
|
return dcWarningMapper.selectAlarmById(id); |
|
|
|
} |
|
|
|
|
|
|
@ -112,10 +121,10 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
* @return 预警信息 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<HashMap<String,Object>> selectDcWarningList(DcWarning dcWarning) |
|
|
|
{ |
|
|
|
public List<HashMap<String, Object>> selectDcWarningList(DcWarning dcWarning) { |
|
|
|
return dcWarningMapper.selectDcWarningList(dcWarning); |
|
|
|
} |
|
|
|
|
|
|
|
//导出
|
|
|
|
@Override |
|
|
|
public List<DcWarning> 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<String, HashMap> redisWarningStrategy = redisCache.getCacheMap(WARNINGSTRATEGY);//获取缓存全部的配置数据
|
|
|
|
if (redisWarningStrategy==null||redisWarningStrategy.size()==UniversalEnum.ZERO.getNumber()){//如果缓存为空,查询数据重新加入缓存
|
|
|
|
if (redisWarningStrategy == null || redisWarningStrategy.size() == UniversalEnum.ZERO.getNumber()) {//如果缓存为空,查询数据重新加入缓存
|
|
|
|
Map<String, JSONObject> redisMap = new HashMap<>(); |
|
|
|
List<DcWaringStrategy> 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<String, Object> 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<String,Object> contentMap = new HashMap<>(); |
|
|
|
Map<String, Object> 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<HashMap<String,Object>> hashMaps = new ArrayList<>(); |
|
|
|
ArrayList<HashMap<String, Object>> 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<String, Object> 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<HashMap<String,Object>> selectDcWarningoTherConfig(DcWarning dcWarning) |
|
|
|
{ |
|
|
|
public List<HashMap<String, Object>> 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<DcWarning> 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<DcEvent> 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<DcWarning> 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<String, Object> mapAll = new HashMap<>(); |
|
|
|
HashMap<String, Object> 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<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
|
|
|
|
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>(); |
|
|
|
ArrayList<HashMap<String, Object>> hashMaps = new ArrayList<>(); |
|
|
|
|
|
|
|
for (HashMap<String,Object> map:mapList){ |
|
|
|
if (StringUtils.isBlank(map.get("stakeMark").toString())){ |
|
|
|
for (HashMap<String, Object> 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<HashMap<String, Object>> employeesMap = dcWarningMapper.selectEmployeesDispatch(id,dcWarning.getId());//人员map
|
|
|
|
List<HashMap<String, Object>> 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<HashMap<String, Object>> employeesMap = dcWarningMapper.selectEmployeesDispatch(id, dcWarning.getId());//人员map
|
|
|
|
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id, dcWarning.getId());//车辆map
|
|
|
|
map.put("employeesMap", employeesMap); |
|
|
|
map.put("vehiclesMap", vehiclesMap); |
|
|
|
hashMaps.add(map); |
|
|
|
} |
|
|
|
List<HashMap<String, Object>> 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<String, Object> 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<String, Object> map = dcWarningMapper.selectDcDispatch(dcWarning.getId());//获取机构id与资源id
|
|
|
|
if (map!=null){ |
|
|
|
if (map != null) { |
|
|
|
HashMap<Object, Object> hashMap = new HashMap<>(); |
|
|
|
Long id =Long.parseLong(map.get("id").toString());//调度记录id
|
|
|
|
Object deptName =map.get("deptName");//部门名称
|
|
|
|
Long id = Long.parseLong(map.get("id").toString());//调度记录id
|
|
|
|
Object deptName = map.get("deptName");//部门名称
|
|
|
|
//List<HashMap<String, Object>> shifts = dcWarningMapper.selectShiftsEmployees();//值班为空把全部的人员信息作为值班人员信息
|
|
|
|
List<HashMap<String, Object>> resource = dcWarningMapper.selectDispatchResource(id);//全部资源信息
|
|
|
|
List<HashMap<String, Object>> employeesChoice = dcWarningMapper.selectEmployeesChoice(id);//选中人员信息
|
|
|
|
List<HashMap<String, Object>> vehiclesChoice = dcWarningMapper.selectVehiclesChoice(id);//选中车辆信息
|
|
|
|
hashMap.put("id",id);//调度记录id
|
|
|
|
hashMap.put("deptName",deptName); |
|
|
|
hashMap.put("id", id);//调度记录id
|
|
|
|
hashMap.put("deptName", deptName); |
|
|
|
//hashMap.put("shifts",shifts);
|
|
|
|
hashMap.put("resource",resource); |
|
|
|
mapAll.put("resource",hashMap); |
|
|
|
mapAll.put("employeesChoice",employeesChoice); |
|
|
|
mapAll.put("vehiclesChoice",vehiclesChoice); |
|
|
|
hashMap.put("resource", resource); |
|
|
|
mapAll.put("resource", hashMap); |
|
|
|
mapAll.put("employeesChoice", employeesChoice); |
|
|
|
mapAll.put("vehiclesChoice", vehiclesChoice); |
|
|
|
} |
|
|
|
return AjaxResult.success(mapAll); |
|
|
|
} |
|
|
|
|
|
|
|
//指挥调度,当调度信息为空的时候调用智能分配资源
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public AjaxResult intelligentSource(DcWarning dcWarning) { |
|
|
|
String stakeMark = dcWarning.getStakeMark(); |
|
|
|
ArrayList<HashMap<String,Object>> hashMaps = new ArrayList<>(); |
|
|
|
ArrayList<HashMap<String, Object>> hashMaps = new ArrayList<>(); |
|
|
|
Map<String, Object> mapAll = new HashMap<>(); |
|
|
|
List<HashMap<String, Object>> mapList = dcWarningMapper.selectRecentlySection();//全部机构的桩号和名称
|
|
|
|
for (HashMap<String,Object> map:mapList){ |
|
|
|
for (HashMap<String, Object> map : mapList) { |
|
|
|
HashMap<String, Object> mapValue = new HashMap<>(); |
|
|
|
if (StringUtils.isBlank(map.get("stakeMark").toString())){ |
|
|
|
if (StringUtils.isBlank(map.get("stakeMark").toString())) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
StakeMarkUtils stakeMarkUtils = new StakeMarkUtils(); |
|
|
|
String stakeMarkValue = map.get("stakeMark").toString(); |
|
|
|
Integer itselfStakeMark = stakeMarkUtils.stakeMarkToInt(stakeMarkValue);//桩号本身的米数
|
|
|
|
Integer afferentStakeMark = stakeMarkUtils.stakeMarkToInt(dcWarning.getStakeMark());//传入的桩号米数
|
|
|
|
Integer difference =Math.abs(afferentStakeMark-itselfStakeMark); //计算距离绝对值
|
|
|
|
Integer difference = Math.abs(afferentStakeMark - itselfStakeMark); //计算距离绝对值
|
|
|
|
|
|
|
|
mapValue.put("difference",difference/1000.0);//米转公里加入到map
|
|
|
|
Long id =Long.parseLong(map.get("id").toString());//机构的id,用户获取人员、车辆等信息
|
|
|
|
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectEmployeesDispatch(id,dcWarning.getId());//人员map
|
|
|
|
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id,dcWarning.getId());//车辆map
|
|
|
|
mapValue.put("difference", difference / 1000.0);//米转公里加入到map
|
|
|
|
Long id = Long.parseLong(map.get("id").toString());//机构的id,用户获取人员、车辆等信息
|
|
|
|
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectEmployeesDispatch(id, dcWarning.getId());//人员map
|
|
|
|
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehiclesDispatch(id, dcWarning.getId());//车辆map
|
|
|
|
String organizationName = dcWarningMapper.organizationName(id); |
|
|
|
mapValue.put("employeesMap",employeesMap); |
|
|
|
mapValue.put("vehiclesMap",vehiclesMap); |
|
|
|
mapValue.put("organizationId",id); |
|
|
|
mapValue.put("organizationName",organizationName); |
|
|
|
mapValue.put("employeesMap", employeesMap); |
|
|
|
mapValue.put("vehiclesMap", vehiclesMap); |
|
|
|
mapValue.put("organizationId", id); |
|
|
|
mapValue.put("organizationName", organizationName); |
|
|
|
hashMaps.add(mapValue); |
|
|
|
} |
|
|
|
mapAll.put("selectData",hashMaps); |
|
|
|
mapAll.put("selectData", hashMaps); |
|
|
|
List<HashMap<String, Object>> sortedHashMaps = hashMaps.stream().sorted(Comparator.comparing(map -> { |
|
|
|
return (Double) map.get("difference"); })).collect(Collectors.toList()); |
|
|
|
return (Double) map.get("difference"); |
|
|
|
})).collect(Collectors.toList()); |
|
|
|
if (!sortedHashMaps.isEmpty()) { |
|
|
|
HashMap<String, Object> map = sortedHashMaps.get(UniversalEnum.ZERO.getNumber()); |
|
|
|
Long id = Long.parseLong(map.get("organizationId").toString());//取出最近的机构id
|
|
|
|
if (id != null) { |
|
|
|
List<HashMap<String, Object>> employeesMap = dcWarningMapper.selectOrganizationEmployees(id);//人员map
|
|
|
|
if (employeesMap != null&&employeesMap.size()>UniversalEnum.ZERO.getNumber()) { |
|
|
|
if (employeesMap != null && employeesMap.size() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
HashMap<String, Object> employeesHashMap = new HashMap<>(); |
|
|
|
// 生成一个随机索引,范围在0到列表长度减1之间
|
|
|
|
int randomIndex = ThreadLocalRandom.current().nextInt(employeesMap.size()); |
|
|
|
HashMap<String, Object> randomEmployee = employeesMap.get(randomIndex); |
|
|
|
Long employeesId = Long.parseLong(randomEmployee.get("id").toString());//随机人员id
|
|
|
|
String employeesName = dcWarningMapper.employeesName(employeesId);//随机人员姓名
|
|
|
|
employeesHashMap.put("employeesId",employeesId); |
|
|
|
employeesHashMap.put("employeesName",employeesName); |
|
|
|
mapAll.put("employees",employeesHashMap); |
|
|
|
employeesHashMap.put("employeesId", employeesId); |
|
|
|
employeesHashMap.put("employeesName", employeesName); |
|
|
|
mapAll.put("employees", employeesHashMap); |
|
|
|
} |
|
|
|
List<HashMap<String, Object>> vehiclesMap = dcWarningMapper.selectVehicles(id);//车辆map
|
|
|
|
if (vehiclesMap != null&&vehiclesMap.size()>UniversalEnum.ZERO.getNumber()) { |
|
|
|
if (vehiclesMap != null && vehiclesMap.size() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
HashMap<String, Object> vehiclesHashMap = new HashMap<>(); |
|
|
|
// 生成一个随机索引,范围在0到列表长度减1之间
|
|
|
|
int randomIndex = ThreadLocalRandom.current().nextInt(vehiclesMap.size()); |
|
|
|
HashMap<String, Object> randomEmployee = vehiclesMap.get(randomIndex); |
|
|
|
Long vehiclesId =Long.parseLong(randomEmployee.get("id").toString());//随机车辆id
|
|
|
|
Long vehiclesId = Long.parseLong(randomEmployee.get("id").toString());//随机车辆id
|
|
|
|
String vehiclesName = dcWarningMapper.vehiclesName(vehiclesId);//随机车辆
|
|
|
|
String vehiclesType = dcWarningMapper.vehiclesType(vehiclesId);//随机车辆
|
|
|
|
vehiclesHashMap.put("vehiclesId",vehiclesId); |
|
|
|
vehiclesHashMap.put("vehiclesName",vehiclesName); |
|
|
|
vehiclesHashMap.put("vehiclesType",vehiclesType); |
|
|
|
mapAll.put("vehicles",vehiclesHashMap); |
|
|
|
vehiclesHashMap.put("vehiclesId", vehiclesId); |
|
|
|
vehiclesHashMap.put("vehiclesName", vehiclesName); |
|
|
|
vehiclesHashMap.put("vehiclesType", vehiclesType); |
|
|
|
mapAll.put("vehicles", vehiclesHashMap); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return AjaxResult.success(mapAll); |
|
|
|
} |
|
|
|
|
|
|
|
//3.指挥调度新增资源
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@ -858,13 +869,13 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
//事件id、事件备注、机构id、资源id
|
|
|
|
String eventId = map.get("eventId").toString();//事件id
|
|
|
|
String remark = Objects.toString(map.get("remark"), UniversalEnum.EMPTY_STRING.getValue()); |
|
|
|
Long employees=null; |
|
|
|
if (map.get("employeesId")!=null){ |
|
|
|
employees = Long.parseLong(map.get("employeesId").toString());//人员
|
|
|
|
Long employees = null; |
|
|
|
if (map.get("employeesId") != null) { |
|
|
|
employees = Long.parseLong(map.get("employeesId").toString());//人员
|
|
|
|
} |
|
|
|
Long vehicles=null; |
|
|
|
if (map.get("vehiclesId")!=null){ |
|
|
|
vehicles = Long.parseLong(map.get("vehiclesId").toString());//车辆
|
|
|
|
Long vehicles = null; |
|
|
|
if (map.get("vehiclesId") != null) { |
|
|
|
vehicles = Long.parseLong(map.get("vehiclesId").toString());//车辆
|
|
|
|
} |
|
|
|
DcDispatch dcDispatch = new DcDispatch(); |
|
|
|
DcDispatchResource dcDispatchResource = new DcDispatchResource(); |
|
|
@ -874,41 +885,41 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
dcDispatch.setDispatchStatus(Long.valueOf(UniversalEnum.TWO.getNumber()));//进行中状态
|
|
|
|
dcDispatch.setRemark(remark); |
|
|
|
HashMap<String, Object> dispatch = dcWarningMapper.selectDcDispatch(eventId);//查询是否存在调度记录
|
|
|
|
if (dispatch!=null){ //不为空说明已经存在处置记录,不在新增
|
|
|
|
if (dispatch != null) { //不为空说明已经存在处置记录,不在新增
|
|
|
|
return AjaxResult.success(UniversalEnum.EXISTING_RECORD.getNumber()); |
|
|
|
} |
|
|
|
Integer integer = dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
|
|
|
|
if (integer==UniversalEnum.ZERO.getNumber()){ |
|
|
|
if (integer == UniversalEnum.ZERO.getNumber()) { |
|
|
|
return AjaxResult.error(); |
|
|
|
} |
|
|
|
Long dispatchId = dcDispatch.getId();//信息记录id
|
|
|
|
String context = ""; |
|
|
|
if (employees!=null) { |
|
|
|
if (employees != null) { |
|
|
|
dcDispatchResource.setResourceId(employees);//资源id
|
|
|
|
dcDispatchResource.setDispatchType(UniversalEnum.ONE.getNumber());//资源类型
|
|
|
|
dcDispatchResource.setDispatchId(dispatchId);//信息记录id
|
|
|
|
Integer employeesSource = dcWarningMapper.insertDispatchResource(dcDispatchResource); |
|
|
|
if (employeesSource==UniversalEnum.ZERO.getNumber()){ |
|
|
|
if (employeesSource == UniversalEnum.ZERO.getNumber()) { |
|
|
|
return AjaxResult.error(UniversalEnum.PERSONNEL_SCHEDULING_EXCEPTION.getValue()); |
|
|
|
} |
|
|
|
String employeesName = dcWarningMapper.employeesName(employees); |
|
|
|
context = "路管人员" + employeesName + "参与事件救援,"; |
|
|
|
} |
|
|
|
if (vehicles!=null) { |
|
|
|
if (vehicles != null) { |
|
|
|
// 生成一个随机索引,范围在0到列表长度减1之间
|
|
|
|
dcDispatchResource.setResourceId(vehicles);//资源id
|
|
|
|
dcDispatchResource.setDispatchType(UniversalEnum.TWO.getNumber());//资源类型
|
|
|
|
dcDispatchResource.setDispatchId(dispatchId);//信息记录id
|
|
|
|
Integer dispatchResource = dcWarningMapper.insertDispatchResource(dcDispatchResource);//绑定车辆信息
|
|
|
|
if (dispatchResource==UniversalEnum.ZERO.getNumber()){ |
|
|
|
if (dispatchResource == UniversalEnum.ZERO.getNumber()) { |
|
|
|
return AjaxResult.error(UniversalEnum.VEHICLE_SCHEDULING_EXCEPTION.getValue()); |
|
|
|
} |
|
|
|
String vehiclePlate = dcWarningMapper.vehiclesName(vehicles); |
|
|
|
context += "救援车辆" + vehiclePlate + "参与事件救援,"; |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(context)){ |
|
|
|
context = context.substring(0,context.length() -1); |
|
|
|
if (StringUtils.isNotBlank(context)) { |
|
|
|
context = context.substring(0, context.length() - 1); |
|
|
|
DcEventProcess dcEventProcess = new DcEventProcess(); |
|
|
|
dcEventProcess.setEventId(eventId); |
|
|
|
dcEventProcess.setSource(UniversalEnum.ONE.getNumber()); |
|
|
@ -921,11 +932,12 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
|
|
|
|
@Override |
|
|
|
public Integer insertDispatch(DcDispatch dcDispatch) { |
|
|
|
if (dcDispatch.getId()==null){ //id为空说明新增
|
|
|
|
if (dcDispatch.getId() == null) { //id为空说明新增
|
|
|
|
return null; |
|
|
|
} |
|
|
|
return dcWarningMapper.updateDcDispatch(dcDispatch); |
|
|
|
} |
|
|
|
|
|
|
|
//4.新增指挥调度资源记录
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@ -940,17 +952,17 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
dcDispatch.setDispatchStatus(Long.valueOf(UniversalEnum.TWO.getNumber()));//进行中状态
|
|
|
|
dcDispatch.setRemark(remark); |
|
|
|
HashMap<String, Object> dispatch = dcWarningMapper.selectDcDispatch(eventId);//查询是否存在调度记录
|
|
|
|
if (dispatch!=null){ //不为空说明已经存在处置记录,不在新增
|
|
|
|
if (dispatch != null) { //不为空说明已经存在处置记录,不在新增
|
|
|
|
return 1; |
|
|
|
} |
|
|
|
dcWarningMapper.insertDcDispatch(dcDispatch);//事件绑定信息记录
|
|
|
|
Long dispatchId = dcDispatch.getId(); |
|
|
|
dcWarningMapper.deleteDispatchResource(dispatchId);//删除全部属于该调度记录下的全部资源
|
|
|
|
ArrayList<Map<String,Object>> employeesArray = (ArrayList<Map<String,Object>>) map.get("employees");//取出人员
|
|
|
|
ArrayList<Map<String, Object>> employeesArray = (ArrayList<Map<String, Object>>) map.get("employees");//取出人员
|
|
|
|
String context = UniversalEnum.EMPTY_STRING.getValue(); |
|
|
|
if (employeesArray!=null&&employeesArray.size()>UniversalEnum.ZERO.getNumber()) { |
|
|
|
if (employeesArray != null && employeesArray.size() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
context += UniversalEnum.ROAD_CONTROL_PERSONNEL.getValue(); |
|
|
|
for (Map<String,Object> array : employeesArray) { |
|
|
|
for (Map<String, Object> array : employeesArray) { |
|
|
|
dcDispatchResource.setDispatchType(UniversalEnum.ONE.getNumber());//类型
|
|
|
|
dcDispatchResource.setResourceId(Long.valueOf(array.get("id").toString()));//资源id
|
|
|
|
dcDispatchResource.setDispatchId(dispatchId);//关联调度记录
|
|
|
@ -960,16 +972,16 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
throw new RuntimeException(UniversalEnum.FAILED_TO_INSERT_RESOURCE.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
context = context.substring(UniversalEnum.ZERO.getNumber(),context.length() -UniversalEnum.ONE.getNumber()); |
|
|
|
context = context.substring(UniversalEnum.ZERO.getNumber(), context.length() - UniversalEnum.ONE.getNumber()); |
|
|
|
context += UniversalEnum.PARTICIPATE_IN_INCIDENT_RESCUE.getValue(); |
|
|
|
} |
|
|
|
ArrayList<Map<String,Object>> vehicleArray = (ArrayList<Map<String,Object>>) map.get("vehicle");////取出车辆
|
|
|
|
if (vehicleArray!=null&&vehicleArray.size()>UniversalEnum.ZERO.getNumber()) { |
|
|
|
if (context.length() > UniversalEnum.ZERO.getNumber()){ |
|
|
|
ArrayList<Map<String, Object>> vehicleArray = (ArrayList<Map<String, Object>>) map.get("vehicle");////取出车辆
|
|
|
|
if (vehicleArray != null && vehicleArray.size() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
if (context.length() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
context += UniversalEnum.CHINESE_COMMA.getValue(); |
|
|
|
} |
|
|
|
context += UniversalEnum.RESCUE_VEHICLE.getValue(); |
|
|
|
for (Map<String,Object> array : vehicleArray) { |
|
|
|
for (Map<String, Object> array : vehicleArray) { |
|
|
|
dcDispatchResource.setDispatchType(UniversalEnum.TWO.getNumber()); |
|
|
|
dcDispatchResource.setResourceId(Long.valueOf(array.get("id").toString())); |
|
|
|
dcDispatchResource.setDispatchId(dispatchId); |
|
|
@ -980,7 +992,7 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
throw new RuntimeException(UniversalEnum.FAILED_TO_INSERT_RESOURCE.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
context = context.substring(UniversalEnum.ZERO.getNumber(),context.length() -UniversalEnum.ONE.getNumber()); |
|
|
|
context = context.substring(UniversalEnum.ZERO.getNumber(), context.length() - UniversalEnum.ONE.getNumber()); |
|
|
|
context += UniversalEnum.PARTICIPATE_IN_INCIDENT_RESCUE.getValue(); |
|
|
|
} |
|
|
|
|
|
|
@ -1001,13 +1013,13 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
@Override |
|
|
|
public Integer updateDispatchSource(HashMap map) { |
|
|
|
DcDispatchResource dcDispatchResource = new DcDispatchResource(); |
|
|
|
Long dispatchId = Long.parseLong(map.get("dispatchId").toString()); |
|
|
|
Long dispatchId = Long.parseLong(map.get("dispatchId").toString()); |
|
|
|
dcWarningMapper.deleteDispatchResource(dispatchId);//删除全部属于该调度记录下的全部资源
|
|
|
|
ArrayList<Map<String,Object>> employeesArray = (ArrayList<Map<String,Object>>) map.get("employees");//取出人员
|
|
|
|
ArrayList<Map<String, Object>> employeesArray = (ArrayList<Map<String, Object>>) map.get("employees");//取出人员
|
|
|
|
String context = UniversalEnum.EMPTY_STRING.getValue(); |
|
|
|
if (employeesArray!=null&&employeesArray.size()>UniversalEnum.ZERO.getNumber()) { |
|
|
|
if (employeesArray != null && employeesArray.size() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
context += UniversalEnum.ROAD_CONTROL_PERSONNEL.getValue(); |
|
|
|
for (Map<String,Object> array : employeesArray) { |
|
|
|
for (Map<String, Object> array : employeesArray) { |
|
|
|
dcDispatchResource.setDispatchType(UniversalEnum.ONE.getNumber());//类型
|
|
|
|
dcDispatchResource.setResourceId(Long.valueOf(array.get("id").toString()));//资源id
|
|
|
|
dcDispatchResource.setDispatchId(dispatchId);//关联调度记录
|
|
|
@ -1017,16 +1029,16 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
throw new RuntimeException(UniversalEnum.FAILED_TO_INSERT_RESOURCE.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
context = context.substring(UniversalEnum.ZERO.getNumber(),context.length() -UniversalEnum.ONE.getNumber()); |
|
|
|
context = context.substring(UniversalEnum.ZERO.getNumber(), context.length() - UniversalEnum.ONE.getNumber()); |
|
|
|
context += UniversalEnum.PARTICIPATE_IN_INCIDENT_RESCUE.getValue(); |
|
|
|
} |
|
|
|
ArrayList<Map<String,Object>> vehicleArray = (ArrayList<Map<String,Object>>) map.get("vehicle");////取出车辆
|
|
|
|
if (vehicleArray!=null&&vehicleArray.size()>UniversalEnum.ZERO.getNumber()) { |
|
|
|
if (context.length() > UniversalEnum.ZERO.getNumber()){ |
|
|
|
ArrayList<Map<String, Object>> vehicleArray = (ArrayList<Map<String, Object>>) map.get("vehicle");////取出车辆
|
|
|
|
if (vehicleArray != null && vehicleArray.size() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
if (context.length() > UniversalEnum.ZERO.getNumber()) { |
|
|
|
context += UniversalEnum.CHINESE_COMMA.getValue(); |
|
|
|
} |
|
|
|
context += UniversalEnum.RESCUE_VEHICLE.getValue(); |
|
|
|
for (Map<String,Object> array : vehicleArray) { |
|
|
|
for (Map<String, Object> array : vehicleArray) { |
|
|
|
dcDispatchResource.setDispatchType(UniversalEnum.TWO.getNumber()); |
|
|
|
dcDispatchResource.setResourceId(Long.valueOf(array.get("id").toString())); |
|
|
|
dcDispatchResource.setDispatchId(dispatchId); |
|
|
@ -1037,7 +1049,7 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
throw new RuntimeException(UniversalEnum.FAILED_TO_INSERT_RESOURCE.getValue()); |
|
|
|
} |
|
|
|
} |
|
|
|
context = context.substring(UniversalEnum.ZERO.getNumber(),context.length() -UniversalEnum.ONE.getNumber()); |
|
|
|
context = context.substring(UniversalEnum.ZERO.getNumber(), context.length() - UniversalEnum.ONE.getNumber()); |
|
|
|
context += UniversalEnum.PARTICIPATE_IN_INCIDENT_RESCUE.getValue(); |
|
|
|
} |
|
|
|
|
|
|
@ -1061,4 +1073,110 @@ public class DcWarningServiceImpl implements IDcWarningService |
|
|
|
return i; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
/** |
|
|
|
* 获取雷达事件视频 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String getRadarIncidentVideo(String id) throws Exception { |
|
|
|
String msg = ""; |
|
|
|
HashMap<String, Object> stringObjectHashMap = dcWarningMapper.selectDcWarningById(id); |
|
|
|
// 给定的时间
|
|
|
|
String givenTime = (String) stringObjectHashMap.get("warningTime"); |
|
|
|
|
|
|
|
// 定义日期时间格式
|
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
|
|
|
|
|
|
|
// 解析给定的时间
|
|
|
|
LocalDateTime currentTime = LocalDateTime.parse(givenTime, formatter); |
|
|
|
// 计算 30 秒后的时间
|
|
|
|
LocalDateTime timeAfter30Seconds = currentTime.plus(Duration.ofSeconds(30)); |
|
|
|
// 获取当前时间
|
|
|
|
LocalDateTime now = LocalDateTime.now(); |
|
|
|
|
|
|
|
// 判断时间与当前时间不能超过两个月
|
|
|
|
boolean isWithinTwoMonths = ChronoUnit.MONTHS.between(now, currentTime) <= 2; |
|
|
|
if (isWithinTwoMonths) { |
|
|
|
// 格式化时间
|
|
|
|
String formattedTime = timeAfter30Seconds.format(formatter); |
|
|
|
|
|
|
|
Object otherConfig = stringObjectHashMap.get("otherConfig"); |
|
|
|
ObjectMapper objectMapper = new ObjectMapper(); |
|
|
|
JsonNode rootNode = objectMapper.readTree(otherConfig.toString()); |
|
|
|
// 提取 cameraIndexCode 的值
|
|
|
|
String cameraIndexCode = extractCameraIndexCode(rootNode); |
|
|
|
//雷达关联监控点查询接口
|
|
|
|
String callPostApiGetRegions = callPostApiGetRegions(cameraIndexCode); |
|
|
|
JsonNode roocallPostApiGetRegionstNode = objectMapper.readTree(callPostApiGetRegions); |
|
|
|
JsonNode jsonNode = roocallPostApiGetRegionstNode.get("data"); |
|
|
|
JsonNode jsonNodelist = jsonNode.get("list"); |
|
|
|
JsonNode code = jsonNodelist.get(0).get("cameraIndexCode"); |
|
|
|
// 使用 textValue() 方法获取纯字符串
|
|
|
|
String codestring = code.textValue(); |
|
|
|
com.alibaba.fastjson.JSONObject jsonObject = videoController.downloadCameraVideo(codestring, formattedTime, 1); |
|
|
|
JsonNode data = objectMapper.readTree(jsonObject.get("data").toString()); |
|
|
|
// 使用 textValue() 方法获取纯字符串
|
|
|
|
String fileUrl = data.get("fileUrl").textValue(); |
|
|
|
return fileUrl; |
|
|
|
} else { |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 雷达关联监控点查询接口 |
|
|
|
* |
|
|
|
* @throws HttpException |
|
|
|
* @throws IOException |
|
|
|
*/ |
|
|
|
|
|
|
|
private String extractCameraIndexCode(JsonNode rootNode) { |
|
|
|
JsonNode dataNode = rootNode.get("data"); |
|
|
|
JsonNode otherConfigurationNode = dataNode.get("otherConfiguration"); |
|
|
|
JsonNode paramsNode = otherConfigurationNode.get("params"); |
|
|
|
JsonNode eventsNode = paramsNode.get("events"); |
|
|
|
|
|
|
|
// 假设只有一个事件,我们只处理第一个事件
|
|
|
|
JsonNode eventDataNode = eventsNode.get(0); |
|
|
|
JsonNode dataNode2 = eventDataNode.get("data"); |
|
|
|
JsonNode vehicleRcogResultNode = dataNode2.get("vehicleRcogResult"); |
|
|
|
|
|
|
|
// 假设只有一个 vehicleRcogResult 对象
|
|
|
|
JsonNode targetAttrsNode = vehicleRcogResultNode.get(0).get("targetAttrs"); |
|
|
|
|
|
|
|
|
|
|
|
return targetAttrsNode.get("cameraIndexCode").asText(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 调用POST请求类型接口,这里以分页获取区域列表为例 |
|
|
|
* 接口实际url:https://ip:port/artemis/api/api/resource/v1/regions
|
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String callPostApiGetRegions(String cameraIndexCode) throws Exception { |
|
|
|
/** |
|
|
|
* https://ip:port/artemis/api/resource/v1/regions
|
|
|
|
* 过查阅AI Cloud开放平台文档或网关门户的文档可以看到分页获取区域列表的定义,这是一个POST请求的Rest接口, 入参为JSON字符串,接口协议为https。 |
|
|
|
* ArtemisHttpUtil工具类提供了doPostStringArtemis调用POST请求的方法,入参可传JSON字符串, 请阅读开发指南了解方法入参,没有的参数可传null |
|
|
|
*/ |
|
|
|
com.alibaba.fastjson.JSONObject radarCorrelation = com.alibaba.fastjson.JSONObject.parseObject(configService.selectConfigByKey("radarCorrelation")); |
|
|
|
|
|
|
|
ArtemisConfig config = new ArtemisConfig(); |
|
|
|
config.setHost(radarCorrelation.getString("url")); // 雷达关联监控点查询接口
|
|
|
|
config.setAppKey(radarCorrelation.getString("appkey")); // 秘钥appkey
|
|
|
|
config.setAppSecret(radarCorrelation.getString("appSecret"));// 秘钥appSecret
|
|
|
|
final String getCamsApi = ARTEMIS_PATH + UniversalEnum.RADAR_ASSOCIATED_MONITORING_POINT_QUERY_INTERFACE.getValue(); |
|
|
|
Map<String, String> paramMap = new HashMap<String, String>();// post请求Form表单参数
|
|
|
|
paramMap.put("pageNo", "1"); |
|
|
|
paramMap.put("pageSize", "20"); |
|
|
|
paramMap.put("radarIndexCode", cameraIndexCode); |
|
|
|
String body = JSON.toJSON(paramMap).toString(); |
|
|
|
Map<String, String> path = new HashMap<String, String>(2) { |
|
|
|
{ |
|
|
|
put("https://", getCamsApi); |
|
|
|
} |
|
|
|
}; |
|
|
|
return ArtemisHttpUtil.doPostStringArtemis(config, path, body, null, null, "application/json"); |
|
|
|
} |
|
|
|
|
|
|
|
} |