Commit f55ddf28 authored by tongzuqi's avatar tongzuqi

0625提交

parent 3d1dd2f6
...@@ -8,6 +8,8 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.RealT ...@@ -8,6 +8,8 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.RealT
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.RealTimeVehicleWsClient; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.RealTimeVehicleWsClient;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner; import org.springframework.boot.ApplicationRunner;
...@@ -50,7 +52,7 @@ public class WsApplicationRunner implements ApplicationRunner { ...@@ -50,7 +52,7 @@ public class WsApplicationRunner implements ApplicationRunner {
@Value("${qxsd.xlw.organizationId}") @Value("${qxsd.xlw.organizationId}")
private String organizationId; private String organizationId;
//设备列表 //设备列表
public static Map<String,String> deviceMap = null; public static Map<String,String> deviceMap = new HashedMap();
@Override @Override
...@@ -61,12 +63,18 @@ public class WsApplicationRunner implements ApplicationRunner { ...@@ -61,12 +63,18 @@ public class WsApplicationRunner implements ApplicationRunner {
XlwOrganizationId xlwOrganizationId = new XlwOrganizationId(); XlwOrganizationId xlwOrganizationId = new XlwOrganizationId();
xlwOrganizationId.setOrganizationId(organizationId); xlwOrganizationId.setOrganizationId(organizationId);
try { try {
List<XlwDeviceInfoDTO> deviceInfoList = xlwClientFeign.deviceInfo(xlwOrganizationId).getData(); for (int i = 1; i < 11; i++) {
if (deviceInfoList!=null) { List<XlwDeviceInfoDTO> deviceInfoList = xlwClientFeign.deviceInfo(xlwOrganizationId).getData();
deviceMap = deviceInfoList.stream().filter(e -> e.getDeviceSn() != null && e.getMilestone() != null) if (CollectionUtils.isNotEmpty(deviceInfoList)){
.collect(Collectors.toMap(XlwDeviceInfoDTO::getDeviceSn, XlwDeviceInfoDTO::getMilestone)); deviceMap = deviceInfoList.stream().filter(e -> e.getDeviceSn() != null && e.getMilestone() != null)
.collect(Collectors.toMap(XlwDeviceInfoDTO::getDeviceSn, XlwDeviceInfoDTO::getMilestone));
log.info("获得设备列表信息成功");
break;
}else{
log.error("获得设备列表信息为空,重试:{}次",i);
}
} }
log.info("获得设备列表信息:{}条",deviceMap.size());
//事件 //事件
// realTimeEventWsClient.connectAndHandleMessage(xlwWsUrl +"/client/event",tunnelDownId); // realTimeEventWsClient.connectAndHandleMessage(xlwWsUrl +"/client/event",tunnelDownId);
realTimeEventWsClient.connectAndHandleMessage(xlwWsUrl +"/client/event",tunnelUpId); realTimeEventWsClient.connectAndHandleMessage(xlwWsUrl +"/client/event",tunnelUpId);
...@@ -78,9 +86,18 @@ public class WsApplicationRunner implements ApplicationRunner { ...@@ -78,9 +86,18 @@ public class WsApplicationRunner implements ApplicationRunner {
//realTimeEventWsClient.connectAndHandleMessage("ws://ucloud.weisea.xyz:8888/pushx/client/event",tunnelDownId); //realTimeEventWsClient.connectAndHandleMessage("ws://ucloud.weisea.xyz:8888/pushx/client/event",tunnelDownId);
//realTimeVehicleWsClient.connectAndHandleMessage(xlwWsUrl + "/client/carInfo",tunnelDownId,"下行"); //realTimeVehicleWsClient.connectAndHandleMessage(xlwWsUrl + "/client/carInfo",tunnelDownId,"下行");
try {
//测试本地
realTimeEventWsClient.connectAndHandleMessage("ws://127.0.0.1:8765",tunnelUpId);
realTimeVehicleWsClient.connectAndHandleMessage("ws://127.0.0.1:8766",tunnelUpId,"上行",215808);
} catch (Exception e) {
log.error("=============ws异常:没有开启本地python的ws服务,如需测试请开启本地python的ws服务!==============");
}
//将第三方事件设置为完成状态 //将第三方事件设置为完成状态
} catch (Exception e) { } catch (Exception e) {
log.error("=============ws异常:{}==============",e.getMessage()); log.error("=============ws异常:{}==============",e.getMessage());
} }
} }
} }
package com.cico.nest.lcdp.boot.core.qxsd.adapter.web; package com.cico.nest.lcdp.boot.core.qxsd.adapter.web;
import cn.hutool.core.date.DateUtil;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.ReportCarTypeFlowVO; import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.ReportCarTypeFlowVO;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.StatisticalByEventType;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.StatisticalHoleVo;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.TableStatsReqVO; import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.TableStatsReqVO;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.StatisticalReportsService; import com.cico.nest.lcdp.boot.core.qxsd.application.service.StatisticalReportsService;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.TunnelHoleService;
import com.cico.nest.lcdp.boot.core.qxsd.domain.event.EventType;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.EventDetailMapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.EventDetailDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelHoleV2DO;
import com.cico.nest.lcdp.framework.common.pojo.CommonResult; import com.cico.nest.lcdp.framework.common.pojo.CommonResult;
import com.cico.nest.lcdp.framework.mybatis.core.query.LambdaQueryWrapperX;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -28,6 +42,10 @@ public class StatisticalReportsController { ...@@ -28,6 +42,10 @@ public class StatisticalReportsController {
@Resource @Resource
private StatisticalReportsService statisticalReportsService; private StatisticalReportsService statisticalReportsService;
@Resource
private TunnelHoleService tunnelHoleService;
@Resource
private EventDetailMapper eventDetailMapper;
/** /**
* 通行车次统计 * 通行车次统计
...@@ -73,4 +91,90 @@ public class StatisticalReportsController { ...@@ -73,4 +91,90 @@ public class StatisticalReportsController {
return CommonResult.success(statisticalReportsService.carTypeSpeedTrend(tableStatsReqVO)); return CommonResult.success(statisticalReportsService.carTypeSpeedTrend(tableStatsReqVO));
} }
/**
* 整个隧道今日流量
* @param tableStatsReqVO
* @return
*/
@PostMapping("/tunnelStatisticalTodayByHole")
@Operation(summary = "整个隧道今日流量")
CommonResult<StatisticalHoleVo> tunnelStatisticalTodayByHole(@RequestBody TableStatsReqVO tableStatsReqVO){
StatisticalHoleVo statisticalHoleVo = new StatisticalHoleVo();
String day = DateUtil.today().replaceAll("-","");
tableStatsReqVO.setStartStatisticsDay(day);
tableStatsReqVO.setEndStatisticsDay(day);
List<TunnelHoleV2DO> holeV2DOList = tunnelHoleService.getTunnelBaseId(tableStatsReqVO.getTunnelBaseId());
for (TunnelHoleV2DO tunnelHoleV2DO : holeV2DOList) {
if("tunnel_up".equals(tunnelHoleV2DO.getSfHoleId())){
tableStatsReqVO.setXlwTunnelId(tunnelHoleV2DO.getSfHoleId());
List<ReportCarTypeFlowVO> list = statisticalReportsService.carTypeFlow(tableStatsReqVO);
if(CollectionUtils.isNotEmpty(list)){
Integer count = list.stream().filter(item -> "全部".equals(item.getCatType())).findFirst().map(ReportCarTypeFlowVO::getCount).orElse(0);
statisticalHoleVo.setTunnelUpOld(count);
}
}
}
return CommonResult.success(statisticalHoleVo);
}
/**
* 整个隧道事件统计
* @return
*/
@PostMapping("/tunnelStatisticalByEventType")
@Operation(summary = "整个隧道今日流量")
CommonResult<Map<String, EventType.TypeStatistics>> carTypeFlowByHole(@Validated @RequestBody StatisticalByEventType statisticalByEventType ){
String startTime = "";
String endTime = "";
// 1:今日;2:本月;3:本年;
if( 1 == statisticalByEventType.getType()){
startTime = DateUtil.today() + " 00:00:00";
endTime = DateUtil.today() + " 23:59:59";
}else if( 2 == statisticalByEventType.getType()){
startTime = getCurrentMonthStartTime();
endTime = getCurrentMonthEndTime();
}else if( 3 == statisticalByEventType.getType()){
startTime = DateUtil.year(new Date()) + "-01-01 00:00:00";
endTime = DateUtil.year(new Date()) + "-12-31 23:59:59";
}
LambdaQueryWrapperX<EventDetailDO> wrapper = new LambdaQueryWrapperX<>();
wrapper.eq(EventDetailDO::getBaseTunnelId, statisticalByEventType.getTunnelBaseId());
wrapper.between(EventDetailDO::getEventStartTime,startTime,endTime);
List<EventDetailDO> list = eventDetailMapper.selectList(wrapper);
Map<String, EventType.TypeStatistics> map = EventType.getTypeStatistics();
for (String key : map.keySet()) {
EventType.TypeStatistics typeStatistics = map.get(key);
if(CollectionUtils.isNotEmpty(typeStatistics.getTypes())){
long count = list.stream().filter(item -> typeStatistics.getTypes().contains(item.getEventType())).count();
typeStatistics.setCount(count);
}
}
return CommonResult.success(map);
}
/**
* 获取当前月份开始时间并转换到字符串
* 如 当前为10月1日,返回2024-10-01 00:00:00
* @return 2024-10-01 00:00:00
*/
public static String getCurrentMonthStartTime() {
LocalDate startOfMonth = LocalDate.now().withDayOfMonth(1);
return startOfMonth.atStartOfDay().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
/**
* 获取当前月份结束时间并转换到字符串
* 如 当前为10月1日,返回2024-10-31 23:59:59
* @return 2024-10-31 23:59:59
*/
public static String getCurrentMonthEndTime() {
LocalDate endOfMonth = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth());
return endOfMonth.atTime(23, 59, 59).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
} }
package com.cico.nest.lcdp.boot.core.qxsd.adapter.web; package com.cico.nest.lcdp.boot.core.qxsd.adapter.web;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request.LocusDataRequest; import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request.LocusDataRequest;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request.PassingProfileRequest; import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request.PassingProfileRequest;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request.RealTimeVehicleQueryRequest; import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request.RealTimeVehicleQueryRequest;
...@@ -8,6 +10,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.PassingProfileVO; ...@@ -8,6 +10,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.PassingProfileVO;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.RealTimeVehicleVO; import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.RealTimeVehicleVO;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.TunnelBaseService; import com.cico.nest.lcdp.boot.core.qxsd.application.service.TunnelBaseService;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.VehicleService; import com.cico.nest.lcdp.boot.core.qxsd.application.service.VehicleService;
import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.HistoryGateway;
import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.HistoryTunnelVehicle; import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.HistoryTunnelVehicle;
import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.TunnelRealTimeVehicle; import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.TunnelRealTimeVehicle;
import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.VehicleInfo; import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.VehicleInfo;
...@@ -17,6 +20,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.qjmh.dt ...@@ -17,6 +20,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.qjmh.dt
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.qjmh.dto.QjmhCarParamPageDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.qjmh.dto.QjmhCarParamPageDTO;
import com.cico.nest.lcdp.framework.common.pojo.CommonResult; import com.cico.nest.lcdp.framework.common.pojo.CommonResult;
import com.cico.nest.lcdp.framework.common.pojo.PageResult; import com.cico.nest.lcdp.framework.common.pojo.PageResult;
import com.cico.nest.lcdp.framework.common.util.date.DateUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
...@@ -27,6 +31,8 @@ import org.apache.commons.lang3.StringUtils; ...@@ -27,6 +31,8 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -49,6 +55,10 @@ public class VehicleController { ...@@ -49,6 +55,10 @@ public class VehicleController {
private IQjmhCarService qjmhCarService; private IQjmhCarService qjmhCarService;
@Value("${qxsd.qjmh.tunnel-name}") @Value("${qxsd.qjmh.tunnel-name}")
private String qjmhTunnelName; private String qjmhTunnelName;
@Value("${qxsd.xlw.images}")
private String xlwImagePath;
@Resource
private HistoryGateway historyGateway;
/** /**
* 留存车辆列表 * 留存车辆列表
...@@ -151,5 +161,16 @@ public class VehicleController { ...@@ -151,5 +161,16 @@ public class VehicleController {
public CommonResult<List<HistoryTunnelVehicle>> getCarLocusData(@RequestBody LocusDataRequest request){ public CommonResult<List<HistoryTunnelVehicle>> getCarLocusData(@RequestBody LocusDataRequest request){
return CommonResult.success(vehicleService.getCarLocusData(request)); return CommonResult.success(vehicleService.getCarLocusData(request));
} }
// @Operation(summary = "获取车辆卡口图片")
// @GetMapping("/getCarBayonetImageList")
// public CommonResult<List<String>> getCarBayonetImageList(@RequestParam("carPlate") String carPlate, @RequestParam("time") String time){
// // todo 说是新老洞的取发不同
// List<String> list = new ArrayList<>();
// list = historyGateway.saveBayonetImage(carPlate,DateUtil.parse(time, DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
// if(CollUtil.isNotEmpty(list)){
// list.stream().filter(e->e.startsWith("/")).map(xlwImagePath::concat).toList();
// }
// return CommonResult.success(list);
// }
} }
...@@ -2,6 +2,7 @@ package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request; ...@@ -2,6 +2,7 @@ package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors;
/** /**
* @author zws * @author zws
...@@ -9,6 +10,7 @@ import lombok.Data; ...@@ -9,6 +10,7 @@ import lombok.Data;
*/ */
@Data @Data
@Accessors(chain = true)
public class LocusDataRequest { public class LocusDataRequest {
@Schema(description = "隧道id") @Schema(description = "隧道id")
......
package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
/**
* @author tongzuqi
* @create 2025/6/22 11:47 AM
*/
@Data
public class StatisticalByEventType {
//隧道id
private String tunnelBaseId ="59b968f5-5438-4069-9e36-d68940e36765";
@NotNull(message = "type不能为空")
@Range(min = 1 ,max= 3,message = "类型不在范围")
private Integer type;
}
package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo;
import lombok.Data;
/**
* @author tongzuqi
* @create 2025/6/22 11:46 AM
*/
@Data
public class StatisticalByEventTypeVo {
}
package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo;
import lombok.Data;
/**
* @author tongzuqi
* @create 2025/6/22 11:31 AM
*/
@Data
public class StatisticalHoleVo {
private Integer tunnelUpOld = 0;
private Integer tunnelUpNew = 0;
private Integer tunnelDownOld = 0;
private Integer tunnelDownNew = 0;
}
...@@ -16,7 +16,10 @@ public class TableStatsReqVO { ...@@ -16,7 +16,10 @@ public class TableStatsReqVO {
private String endStatisticsDay; private String endStatisticsDay;
//隧道id //隧道id
private String tunnelBaseId ="59b968f5-5438-4069-9e36-d68940e36765";
//隧道id(qxsd_tunnel_detail)如(xl_tunnel_up)
private String tunnelId; private String tunnelId;
private String xlwTunnelId;
//开始统计时间,格式:yyyyMMddhh //开始统计时间,格式:yyyyMMddhh
private String startStatisticsHour; private String startStatisticsHour;
......
package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.event;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 事件告警 Response VO")
@Data
public class EventDetailAlarmVO {
private EventDetailRespVO eventDetailRespVO;
private EventHisRespVO eventHisRespVO;
}
...@@ -20,4 +20,9 @@ public class EventDetailDispelReqVO { ...@@ -20,4 +20,9 @@ public class EventDetailDispelReqVO {
@NotNull @NotNull
private String dispelCause; private String dispelCause;
/**
* 处理操作人姓名
*/
private String processingOperationsName;
} }
package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.event; package com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.event;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*; import lombok.*;
import java.util.*; import java.util.*;
...@@ -14,9 +16,23 @@ import org.springframework.format.annotation.DateTimeFormat; ...@@ -14,9 +16,23 @@ import org.springframework.format.annotation.DateTimeFormat;
@ToString(callSuper = true) @ToString(callSuper = true)
public class EventDetailPageReqVO extends PageParam { public class EventDetailPageReqVO extends PageParam {
@Schema(description = "隧道id", example = "6586")
/**
* 主键id
*/
private String id;
@Schema(description = "隧道id-(目前保存的是隧道信息的id)", example = "6586")
private String tunnelId; private String tunnelId;
@Schema(description = "所属隧道id", example = "6586")
private String baseTunnelId;
@Schema(description = "所属隧道code", example = "6586")
private String baseTunnelCode;
@Schema(description = "所属洞id", example = "6586")
private String holeId;
@Schema(description = "方向 上行/下行") @Schema(description = "方向 上行/下行")
private List<String> direction; private List<String> direction;
...@@ -56,6 +72,9 @@ public class EventDetailPageReqVO extends PageParam { ...@@ -56,6 +72,9 @@ public class EventDetailPageReqVO extends PageParam {
@Schema(description = "车辆号码") @Schema(description = "车辆号码")
private String eventCarPlate; private String eventCarPlate;
/**
* 事件列表关键词
*/
@Schema(description = "关键词") @Schema(description = "关键词")
private String keyword; private String keyword;
...@@ -74,4 +93,11 @@ public class EventDetailPageReqVO extends PageParam { ...@@ -74,4 +93,11 @@ public class EventDetailPageReqVO extends PageParam {
*/ */
private String alarmId; private String alarmId;
/**
* 首页-实时事件-关键词
* 桩号 + 隧道方向
*/
@Schema(description = "关键词")
private String keyword2;
} }
...@@ -22,9 +22,24 @@ public class EventDetailRespVO { ...@@ -22,9 +22,24 @@ public class EventDetailRespVO {
@ExcelProperty("三方系统id") @ExcelProperty("三方系统id")
private String thirdPartyId; private String thirdPartyId;
/**
* 隧道id-(目前保存的是隧道信息的id)
*/
@Schema(description = "隧道id", example = "6586") @Schema(description = "隧道id", example = "6586")
@ExcelProperty("隧道id") @ExcelProperty("隧道id")
private String tunnelId; private String tunnelId;
/**
* 所属隧道id
*/
@Schema(description = "所属隧道id", example = "6586")
@ExcelProperty("所属隧道id")
private String baseTunnelId;
/**
* 所属洞id
*/
@Schema(description = "所属洞id", example = "6586")
@ExcelProperty("所属洞id")
private String holeId;
@Schema(description = "方向 上行/下行") @Schema(description = "方向 上行/下行")
@ExcelProperty("方向 上行/下行") @ExcelProperty("方向 上行/下行")
...@@ -37,6 +52,9 @@ public class EventDetailRespVO { ...@@ -37,6 +52,9 @@ public class EventDetailRespVO {
@Schema(description = "桩号") @Schema(description = "桩号")
@ExcelProperty("桩号") @ExcelProperty("桩号")
private String milestone; private String milestone;
@Schema(description = "桩号(显示)")
@ExcelProperty("桩号")
private String milestoneStr;
@Schema(description = "车道号") @Schema(description = "车道号")
@ExcelProperty("车道号") @ExcelProperty("车道号")
...@@ -48,6 +66,12 @@ public class EventDetailRespVO { ...@@ -48,6 +66,12 @@ public class EventDetailRespVO {
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date eventStartTime; private Date eventStartTime;
@Schema(description = "事件开始时间(格式化)")
@ExcelProperty("事件开始时间(格式化)")
@JsonFormat(timezone = "GMT+8", pattern = "MM-dd HH:mm")
@DateTimeFormat(pattern = "MM-dd HH:mm")
private Date eventStartTimeFormat;
@Schema(description = "0急加速1急减速2实线变道3蛇形驾驶4逆行5拥堵6可疑事件7追尾8停车", example = "2") @Schema(description = "0急加速1急减速2实线变道3蛇形驾驶4逆行5拥堵6可疑事件7追尾8停车", example = "2")
@ExcelProperty("0急加速1急减速2实线变道3蛇形驾驶4逆行5拥堵6可疑事件7追尾8停车") @ExcelProperty("0急加速1急减速2实线变道3蛇形驾驶4逆行5拥堵6可疑事件7追尾8停车")
private Integer eventType; private Integer eventType;
...@@ -146,5 +170,18 @@ public class EventDetailRespVO { ...@@ -146,5 +170,18 @@ public class EventDetailRespVO {
@Schema(description = "现场情况") @Schema(description = "现场情况")
private String situationSpot; private String situationSpot;
/**
* 处置方式(1:上报事件;2:消除事件;)
*/
private Integer processingType;
/**
* 处置操作人姓名
*/
private String processingOperationsName;
/**
* 处置时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date processingTime;
} }
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONArray; ...@@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONArray;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -20,6 +21,11 @@ public class EventHisRespVO { ...@@ -20,6 +21,11 @@ public class EventHisRespVO {
@Schema(description = "事件id", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "事件id", requiredMode = Schema.RequiredMode.REQUIRED)
private String eventId; private String eventId;
/**
* 车辆入隧时间
*/
@Schema(description = "车辆入隧时间", requiredMode = Schema.RequiredMode.REQUIRED)
private JSONArray vehicleInTunnelTime;
/** /**
* 历史车辆轨迹 * 历史车辆轨迹
*/ */
...@@ -38,6 +44,11 @@ public class EventHisRespVO { ...@@ -38,6 +44,11 @@ public class EventHisRespVO {
@Schema(description = "卡口图片", requiredMode = Schema.RequiredMode.REQUIRED) @Schema(description = "卡口图片", requiredMode = Schema.RequiredMode.REQUIRED)
private List<Map> bayonetImage; private List<Map> bayonetImage;
/**
* 海康摄像头唯一编码
*/
private String cameraIndexCode;
/** /**
* 视频地址 * 视频地址
*/ */
......
...@@ -38,6 +38,7 @@ public class RealTimeEventWs extends AbstractRealTimeEventWs { ...@@ -38,6 +38,7 @@ public class RealTimeEventWs extends AbstractRealTimeEventWs {
public void onOpen(Session session){ public void onOpen(Session session){
session.setMaxIdleTimeout(60000); session.setMaxIdleTimeout(60000);
sessionList.add(session); sessionList.add(session);
logger.info("ws建立连接-realTimeEvent,当前连接数:{}",sessionList.size());
} }
/** /**
......
...@@ -37,6 +37,7 @@ public class RealTimeEventWs1 extends AbstractRealTimeEventWs { ...@@ -37,6 +37,7 @@ public class RealTimeEventWs1 extends AbstractRealTimeEventWs {
public void onOpen(Session session){ public void onOpen(Session session){
session.setMaxIdleTimeout(60000); session.setMaxIdleTimeout(60000);
sessionList.add(session); sessionList.add(session);
logger.info("ws建立连接-realTimeEvent1,当前连接数:{}",sessionList.size());
} }
/** /**
......
...@@ -38,6 +38,9 @@ public class RealTimeVehicleWs extends AbstractRealTimeVehicleWs { ...@@ -38,6 +38,9 @@ public class RealTimeVehicleWs extends AbstractRealTimeVehicleWs {
public void onOpen(Session session){ public void onOpen(Session session){
session.setMaxIdleTimeout(60000); session.setMaxIdleTimeout(60000);
sessionList.add(session); sessionList.add(session);
logger.info("ws建立连接-realTimeCar,当前连接数:{}",sessionList.size());
} }
/** /**
......
...@@ -39,6 +39,7 @@ public class RealTimeVehicleWs1 extends AbstractRealTimeVehicleWs { ...@@ -39,6 +39,7 @@ public class RealTimeVehicleWs1 extends AbstractRealTimeVehicleWs {
public void onOpen(Session session){ public void onOpen(Session session){
session.setMaxIdleTimeout(60000); session.setMaxIdleTimeout(60000);
sessionList.add(session); sessionList.add(session);
logger.info("ws建立连接-realTimeCar1,当前连接数:{}",sessionList.size());
} }
/** /**
......
...@@ -34,7 +34,7 @@ public interface EventDetailService{ ...@@ -34,7 +34,7 @@ public interface EventDetailService{
* 事件消除 * 事件消除
* @param id 事件id * @param id 事件id
*/ */
void dispelEvent(String id,String dispelCause); void dispelEvent(String id,String dispelCause,String processingOperationsName);
/** /**
* 上报隧道管控新事件 * 上报隧道管控新事件
......
...@@ -5,6 +5,8 @@ import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.tunnelHole.*; ...@@ -5,6 +5,8 @@ import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.tunnelHole.*;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelHoleV2DO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelHoleV2DO;
import com.cico.nest.lcdp.framework.common.pojo.PageResult; import com.cico.nest.lcdp.framework.common.pojo.PageResult;
import java.util.List;
/** /**
* 隧道设施上下行洞 Service 接口 * 隧道设施上下行洞 Service 接口
* *
...@@ -50,4 +52,20 @@ public interface TunnelHoleService { ...@@ -50,4 +52,20 @@ public interface TunnelHoleService {
*/ */
PageResult<TunnelHoleV2DO> getTunnelHolePage(TunnelHolePageReqVO pageReqVO); PageResult<TunnelHoleV2DO> getTunnelHolePage(TunnelHolePageReqVO pageReqVO);
/**
* 根据sfHoleId获取隧道设施上下行洞
* @param sfHoleId
* @return
*/
TunnelHoleV2DO getTunnelSfHoleId(String sfHoleId);
/**
* 获得隧道tunnelId 关联的洞信息
*
* @param baseTunnelId 编号
* @return 隧道设施上下行洞
*/
List<TunnelHoleV2DO> getTunnelBaseId(String baseTunnelId);
} }
...@@ -19,6 +19,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.mqtt.handler ...@@ -19,6 +19,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.mqtt.handler
import com.cico.nest.lcdp.framework.common.exception.ServiceException; import com.cico.nest.lcdp.framework.common.exception.ServiceException;
import com.cico.nest.lcdp.framework.common.pojo.PageResult; import com.cico.nest.lcdp.framework.common.pojo.PageResult;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -83,7 +84,7 @@ public class EventDetailServiceImpl implements EventDetailService { ...@@ -83,7 +84,7 @@ public class EventDetailServiceImpl implements EventDetailService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void dispelEvent(String id,String dispelCause) { public void dispelEvent(String id,String dispelCause,String processingOperationsName) {
EventDetailDO eventDetailDO = eventDetailMapper.selectById(id); EventDetailDO eventDetailDO = eventDetailMapper.selectById(id);
if(Objects.isNull(eventDetailDO)){ if(Objects.isNull(eventDetailDO)){
throw new ServiceException(INTERNAL_SERVER_ERROR.getCode(),"事件不存在"); throw new ServiceException(INTERNAL_SERVER_ERROR.getCode(),"事件不存在");
...@@ -97,6 +98,9 @@ public class EventDetailServiceImpl implements EventDetailService { ...@@ -97,6 +98,9 @@ public class EventDetailServiceImpl implements EventDetailService {
} }
eventDetailDO.setEventStatus(EventStatus.disposing_end.type); eventDetailDO.setEventStatus(EventStatus.disposing_end.type);
eventDetailDO.setDispelCause(dispelCause); eventDetailDO.setDispelCause(dispelCause);
eventDetailDO.setProcessingType(2);
eventDetailDO.setProcessingOperationsName(processingOperationsName);
eventDetailDO.setProcessingTime(new Date());
eventDetailMapper.updateById(eventDetailDO); eventDetailMapper.updateById(eventDetailDO);
} }
...@@ -120,9 +124,11 @@ public class EventDetailServiceImpl implements EventDetailService { ...@@ -120,9 +124,11 @@ public class EventDetailServiceImpl implements EventDetailService {
@Override @Override
public EventHisRespVO getEventHisDetail(String eventId) { public EventHisRespVO getEventHisDetail(String eventId) {
EventHisDO eventHis = eventHisMapper.selectByEventId(eventId); EventHisDO eventHis = eventHisMapper.selectByEventId(eventId);
EventDetailDO eventDetailDO = eventDetailMapper.selectById(eventId);
EventHisRespVO respVO = new EventHisRespVO(); EventHisRespVO respVO = new EventHisRespVO();
respVO.setEventId(eventId); EventDetailDO eventDetailDO = eventDetailMapper.selectById(eventId);
if(Objects.isNull(eventDetailDO)){
return respVO;
}
if(Objects.isNull(eventHis)){ if(Objects.isNull(eventHis)){
//取实时的事件图片 //取实时的事件图片
List<String> eventImagesPath = eventDetailDO.getEventImagesPath(); List<String> eventImagesPath = eventDetailDO.getEventImagesPath();
...@@ -130,6 +136,7 @@ public class EventDetailServiceImpl implements EventDetailService { ...@@ -130,6 +136,7 @@ public class EventDetailServiceImpl implements EventDetailService {
respVO.setEventImagesPath(eventImagesPath.stream().filter(e->e.startsWith("/")).map(e->xlwImagesPath.concat(e)).toList()); respVO.setEventImagesPath(eventImagesPath.stream().filter(e->e.startsWith("/")).map(e->xlwImagesPath.concat(e)).toList());
} }
}else{ }else{
BeanUtils.copyProperties(eventHis,respVO);
respVO.setExistHisData(true); respVO.setExistHisData(true);
List<String> eventImagesPath = eventHis.getEventImagesPath(); List<String> eventImagesPath = eventHis.getEventImagesPath();
if(CollUtil.isNotEmpty(eventImagesPath)){ if(CollUtil.isNotEmpty(eventImagesPath)){
...@@ -152,6 +159,7 @@ public class EventDetailServiceImpl implements EventDetailService { ...@@ -152,6 +159,7 @@ public class EventDetailServiceImpl implements EventDetailService {
respVO.setBayonetImage(bayonetImagePath); respVO.setBayonetImage(bayonetImagePath);
} }
respVO.setHisVehicleInfo(eventHis.getHisVehicleInfo()); respVO.setHisVehicleInfo(eventHis.getHisVehicleInfo());
respVO.setCameraIndexCode(eventHis.getCameraIndexCode());
//视频 //视频
String videoPath = eventHis.getVideoPath(); String videoPath = eventHis.getVideoPath();
if(StrUtil.isNotBlank(videoPath) && !videoPath.contains("error")){ if(StrUtil.isNotBlank(videoPath) && !videoPath.contains("error")){
......
...@@ -9,6 +9,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dat ...@@ -9,6 +9,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dat
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.XlwTableStatsDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.XlwTableStatsDTO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.feign.XlwClientFeign; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.feign.XlwClientFeign;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -36,8 +37,12 @@ public class StatisticalReportsServiceImpl implements StatisticalReportsService ...@@ -36,8 +37,12 @@ public class StatisticalReportsServiceImpl implements StatisticalReportsService
public List<ReportCarTypeFlowVO> carTypeFlow(TableStatsReqVO tableStatsReqVO) { public List<ReportCarTypeFlowVO> carTypeFlow(TableStatsReqVO tableStatsReqVO) {
XlwTableStatsDTO dto = new XlwTableStatsDTO(); XlwTableStatsDTO dto = new XlwTableStatsDTO();
BeanUtils.copyProperties(tableStatsReqVO,dto); BeanUtils.copyProperties(tableStatsReqVO,dto);
TunnelDetailDO tunnelDetailDO = tunnelDetailMapper.selectById(tableStatsReqVO.getTunnelId()); if(StringUtils.isEmpty(tableStatsReqVO.getXlwTunnelId())){
dto.setTunnelId(tunnelDetailDO.getXlwTunnelId()); TunnelDetailDO tunnelDetailDO = tunnelDetailMapper.selectById(tableStatsReqVO.getTunnelId());
dto.setTunnelId(tunnelDetailDO.getXlwTunnelId());
}else{
dto.setTunnelId(tableStatsReqVO.getXlwTunnelId());
}
XlwResultData<List<Map<String,Object>>> resultData = xlwClientFeign.carFlowPageDay(dto); XlwResultData<List<Map<String,Object>>> resultData = xlwClientFeign.carFlowPageDay(dto);
List<Map<String,Object>> data = resultData.getData(); List<Map<String,Object>> data = resultData.getData();
//危化品车辆数量 //危化品车辆数量
......
...@@ -334,7 +334,8 @@ public class TunnelBaseServiceImpl implements TunnelBaseService { ...@@ -334,7 +334,8 @@ public class TunnelBaseServiceImpl implements TunnelBaseService {
//查询上下行洞 //查询上下行洞
LambdaQueryWrapper<TunnelHoleV2DO> holeWrapper = new LambdaQueryWrapperX<TunnelHoleV2DO>() LambdaQueryWrapper<TunnelHoleV2DO> holeWrapper = new LambdaQueryWrapperX<TunnelHoleV2DO>()
.eq(TunnelHoleV2DO::getTunnelId,tunnelId) .eq(TunnelHoleV2DO::getTunnelId,tunnelId)
.eq(TunnelHoleV2DO::getDeleted,0); .eq(TunnelHoleV2DO::getDeleted,0)
.orderByAsc(TunnelHoleV2DO::getOrderNo);
List<TunnelHoleV2DO> holeV2DOS = tunnelHoleMapper.selectList(holeWrapper); List<TunnelHoleV2DO> holeV2DOS = tunnelHoleMapper.selectList(holeWrapper);
List<TunnelHoleRespVO> holeRespVOS = BeanUtils.toBean(holeV2DOS, TunnelHoleRespVO.class); List<TunnelHoleRespVO> holeRespVOS = BeanUtils.toBean(holeV2DOS, TunnelHoleRespVO.class);
//查询标志线 //查询标志线
......
...@@ -9,6 +9,9 @@ import jakarta.annotation.Resource; ...@@ -9,6 +9,9 @@ import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import com.cico.nest.lcdp.framework.common.pojo.PageResult; import com.cico.nest.lcdp.framework.common.pojo.PageResult;
import com.cico.nest.lcdp.framework.common.util.object.BeanUtils; import com.cico.nest.lcdp.framework.common.util.object.BeanUtils;
import java.util.List;
import static com.cico.nest.lcdp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR; import static com.cico.nest.lcdp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
import static com.cico.nest.lcdp.framework.common.exception.util.ServiceExceptionUtil.exception; import static com.cico.nest.lcdp.framework.common.exception.util.ServiceExceptionUtil.exception;
...@@ -66,4 +69,12 @@ public class TunnelHoleServiceImpl implements TunnelHoleService { ...@@ -66,4 +69,12 @@ public class TunnelHoleServiceImpl implements TunnelHoleService {
return tunnelHoleMapper.selectPage(pageReqVO); return tunnelHoleMapper.selectPage(pageReqVO);
} }
@Override
public TunnelHoleV2DO getTunnelSfHoleId(String sfHoleId) {
return tunnelHoleMapper.selectOne(TunnelHoleV2DO::getSfHoleId, sfHoleId);
}
@Override
public List<TunnelHoleV2DO> getTunnelBaseId(String baseTunnelId) {
return tunnelHoleMapper.selectList(TunnelHoleV2DO::getTunnelId, baseTunnelId);
}
} }
package com.cico.nest.lcdp.boot.core.qxsd.domain.event; package com.cico.nest.lcdp.boot.core.qxsd.domain.event;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* @author zws * @author zws
* @date 2024/8/15 * @date 2024/8/15
...@@ -13,9 +21,29 @@ public enum EventType { ...@@ -13,9 +21,29 @@ public enum EventType {
retrograde(4,"逆行"), retrograde(4,"逆行"),
congestion(5,"拥堵"), congestion(5,"拥堵"),
suspicious_events(6,"可疑事件"), suspicious_events(6,"可疑事件"),
rear_end_chase(7,"追尾"), rear_end_chase(7,"事故"),
parking(8,"停车"), parking(8,"违章停车"),
other(100,"其他");
slow_driving(9,"缓慢行驶"),
super_slow_driving(10,"超慢行驶"),
stop(11,"停驶"),
pedestrian(12,"行人"),
spill(13,"抛洒物"),
fire(14,"火灾"),
abnormal_weather(15,"异常天气"),
overspeed(16,"超速"),
intrude(17,"闯入"),
not_flow_lane(18,"不按车道行驶"),
non_motor(19,"非机动车"),
danger_truck(20,"危化品车辆"),
other(100,"其他"),
nothing(99,"无"),
motor_intrude(22,"机动车闯禁行"),
bus(21,"大型客车"),
;
public final int type; public final int type;
...@@ -37,4 +65,28 @@ public enum EventType { ...@@ -37,4 +65,28 @@ public enum EventType {
return other; return other;
} }
/**
* 首页需要分组的
* 交通事故:追尾、刮擦、翻车、撞固定物、撞行人、撞抛洒物、车辆起火(火灾)
* 路面状况:抛洒物、违章停车、停驶、逆行、非机动车、行人、急加速、急减速、蛇形驾驶、机动车闯禁行、不按车道行驶、拥堵、缓慢行驶、危化品车、大型客车、违法变道、超速、可疑事件
* 车辆故障:抛锚、爆胎、
* 道路施工:日常养护(占道)、专项工程(占道)、临时抢修(占道)、日常养护(断路)、专项工程(断路)、临时抢修(断路)、专项工程(借道))、临时抢修(借道)、拓宽施工
* 其他:
*/
public static Map<String,TypeStatistics> getTypeStatistics(){
Map<String,TypeStatistics> map = new HashMap(5);
map.put("交通事故",new EventType.TypeStatistics().setTypes(List.of(7,14)));
map.put("路面状况",new TypeStatistics().setTypes(List.of(0,1,2,3,4,5,6,8,16,22,21,9,10,11,12,13,17,18,19,20)));
map.put("车辆故障",new TypeStatistics());
map.put("道路施工",new TypeStatistics());
map.put("其他",new TypeStatistics().setTypes(List.of(100,99,15)));
return map;
}
@Data
@Accessors(chain = true)
public static class TypeStatistics{
private List<Integer> types = new ArrayList<>();
private long count = 0;
}
} }
...@@ -14,8 +14,9 @@ public interface EventGateway { ...@@ -14,8 +14,9 @@ public interface EventGateway {
/** /**
* 推送实时事件数据 * 推送实时事件数据
* @param tunnelId 隧道id * @param tunnelId 隧道id
* @param eventDetailId 事件详情id
*/ */
void pushRealTimeEventData(String tunnelId); void pushRealTimeEventData(String tunnelId,String eventDetailId);
/** /**
* 查询事件列表 * 查询事件列表
......
package com.cico.nest.lcdp.boot.core.qxsd.domain.gateway; package com.cico.nest.lcdp.boot.core.qxsd.domain.gateway;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request.LocusDataRequest;
import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.HistoryTunnelVehicle; import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.HistoryTunnelVehicle;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelDeviceDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.XlwHolographicTimeHistoryDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.XlwHolographicTimeHistoryDTO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeVehicleDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeVehicleDTO;
...@@ -30,17 +32,31 @@ public interface HistoryGateway { ...@@ -30,17 +32,31 @@ public interface HistoryGateway {
List<String> saveBayonetImage(String carPlate, Date eventStartTime); List<String> saveBayonetImage(String carPlate, Date eventStartTime);
/** /**
* 获取视频流 * 获取设备信息
* @param deviceMilestone 设备桩号 * @param deviceMilestone 设备桩号
* @return TunnelDeviceDO 设备信息
*/
TunnelDeviceDO getDevice(String tunnelCode,String holeId,Integer deviceMilestone,Integer direction);
/**
* 获取视频流
* @param cameraIndexCode 海康摄像机唯一编号
* @return 视频数据 * @return 视频数据
*/ */
String saveVideo(String facilityId,Integer deviceMilestone,Integer direction,String beginTime,String endTime,String outputFile); String saveVideo(String cameraIndexCode,String beginTime,String endTime,String outputFile);
/** /**
* 获取事件车辆信息 * 获取事件车辆信息
* @param eventId 事件id * @param eventId 事件id
* @return 车辆数据 * @return 车辆数据
*/ */
List<HistoryTunnelVehicle> getVehicleInfo(String eventId,String tunnelId,String direction,int startMilestone); List<HistoryTunnelVehicle> getVehicleInfo(LocusDataRequest locusDataRequest);
/**
* 保存切片视频
* @param rtspUrl 视频流
* @param outputFile 保存路径
*/
void videoPuller(String rtspUrl, String outputFile);
} }
package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.constatnt; package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.constatnt;
import java.util.Arrays;
import java.util.List;
/** /**
* @author zws * @author zws
* @date 2024/8/7 * @date 2024/8/7
...@@ -14,7 +17,7 @@ public interface XlwConstants { ...@@ -14,7 +17,7 @@ public interface XlwConstants {
/** /**
* 登录接口 * 登录接口
*/ */
String LOGIN_INTERFACE = "/common/login.htm"; List<String> LOGIN_INTERFACE_LIST = Arrays.asList("/common/login.htm","/backDoor/getDemoSessionId.htm");
/** /**
......
...@@ -11,6 +11,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto ...@@ -11,6 +11,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeEventDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeEventDTO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeVehicleDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeVehicleDTO;
import com.cico.nest.lcdp.framework.common.util.date.DateUtils; import com.cico.nest.lcdp.framework.common.util.date.DateUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -25,10 +26,12 @@ import static com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.VehicleType.*; ...@@ -25,10 +26,12 @@ import static com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.VehicleType.*;
* @author zws * @author zws
* @date 2024/8/8 * @date 2024/8/8
*/ */
@Slf4j
public class VehicleConvertor { public class VehicleConvertor {
public static TunnelRealTimeVehicle convert2TunnelRTV(XlwRealTimeVehicleDTO dto,String tunnelId,String direction,int startMilestone) { public static TunnelRealTimeVehicle convert2TunnelRTV(XlwRealTimeVehicleDTO dto,String tunnelId,String direction,int startMilestone) {
TunnelRealTimeVehicle tunnelRealTimeVehicle = new TunnelRealTimeVehicle(); TunnelRealTimeVehicle tunnelRealTimeVehicle = new TunnelRealTimeVehicle();
BeanUtils.copyProperties(dto,tunnelRealTimeVehicle); BeanUtils.copyProperties(dto,tunnelRealTimeVehicle);
...@@ -88,6 +91,10 @@ public class VehicleConvertor { ...@@ -88,6 +91,10 @@ public class VehicleConvertor {
vehicleInfo.setRetainedMinutesTime(5); vehicleInfo.setRetainedMinutesTime(5);
if(Objects.nonNull(xlwCarInfo.getInTunnelTime())){ if(Objects.nonNull(xlwCarInfo.getInTunnelTime())){
long diffMinTime = ((currentTime - xlwCarInfo.getInTunnelTime())/1000/60); long diffMinTime = ((currentTime - xlwCarInfo.getInTunnelTime())/1000/60);
if(diffMinTime < 0){
// log.error("留存时间计算异常:值{},currentTime:{}-xlwCarInfo.getInTunnelTime():{}",diffMinTime,DateUtil.formatDateTime(new Date(currentTime)),DateUtil.formatDateTime(new Date(xlwCarInfo.getInTunnelTime())));
diffMinTime = 0;
}
vehicleInfo.setRetainedMinutesTime((int) diffMinTime); vehicleInfo.setRetainedMinutesTime((int) diffMinTime);
} }
//进入隧道时间转换 //进入隧道时间转换
......
...@@ -4,15 +4,21 @@ import cn.hutool.core.collection.CollUtil; ...@@ -4,15 +4,21 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.extra.spring.SpringUtil; import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson2.JSONArray; import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.event.EventDetailPageReqVO;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.event.EventDetailRespVO; import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.event.EventDetailRespVO;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.ws.AbstractRealTimeEventWs; import com.cico.nest.lcdp.boot.core.qxsd.adapter.ws.AbstractRealTimeEventWs;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.ws.IRealTimeWs; import com.cico.nest.lcdp.boot.core.qxsd.adapter.ws.IRealTimeWs;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.EventDetailService;
import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.EventGateway; import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.EventGateway;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.EventDetailMapper; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.EventDetailMapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.EventDetailDO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.EventDetailDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.EventMapper; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.EventMapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.vo.RealTimeEventWsVO;
import com.cico.nest.lcdp.framework.common.pojo.PageResult;
import com.cico.nest.lcdp.framework.common.util.date.DateUtils; import com.cico.nest.lcdp.framework.common.util.date.DateUtils;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -26,34 +32,34 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -26,34 +32,34 @@ import java.util.concurrent.ConcurrentHashMap;
* @author zws * @author zws
* @date 2024/8/15 * @date 2024/8/15
*/ */
@Slf4j
@Service @Service
public class EventGatewayImpl implements EventGateway { public class EventGatewayImpl implements EventGateway {
@Resource @Resource
private EventMapper eventMapper; private EventMapper eventMapper;
@Resource @Resource
private EventDetailMapper eventDetailMapper; private EventDetailMapper eventDetailMapper;
@Resource
private EventDetailService eventDetailService;
public final Map<String, IRealTimeWs> realTimeWsMap = new ConcurrentHashMap<>(); public final Map<String, IRealTimeWs> realTimeWsMap = new ConcurrentHashMap<>();
@Override @Override
public void pushRealTimeEventData(String tunnelId) { public void pushRealTimeEventData(String tunnelId,String eventDetailId) {
List<EventDetailDO> eventDetailDOList = eventDetailMapper.selectByTunnelIdAndThirdEventStatusNotFinish(tunnelId); //组装数据并推送
List<EventDetailRespVO> eventDetailRespList = eventDetailDOList.stream().map(eventDetailDO -> { RealTimeEventWsVO realTimeEventWsVO = new RealTimeEventWsVO()
EventDetailRespVO eventDetailRespVO = new EventDetailRespVO(); // 事件未完成集合
BeanUtils.copyProperties(eventDetailDO,eventDetailRespVO); .setEventThirdEventStatusNotFinishList(this.selectByTunnelIdAndThirdEventStatusNotFinish(tunnelId))
if(Objects.nonNull(eventDetailDO.getCarInfoList())){ .setEventCount(this.getEventCount(tunnelId))
eventDetailRespVO.setCarInfoList(JSONArray.parseArray(eventDetailDO.getCarInfoList().toJSONString(), EventDetailDO.EventCarInfo.class)); .setEventDetailRespVO(this.getEventDetailById(tunnelId,eventDetailId))
} ;
long diffSecond = DateUtils.diff(new Date(),eventDetailDO.getEventStartTime())/1000; String eventDetailJson = JSONObject.toJSONString(realTimeEventWsVO);
int excessSecond = (int)diffSecond % 60; // String eventDetailJson = JSONObject.toJSONString(eventDetailRespList);
int minute = (int)diffSecond / 60;
eventDetailRespVO.setRetainedTime(minute+"分"+excessSecond+"秒");
return eventDetailRespVO;
}).toList();
String eventDetailJson = JSONObject.toJSONString(eventDetailRespList);
IRealTimeWs realTimeWs = getRealTimeWs(tunnelId); IRealTimeWs realTimeWs = getRealTimeWs(tunnelId);
log.info("------------------推送开始-----------------");
log.info("推送事件给前端:{}",eventDetailJson);
log.info("------------------推送结束-----------------");
realTimeWs.sendMessage(eventDetailJson); realTimeWs.sendMessage(eventDetailJson);
} }
...@@ -69,10 +75,74 @@ public class EventGatewayImpl implements EventGateway { ...@@ -69,10 +75,74 @@ public class EventGatewayImpl implements EventGateway {
if(CollUtil.isNotEmpty(beansOfType)){ if(CollUtil.isNotEmpty(beansOfType)){
for(Map.Entry<String, AbstractRealTimeEventWs> entry : beansOfType.entrySet()){ for(Map.Entry<String, AbstractRealTimeEventWs> entry : beansOfType.entrySet()){
AbstractRealTimeEventWs abstractRealTimeEventWs = entry.getValue(); AbstractRealTimeEventWs abstractRealTimeEventWs = entry.getValue();
realTimeWsMap.put(abstractRealTimeEventWs.tunnelId(),abstractRealTimeEventWs); if(StringUtils.isEmpty(abstractRealTimeEventWs.tunnelId())){
log.error("隧道ID为空,无法推送事件数据,class:{}",abstractRealTimeEventWs.getClass().getName());
}else{
realTimeWsMap.put(abstractRealTimeEventWs.tunnelId(),abstractRealTimeEventWs);
}
} }
} }
} }
return realTimeWsMap.get(tunnelId); return realTimeWsMap.get(tunnelId);
} }
/**
* 根据隧道ID查询事件信息
* 第三方事件状态事件状态 0结束、1预警、2处理中 = != 0 的信息
* @param tunnelId
* @return
*/
public List<EventDetailRespVO> selectByTunnelIdAndThirdEventStatusNotFinish(String tunnelId){
List<EventDetailDO> eventDetailDOList = eventDetailMapper.selectByTunnelIdAndThirdEventStatusNotFinish(tunnelId);
return eventDetailDOList.stream().map(eventDetailDO -> {
EventDetailRespVO eventDetailRespVO = new EventDetailRespVO();
BeanUtils.copyProperties(eventDetailDO,eventDetailRespVO);
if(Objects.nonNull(eventDetailDO.getCarInfoList())){
eventDetailRespVO.setCarInfoList(JSONArray.parseArray(eventDetailDO.getCarInfoList().toJSONString(), EventDetailDO.EventCarInfo.class));
}
long diffSecond = DateUtils.diff(new Date(),eventDetailDO.getEventStartTime())/1000;
int excessSecond = (int)diffSecond % 60;
int minute = (int)diffSecond / 60;
eventDetailRespVO.setRetainedTime(minute+"分"+excessSecond+"秒");
return eventDetailRespVO;
}).toList();
}
/**
* 查询当前事件总数
* @param tunnelId
* @return
*/
public Long getEventCount(String tunnelId){
// 查询当前事件列表 未处理完成的总数,这里之间调用列表分页接口
EventDetailPageReqVO pageReqVO = new EventDetailPageReqVO();
pageReqVO.setPageNo(1);
pageReqVO.setPageSize(1);
pageReqVO.setTunnelId(tunnelId);
pageReqVO.setEventStatusSearch(0);
PageResult pageResult = eventDetailMapper.selectPage(pageReqVO);
if(Objects.nonNull(pageResult)){
return pageResult.getTotal();
}
return 0L;
}
/**
* 查询当前事件
* @param tunnelId
* @return
*/
public EventDetailRespVO getEventDetailById(String tunnelId,String eventDetailId){
// 查询当前事件列表 未处理完成的总数,这里之间调用列表分页接口
EventDetailDO eventDetailDO = eventDetailMapper.selectOne(
EventDetailDO::getId,eventDetailId,
EventDetailDO::getTunnelId,tunnelId
);
if(Objects.nonNull(eventDetailDO)){
return EventDetailDO.convert2VO(eventDetailDO,"");
}
log.error("事件详情查询失败,eventDetailId:{}",eventDetailId);
return new EventDetailRespVO();
}
} }
...@@ -2,24 +2,34 @@ package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl; ...@@ -2,24 +2,34 @@ package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.request.LocusDataRequest;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.TunnelDetailService;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.TunnelDeviceService;
import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.HistoryGateway; import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.HistoryGateway;
import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.VehicleGateway;
import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.HistoryTunnelVehicle; import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.HistoryTunnelVehicle;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.result.HkVideoResultData; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.result.HkVideoResultData;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.result.XlwResultData; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.result.XlwResultData;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.convertor.VehicleConvertor; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.convertor.VehicleConvertor;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.TunnelDeviceMapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.TunnelEquipmentMapper; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.TunnelEquipmentMapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelDeviceDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelEquipmentDO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelEquipmentDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.HistoryMapper; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.HistoryMapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.hk.HkVideoMapper; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.hk.HkVideoMapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.XlwHolographicTimeHistoryDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.XlwHolographicTimeHistoryDTO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeVehicleDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeVehicleDTO;
import com.cico.nest.lcdp.boot.core.system.dal.dataobject.social.SocialUserDO;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.bytedeco.ffmpeg.global.avcodec; import org.bytedeco.ffmpeg.global.avcodec;
import org.bytedeco.javacv.*; import org.bytedeco.javacv.*;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
...@@ -29,12 +39,15 @@ import java.util.Objects; ...@@ -29,12 +39,15 @@ import java.util.Objects;
* @date 2024/8/20 * @date 2024/8/20
*/ */
@Slf4j
@Service @Service
public class HistoryGatewayImpl implements HistoryGateway { public class HistoryGatewayImpl implements HistoryGateway {
@Resource @Resource
private HistoryMapper historyMapper; private HistoryMapper historyMapper;
@Resource @Resource
private TunnelEquipmentMapper equipmentMapper; private VehicleGateway vehicleGateway;
@Resource
private TunnelDeviceMapper tunnelDeviceMapper;
@Resource @Resource
private HkVideoMapper hkVideoMapper; private HkVideoMapper hkVideoMapper;
@Value("${qxsd.video.eventHisSavePath}") @Value("${qxsd.video.eventHisSavePath}")
...@@ -50,34 +63,59 @@ public class HistoryGatewayImpl implements HistoryGateway { ...@@ -50,34 +63,59 @@ public class HistoryGatewayImpl implements HistoryGateway {
return historyMapper.saveBayonetImage(carPlate,eventStartTime); return historyMapper.saveBayonetImage(carPlate,eventStartTime);
} }
@Override @Override
public String saveVideo(String facilityId,Integer deviceMilestone,Integer direction,String beginTime,String endTime,String outputFile) { public TunnelDeviceDO getDevice(String tunnelCode,String holeId,Integer deviceMilestone,Integer direction) {
TunnelEquipmentDO tunnelEquipmentDO = new TunnelEquipmentDO(); TunnelDeviceDO tunnelDeviceDO = tunnelDeviceMapper.selectOne(new LambdaQueryWrapper<TunnelDeviceDO>()
tunnelEquipmentDO.setBelongFacilityId(facilityId); .eq(TunnelDeviceDO::getTunnelCode, tunnelCode)
tunnelEquipmentDO.setEquipmentStation(deviceMilestone); .eq(TunnelDeviceDO::getHoleId, holeId)
tunnelEquipmentDO.setUplinkDownlinkRoad(direction); .eq(TunnelDeviceDO::getDirectionUpdown, direction)
List<TunnelEquipmentDO> equipmentList = equipmentMapper.getEquipmentList(tunnelEquipmentDO); .eq(TunnelDeviceDO::getCameraLable, 1)
if(CollUtil.isEmpty(equipmentList)){ .gt(TunnelDeviceDO::getMileStart, deviceMilestone)
return "error未找到对应摄像头"; ,false);
} // 摄像头 查询几个点
TunnelEquipmentDO equipmentDO = equipmentList.get(0); // 同一个tunnel_code,hole_id,上下行方向:100700上行/100701下行
String hkVideoResultDataStr = hkVideoMapper.getPlaybackURLs(equipmentDO.getCameraIndexCode(),beginTime,endTime); // camera_lable(摄像机标签) = 1(全息相机)
// deviceMilestone:215838,direction:100700
// 条件是lt 查询到的: 215700 < 215838
// 条件是gt 查询到的: 216100 > 215838
// 小于号是这样表示的:&lt ;大于号是这样表示的:&gt ;
// todo 是否需要判断超出最大桩号?
return tunnelDeviceDO;
}
@Override
public String saveVideo(String cameraIndexCode,String beginTime,String endTime,String outputFile) {
String hkVideoResultDataStr = hkVideoMapper.getPlaybackURLs(cameraIndexCode,beginTime,endTime);
HkVideoResultData hkVideoResultData = JSONObject.parseObject(hkVideoResultDataStr, HkVideoResultData.class); HkVideoResultData hkVideoResultData = JSONObject.parseObject(hkVideoResultDataStr, HkVideoResultData.class);
Object urlObject = hkVideoResultData.getData().get("url"); Object urlObject = hkVideoResultData.getData().get("url");
if(Objects.nonNull(urlObject)){ if(Objects.nonNull(urlObject)){
videoPuller(urlObject.toString(),eventHisSaveVideoPath + "/" + outputFile); try {
return outputFile; videoPuller(urlObject.toString(),eventHisSaveVideoPath + "/" + outputFile);
return outputFile;
} catch (Exception e) {
return "error保存回放视频流失败";
}
} }
return "error获取回放视频流失败"; return "error获取回放视频流失败";
} }
@Override @Override
public List<HistoryTunnelVehicle> getVehicleInfo(String eventId,String tunnelId,String direction,int startMilestone) { public List<HistoryTunnelVehicle> getVehicleInfo(LocusDataRequest locusDataRequest) {
List<XlwHolographicTimeHistoryDTO> xlwHistoryEventList = historyMapper.getVehicleInfo(eventId); // List<XlwHolographicTimeHistoryDTO> xlwHistoryEventList = historyMapper.getVehicleInfo(guid);
return VehicleConvertor.convert2HistoryTunnelVehicle(xlwHistoryEventList,tunnelId,direction,startMilestone); // if(CollUtil.isEmpty(xlwHistoryEventList)){
// log.error("获取事件全息回放数据为空,guid:{}", guid);
// return new ArrayList<>();
// }
// return VehicleConvertor.convert2HistoryTunnelVehicle(xlwHistoryEventList,tunnelId,direction,startMilestone);
// 2025-06 说让调用 4.5 todo
return vehicleGateway.getCarLocusData(locusDataRequest);
} }
public static void videoPuller(String rtspUrl, String outputFile) { @Override
public void videoPuller(String rtspUrl, String outputFile) {
log.info("保存视频-保存切片视频:{},outputFile:{}",rtspUrl,outputFile);
// 创建抓取器 // 创建抓取器
FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(rtspUrl); FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(rtspUrl);
try { try {
......
...@@ -24,10 +24,14 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dat ...@@ -24,10 +24,14 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dat
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.*; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.*;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.feign.XlwClientFeign; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.feign.XlwClientFeign;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.RealTimeVehicleWsClient; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.RealTimeVehicleWsClient;
import com.cico.nest.lcdp.framework.common.exception.ServiceException;
import com.cico.nest.lcdp.framework.common.pojo.PageResult; import com.cico.nest.lcdp.framework.common.pojo.PageResult;
import com.cico.nest.lcdp.framework.common.util.json.JsonUtils;
import com.google.common.collect.HashBasedTable; import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table; import com.google.common.collect.Table;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.formula.functions.T; import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
...@@ -38,11 +42,15 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -38,11 +42,15 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.cico.nest.lcdp.boot.api.infra.enums.ErrorCodeConstants.CODEGEN_TABLE_EXISTS;
import static com.cico.nest.lcdp.framework.common.exception.enums.GlobalErrorCodeConstants.INTERNAL_SERVER_ERROR;
import static com.cico.nest.lcdp.framework.common.exception.util.ServiceExceptionUtil.exception;
/** /**
* @author zws * @author zws
* @date 2024/8/5 * @date 2024/8/5
*/ */
@Slf4j
@Service @Service
public class VehicleGatewayImpl implements VehicleGateway { public class VehicleGatewayImpl implements VehicleGateway {
@Resource @Resource
...@@ -79,12 +87,12 @@ public class VehicleGatewayImpl implements VehicleGateway { ...@@ -79,12 +87,12 @@ public class VehicleGatewayImpl implements VehicleGateway {
} }
} }
} }
//取差集(删除标记缓存) // //取差集(删除标记缓存)
List<String> delRedisMarkKey = CollUtil.subtractToList(redisMrkVehicleCarIds,realTimeVehicleCarIds); // List<String> delRedisMarkKey = CollUtil.subtractToList(redisMrkVehicleCarIds,realTimeVehicleCarIds);
delRedisMarkKey = delRedisMarkKey.stream() // delRedisMarkKey = delRedisMarkKey.stream()
.map(RedisConstants.REDIS_FOCUS_VEHICLE_MARK_KEY::concat) // .map(RedisConstants.REDIS_FOCUS_VEHICLE_MARK_KEY::concat)
.collect(Collectors.toList()); // .collect(Collectors.toList());
stringRedisTemplate.delete(delRedisMarkKey); // stringRedisTemplate.delete(delRedisMarkKey);
String realTimeVehicleJson = JSON.toJSONString(realTimeVehicle,SerializerFeature.WriteMapNullValue); String realTimeVehicleJson = JSON.toJSONString(realTimeVehicle,SerializerFeature.WriteMapNullValue);
stringRedisTemplate.opsForValue().set(RedisConstants.REDIS_REAL_TIME_VEHICLE_KEY.concat(tunnelId),realTimeVehicleJson,10, TimeUnit.SECONDS); stringRedisTemplate.opsForValue().set(RedisConstants.REDIS_REAL_TIME_VEHICLE_KEY.concat(tunnelId),realTimeVehicleJson,10, TimeUnit.SECONDS);
...@@ -168,9 +176,15 @@ public class VehicleGatewayImpl implements VehicleGateway { ...@@ -168,9 +176,15 @@ public class VehicleGatewayImpl implements VehicleGateway {
@Override @Override
public List<HistoryTunnelVehicle> getCarLocusData(LocusDataRequest request) { public List<HistoryTunnelVehicle> getCarLocusData(LocusDataRequest request) {
XlwLocusDataSearchDTO searchDTO = new XlwLocusDataSearchDTO(); XlwLocusDataSearchDTO searchDTO = new XlwLocusDataSearchDTO();
searchDTO.setTunnelId(request.getTunnelId());
searchDTO.setStartTime(request.getStartTime()); searchDTO.setStartTime(request.getStartTime());
searchDTO.setEndTime(request.getEndTime()); searchDTO.setEndTime(request.getEndTime());
XlwResultData<List<XlwHolographicTimeHistoryDTO>> resultData = xlwClientFeign.getCarLocusData(searchDTO); XlwResultData<List<XlwHolographicTimeHistoryDTO>> resultData = xlwClientFeign.getCarLocusData(searchDTO);
if(CollectionUtils.isEmpty(resultData.getData())){
log.error("调用4.5接口获取车辆轨迹数据为空,参数:{}", JsonUtils.toJsonString(searchDTO));
log.error("调用4.5接口获取车辆轨迹数据为空,返回值:{}", resultData.getMessage());
return new ArrayList<>();
}
List<XlwHolographicTimeHistoryDTO> dtos = resultData.getData(); List<XlwHolographicTimeHistoryDTO> dtos = resultData.getData();
TunnelDetailDO tunnelDetailDO = tunnelDetailMapper.selectById(request.getTunnelId()); TunnelDetailDO tunnelDetailDO = tunnelDetailMapper.selectById(request.getTunnelId());
dtos = dtos.stream().filter(s->tunnelDetailDO.getXlwTunnelId().equals(s.getTunnelId())).toList(); dtos = dtos.stream().filter(s->tunnelDetailDO.getXlwTunnelId().equals(s.getTunnelId())).toList();
......
...@@ -10,6 +10,7 @@ import com.cico.nest.lcdp.framework.common.pojo.PageResult; ...@@ -10,6 +10,7 @@ import com.cico.nest.lcdp.framework.common.pojo.PageResult;
import com.cico.nest.lcdp.framework.mybatis.core.mapper.BaseMapperX; import com.cico.nest.lcdp.framework.mybatis.core.mapper.BaseMapperX;
import com.cico.nest.lcdp.framework.mybatis.core.query.LambdaQueryWrapperX; import com.cico.nest.lcdp.framework.mybatis.core.query.LambdaQueryWrapperX;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
...@@ -23,14 +24,24 @@ public interface EventDetailMapper extends BaseMapperX<EventDetailDO> { ...@@ -23,14 +24,24 @@ public interface EventDetailMapper extends BaseMapperX<EventDetailDO> {
default PageResult<EventDetailDO> selectPage(EventDetailPageReqVO reqVO) { default PageResult<EventDetailDO> selectPage(EventDetailPageReqVO reqVO) {
Integer retainedTime = reqVO.getRetainedTime(); Integer retainedTime = reqVO.getRetainedTime();
LambdaQueryWrapperX<EventDetailDO> wrapper = new LambdaQueryWrapperX<EventDetailDO>() LambdaQueryWrapperX<EventDetailDO> wrapper = new LambdaQueryWrapperX<EventDetailDO>()
.eqIfPresent(EventDetailDO::getId, reqVO.getId())
.geIfPresent(EventDetailDO::getEventStartTime,reqVO.getEventStartTimeSearchStart()) .geIfPresent(EventDetailDO::getEventStartTime,reqVO.getEventStartTimeSearchStart())
.leIfPresent(EventDetailDO::getEventStartTime,reqVO.getEventStartTimeSearchEnd()) .leIfPresent(EventDetailDO::getEventStartTime,reqVO.getEventStartTimeSearchEnd())
.eqIfPresent(EventDetailDO::getTunnelId, reqVO.getTunnelId()) .eqIfPresent(EventDetailDO::getTunnelId, reqVO.getTunnelId())
.eqIfPresent(EventDetailDO::getBaseTunnelId, reqVO.getBaseTunnelId())
.eqIfPresent(EventDetailDO::getHoleId, reqVO.getHoleId())
.inIfPresent(EventDetailDO::getDirection, reqVO.getDirection()) .inIfPresent(EventDetailDO::getDirection, reqVO.getDirection())
// .inIfPresent(EventDetailDO::getEventType, reqVO.getEventType()) // .inIfPresent(EventDetailDO::getEventType, reqVO.getEventType())
.likeIfPresent(EventDetailDO::getEventCarPlate, reqVO.getEventCarPlate()) .likeIfPresent(EventDetailDO::getEventCarPlate, reqVO.getEventCarPlate())
.eqIfPresent(EventDetailDO::getEventStatus,reqVO.getEventStatus()); .eqIfPresent(EventDetailDO::getEventStatus,reqVO.getEventStatus());
wrapper.ne(EventDetailDO::getIsRepeat,1);//只筛选不重复的事件 wrapper.ne(EventDetailDO::getIsRepeat,1);//只筛选不重复的事件
// keyword2 桩号 + 隧道方向
// 桩号 模糊查询 如 k215/k215+838 可以搜的到 215838 数据 参数不为空,去掉k去掉+ 左匹配
Optional.ofNullable(reqVO.getKeyword2()).ifPresent(
keyword2 -> wrapper.and(q -> q.likeRight(EventDetailDO::getMilestone,keyword2.replace("k","").replace("K","").replace("zk","").replace("ZK","").replace("+",""))
.or().like(EventDetailDO::getDirectionName, keyword2)
));
if (CollectionUtils.isNotEmpty(reqVO.getEventType()) && reqVO.getEventType().size()>0){ if (CollectionUtils.isNotEmpty(reqVO.getEventType()) && reqVO.getEventType().size()>0){
wrapper.inIfPresent(EventDetailDO::getEventType, reqVO.getEventType()); wrapper.inIfPresent(EventDetailDO::getEventType, reqVO.getEventType());
} }
......
...@@ -44,9 +44,21 @@ public class EventDetailDO { ...@@ -44,9 +44,21 @@ public class EventDetailDO {
*/ */
private String thirdPartyId; private String thirdPartyId;
/** /**
* 隧道id-(目前保存的是信路威洞的id) * 隧道id-(目前保存的是隧道信息的id)
*/ */
private String tunnelId; private String tunnelId;
/**
* 所属隧道id
*/
private String baseTunnelId;
/**
* 所属隧道code
*/
private String baseTunnelCode;
/**
* 所属洞id
*/
private String holeId;
/** /**
* 方向 上行/下行 * 方向 上行/下行
*/ */
...@@ -157,6 +169,20 @@ public class EventDetailDO { ...@@ -157,6 +169,20 @@ public class EventDetailDO {
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private java.util.Date reportTime; private java.util.Date reportTime;
/**
* 处置方式(1:上报事件;2:消除事件;)
*/
private Integer processingType;
/**
* 处置操作人姓名
*/
private String processingOperationsName;
/**
* 处置时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date processingTime;
/** /**
* 创建时间 * 创建时间
*/ */
...@@ -212,6 +238,25 @@ public class EventDetailDO { ...@@ -212,6 +238,25 @@ public class EventDetailDO {
* 车牌图片 * 车牌图片
*/ */
private String plateImageUrl; private String plateImageUrl;
/**
* 危是否化品车辆,枚举:0否、1是
*/
private Boolean isDangerous = false;
//是否重点标记
private Boolean isFocusMark = false;
//留存时间(分钟)
private Integer retainedMinutesTime = 0;
//是否驶出隧道
private Boolean isDriveTunnel = false;
/**
* 进隧道时间
*/
private String inTunnelTimeStr;
} }
...@@ -254,11 +299,11 @@ public class EventDetailDO { ...@@ -254,11 +299,11 @@ public class EventDetailDO {
singMultiCar="单车"; singMultiCar="单车";
} }
} }
String eventSituation = DateUtil.format(eventDetail.getEventStartTime(),"yyyy-MM-dd HH:mm"); String eventSituation = "";
TunnelDetailService tunnelDetailService = SpringUtil.getBean(TunnelDetailService.class); TunnelDetailService tunnelDetailService = SpringUtil.getBean(TunnelDetailService.class);
TunnelDetailDO tunnelDetailDO = tunnelDetailService.getTunnelDetail(eventDetail.getTunnelId()); TunnelDetailDO tunnelDetailDO = tunnelDetailService.getTunnelDetail(eventDetail.getTunnelId());
if(Objects.nonNull(tunnelDetailDO)){ if(Objects.nonNull(tunnelDetailDO)){
eventSituation = eventSituation.concat(" ").concat(tunnelDetailDO.getTunnelName()) eventSituation = eventSituation.concat(tunnelDetailDO.getTunnelName())
.concat(tunnelDetailDO.getDirectionName()); .concat(tunnelDetailDO.getDirectionName());
} }
EventType eventType = EventType.findByType(eventDetail.getEventType()); EventType eventType = EventType.findByType(eventDetail.getEventType());
...@@ -295,8 +340,12 @@ public class EventDetailDO { ...@@ -295,8 +340,12 @@ public class EventDetailDO {
if(CollUtil.isNotEmpty(eventImagesPath)){ if(CollUtil.isNotEmpty(eventImagesPath)){
eventDetailRespVO.setEventImagesPath(eventImagesPath.stream().filter(e->e.startsWith("/")).map(xlwImagePath::concat).toList()); eventDetailRespVO.setEventImagesPath(eventImagesPath.stream().filter(e->e.startsWith("/")).map(xlwImagePath::concat).toList());
} }
//事件开始时间格式化
if(Objects.nonNull(eventDetail.getEventStartTime())){
eventDetailRespVO.setEventStartTimeFormat(eventDetail.getEventStartTime());
}
eventDetailRespVO.setEventSituation(eventSituation); eventDetailRespVO.setEventSituation(eventSituation);
eventDetailRespVO.setMilestoneStr(milestone);
eventDetailRespVO.setDirectionalPosition(directionalPosition); eventDetailRespVO.setDirectionalPosition(directionalPosition);
eventDetailRespVO.setSituationSpot(situationSpot); eventDetailRespVO.setSituationSpot(situationSpot);
return eventDetailRespVO; return eventDetailRespVO;
......
...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; ...@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.HistoryTunnelVehicle; import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.HistoryTunnelVehicle;
import com.cico.nest.lcdp.framework.mybatis.core.type.StringListTypeHandler; import com.cico.nest.lcdp.framework.mybatis.core.type.StringListTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*; import lombok.*;
import org.checkerframework.checker.units.qual.A; import org.checkerframework.checker.units.qual.A;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
...@@ -39,6 +40,11 @@ public class EventHisDO { ...@@ -39,6 +40,11 @@ public class EventHisDO {
*/ */
private String eventId; private String eventId;
/**
* 车辆入隧时间
*/
@TableField(typeHandler = JacksonTypeHandler.class)
private JSONArray vehicleInTunnelTime;
/** /**
* 历史车辆轨迹 * 历史车辆轨迹
*/ */
...@@ -57,6 +63,10 @@ public class EventHisDO { ...@@ -57,6 +63,10 @@ public class EventHisDO {
@TableField(typeHandler = JacksonTypeHandler.class) @TableField(typeHandler = JacksonTypeHandler.class)
private JSONArray bayonetImage; private JSONArray bayonetImage;
/**
* 海康摄像头唯一编码
*/
private String cameraIndexCode;
/** /**
* 视频路径 * 视频路径
*/ */
......
...@@ -19,4 +19,6 @@ public interface EventMapper { ...@@ -19,4 +19,6 @@ public interface EventMapper {
*/ */
List<EventDetailDO> syncEventDetailList(Date startDateTime, Date endDateTime); List<EventDetailDO> syncEventDetailList(Date startDateTime, Date endDateTime);
List<EventDetailDO> syncEventDetailListV2(String startDateTime, String endDateTime);
} }
...@@ -55,7 +55,9 @@ public class XlwAuthMapper implements AuthMapper { ...@@ -55,7 +55,9 @@ public class XlwAuthMapper implements AuthMapper {
XlwResultData<Map<String, Object>> loginResult = xlwClientFeign.login(xlwLoginDTO); XlwResultData<Map<String, Object>> loginResult = xlwClientFeign.login(xlwLoginDTO);
Map<String, Object> resultData = loginResult.getData(); Map<String, Object> resultData = loginResult.getData();
token = (String) resultData.get("sessionId"); token = (String) resultData.get("sessionId");
stringRedisTemplate.opsForValue().set(XlwConstants.REDIS_TOKEN_KEY, token, 6, TimeUnit.HOURS); // token 这里的有效期要小于新路威token 的有效期,不让就会 redis 中还存在,其实登陆失败了
// stringRedisTemplate.opsForValue().set(XlwConstants.REDIS_TOKEN_KEY, token, 6, TimeUnit.HOURS);
stringRedisTemplate.opsForValue().set(XlwConstants.REDIS_TOKEN_KEY, token, 5, TimeUnit.MINUTES);
} }
return token; return token;
} }
......
...@@ -2,6 +2,7 @@ package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw; ...@@ -2,6 +2,7 @@ package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.result.XlwResultData; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.result.XlwResultData;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.EventDetailMapper; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.EventDetailMapper;
...@@ -10,6 +11,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.EventMa ...@@ -10,6 +11,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.EventMa
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.*; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.*;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.feign.XlwClientFeign; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.feign.XlwClientFeign;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.*; import java.util.*;
...@@ -19,6 +21,7 @@ import java.util.stream.Collectors; ...@@ -19,6 +21,7 @@ import java.util.stream.Collectors;
* @author zws * @author zws
* @date 2024/8/21 * @date 2024/8/21
*/ */
@Slf4j
@Component @Component
public class XlwEventMapper implements EventMapper { public class XlwEventMapper implements EventMapper {
...@@ -34,6 +37,7 @@ public class XlwEventMapper implements EventMapper { ...@@ -34,6 +37,7 @@ public class XlwEventMapper implements EventMapper {
XlwResultData<XlwPageDTO<XlwEventListDTO>> resultData = xlwClientFeign.allEventList(xlwEventListSearchDTO); XlwResultData<XlwPageDTO<XlwEventListDTO>> resultData = xlwClientFeign.allEventList(xlwEventListSearchDTO);
XlwPageDTO<XlwEventListDTO> xlwPageDTO = resultData.getData(); XlwPageDTO<XlwEventListDTO> xlwPageDTO = resultData.getData();
long total = xlwPageDTO.getTotal(); long total = xlwPageDTO.getTotal();
log.info("syncEventDetailList,total:{}",total);
List<XlwEventListDTO> xlwEventListDTOList = new ArrayList<>(); List<XlwEventListDTO> xlwEventListDTOList = new ArrayList<>();
if(total > 1000){ if(total > 1000){
int pageSize = 1000; int pageSize = 1000;
...@@ -91,4 +95,74 @@ public class XlwEventMapper implements EventMapper { ...@@ -91,4 +95,74 @@ public class XlwEventMapper implements EventMapper {
} }
return detailDOList; return detailDOList;
} }
@Override
public List<EventDetailDO> syncEventDetailListV2(String startDateTime, String endDateTime) {
XlwEventListSearchDTO xlwEventListSearchDTO = new XlwEventListSearchDTO();
xlwEventListSearchDTO.setPage(1);
xlwEventListSearchDTO.setPageSize(10);
xlwEventListSearchDTO.setStartTime(startDateTime);
xlwEventListSearchDTO.setEndTime(endDateTime);
XlwResultData<XlwPageDTO<XlwEventListDTO>> resultData = xlwClientFeign.allEventList(xlwEventListSearchDTO);
XlwPageDTO<XlwEventListDTO> xlwPageDTO = resultData.getData();
long total = xlwPageDTO.getTotal();
log.info("syncEventDetailListV2,条件查询,startDateTime:{},endDateTime:{}获取total:{}",startDateTime,endDateTime,total);
List<XlwEventListDTO> xlwEventListDTOList = new ArrayList<>();
if(total > 1000){
int pageSize = 1000;
int maxPageNo = ((int)total/pageSize) + 1;
for(int i = 1; i <= maxPageNo; i++){
xlwEventListSearchDTO.setPage(i);
xlwEventListSearchDTO.setPageSize(pageSize);
resultData = xlwClientFeign.allEventList(xlwEventListSearchDTO);
xlwPageDTO = resultData.getData();
xlwEventListDTOList.addAll(xlwPageDTO.getRows());
}
}else{
xlwEventListSearchDTO.setPageSize(Integer.valueOf(total+""));
resultData = xlwClientFeign.allEventList(xlwEventListSearchDTO);
xlwPageDTO = resultData.getData();
xlwEventListDTOList = xlwPageDTO.getRows();
}
LambdaQueryWrapper<EventDetailDO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.select(EventDetailDO::getThirdPartyId);
queryWrapper.ge(EventDetailDO::getEventStartTime,startDateTime);
queryWrapper.le(EventDetailDO::getEventStartTime,endDateTime);
List<EventDetailDO> eventDetailDOList = eventDetailMapper.selectList(queryWrapper);
List<String> thirdPartyIdList = eventDetailDOList.stream().map(EventDetailDO::getThirdPartyId).toList();
List<String> eventIdList = xlwEventListDTOList.stream().map(XlwEventListDTO::getGuid).toList();
//取差集需要同步的event
List<String> syncEventIdList = CollUtil.subtractToList(eventIdList,thirdPartyIdList);
if(CollUtil.isEmpty(eventIdList)){
return List.of();
}
log.info("syncEventDetailListV2,syncEventIdList.size():{}",syncEventIdList.size());
xlwEventListDTOList = xlwEventListDTOList.stream().filter(event-> syncEventIdList.contains(event.getGuid())).toList();
List<EventDetailDO> detailDOList = XlwEventListDTO.convert2DO(xlwEventListDTOList);
Map<String,List<XlwEventImageDTO>> eventIdImageListMap = new HashMap<>();
for(XlwEventListDTO xlwEventListDTO : xlwEventListDTOList){
XlwEventIdDTO xlwEventIdDTO = new XlwEventIdDTO(xlwEventListDTO.getGuid());
XlwResultData<List<XlwEventImageDTO>> imageResultData = xlwClientFeign.getEventImageById(xlwEventIdDTO);
List<XlwEventImageDTO> imageList = imageResultData.getData();
eventIdImageListMap.put(xlwEventListDTO.getGuid(),imageList);
}
for(EventDetailDO eventDetailDO : detailDOList){
List<XlwEventImageDTO> imageList = eventIdImageListMap.get(eventDetailDO.getThirdPartyId());
List<String> imagePathList = new ArrayList<>();
if(Objects.nonNull(imageList)){
imageList.forEach(eventImage->{
if(StrUtil.isNotBlank(eventImage.getHeadImage())){
imagePathList.add(eventImage.getHeadImage());
}
if(StrUtil.isNotBlank(eventImage.getTailImage())){
imagePathList.add(eventImage.getTailImage());
}
});
}
eventDetailDO.setEventImagesPath(imagePathList);
}
// eventDetailMapper.insertBatch(detailDOList);
return detailDOList;
}
} }
...@@ -10,6 +10,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.History ...@@ -10,6 +10,7 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.History
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.*; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.dto.*;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.feign.XlwClientFeign; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.feign.XlwClientFeign;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeVehicleDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeVehicleDTO;
import com.cico.nest.lcdp.framework.common.util.json.JsonUtils;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -85,14 +86,17 @@ public class XlwHistoryMapper implements HistoryMapper { ...@@ -85,14 +86,17 @@ public class XlwHistoryMapper implements HistoryMapper {
try { try {
XlwPageDTO<XlwBayonetPictureDTO> pageDTO = xlwClientFeign.getBayonetPicture(searchDTO).getData(); XlwPageDTO<XlwBayonetPictureDTO> pageDTO = xlwClientFeign.getBayonetPicture(searchDTO).getData();
pictureDTOS = pageDTO.getRows(); pictureDTOS = pageDTO.getRows();
log.info("查询信路威抓拍流水卡口图片,参数:{},返回条数:{}" ,searchDTO,pageDTO.getRows().size() );
} catch (Exception e) { } catch (Exception e) {
log.info("查询信路威抓拍流水卡口图片参数:{}" , JsonUtils.toJsonString(searchDTO));
log.info("查询信路威抓拍流水卡口图片异常:{}" ,e.getMessage()); log.info("查询信路威抓拍流水卡口图片异常:{}" ,e.getMessage());
return new ArrayList<>();
} }
List<String> bayonetImageUrls = new ArrayList<>(); List<String> bayonetImageUrls = new ArrayList<>();
if(!pictureDTOS.isEmpty()){ if(!pictureDTOS.isEmpty()){
XlwBayonetPictureDTO bayonetPictureDTO = pictureDTOS.get(0); XlwBayonetPictureDTO bayonetPictureDTO = pictureDTOS.get(0);
String plateImageUrl = bayonetPictureDTO.getPlateImage(); String plateImageUrl = bayonetPictureDTO.getPlateImage();
log.info("车牌卡口图片路径:" + plateImageUrl); log.info("查询信路威抓拍流水卡口图片,车牌【{}】,卡口图片路径:{}" ,carPlate, plateImageUrl);
if(StringUtils.isEmpty(plateImageUrl)){ if(StringUtils.isEmpty(plateImageUrl)){
return bayonetImageUrls; return bayonetImageUrls;
} }
...@@ -110,7 +114,7 @@ public class XlwHistoryMapper implements HistoryMapper { ...@@ -110,7 +114,7 @@ public class XlwHistoryMapper implements HistoryMapper {
bayonetImageUrls.add("/" + dateFolder + "/" + plateUrlPaths[plateUrlPaths.length - 1]); bayonetImageUrls.add("/" + dateFolder + "/" + plateUrlPaths[plateUrlPaths.length - 1]);
} }
String headImageUrl = bayonetPictureDTO.getHeadImage(); String headImageUrl = bayonetPictureDTO.getHeadImage();
log.info("车头图片路径:" + headImageUrl); log.info("查询信路威抓拍流水卡口图片,车牌【{}】,车头图片路径:{}" ,carPlate, headImageUrl);
String [] headUrlPaths = headImageUrl.split("/"); String [] headUrlPaths = headImageUrl.split("/");
String headSaveImageUrl = bayonetSavePath + "/" + dateFolder + "/" + headUrlPaths[headUrlPaths.length - 1]; String headSaveImageUrl = bayonetSavePath + "/" + dateFolder + "/" + headUrlPaths[headUrlPaths.length - 1];
String headSavePath = doSaveImage( xlwImagePath +headImageUrl,headSaveImageUrl); String headSavePath = doSaveImage( xlwImagePath +headImageUrl,headSaveImageUrl);
......
...@@ -11,6 +11,9 @@ import lombok.Data; ...@@ -11,6 +11,9 @@ import lombok.Data;
@Data @Data
public class XlwLocusDataSearchDTO { public class XlwLocusDataSearchDTO {
//隧道ID
private String tunnelId;
//开始时间 //开始时间
private String startTime; private String startTime;
......
...@@ -18,10 +18,12 @@ public interface XlwClientFeign { ...@@ -18,10 +18,12 @@ public interface XlwClientFeign {
/** /**
* 登录接口 * 登录接口
* 1.6 /common/login.htm 老
* 1.3 /backDoor/getDemoSessionId.htm 新
* @param loginDTO 请求参数 * @param loginDTO 请求参数
* @return result * @return result
*/ */
@PostMapping("/common/login.htm") @PostMapping("/backDoor/getDemoSessionId.htm")
XlwResultData<Map<String,Object>> login(@RequestBody XlwLoginDTO loginDTO); XlwResultData<Map<String,Object>> login(@RequestBody XlwLoginDTO loginDTO);
/** /**
......
...@@ -14,7 +14,7 @@ public class XlwClientFeignIntercept implements RequestInterceptor { ...@@ -14,7 +14,7 @@ public class XlwClientFeignIntercept implements RequestInterceptor {
@Override @Override
public void apply(RequestTemplate requestTemplate) { public void apply(RequestTemplate requestTemplate) {
//跳过登录接口 //跳过登录接口
if(!requestTemplate.url().equals(XlwConstants.LOGIN_INTERFACE)){ if(!XlwConstants.LOGIN_INTERFACE_LIST.contains(requestTemplate.url())){
AuthMapper authMapper = SpringUtil.getBean(AuthMapper.class); AuthMapper authMapper = SpringUtil.getBean(AuthMapper.class);
String token = authMapper.getXlwLoginToken(); String token = authMapper.getXlwLoginToken();
//请求头中添加sessionId //请求头中添加sessionId
......
...@@ -61,14 +61,17 @@ public class SdgkTrafficEventHandler implements MqttMessageHandler<SdgkEventMqRe ...@@ -61,14 +61,17 @@ public class SdgkTrafficEventHandler implements MqttMessageHandler<SdgkEventMqRe
//查找本地已有事件 //查找本地已有事件
EventDetailDO detailDO = eventDetailMapper.selectByThirdPartyId(eventDetailDO.getThirdPartyId()); EventDetailDO detailDO = eventDetailMapper.selectByThirdPartyId(eventDetailDO.getThirdPartyId());
if(Objects.isNull(detailDO) ){ if(Objects.isNull(detailDO) ){
// 事是否是重复事件:0不是,1是
eventDetailDO.setReportTime(eventDetailDO.getIsRepeat()!=1?new Date():null); eventDetailDO.setReportTime(eventDetailDO.getIsRepeat()!=1?new Date():null);
if(eventDetailDO.getIsRepeat()!=1){
//发送给前端数据库
eventGateway.pushRealTimeEventData(tunnelId,eventDetailDO.getId());
}
eventDetailMapper.insert(eventDetailDO); eventDetailMapper.insert(eventDetailDO);
}else{ }else{
eventDetailDO.setId(detailDO.getId()); eventDetailDO.setId(detailDO.getId());
eventDetailMapper.updateById(eventDetailDO); eventDetailMapper.updateById(eventDetailDO);
} }
//发送给前端数据库
eventGateway.pushRealTimeEventData(tunnelId);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
log.error("接收隧道管控事件的上报处理异常,{}",e.getMessage()); log.error("接收隧道管控事件的上报处理异常,{}",e.getMessage());
} }
......
...@@ -4,7 +4,9 @@ import cn.hutool.core.util.StrUtil; ...@@ -4,7 +4,9 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.EventDetailService; import com.cico.nest.lcdp.boot.core.qxsd.application.service.EventDetailService;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.HistoryService; import com.cico.nest.lcdp.boot.core.qxsd.application.service.HistoryService;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.TunnelBaseService;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.TunnelDetailService; import com.cico.nest.lcdp.boot.core.qxsd.application.service.TunnelDetailService;
import com.cico.nest.lcdp.boot.core.qxsd.application.service.TunnelHoleService;
import com.cico.nest.lcdp.boot.core.qxsd.domain.event.EventSource; import com.cico.nest.lcdp.boot.core.qxsd.domain.event.EventSource;
import com.cico.nest.lcdp.boot.core.qxsd.domain.event.EventTypeAllEnum; import com.cico.nest.lcdp.boot.core.qxsd.domain.event.EventTypeAllEnum;
import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.EventGateway; import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.EventGateway;
...@@ -12,12 +14,15 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.constatnt.XlwCons ...@@ -12,12 +14,15 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.constatnt.XlwCons
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.result.XlwResultData; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.common.result.XlwResultData;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.EventDetailMapper; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.EventDetailMapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.EventDetailDO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.EventDetailDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelBaseDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelDetailDO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelDetailDO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.database.dataobject.TunnelHoleV2DO;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.XlwAuthMapper; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.http.xlw.XlwAuthMapper;
import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeEventDTO; import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.XlwRealTimeEventDTO;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.socket.CloseStatus; import org.springframework.web.socket.CloseStatus;
import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.TextMessage;
...@@ -52,9 +57,14 @@ public class RealTimeEventWsClient { ...@@ -52,9 +57,14 @@ public class RealTimeEventWsClient {
@Resource @Resource
private EventGateway eventGateway; private EventGateway eventGateway;
@Resource
private TunnelBaseService tunnelBaseService;
@Resource @Resource
private TunnelDetailService tunnelDetailService; private TunnelDetailService tunnelDetailService;
@Resource @Resource
private TunnelHoleService tunnelHoleService;
@Resource
private HistoryService historyService; private HistoryService historyService;
private final ExecutorService service = Executors.newFixedThreadPool(5); private final ExecutorService service = Executors.newFixedThreadPool(5);
...@@ -66,15 +76,15 @@ public class RealTimeEventWsClient { ...@@ -66,15 +76,15 @@ public class RealTimeEventWsClient {
public void handleTextMessage(WebSocketSession session, TextMessage message) { public void handleTextMessage(WebSocketSession session, TextMessage message) {
// 处理从服务器接收到的消息 // 处理从服务器接收到的消息
try{ try{
log.info("接收到的事件数据:" + message.getPayload()); log.info("detailTunnelId:{},接收到的事件实时数据:{}" ,tunnelId, message.getPayload());
if(StrUtil.isBlank(message.getPayload())){
return;
}
XlwResultData<JSONObject> xlwResultData = JSONObject.parseObject(message.getPayload(), XlwResultData.class); XlwResultData<JSONObject> xlwResultData = JSONObject.parseObject(message.getPayload(), XlwResultData.class);
XlwRealTimeEventDTO xlwRealTimeEventDTO = JSONObject.parseObject(xlwResultData.getData().toString(),XlwRealTimeEventDTO.class); XlwRealTimeEventDTO xlwRealTimeEventDTO = JSONObject.parseObject(xlwResultData.getData().toString(),XlwRealTimeEventDTO.class);
EventDetailDO eventDetailDO = XlwRealTimeEventDTO.convert2DO(xlwRealTimeEventDTO); EventDetailDO eventDetailDO = XlwRealTimeEventDTO.convert2DO(xlwRealTimeEventDTO);
eventDetailDO.setTunnelId(tunnelId); // 补全隧道信息 如果要考虑性能,可以考虑缓存
eventDetailDO.setCreateTime(new Date()); completionTunnelHole(tunnelId,eventDetailDO);
TunnelDetailDO tunnelDetailDO = tunnelDetailService.getTunnelDetail(tunnelId);
eventDetailDO.setDirection(tunnelDetailDO.getDirection());
eventDetailDO.setDirectionName(tunnelDetailDO.getDirectionName());
eventDetailDO.setThirdEventStatus(xlwRealTimeEventDTO.getEventStatus()); eventDetailDO.setThirdEventStatus(xlwRealTimeEventDTO.getEventStatus());
EventDetailDO detailDO = eventDetailMapper.selectByThirdPartyId(eventDetailDO.getThirdPartyId()); EventDetailDO detailDO = eventDetailMapper.selectByThirdPartyId(eventDetailDO.getThirdPartyId());
// 判断跟隧道管控事件去重 如果隧道管控同车同类型事件已存在 则标记重复 // 判断跟隧道管控事件去重 如果隧道管控同车同类型事件已存在 则标记重复
...@@ -95,8 +105,10 @@ public class RealTimeEventWsClient { ...@@ -95,8 +105,10 @@ public class RealTimeEventWsClient {
} }
if(Objects.isNull(detailDO) ){ if(Objects.isNull(detailDO) ){
eventDetailMapper.insert(eventDetailDO); eventDetailMapper.insert(eventDetailDO);
eventGateway.pushRealTimeEventData(tunnelId); //推送实时事件数据到前端websocket服务
eventGateway.pushRealTimeEventData(tunnelId,eventDetailDO.getId());
}else{ }else{
eventDetailDO.setId(detailDO.getId());
//如果已存在事件,则只做状态的更新 //如果已存在事件,则只做状态的更新
EventDetailDO updateDetailDO = new EventDetailDO(); EventDetailDO updateDetailDO = new EventDetailDO();
updateDetailDO.setId(detailDO.getId()); updateDetailDO.setId(detailDO.getId());
...@@ -106,13 +118,14 @@ public class RealTimeEventWsClient { ...@@ -106,13 +118,14 @@ public class RealTimeEventWsClient {
} }
updateDetailDO.setUpdateTime(new Date()); updateDetailDO.setUpdateTime(new Date());
eventDetailMapper.updateById(updateDetailDO); eventDetailMapper.updateById(updateDetailDO);
log.info("更新事件状态成功,id:{},guid:{},三方状态:{}",detailDO.getId(),eventDetailDO.getThirdPartyId(),xlwRealTimeEventDTO.getEventStatus());
} }
if(xlwRealTimeEventDTO.getEventStatus() == 0){ // if(xlwRealTimeEventDTO.getEventStatus() == 0){
//当第二次收到信路威结束事件时, 异步获取车流数据和视频回放数据 //当第二次收到信路威结束事件时, 异步获取车流数据和视频回放数据
service.submit(()->{ service.submit(()->{
historyService.saveEventHistoryData(eventDetailDO); historyService.saveEventHistoryData(eventDetailDO);
}); });
} // }
}catch (Exception e){ }catch (Exception e){
log.error("处理实时数据失败",e); log.error("处理实时数据失败",e);
} }
...@@ -135,6 +148,30 @@ public class RealTimeEventWsClient { ...@@ -135,6 +148,30 @@ public class RealTimeEventWsClient {
WebSocketHttpHeaders webSocketHttpHeaders = new WebSocketHttpHeaders(); WebSocketHttpHeaders webSocketHttpHeaders = new WebSocketHttpHeaders();
webSocketHttpHeaders.add(XlwConstants.AUTH_HEADER,xlwAuthMapper.getXlwLoginToken()); webSocketHttpHeaders.add(XlwConstants.AUTH_HEADER,xlwAuthMapper.getXlwLoginToken());
client.execute(handler, webSocketHttpHeaders, new URI(url)); client.execute(handler, webSocketHttpHeaders, new URI(url));
log.info("websocket连接成功,连接地址:{}",url);
}
private void completionTunnelHole(String tunnelDetailId,EventDetailDO eventDetailDO){
eventDetailDO.setTunnelId(tunnelDetailId);
TunnelDetailDO tunnelDetailDO = tunnelDetailService.getTunnelDetail(tunnelDetailId);
if(Objects.isNull(tunnelDetailDO)){
log.error("ws事件数据异常,tunnelDetailId:{},TunnelDetailDO对象为空",tunnelDetailId);
}
eventDetailDO.setDirection(tunnelDetailDO.getDirection());
eventDetailDO.setDirectionName(tunnelDetailDO.getDirectionName());
TunnelHoleV2DO tunnelHoleV2DO = tunnelHoleService.getTunnelSfHoleId(tunnelDetailDO.getXlwTunnelId());
if(Objects.isNull(tunnelHoleV2DO)){
log.error("ws事件数据异常,xlwTunnelId:{},tunnelHoleV2DO对象为空",tunnelDetailDO.getXlwTunnelId());
}
TunnelBaseDO tunnelBaseDO = tunnelBaseService.getTunnelBase(tunnelHoleV2DO.getTunnelId());
if(Objects.isNull(tunnelBaseDO)){
log.error("ws事件数据异常,tunnelId:{},tunnelBaseDO对象为空",tunnelHoleV2DO.getTunnelId());
}
eventDetailDO.setBaseTunnelId(tunnelHoleV2DO.getTunnelId());
eventDetailDO.setBaseTunnelCode(tunnelBaseDO.getTunnelCode());
eventDetailDO.setHoleId(tunnelHoleV2DO.getId());
eventDetailDO.setCreateTime(new Date());
} }
} }
package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw; package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.VehicleGateway; import com.cico.nest.lcdp.boot.core.qxsd.domain.gateway.VehicleGateway;
import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.TunnelRealTimeVehicle; import com.cico.nest.lcdp.boot.core.qxsd.domain.vehicle.TunnelRealTimeVehicle;
...@@ -11,13 +13,16 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.X ...@@ -11,13 +13,16 @@ import com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.dto.X
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.websocket.WebSocketContainer; import jakarta.websocket.WebSocketContainer;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.tomcat.websocket.WsWebSocketContainer; import org.apache.tomcat.websocket.WsWebSocketContainer;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.socket.*; import org.springframework.web.socket.*;
import org.springframework.web.socket.client.standard.StandardWebSocketClient; import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.handler.TextWebSocketHandler; import org.springframework.web.socket.handler.TextWebSocketHandler;
import java.net.URI; import java.net.URI;
import java.util.List;
/** /**
* 对接 信路威 车辆实时信息 websocket 客户端 * 对接 信路威 车辆实时信息 websocket 客户端
...@@ -28,6 +33,8 @@ import java.net.URI; ...@@ -28,6 +33,8 @@ import java.net.URI;
@Slf4j @Slf4j
public class RealTimeVehicleWsClient { public class RealTimeVehicleWsClient {
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource @Resource
private XlwAuthMapper xlwAuthMapper; private XlwAuthMapper xlwAuthMapper;
@Resource @Resource
...@@ -50,9 +57,24 @@ public class RealTimeVehicleWsClient { ...@@ -50,9 +57,24 @@ public class RealTimeVehicleWsClient {
public void handleTextMessage(WebSocketSession session, TextMessage message) { public void handleTextMessage(WebSocketSession session, TextMessage message) {
try{ try{
//处理从服务器接收到的消息 //处理从服务器接收到的消息
//log.info(tunnelId +"接收到的车辆数据:" + message.getPayload()); // log.info("detailTunnelId:{},接收到的车辆实时数据:{}" ,tunnelId, message.getPayload());
if(StrUtil.isBlank(message.getPayload())){
return;
}
XlwResultData<JSONObject> xlwResultData = JSONObject.parseObject(message.getPayload(), XlwResultData.class); XlwResultData<JSONObject> xlwResultData = JSONObject.parseObject(message.getPayload(), XlwResultData.class);
XlwRealTimeVehicleDTO xlwRealTimeVehicleDTO = JSONObject.parseObject(xlwResultData.getData().toString(), XlwRealTimeVehicleDTO.class); XlwRealTimeVehicleDTO xlwRealTimeVehicleDTO = JSONObject.parseObject(xlwResultData.getData().toString(), XlwRealTimeVehicleDTO.class);
/*********************************************************************************/
//todo 测试事件和车辆交集 从redis中获取key的值,往List<CarInfo>中添加数据 让车辆一直保留在隧道中
String redisKey = "VehicleWs:addCarInfo";
String vehicleJson = stringRedisTemplate.opsForValue().get(redisKey);
List<XlwRealTimeVehicleDTO.CarInfo> carInfoList = JSONArray.parseArray(vehicleJson, XlwRealTimeVehicleDTO.CarInfo.class);
if(CollectionUtils.isNotEmpty(carInfoList)){
log.info("测试事件和车辆交集,原:{}条",xlwRealTimeVehicleDTO.getCarInfo().size());
log.info("从redis中获取:{},的值,往List<CarInfo>中添加数据 让车辆一直保留在隧道中,插入{}条数据",redisKey,carInfoList.size());
xlwRealTimeVehicleDTO.getCarInfo().addAll(carInfoList);
log.info("测试事件和车辆交集,操作后:{}条",xlwRealTimeVehicleDTO.getCarInfo().size());
}
/*********************************************************************************/
TunnelRealTimeVehicle tunnelRealTimeVehicle = VehicleConvertor.convert2TunnelRTV(xlwRealTimeVehicleDTO,tunnelId,direction,startMilestone); TunnelRealTimeVehicle tunnelRealTimeVehicle = VehicleConvertor.convert2TunnelRTV(xlwRealTimeVehicleDTO,tunnelId,direction,startMilestone);
vehicleGateway.pushRealTimeVehicleData(tunnelRealTimeVehicle,tunnelId); vehicleGateway.pushRealTimeVehicleData(tunnelRealTimeVehicle,tunnelId);
}catch (Exception e){ }catch (Exception e){
......
package com.cico.nest.lcdp.boot.core.qxsd.infrastructure.gatewayimpl.ws.xlw.vo;
import com.cico.nest.lcdp.boot.core.qxsd.adapter.web.vo.event.EventDetailRespVO;
import lombok.Data;
import lombok.experimental.Accessors;
import java.util.List;
/**
* @author tongzuqi
* @create 2025/6/14 10:42 AM
*/
@Accessors(chain = true)
@Data
public class RealTimeEventWsVO {
/**
* 事件列表数量
*/
Long eventCount = 0L;
/**
* 事件未完成集合
*/
List<EventDetailRespVO> eventThirdEventStatusNotFinishList;
/**
* 当前推送事件信息
*/
EventDetailRespVO eventDetailRespVO;
}
server: server:
port: 48088 port: 48078
tomcat: tomcat:
connection-timeout: 60000 connection-timeout: 60000
...@@ -53,9 +53,9 @@ spring: ...@@ -53,9 +53,9 @@ spring:
datasource: datasource:
master: master:
name: nest-qxsd-xl name: nest-qxsd-xl
url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 url: jdbc:mysql://192.168.1.196:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例
username: root username: root
password: root password: 123456
#slave: # 模拟从库,可根据自己需要修改 #slave: # 模拟从库,可根据自己需要修改
# name: nest-fbi # name: nest-fbi
# lazy: true # 开启懒加载,保证启动速度 # lazy: true # 开启懒加载,保证启动速度
...@@ -64,10 +64,10 @@ spring: ...@@ -64,10 +64,10 @@ spring:
# password: YUkXGpfH!3ZjP%TN # password: YUkXGpfH!3ZjP%TN
data: data:
redis: redis:
host: 127.0.0.1 # 地址 host: 192.168.1.210 # 地址
port: 6379 # 端口 port: 6379 # 端口
database: 1 # 数据库索引 database: 11 # 数据库索引
#password: YUkXGpfH!3ZjP%TN password: 123456
--- #################### 定时任务相关配置 #################### --- #################### 定时任务相关配置 ####################
...@@ -272,8 +272,12 @@ qxsd: ...@@ -272,8 +272,12 @@ qxsd:
http: http://33.64.92.130:8091 http: http://33.64.92.130:8091
ws: ws://33.64.92.130:8093 ws: ws://33.64.92.130:8093
images: http://33.64.92.130:8800 images: http://33.64.92.130:8800
loginName: gaoxin #1.3 xwl 新账号密码
loginPwd: 7cc2cf8a95f80a8ea500ff997f9623e4 #MD5(1234zxcv) loginName: ForShowDemo
loginPwd: 5416d7cd6ef195a0f7622a9c56b55e84
#1.6 xwl 老账号密码
# loginName: gaoxin
# loginPwd: 7cc2cf8a95f80a8ea500ff997f9623e4 #MD5(1234zxcv)
organizationId: org0001 organizationId: org0001
hk: hk:
host: 12.1.89.1:443 host: 12.1.89.1:443
...@@ -281,12 +285,12 @@ qxsd: ...@@ -281,12 +285,12 @@ qxsd:
appSecret: EvCN2P1jYX20UWn2ZrGh appSecret: EvCN2P1jYX20UWn2ZrGh
images: images:
bayonetDownPath: http://33.67.51.196:10000/iot/images bayonetDownPath: http://33.67.51.196:10000/iot/images
eventSavePath: /home/gaoxin/nest-qxsd/web/images/event eventSavePath: /Users/tongzuqi/Desktop/tzq/dongchi/upload-gaoxin/nest-qxsd/web/images/event
bayonetSavePath: /home/gaoxin/nest-qxsd/web/images/bayonet bayonetSavePath: /Users/tongzuqi/Desktop/tzq/dongchi/upload-gaoxin/nest-qxsd/web/images/bayonet
#eventSavePath: D:\\home\\images\\event #eventSavePath: D:\\home\\images\\event
#bayonetSavePath: D:\\home\\images\\bayonet #bayonetSavePath: D:\\home\\images\\bayonet
video: video:
eventHisSavePath: /home/gaoxin/nest-qxsd/web/video/eventHis eventHisSavePath: /Users/tongzuqi/Desktop/tzq/dongchi/upload-gaoxin/nest-qxsd/web/video/eventHis
#eventHisSavePath: D:\\home\\video\\eventHis #eventHisSavePath: D:\\home\\video\\eventHis
static-resource: static-resource:
event-images: http://12.1.97.101:9888/images/event event-images: http://12.1.97.101:9888/images/event
......
...@@ -2,7 +2,7 @@ spring: ...@@ -2,7 +2,7 @@ spring:
application: application:
name: nest-lcdp-boot name: nest-lcdp-boot
profiles: profiles:
active: xl active: localhost
main: main:
allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。
# Servlet 配置 # Servlet 配置
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</root> </root>
</springProfile> </springProfile>
<!-- 其它环境 --> <!-- 其它环境 -->
<springProfile name="249,localhost,gfj,xl"> <springProfile name="249,localhost,gfj,xl,xl-v2">
<root level="INFO"> <root level="INFO">
<appender-ref ref="STDOUT"/> <appender-ref ref="STDOUT"/>
<appender-ref ref="ASYNC"/> <appender-ref ref="ASYNC"/>
......
#!/bin/sh -l
function mvn_server(){
source ~/.zshrc
export JAVA_HOME=$JAVA_HOME_17
# 执行maven命令
log_yellow "切换jdk17"
log_black `java -version`
log_black "mvn clean package -Dmaven.test.skip=true"
mvn clean package -Dmaven.test.skip=true
export JAVA_HOME=$JAVA_HOME_8
log_black `java -version`
log_yellow "切换jdk8"
LOG "编译完成"
}
function git_pull()
{
# # 切换临时目录
# log_black "rm -rf $temp_project_path"
# rm -rf $temp_project_path
# log_black "cd $temp_base_path"
# cd $temp_base_path
# # 拉取代码
# log_black "git clone http://gitlab.totalapp.cn:8880/$GIT_SERVICE_TYPE/$GIT_SERVICE_NAME.git"
# git clone http://gitlab.totalapp.cn:8880/$GIT_SERVICE_TYPE/$GIT_SERVICE_NAME.git
# log_black "cd $GIT_SERVICE_NAME"
# cd $GIT_SERVICE_NAME
#切换分支
log_black "git checkout $branch"
branch_retuen=`git checkout $branch`
if [[ ! $branch_retuen ]]; then
LOG "输入的分支错误,请核实"
exit 1
else
LOG "切换[$branch]分支,返回:"$branch_retuen
fi
}
# 绿字
function LOG(){
echo -e "\033[32m $1 \033[0m"
}
# 黄字
function log_yellow(){
echo -e "\033[33m $1 \033[0m"
}
# 红字
function log_red(){
echo -e "\033[31m $1 \033[0m"
}
# 黑字
function log_black(){
echo -e "\033[47;30m $1 \033[0m"
}
log_red "使用此脚本拉取git并使用maven配置进行打包,需要记得修改,请注意!!!!"
log_red "temp_base_path sh脚本目录"
log_red "mvm_path maven文件jar目录"
branch="提交过代码后的"
cd /Users/tongzuqi/pro/dongchi/gaoxin/nestqxsdboot
pwd=`pwd`
mvm_path=/Users/ONE/maven/apache-maven-3.6.1/lib/repo
log_red "maven路径:"$mvm_path
log_red "当前路径:"$pwd
log_red "分支名:"$branch
rm -rf /Users/tongzuqi/pro/dongchi/gaoxin/nestqxsdboot/nest-lcdp-boot-server/target/
LOG "-------编译中:-----------"
mvn_server;
LOG "-------删除git临时目录-------"
set -x
pwd
chmod 755 /Users/tongzuqi/pro/dongchi/gaoxin/nestqxsdboot/nest-lcdp-boot-server/target/*.jar
scp -r /Users/tongzuqi/pro/dongchi/gaoxin/nestqxsdboot/nest-lcdp-boot-server/target/nest-lcdp-boot-server.jar root@12.1.89.111:/home/gaoxin/nest-qxsd-v2/nest-lcdp-boot-server-v2.jar
ssh -tt -p 22 root@12.1.89.111 <<EOF
cd /home/gaoxin/nest-qxsd-v2/
sh run.sh restart
echo "启动服务结束"
exit
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment