|
@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSON;
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.ozs.common.core.domain.entity.SysDictData;
|
|
|
+import com.ozs.common.core.redis.RedisCache;
|
|
|
import com.ozs.common.utils.ApiTokenUtils;
|
|
|
import com.ozs.common.utils.AppendUtils;
|
|
|
import com.ozs.common.utils.ChineseToPingyin;
|
|
@@ -30,6 +31,7 @@ import com.ozs.entity.SkynetHeartbeatLog;
|
|
|
import com.ozs.entity.SvcAddress;
|
|
|
import com.ozs.entity.TerminalIgnoreAlarm;
|
|
|
import com.ozs.entity.VehiclePosition;
|
|
|
+import com.ozs.entity.response.BaseVideoTrains;
|
|
|
import com.ozs.entity.response.PreAlarmResponse;
|
|
|
import com.ozs.entity.vo.AlarmFilesVo;
|
|
|
import com.ozs.entity.vo.AlarmHeartbeatLog;
|
|
@@ -37,6 +39,7 @@ import com.ozs.entity.vo.AlarmInfoVo;
|
|
|
import com.ozs.entity.vo.AlarmListVo;
|
|
|
import com.ozs.entity.vo.CameraPlayVo;
|
|
|
import com.ozs.entity.vo.CameraVo;
|
|
|
+import com.ozs.entity.vo.CameraVos;
|
|
|
import com.ozs.entity.vo.CamerasVo;
|
|
|
import com.ozs.entity.vo.Files;
|
|
|
import com.ozs.entity.vo.HeartbeatVo;
|
|
@@ -60,6 +63,7 @@ import com.ozs.service.BaseTerminalLogService;
|
|
|
import com.ozs.service.BaseTerminalService;
|
|
|
import com.ozs.service.BaseUserService;
|
|
|
import com.ozs.service.BaseVehicleTerminalService;
|
|
|
+import com.ozs.service.BaseVideoTrainsService;
|
|
|
import com.ozs.service.MsgAlarmExtService;
|
|
|
import com.ozs.service.MsgAlarmFrequencyService;
|
|
|
import com.ozs.service.MsgAlarmService;
|
|
@@ -84,9 +88,12 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
@@ -157,6 +164,10 @@ public class GeoHazardMonitorTokenController {
|
|
|
private BaseTerminalLogService baseTerminalLogService;
|
|
|
@Resource
|
|
|
private PreAlarmService preAlarmService;
|
|
|
+ @Resource
|
|
|
+ private RedisCache redisCache;
|
|
|
+ @Resource
|
|
|
+ private BaseVideoTrainsService baseVideoTrainsService;
|
|
|
|
|
|
/**
|
|
|
* 获取web访问令牌
|
|
@@ -439,16 +450,19 @@ public class GeoHazardMonitorTokenController {
|
|
|
*/
|
|
|
@PostMapping("/api/terminal/heartbeat")
|
|
|
@Transactional
|
|
|
- public String heartbeat(@RequestBody ParameterVo parameterVo, HttpServletRequest request) {
|
|
|
- AjaxResults AjaxResults1 = null;
|
|
|
+ public String heartbeat(@RequestBody ParameterVo parameterVo, HttpServletRequest request) throws Exception {
|
|
|
long begin = System.currentTimeMillis();
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+ log.info("接受心跳时间: " + sdf.format(new Date(begin)));
|
|
|
Map<String, Object> twoMap = new HashMap<>();
|
|
|
+ String playFlv1;
|
|
|
int distance = 0;
|
|
|
- int type = 0;
|
|
|
+ boolean type = true;
|
|
|
RespHeartbeatVo respHeartbeatVo = new RespHeartbeatVo();
|
|
|
String token = apiTokenUtils.getGeoHazardMonitorToken(request);
|
|
|
- //log.info("token:{}", token);
|
|
|
- //log.info("parameter:{}", parameterVo);
|
|
|
+ log.info("token:{}", token);
|
|
|
+ log.info("parameter:{}", parameterVo);
|
|
|
+ AjaxResults AjaxResults1 = null;
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
String[] split = token.split("-");
|
|
|
String key = split[split.length - 1];
|
|
@@ -473,7 +487,7 @@ public class GeoHazardMonitorTokenController {
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
}
|
|
|
if (ObjectUtils.isEmpty(heartbeatVo.getLongitude())) {
|
|
|
- AjaxResults1 = new AjaxResults(0, "当前所在经度不能为空");
|
|
|
+ AjaxResults1 = new AjaxResults(0, "当前所在纬度不能为空");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
}
|
|
|
LambdaQueryWrapper<BaseRailwayManagement> railway = new LambdaQueryWrapper<BaseRailwayManagement>();
|
|
@@ -487,7 +501,7 @@ public class GeoHazardMonitorTokenController {
|
|
|
}
|
|
|
if (heartbeatVo.getLineDir() != 1 && heartbeatVo.getLineDir() != 2) {
|
|
|
AjaxResults1 = new AjaxResults(0, "行别填写错误");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
}
|
|
|
if (!heartbeatVo.getVisualDistance().toString().matches(PATTERNS)) {
|
|
|
AjaxResults1 = new AjaxResults(0, "司机目视距离填写错误");
|
|
@@ -495,21 +509,20 @@ public class GeoHazardMonitorTokenController {
|
|
|
}
|
|
|
if (heartbeatVo.getSignalStrength() != 1 && heartbeatVo.getSignalStrength() != 2) {
|
|
|
AjaxResults1 = new AjaxResults(0, "信号强度填写错误");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
}
|
|
|
VehiclePosition vehiclePosition = new VehiclePosition();
|
|
|
+ BaseVideoTrains baseVideoTrains=new BaseVideoTrains();
|
|
|
BeanUtils.copyProperties(heartbeatVo, vehiclePosition);
|
|
|
LambdaQueryWrapper<BaseVehicleTerminal> wrapper = new LambdaQueryWrapper<>();
|
|
|
wrapper.eq(BaseVehicleTerminal::getTerminalCode, vehiclePosition.getTerminalCode());
|
|
|
BaseVehicleTerminal baseTerminal = baseVehicleTerminalService.getOne(wrapper);
|
|
|
if (ObjectUtils.isEmpty(baseTerminal)) {
|
|
|
AjaxResults1 = new AjaxResults(0, "关联表中没有改终端编码的信息");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
}
|
|
|
- if (heartbeatVo.getSignalStrength() == 1) {
|
|
|
- type = 0;
|
|
|
- } else if (heartbeatVo.getSignalStrength() == 2) {
|
|
|
- type = 1;
|
|
|
+ if (heartbeatVo.getSignalStrength() == 2) {
|
|
|
+ type = false;
|
|
|
}
|
|
|
vehiclePosition.setTravelMile(heartbeatVo.getCurrentMile());
|
|
|
vehiclePosition.setVehicleCode(baseTerminal.getVehicleCode());
|
|
@@ -527,15 +540,20 @@ public class GeoHazardMonitorTokenController {
|
|
|
LambdaQueryWrapper<BaseTerminal> terminal = new LambdaQueryWrapper<>();
|
|
|
terminal.eq(BaseTerminal::getTerminalCode, vehiclePosition.getTerminalCode());
|
|
|
boolean update = baseTerminalService.update(baseTerminal1, terminal);
|
|
|
-
|
|
|
+ baseVideoTrains.setTrainsMile(heartbeatVo.getCurrentMile());
|
|
|
//目视距离和里程位置
|
|
|
if (save && update) {
|
|
|
LambdaQueryWrapper<MsgAlarm> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.ge(MsgAlarm::getAlarmMile, heartbeatVo.getCurrentMile());
|
|
|
- queryWrapper.le(MsgAlarm::getAlarmMile, (heartbeatVo.getCurrentMile() + 10000));
|
|
|
- queryWrapper.eq(MsgAlarm::getLineDir, heartbeatVo.getLineDir());
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ queryWrapper.ge(MsgAlarm::getAlarmMile, heartbeatVo.getCurrentMile());
|
|
|
+ queryWrapper.le(MsgAlarm::getAlarmMile, (heartbeatVo.getCurrentMile() + 10000));
|
|
|
+ queryWrapper.orderByAsc(MsgAlarm::getAlarmMile);
|
|
|
+ } else if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ queryWrapper.le(MsgAlarm::getAlarmMile, heartbeatVo.getCurrentMile());
|
|
|
+ queryWrapper.ge(MsgAlarm::getAlarmMile, (heartbeatVo.getCurrentMile() - 10000));
|
|
|
+ queryWrapper.orderByDesc(MsgAlarm::getAlarmMile);
|
|
|
+ }
|
|
|
queryWrapper.eq(MsgAlarm::getRailwayCode, heartbeatVo.getRailwayCode());
|
|
|
- queryWrapper.orderByAsc(MsgAlarm::getAlarmMile);
|
|
|
queryWrapper.eq(MsgAlarm::getIsRelease, 2);
|
|
|
List<MsgAlarm> alarmsList = msgAlarmService.list(queryWrapper);
|
|
|
//根据终端编码 判断终端忽略报警信息记录表中的是否有忽略的报警
|
|
@@ -550,15 +568,18 @@ public class GeoHazardMonitorTokenController {
|
|
|
String previousFormattedDateTime = previousDateTime.format(formatter);
|
|
|
|
|
|
LambdaQueryWrapper<TerminalIgnoreAlarm> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ //报警信息表中报警标识的信息
|
|
|
List<String> collect = alarmsList.stream().map(MsgAlarm::getAlarmId).collect(Collectors.toList());
|
|
|
queryWrapper1.in(TerminalIgnoreAlarm::getAlarmId, collect);
|
|
|
queryWrapper1.eq(TerminalIgnoreAlarm::getTerminalCode, heartbeatVo.getTerminalCode());
|
|
|
queryWrapper1.ge(TerminalIgnoreAlarm::getIgnoreTime, previousFormattedDateTime);
|
|
|
queryWrapper1.le(TerminalIgnoreAlarm::getIgnoreTime, currentFormattedDateTime);
|
|
|
+ //终端忽略报警信息记录表
|
|
|
List<TerminalIgnoreAlarm> list2 = terminalIgnoreAlarmService.list(queryWrapper1);
|
|
|
//找出未忽略的报警信息
|
|
|
LambdaQueryWrapper<MsgAlarm> queryWrapper2 = new LambdaQueryWrapper<>();
|
|
|
if (!ObjectUtils.isEmpty(list2)) {
|
|
|
+ //忽略报警表中报警标识的信息
|
|
|
List<String> collect1 = list2.stream().map(TerminalIgnoreAlarm::getAlarmId).collect(Collectors.toList());
|
|
|
List<String> list = collect.stream()
|
|
|
.filter(item -> !collect1.contains(item))
|
|
@@ -571,59 +592,109 @@ public class GeoHazardMonitorTokenController {
|
|
|
} else {
|
|
|
queryWrapper2.in(MsgAlarm::getAlarmId, collect);
|
|
|
}
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ queryWrapper2.orderByAsc(MsgAlarm::getAlarmMile);
|
|
|
+ } else if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ queryWrapper2.orderByDesc(MsgAlarm::getAlarmMile);
|
|
|
+ }
|
|
|
List<MsgAlarm> list = msgAlarmService.list(queryWrapper2);
|
|
|
+ PreAlarm preAlarm = preAlarmService.getOne(new LambdaQueryWrapper<PreAlarm>()
|
|
|
+ .eq(PreAlarm::getTrainId, heartbeatVo.getVehicleCode())
|
|
|
+ .orderByDesc(PreAlarm::getPreAlarmTime)
|
|
|
+ .last("limit 1"));
|
|
|
+ log.info("--------List<MsgAlarm>--------" + list);
|
|
|
//有报警信息的时候
|
|
|
+ LambdaQueryWrapper<BaseCameraManagement> camera = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
if (!ObjectUtils.isEmpty(list)) {
|
|
|
//获取报警里程所监控的所有相机
|
|
|
- LambdaQueryWrapper<BaseCameraManagement> camera = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
- camera.ge(BaseCameraManagement::getEndMile, list.get(0).getAlarmMile());
|
|
|
- camera.le(BaseCameraManagement::getBeginMile, list.get(0).getAlarmMile());
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ log.info("-------getLineDir() == 1--------" + list.get(0).getAlarmMile());
|
|
|
+ camera.ge(BaseCameraManagement::getEndMile, list.get(0).getAlarmMile());
|
|
|
+ camera.le(BaseCameraManagement::getBeginMile, list.get(0).getAlarmMile());
|
|
|
+ camera.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
|
|
|
+ camera.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
|
|
|
+ }
|
|
|
+ if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ log.info("-------getLineDir() == 2--------" + list.get(0).getAlarmMile());
|
|
|
+ camera.ge(BaseCameraManagement::getEndMile, list.get(0).getAlarmMile());
|
|
|
+ camera.le(BaseCameraManagement::getBeginMile, list.get(0).getAlarmMile());
|
|
|
+ camera.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
|
|
|
+ camera.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
|
|
|
+ }
|
|
|
camera.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
|
|
|
-// camera.eq(BaseCameraManagement::getOnline,2);
|
|
|
+ camera.eq(BaseCameraManagement::getOnline, 2);
|
|
|
camera.eq(BaseCameraManagement::getEnableOrNot, 1);
|
|
|
- camera.orderByAsc(BaseCameraManagement::getInstallMile);
|
|
|
List<BaseCameraManagement> baseCameraManagementList = baseCameraManagementService.list(camera);
|
|
|
+ log.info("-------baseCameraManagementList123111--------" + baseCameraManagementList);
|
|
|
List<AlarmListVo> listVos = new ArrayList<>();
|
|
|
if (baseCameraManagementList.size() > 0) {
|
|
|
- //获取视频点播地址
|
|
|
- CamerasVo camerasVo = new CamerasVo();
|
|
|
- camerasVo.setStreamType(type);
|
|
|
- camerasVo.setCameraIndexCode(baseCameraManagementList.get(0).getCameraCode());
|
|
|
- String playFlv = cameraUtil.apiPreviewURLs(camerasVo);
|
|
|
- if ("1".equals(playFlv)) {
|
|
|
- AjaxResults1 = new AjaxResults(0, "天网实时流接口调用失败");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ int minDifference = Integer.MAX_VALUE;
|
|
|
+ String code = null;
|
|
|
+ String channel = null;
|
|
|
+ for (BaseCameraManagement baseCameraManagement : baseCameraManagementList) {
|
|
|
+ log.info("------------baseCameraManagement.getInstallMile()-------" + baseCameraManagement.getInstallMile());
|
|
|
+ log.info("------------list.get(0).getAlarmMile()-------" + list.get(0).getAlarmMile());
|
|
|
+ int difference = Math.abs(baseCameraManagement.getInstallMile() - list.get(0).getAlarmMile());
|
|
|
+ log.info("------------difference-------" + difference);
|
|
|
+ log.info("------------minDifference-------" + minDifference);
|
|
|
+ if (difference < minDifference) {
|
|
|
+ minDifference = difference;
|
|
|
+ log.info("------------minDifference变更-------" + minDifference);
|
|
|
+ code = baseCameraManagement.getCameraCode();
|
|
|
+ log.info("------------code-------" + code);
|
|
|
+ channel = baseCameraManagement.getChannel();
|
|
|
+ log.info("------------channel-------" + channel);
|
|
|
+ }
|
|
|
}
|
|
|
- respHeartbeatVo.setCurrentStream(playFlv);
|
|
|
+ playFlv1 = CameraUtil.getPlayFlvRtsp(code, channel, type);
|
|
|
+ if (StringUtils.isEmpty(playFlv1)) {
|
|
|
+ playFlv1 = CameraUtil.getPlayFlvRtsp(code, channel, type);
|
|
|
+ if (playFlv1.contains("无视频")) {
|
|
|
+ AjaxResults1 = new AjaxResults(0, playFlv1);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("-------playFlv--------" + playFlv1);
|
|
|
+ CameraVos cameraVos = new CameraVos();
|
|
|
+ cameraVos.setCameraCode(baseCameraManagementList.get(0).getCameraCode());
|
|
|
+ cameraVos.setCurrentStream(playFlv1);
|
|
|
+ List<CameraVos> cameraVosList = new ArrayList<>();
|
|
|
+ cameraVosList.add(cameraVos);
|
|
|
+ respHeartbeatVo.setCameraList(cameraVosList);
|
|
|
respHeartbeatVo.setIsAlarm(1);
|
|
|
- respHeartbeatVo.setCameraCode(baseCameraManagementList.get(0).getCameraCode());
|
|
|
- twoMap.put("currentStream", playFlv);
|
|
|
+ twoMap.put("currentStream", playFlv1);
|
|
|
twoMap.put("cameraCode", baseCameraManagementList.get(0).getCameraCode());
|
|
|
- //alarmInfo对象
|
|
|
- AlarmInfoVo alarmInfoVo = new AlarmInfoVo();
|
|
|
- alarmInfoVo.setAlarmId(list.get(0).getAlarmId());
|
|
|
- alarmInfoVo.setAlarmMile(list.get(0).getAlarmMile());
|
|
|
- alarmInfoVo.setAlarmTime(list.get(0).getAlarmTime().getTime());
|
|
|
- alarmInfoVo.setAlarmContent(list.get(0).getContent());
|
|
|
- alarmInfoVo.setAlarmType(list.get(0).getAlarmType());
|
|
|
- alarmInfoVo.setAlarmLevel(list.get(0).getAlarmLevel());
|
|
|
- LambdaQueryWrapper<MsgAlarmExt> ext = new LambdaQueryWrapper<>();
|
|
|
- ext.eq(MsgAlarmExt::getAlarmId, list.get(0).getAlarmId());
|
|
|
- List<MsgAlarmExt> list1 = msgAlarmExtService.list(ext);
|
|
|
- AlarmFilesVo[] files = new AlarmFilesVo[list1.size()];
|
|
|
- if (!ObjectUtils.isEmpty(list1)) {
|
|
|
- for (int i = 0; i < list1.size(); i++) {
|
|
|
- files[i] = new AlarmFilesVo();
|
|
|
- files[i].setAlarmAttType(list1.get(i).getAlarmAttType());
|
|
|
- files[i].setAlarmAttPath(list1.get(i).getAlarmAttPath());
|
|
|
+ } else {
|
|
|
+ //赋值--股道
|
|
|
+ List<BaseRouteMassage> baseRouteMassageList = baseRouteMassageService.list();
|
|
|
+ if (!ObjectUtils.isEmpty(baseRouteMassageList)) {
|
|
|
+ for (BaseRouteMassage baseRouteMassage : baseRouteMassageList) {
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ if (baseRouteMassage.getMileagePosition() - heartbeatVo.getCurrentMile() <= 1500 && baseRouteMassage.getMileagePosition() - heartbeatVo.getCurrentMile() >= 0) {
|
|
|
+ respHeartbeatVo.setRouteTrack(baseRouteMassage.getRouteStationTrack().toString());
|
|
|
+ respHeartbeatVo.setStationCode(baseRouteMassage.getStationCode());
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ } else if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ if (heartbeatVo.getCurrentMile() - baseRouteMassage.getMileagePosition() <= 1500 && heartbeatVo.getCurrentMile() - baseRouteMassage.getMileagePosition() >= 0) {
|
|
|
+ respHeartbeatVo.setRouteTrack(baseRouteMassage.getRouteStationTrack().toString());
|
|
|
+ respHeartbeatVo.setStationCode(baseRouteMassage.getStationCode());
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- //返回结果
|
|
|
- alarmInfoVo.setAlarmFiles(files);
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
}
|
|
|
- respHeartbeatVo.setAlarmInfo(alarmInfoVo);
|
|
|
- } else {
|
|
|
- AjaxResults1 = new AjaxResults(0, "报警里程无可用相机");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ AjaxResults1 = new AjaxResults(0, "报警里程无可用相机",respHeartbeatVo);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
}
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
MsgHeartbeatAlarmMessage msgHearbeatAlarmMessage = new MsgHeartbeatAlarmMessage();
|
|
@@ -633,138 +704,451 @@ public class GeoHazardMonitorTokenController {
|
|
|
msgHearbeatAlarmMessageMapper.insert(msgHearbeatAlarmMessage);
|
|
|
//获取剩余的报警信息
|
|
|
LambdaQueryWrapper<BaseCameraManagement> ment = new LambdaQueryWrapper<BaseCameraManagement>();
|
|
|
- ment.ge(BaseCameraManagement::getEndMile, list.get(i).getAlarmMile());
|
|
|
- ment.le(BaseCameraManagement::getBeginMile, list.get(i).getAlarmMile());
|
|
|
ment.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
|
|
|
+ ment.eq(BaseCameraManagement::getOnline, 2);
|
|
|
ment.eq(BaseCameraManagement::getEnableOrNot, 1);
|
|
|
- ment.orderByAsc(BaseCameraManagement::getInstallMile);
|
|
|
- if (i == 0) {
|
|
|
- ment.last("limit 1,1000000");
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ ment.ge(BaseCameraManagement::getEndMile, list.get(i).getAlarmMile());
|
|
|
+ ment.le(BaseCameraManagement::getBeginMile, list.get(i).getAlarmMile());
|
|
|
+ ment.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
|
|
|
+ ment.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
|
|
|
+ } else if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ ment.ge(BaseCameraManagement::getEndMile, list.get(i).getAlarmMile());
|
|
|
+ ment.le(BaseCameraManagement::getBeginMile, list.get(i).getAlarmMile());
|
|
|
+ ment.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
|
|
|
+ ment.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
|
|
|
}
|
|
|
//获取所有报警安装里程位置的相机
|
|
|
List<BaseCameraManagement> baseList = baseCameraManagementService.list(ment);
|
|
|
if (baseList.size() > 0) {
|
|
|
- for (int o = 0; o < baseList.size(); o++) {
|
|
|
- //获取视频点播地址
|
|
|
- CamerasVo camerasVo = new CamerasVo();
|
|
|
- camerasVo.setStreamType(type);
|
|
|
- camerasVo.setCameraIndexCode(baseList.get(o).getCameraCode());
|
|
|
- String playFlv = cameraUtil.apiPreviewURLs(camerasVo);
|
|
|
- if ("1".equals(playFlv)) {
|
|
|
- AjaxResults1 = new AjaxResults(0, "天网实时流接口调用失败");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
- }
|
|
|
- AlarmListVo alarmListVo = new AlarmListVo();
|
|
|
- //alarmList对象
|
|
|
- alarmListVo.setCameraStream(playFlv);
|
|
|
- alarmListVo.setCameraCode(baseList.get(o).getCameraCode());
|
|
|
- //alarmInfo对象
|
|
|
- AlarmInfoVo alarmInfoVo1 = new AlarmInfoVo();
|
|
|
- alarmInfoVo1.setAlarmId(list.get(i).getAlarmId());
|
|
|
- alarmInfoVo1.setAlarmMile(list.get(i).getAlarmMile());
|
|
|
- alarmInfoVo1.setAlarmTime(list.get(i).getAlarmTime().getTime());
|
|
|
- alarmInfoVo1.setAlarmType(list.get(i).getAlarmType());
|
|
|
- alarmInfoVo1.setAlarmContent(list.get(i).getContent());
|
|
|
- alarmInfoVo1.setAlarmLevel(list.get(i).getAlarmLevel());
|
|
|
- LambdaQueryWrapper<MsgAlarmExt> alarm = new LambdaQueryWrapper<>();
|
|
|
- alarm.eq(MsgAlarmExt::getAlarmId, list.get(0).getAlarmId());
|
|
|
- List<MsgAlarmExt> list1 = msgAlarmExtService.list(alarm);
|
|
|
- if (list1.size() > 0) {
|
|
|
- AlarmFilesVo[] vo = new AlarmFilesVo[list1.size()];
|
|
|
- for (int i1 = 0; i1 < list1.size(); i1++) {
|
|
|
- vo[i1] = new AlarmFilesVo();
|
|
|
- vo[i1].setAlarmAttType(list1.get(i1).getAlarmAttType());
|
|
|
- vo[i1].setAlarmAttPath(list1.get(i1).getAlarmAttPath());
|
|
|
+ if (i > 0) {
|
|
|
+ int minDifference = Integer.MAX_VALUE;
|
|
|
+ String code = null;
|
|
|
+ String channel = null;
|
|
|
+ for (BaseCameraManagement baseCameraManagement : baseList) {
|
|
|
+ log.info("------------baseCameraManagement.getInstallMile()-------" + baseCameraManagement.getInstallMile());
|
|
|
+ log.info("------------list.get(0).getAlarmMile()-------" + list.get(0).getAlarmMile());
|
|
|
+ int difference = Math.abs(baseCameraManagement.getInstallMile() - list.get(0).getAlarmMile());
|
|
|
+ log.info("------------difference-------" + difference);
|
|
|
+ log.info("------------minDifference-------" + minDifference);
|
|
|
+ if (difference < minDifference) {
|
|
|
+ minDifference = difference;
|
|
|
+ log.info("------------minDifference变更-------" + minDifference);
|
|
|
+ code = baseCameraManagement.getCameraCode();
|
|
|
+ log.info("------------code-------" + code);
|
|
|
+ channel = baseCameraManagement.getChannel();
|
|
|
+ log.info("------------channel-------" + channel);
|
|
|
}
|
|
|
- alarmInfoVo1.setAlarmFiles(vo);
|
|
|
}
|
|
|
- alarmListVo.setAlarmInfo(alarmInfoVo1);
|
|
|
- listVos.add(alarmListVo);
|
|
|
+ playFlv1 = CameraUtil.getPlayFlvRtsp(code, channel, type);
|
|
|
+ }
|
|
|
+ AlarmListVo alarmListVo = new AlarmListVo();
|
|
|
+ //alarmList对象
|
|
|
+ if (playFlv1 != null) {
|
|
|
+ alarmListVo.setCameraStream(playFlv1);
|
|
|
+ } else {
|
|
|
+ alarmListVo.setCameraStream("");
|
|
|
+ }
|
|
|
+ alarmListVo.setCameraCode(baseList.get(0).getCameraCode());
|
|
|
+ //alarmInfo对象
|
|
|
+ AlarmInfoVo alarmInfoVo1 = new AlarmInfoVo();
|
|
|
+ log.info("----------------list.get(i).getAlarmId()---后续-----------" + list.get(i).getAlarmId());
|
|
|
+ alarmInfoVo1.setAlarmId(list.get(i).getAlarmId());
|
|
|
+ alarmInfoVo1.setAlarmMile(list.get(i).getAlarmMile());
|
|
|
+ alarmInfoVo1.setAlarmTime(list.get(i).getAlarmTime().getTime());
|
|
|
+ alarmInfoVo1.setAlarmType(list.get(i).getAlarmType());
|
|
|
+ alarmInfoVo1.setAlarmContent(list.get(i).getContent());
|
|
|
+ alarmInfoVo1.setAlarmLevel(list.get(i).getAlarmLevel());
|
|
|
+ LambdaQueryWrapper<MsgAlarmExt> alarm = new LambdaQueryWrapper<>();
|
|
|
+ alarm.eq(MsgAlarmExt::getAlarmId, list.get(i).getAlarmId());
|
|
|
+ List<MsgAlarmExt> list1 = msgAlarmExtService.list(alarm);
|
|
|
+ if (list1.size() > 0) {
|
|
|
+ AlarmFilesVo[] vo = new AlarmFilesVo[list1.size()];
|
|
|
+ for (int i1 = 0; i1 < list1.size(); i1++) {
|
|
|
+ vo[i1] = new AlarmFilesVo();
|
|
|
+ vo[i1].setAlarmAttType(list1.get(i1).getAlarmAttType());
|
|
|
+ vo[i1].setAlarmAttPath(list1.get(i1).getAlarmAttPath());
|
|
|
+ }
|
|
|
+ alarmInfoVo1.setAlarmFiles(vo);
|
|
|
}
|
|
|
+ alarmListVo.setAlarmInfo(alarmInfoVo1);
|
|
|
+ log.info("----------------alarmListVo-----------" + alarmListVo);
|
|
|
+ listVos.add(alarmListVo);
|
|
|
}
|
|
|
}
|
|
|
AlarmListVo[] array = listVos.toArray(new AlarmListVo[]{});
|
|
|
+ log.info("----------------array-----------" + Arrays.toString(array));
|
|
|
respHeartbeatVo.setAlarmList(array);
|
|
|
- } else {
|
|
|
- //没有报警信息的时候
|
|
|
- distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
|
|
|
+ //获取机车前一路视频
|
|
|
+ int mile = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
|
|
|
LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ base.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
|
|
|
+ base.gt(BaseCameraManagement::getInstallMile, mile);
|
|
|
+ }
|
|
|
+ if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ base.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
|
|
|
+ base.lt(BaseCameraManagement::getInstallMile, mile);
|
|
|
+ }
|
|
|
base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
|
|
|
- base.orderByAsc(BaseCameraManagement::getInstallMile);
|
|
|
+ base.eq(BaseCameraManagement::getOnline, 2);
|
|
|
base.eq(BaseCameraManagement::getEnableOrNot, 1);
|
|
|
- base.last("limit 4");
|
|
|
- List<BaseCameraManagement> list1 = baseCameraManagementService.list(base);
|
|
|
+ base.last("limit 1");
|
|
|
+ BaseCameraManagement baseCameraManagement = baseCameraManagementService.getOne(base);
|
|
|
+ //根据相机ID找出分组并排序
|
|
|
+ List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
|
|
|
+ if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
|
|
|
+ for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
|
|
|
+ String playFlv = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (StringUtils.isEmpty(playFlv)) {
|
|
|
+ String url = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (url.contains("无视频")) {
|
|
|
+ AjaxResults1 = new AjaxResults(0, url);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (!ObjectUtils.isEmpty(preAlarm)){
|
|
|
+ List<PreAlarmResponse.PreAlarmList> preAlarmList = JSON.parseArray(preAlarm.getPreAlarmList(), PreAlarmResponse.PreAlarmList.class);
|
|
|
+ Comparator<PreAlarmResponse.PreAlarmList> distanceComparator = new Comparator<PreAlarmResponse.PreAlarmList>() {
|
|
|
+ @Override
|
|
|
+ public int compare(PreAlarmResponse.PreAlarmList o1, PreAlarmResponse.PreAlarmList o2) {
|
|
|
+ return Integer.compare(o1.getDistance(), o2.getDistance());
|
|
|
+ }
|
|
|
+ };
|
|
|
+ //排序
|
|
|
+ preAlarmList.sort(distanceComparator);
|
|
|
+ for (PreAlarmResponse.PreAlarmList alarmList : preAlarmList) {
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ int mile=alarmList.getDistance()+heartbeatVo.getCurrentMile();
|
|
|
+ camera.ge(BaseCameraManagement::getEndMile, mile);
|
|
|
+ camera.le(BaseCameraManagement::getBeginMile, mile);
|
|
|
+ camera.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
|
|
|
+ camera.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
|
|
|
+ }
|
|
|
+ if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ int mile=heartbeatVo.getCurrentMile()-alarmList.getDistance();
|
|
|
+ camera.ge(BaseCameraManagement::getEndMile, mile);
|
|
|
+ camera.le(BaseCameraManagement::getBeginMile, mile);
|
|
|
+ camera.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
|
|
|
+ camera.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ //没有报警信息的时候
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
|
|
|
+ camera.ge(BaseCameraManagement::getInstallMile, distance);
|
|
|
+ camera.le(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() + 10000));
|
|
|
+ camera.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
|
|
|
+ camera.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
|
|
|
+ }
|
|
|
+ if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ distance = heartbeatVo.getCurrentMile() - heartbeatVo.getVisualDistance();
|
|
|
+ camera.le(BaseCameraManagement::getInstallMile, distance);
|
|
|
+ camera.ge(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() - 10000));
|
|
|
+ camera.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
|
|
|
+ camera.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
|
|
|
+ ;
|
|
|
+ }
|
|
|
+ camera.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
|
|
|
+ camera.eq(BaseCameraManagement::getOnline, 2);
|
|
|
+ camera.eq(BaseCameraManagement::getEnableOrNot, 1);
|
|
|
+ camera.last("limit 2");
|
|
|
+ List<BaseCameraManagement> list1 = baseCameraManagementService.list(camera);
|
|
|
if (list1.size() <= 0) {
|
|
|
- AjaxResults1 = new AjaxResults(0, "没有监控里程的相机");
|
|
|
+ //赋值--股道
|
|
|
+ List<BaseRouteMassage> baseRouteMassageList = baseRouteMassageService.list();
|
|
|
+ if (!ObjectUtils.isEmpty(baseRouteMassageList)) {
|
|
|
+ for (BaseRouteMassage baseRouteMassage : baseRouteMassageList) {
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ if (baseRouteMassage.getMileagePosition() - heartbeatVo.getCurrentMile() <= 1500 && baseRouteMassage.getMileagePosition() - heartbeatVo.getCurrentMile() >= 0) {
|
|
|
+ respHeartbeatVo.setRouteTrack(baseRouteMassage.getRouteStationTrack().toString());
|
|
|
+ respHeartbeatVo.setStationCode(baseRouteMassage.getStationCode());
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ } else if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ if (heartbeatVo.getCurrentMile() - baseRouteMassage.getMileagePosition() <= 1500 && heartbeatVo.getCurrentMile() - baseRouteMassage.getMileagePosition() >= 0) {
|
|
|
+ respHeartbeatVo.setRouteTrack(baseRouteMassage.getRouteStationTrack().toString());
|
|
|
+ respHeartbeatVo.setStationCode(baseRouteMassage.getStationCode());
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ AjaxResults1 = new AjaxResults(0, "前方没有摄像机",respHeartbeatVo);
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
}
|
|
|
- //获取视频点播地址
|
|
|
- CamerasVo camerasVo = new CamerasVo();
|
|
|
- camerasVo.setStreamType(type);
|
|
|
- camerasVo.setCameraIndexCode(list1.get(0).getCameraCode());
|
|
|
- String playFlv = cameraUtil.apiPreviewURLs(camerasVo);
|
|
|
- if ("1".equals(playFlv)) {
|
|
|
- AjaxResults1 = new AjaxResults(0, "天网实时流接口调用失败");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ log.info("流程1----------------->");
|
|
|
+ //判断流媒体是否有流
|
|
|
+ String playFlv = CameraUtil.getPlayFlvRtsp(list1.get(0).getCameraCode(), list1.get(0).getChannel(), type);
|
|
|
+ log.info("playFlv------------>" + playFlv);
|
|
|
+ baseVideoTrains.setVideoMile(list1.get(0).getInstallMile());
|
|
|
+ long delay = System.currentTimeMillis();
|
|
|
+ log.info("关联距离时间: " + sdf.format(new Date(delay)));
|
|
|
+ long mile= delay - begin;
|
|
|
+ log.info("关联距离请求用时时间:" + mile + "毫秒");
|
|
|
+ baseVideoTrains.setDelay((int)mile);
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ baseVideoTrains.setDistance(list1.get(0).getInstallMile() - heartbeatVo.getCurrentMile());
|
|
|
+ }else {
|
|
|
+ baseVideoTrains.setDistance(heartbeatVo.getCurrentMile() - list1.get(0).getInstallMile());
|
|
|
+ }
|
|
|
+ if (baseVideoTrains.getDistance()>=1000&&baseVideoTrains.getDistance()<=10000){
|
|
|
+ baseVideoTrains.setIsAccuracy(1);
|
|
|
+ }else {
|
|
|
+ baseVideoTrains.setIsAccuracy(2);
|
|
|
+ }
|
|
|
+ //拉两路视频
|
|
|
+ if (StringUtils.isEmpty(playFlv)) {
|
|
|
+ log.info("--------------->>已进入拉两路视频");
|
|
|
+ for (BaseCameraManagement baseCameraManagement : list1) {
|
|
|
+ List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
|
|
|
+ if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
|
|
|
+ for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
|
|
|
+ String flv = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (StringUtils.isEmpty(flv)) {
|
|
|
+ String url = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (url.contains("无视频")) {
|
|
|
+ AjaxResults1 = new AjaxResults(0,url);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BaseCameraManagement idOne = baseCameraManagementService.getById(list1.get(0).getId());
|
|
|
+ BaseCameraManagement idTwo = baseCameraManagementService.getById(list1.get(1).getId());
|
|
|
+ if (idOne.getGrou().equals(idTwo.getGrou())) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+// CompletableFuture.runAsync(() -> {
|
|
|
+// cameraUtil.removePlayFlv(heartbeatVo.getLineDir(), heartbeatVo.getCurrentMile(), heartbeatVo.getVisualDistance());
|
|
|
+// });
|
|
|
+ } else {
|
|
|
+ log.info("-------------->>已进入拉一路视频");
|
|
|
+ log.info("list1-------------->>" + list1.size());
|
|
|
+ for (int i = 1; i < list1.size(); i++) {
|
|
|
+ List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(i).getId(), heartbeatVo.getLineDir());
|
|
|
+ if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
|
|
|
+ for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
|
|
|
+ String flv = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (StringUtils.isEmpty(flv)) {
|
|
|
+ String url = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (url.contains("无视频")) {
|
|
|
+ AjaxResults1 = new AjaxResults(0,url);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(0).getId(), heartbeatVo.getLineDir());
|
|
|
+ if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
|
|
|
+ List<CameraVos> cameraVosList = new ArrayList<>();
|
|
|
+ for (BaseCameraManagement baseCameraManagement : baseCameraManagementList1) {
|
|
|
+ CameraVos cameraVos = new CameraVos();
|
|
|
+ cameraVos.setCameraCode(baseCameraManagement.getCameraCode());
|
|
|
+ cameraVos.setCurrentStream(CameraUtil.getPlayFlvRtsp(baseCameraManagement.getCameraCode(), baseCameraManagement.getChannel(), type));
|
|
|
+ cameraVosList.add(cameraVos);
|
|
|
+ }
|
|
|
+ respHeartbeatVo.setCameraList(cameraVosList);
|
|
|
}
|
|
|
twoMap.put("currentStream", playFlv);
|
|
|
twoMap.put("cameraCode", list1.get(0).getCameraCode());
|
|
|
- respHeartbeatVo.setCurrentStream(playFlv);
|
|
|
respHeartbeatVo.setIsAlarm(2);
|
|
|
- respHeartbeatVo.setCameraCode(list1.get(0).getCameraCode());
|
|
|
- respHeartbeatVo.setAlarmList(null);
|
|
|
- respHeartbeatVo.setAlarmInfo(null);
|
|
|
}
|
|
|
} else {
|
|
|
//没有报警信息的时候
|
|
|
- distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
|
|
|
LambdaQueryWrapper<BaseCameraManagement> base = new LambdaQueryWrapper<>();
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ distance = heartbeatVo.getVisualDistance() + heartbeatVo.getCurrentMile();
|
|
|
+ base.ge(BaseCameraManagement::getInstallMile, distance);
|
|
|
+ base.in(BaseCameraManagement::getMonitoringDirection, 1, 3);
|
|
|
+ base.orderByAsc(BaseCameraManagement::getGrou).orderByAsc(BaseCameraManagement::getSort);
|
|
|
+ base.le(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() + 10000));
|
|
|
+ }
|
|
|
+ if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ distance = heartbeatVo.getCurrentMile() - heartbeatVo.getVisualDistance();
|
|
|
+ base.le(BaseCameraManagement::getInstallMile, distance);
|
|
|
+ base.ge(BaseCameraManagement::getInstallMile, (heartbeatVo.getCurrentMile() - 10000));
|
|
|
+ base.in(BaseCameraManagement::getMonitoringDirection, 2, 3);
|
|
|
+ base.orderByDesc(BaseCameraManagement::getGrou).orderByDesc(BaseCameraManagement::getSort);
|
|
|
+ }
|
|
|
base.eq(BaseCameraManagement::getRailwayCode, heartbeatVo.getRailwayCode());
|
|
|
- base.orderByAsc(BaseCameraManagement::getInstallMile);
|
|
|
+ base.eq(BaseCameraManagement::getOnline, 2);
|
|
|
base.eq(BaseCameraManagement::getEnableOrNot, 1);
|
|
|
- base.last("limit 4");
|
|
|
+ base.last("limit 2");
|
|
|
List<BaseCameraManagement> list1 = baseCameraManagementService.list(base);
|
|
|
if (list1.size() <= 0) {
|
|
|
- AjaxResults1 = new AjaxResults(0, "没有监控里程的相机");
|
|
|
+ //赋值--股道
|
|
|
+ List<BaseRouteMassage> list = baseRouteMassageService.list();
|
|
|
+ if (!ObjectUtils.isEmpty(list)) {
|
|
|
+ for (BaseRouteMassage baseRouteMassage : list) {
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ if (baseRouteMassage.getMileagePosition() - heartbeatVo.getCurrentMile() <= 1500 && baseRouteMassage.getMileagePosition() - heartbeatVo.getCurrentMile() >= 0) {
|
|
|
+ respHeartbeatVo.setRouteTrack(baseRouteMassage.getRouteStationTrack().toString());
|
|
|
+ respHeartbeatVo.setStationCode(baseRouteMassage.getStationCode());
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ } else if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ if (heartbeatVo.getCurrentMile() - baseRouteMassage.getMileagePosition() <= 1500 && heartbeatVo.getCurrentMile() - baseRouteMassage.getMileagePosition() >= 0) {
|
|
|
+ respHeartbeatVo.setRouteTrack(baseRouteMassage.getRouteStationTrack().toString());
|
|
|
+ respHeartbeatVo.setStationCode(baseRouteMassage.getStationCode());
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ AjaxResults1 = new AjaxResults(0,"前方没有摄像机",respHeartbeatVo);
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
}
|
|
|
- //获取视频点播地址
|
|
|
- CamerasVo camerasVo = new CamerasVo();
|
|
|
- camerasVo.setStreamType(type);
|
|
|
- camerasVo.setCameraIndexCode(list1.get(0).getCameraCode());
|
|
|
- String playFlv = cameraUtil.apiPreviewURLs(camerasVo);
|
|
|
- if ("1".equals(playFlv)) {
|
|
|
- AjaxResults1 = new AjaxResults(0, "天网实时流接口调用失败");
|
|
|
- return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ log.info("流程2----------------->");
|
|
|
+ //判断流媒体是否有流
|
|
|
+ String playFlv = CameraUtil.getPlayFlvRtsp(list1.get(0).getCameraCode(), list1.get(0).getChannel(), type);
|
|
|
+ log.info("playFlv------------>" + playFlv);
|
|
|
+ baseVideoTrains.setVideoMile(list1.get(0).getInstallMile());
|
|
|
+ long delay = System.currentTimeMillis();
|
|
|
+ log.info("关联距离时间: " + sdf.format(new Date(delay)));
|
|
|
+ long mile= delay - begin;
|
|
|
+ log.info("关联距离请求用时时间:" + mile + "毫秒");
|
|
|
+ baseVideoTrains.setDelay((int)mile);
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ baseVideoTrains.setDistance(list1.get(0).getInstallMile() - heartbeatVo.getCurrentMile());
|
|
|
+ }else {
|
|
|
+ baseVideoTrains.setDistance(heartbeatVo.getCurrentMile() - list1.get(0).getInstallMile());
|
|
|
+ }
|
|
|
+ if (baseVideoTrains.getDistance()>=1000&&baseVideoTrains.getDistance()<=10000){
|
|
|
+ baseVideoTrains.setIsAccuracy(1);
|
|
|
+ }else {
|
|
|
+ baseVideoTrains.setIsAccuracy(2);
|
|
|
+ }
|
|
|
+ //拉两路视频
|
|
|
+ if (StringUtils.isEmpty(playFlv)) {
|
|
|
+ log.info("--------------->>已进入拉两路视频");
|
|
|
+ for (BaseCameraManagement baseCameraManagement : list1) {
|
|
|
+ List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(baseCameraManagement.getId(), heartbeatVo.getLineDir());
|
|
|
+ if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
|
|
|
+ for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
|
|
|
+ String flv = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (StringUtils.isEmpty(flv)) {
|
|
|
+ String url = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (url.contains("无视频")) {
|
|
|
+ AjaxResults1 = new AjaxResults(0,url);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ BaseCameraManagement idOne = baseCameraManagementService.getById(list1.get(0).getId());
|
|
|
+ BaseCameraManagement idTwo = baseCameraManagementService.getById(list1.get(1).getId());
|
|
|
+ if (idOne.getGrou().equals(idTwo.getGrou())) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.info("-------------->>已进入拉一路路视频");
|
|
|
+ log.info("list1-------------->>" + list1.size());
|
|
|
+ for (int i = 1; i < list1.size(); i++) {
|
|
|
+ List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(i).getId(), heartbeatVo.getLineDir());
|
|
|
+ if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
|
|
|
+ for (BaseCameraManagement cameraManagement : baseCameraManagementList1) {
|
|
|
+ String flv = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (StringUtils.isEmpty(flv)) {
|
|
|
+ String url = CameraUtil.getPlayFlvRtsp(cameraManagement.getCameraCode(), cameraManagement.getChannel(), type);
|
|
|
+ if (url.contains("无视频")) {
|
|
|
+ AjaxResults1 = new AjaxResults(0,url);
|
|
|
+ return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<BaseCameraManagement> baseCameraManagementList1 = cameraUtil.getBaseCameraManagementList(list1.get(0).getId(), heartbeatVo.getLineDir());
|
|
|
+ if (!ObjectUtils.isEmpty(baseCameraManagementList1)) {
|
|
|
+ List<CameraVos> cameraVosList = new ArrayList<>();
|
|
|
+ for (BaseCameraManagement baseCameraManagement : baseCameraManagementList1) {
|
|
|
+ CameraVos cameraVos = new CameraVos();
|
|
|
+ cameraVos.setCameraCode(baseCameraManagement.getCameraCode());
|
|
|
+ String cacheObject = redisCache.getCacheObject(baseCameraManagement.getCameraCode());
|
|
|
+ cameraVos.setCurrentStream(CameraUtil.getPlayFlvRtsp(baseCameraManagement.getCameraCode(), baseCameraManagement.getChannel(), type));
|
|
|
+ cameraVosList.add(cameraVos);
|
|
|
+ }
|
|
|
+ respHeartbeatVo.setCameraList(cameraVosList);
|
|
|
}
|
|
|
twoMap.put("currentStream", playFlv);
|
|
|
twoMap.put("cameraCode", list1.get(0).getCameraCode());
|
|
|
- respHeartbeatVo.setCurrentStream(playFlv);
|
|
|
+ respHeartbeatVo.setIsAlarm(2);
|
|
|
//赋值--股道
|
|
|
List<BaseRouteMassage> list = baseRouteMassageService.list();
|
|
|
if (!ObjectUtils.isEmpty(list)) {
|
|
|
- if (list.get(0).getMileagePosition() - heartbeatVo.getCurrentMile() <= 500 && list.get(0).getMileagePosition() - heartbeatVo.getCurrentMile() >= 0) {
|
|
|
- respHeartbeatVo.setRouteTrack(list.get(0).getRouteStationTrack());
|
|
|
+ for (BaseRouteMassage baseRouteMassage : list) {
|
|
|
+ if (heartbeatVo.getLineDir() == 1) {
|
|
|
+ if (baseRouteMassage.getMileagePosition() - heartbeatVo.getCurrentMile() <= 1500 && baseRouteMassage.getMileagePosition() - heartbeatVo.getCurrentMile() >= 0) {
|
|
|
+ respHeartbeatVo.setRouteTrack(baseRouteMassage.getRouteStationTrack().toString());
|
|
|
+ respHeartbeatVo.setStationCode(baseRouteMassage.getStationCode());
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ } else if (heartbeatVo.getLineDir() == 2) {
|
|
|
+ if (heartbeatVo.getCurrentMile() - baseRouteMassage.getMileagePosition() <= 1500 && heartbeatVo.getCurrentMile() - baseRouteMassage.getMileagePosition() >= 0) {
|
|
|
+ respHeartbeatVo.setRouteTrack(baseRouteMassage.getRouteStationTrack().toString());
|
|
|
+ respHeartbeatVo.setStationCode(baseRouteMassage.getStationCode());
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ } else {
|
|
|
+ respHeartbeatVo.setRouteTrack("");
|
|
|
+ respHeartbeatVo.setStationCode("");
|
|
|
}
|
|
|
- respHeartbeatVo.setIsAlarm(2);
|
|
|
- respHeartbeatVo.setCameraCode(list1.get(0).getCameraCode());
|
|
|
- respHeartbeatVo.setAlarmList(null);
|
|
|
- respHeartbeatVo.setAlarmInfo(null);
|
|
|
}
|
|
|
twoMap.put("visualDistance", heartbeatVo.getVisualDistance().toString());
|
|
|
String string = JSON.toJSONString(twoMap);
|
|
|
+ baseVideoTrainsService.save(baseVideoTrains);
|
|
|
heartbeatUtils.createHeartbeat(Constant.HERTBEA_KEY + heartbeatVo.getTerminalCode(), string);
|
|
|
- AjaxResults1 = new AjaxResults(1, "ok",respHeartbeatVo);
|
|
|
+ log.info("---------data---结果-------" + respHeartbeatVo);
|
|
|
+ AjaxResults1 = new AjaxResults(0,"视频加载中",respHeartbeatVo);
|
|
|
+ if (StringUtils.isNotEmpty(respHeartbeatVo.getCameraList())) {
|
|
|
+ AjaxResults1 = new AjaxResults(1,"ok",respHeartbeatVo);
|
|
|
+ } else {
|
|
|
+ }
|
|
|
long end = System.currentTimeMillis();
|
|
|
- System.out.println("-------------------" + (begin - end)+"秒");
|
|
|
+ log.info("结束心跳时间: " + sdf.format(new Date(end)));
|
|
|
+ log.info("心跳接口请求用时时间:" + (end - begin) + "毫秒");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
} else {
|
|
|
- AjaxResults1 = new AjaxResults(0, "心跳机制交互失败");
|
|
|
+ AjaxResults1 = new AjaxResults(0,"心跳机制交互失败");
|
|
|
return SM4Utils.encryptData_ECB(JSONObject.toJSONString(AjaxResults1), key);
|
|
|
}
|
|
|
} else {
|
|
|
- AjaxResults1 = new AjaxResults(2, "token验证失败");
|
|
|
+ AjaxResults1 = new AjaxResults(2,"token验证失败");
|
|
|
return JSONObject.toJSONString(AjaxResults1);
|
|
|
}
|
|
|
|