添加 /recordInfo api
This commit is contained in:
parent
e6819b2a15
commit
8c68d9dfa1
@ -4,10 +4,12 @@ import cn.skcks.docking.gb28181.annotation.web.JsonMapping;
|
||||
import cn.skcks.docking.gb28181.annotation.web.methods.GetJson;
|
||||
import cn.skcks.docking.gb28181.annotation.web.methods.PostJson;
|
||||
import cn.skcks.docking.gb28181.common.json.JsonResponse;
|
||||
import cn.skcks.docking.gb28181.core.sip.message.processor.message.types.recordinfo.query.dto.RecordInfoRequestDTO;
|
||||
import cn.skcks.docking.gb28181.sip.manscdp.recordinfo.request.RecordInfoRequestDTO;
|
||||
import cn.skcks.docking.gb28181.wvp.config.SwaggerConfig;
|
||||
import cn.skcks.docking.gb28181.wvp.service.catalog.CatalogService;
|
||||
import cn.skcks.docking.gb28181.wvp.service.device.control.DeviceControlService;
|
||||
import cn.skcks.docking.gb28181.wvp.service.record.RecordInfoService;
|
||||
import cn.skcks.docking.gb28181.wvp.service.record.dto.RecordInfoDTO;
|
||||
import cn.skcks.docking.gb28181.wvp.sip.message.message.catalog.dto.CatalogItemDTO;
|
||||
import cn.skcks.docking.gb28181.wvp.sip.message.message.catalog.dto.CatalogResponseDTO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -27,6 +29,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class Gb28181Controller {
|
||||
private final CatalogService catalogService;
|
||||
private final DeviceControlService deviceControlService;
|
||||
private final RecordInfoService recordInfoService;
|
||||
|
||||
@Bean
|
||||
public GroupedOpenApi gb28181Api() {
|
||||
return SwaggerConfig.api("Gb28181Api", "/gb28181");
|
||||
@ -53,7 +57,8 @@ public class Gb28181Controller {
|
||||
}
|
||||
|
||||
@PostJson("/recordInfo")
|
||||
public JsonResponse<Void> recordInfo(RecordInfoRequestDTO dto){
|
||||
public JsonResponse<RecordInfoRequestDTO> recordInfo(RecordInfoDTO dto){
|
||||
recordInfoService.requestRecordInfo(dto);
|
||||
return JsonResponse.success(null);
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,24 @@
|
||||
package cn.skcks.docking.gb28181.wvp.service.record;
|
||||
|
||||
import cn.skcks.docking.gb28181.core.sip.message.processor.message.types.recordinfo.query.dto.RecordInfoRequestDTO;
|
||||
import cn.skcks.docking.gb28181.common.json.JsonException;
|
||||
import cn.skcks.docking.gb28181.common.xml.XmlUtils;
|
||||
import cn.skcks.docking.gb28181.core.sip.utils.SipUtil;
|
||||
import cn.skcks.docking.gb28181.sip.manscdp.recordinfo.request.RecordInfoRequestDTO;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDevice;
|
||||
import cn.skcks.docking.gb28181.wvp.orm.mybatis.dynamic.model.WvpProxyDocking;
|
||||
import cn.skcks.docking.gb28181.wvp.service.device.DeviceService;
|
||||
import cn.skcks.docking.gb28181.wvp.service.docking.DockingService;
|
||||
import cn.skcks.docking.gb28181.wvp.service.record.dto.RecordInfoDTO;
|
||||
import cn.skcks.docking.gb28181.wvp.sip.request.SipRequestBuilder;
|
||||
import cn.skcks.docking.gb28181.wvp.sip.sender.SipSender;
|
||||
import cn.skcks.docking.gb28181.wvp.sip.subscribe.SipSubscribe;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
@ -22,7 +32,44 @@ public class RecordInfoService {
|
||||
private final DockingService dockingService;
|
||||
private final DeviceService deviceService;
|
||||
|
||||
public void requestRecordInfo(String deviceCode, RecordInfoRequestDTO dto){
|
||||
@SneakyThrows
|
||||
public void requestRecordInfo(RecordInfoDTO dto){
|
||||
String deviceCode = dto.getDeviceCode();
|
||||
Optional<WvpProxyDevice> deviceByDeviceCode = deviceService.getDeviceByDeviceCode(deviceCode);
|
||||
if (deviceByDeviceCode.isEmpty()) {
|
||||
String reason = MessageFormat.format("未能找到 设备编码 为 {0} 的设备", deviceCode);
|
||||
log.error("{}",reason);
|
||||
throw new JsonException(reason);
|
||||
} else {
|
||||
WvpProxyDevice device = deviceByDeviceCode.get();
|
||||
requestRecordInfo(device.getGbDeviceId(), device.getGbDeviceChannelId(), dto);
|
||||
}
|
||||
}
|
||||
|
||||
public void requestRecordInfo(String gbDeviceId, String channel, RecordInfoDTO dto){
|
||||
Optional<WvpProxyDocking> deviceByGbDeviceId = dockingService.getDeviceByGbDeviceId(gbDeviceId);
|
||||
if(deviceByGbDeviceId.isEmpty()){
|
||||
log.info("未能找到 国标编码 {} 的注册信息", gbDeviceId);
|
||||
return;
|
||||
}
|
||||
Optional<WvpProxyDevice> deviceByGbDeviceIdAndChannel = deviceService.getDeviceByGbDeviceIdAndChannel(gbDeviceId, channel);
|
||||
if (deviceByGbDeviceIdAndChannel.isEmpty()) {
|
||||
log.info("未能找到 编码 {}, 通道 {} 的设备", gbDeviceId, channel);
|
||||
return;
|
||||
}
|
||||
WvpProxyDocking device = deviceByGbDeviceId.get();
|
||||
String sn = String.valueOf((int) (Math.random() * 9 + 1) * 100000);
|
||||
RecordInfoRequestDTO recordInfoRequestDTO = RecordInfoRequestDTO.builder()
|
||||
.deviceId(channel)
|
||||
.sn(sn)
|
||||
.startTime(dto.getStartTime())
|
||||
.endTime(dto.getEndTime())
|
||||
.type(dto.getType())
|
||||
.Secrecy(dto.getSecrecy())
|
||||
.filePath(dto.getFilePath())
|
||||
.IndistinctQuery(0)
|
||||
.build();
|
||||
sipSender.sendRequest((provider, ip, port)-> SipRequestBuilder.createMessageRequest(device,ip,port,SipRequestBuilder.getCSeq(), XmlUtils.toXml(recordInfoRequestDTO), SipUtil.generateViaTag(),
|
||||
SipUtil.generateFromTag(), provider.getNewCallId()));
|
||||
}
|
||||
}
|
||||
|
@ -2,45 +2,30 @@ package cn.skcks.docking.gb28181.wvp.service.record.dto;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.skcks.docking.gb28181.constant.GB28181Constant;
|
||||
import cn.skcks.docking.gb28181.core.sip.gb28181.constant.CmdType;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class RecordInfoDTO {
|
||||
private String cmdType = CmdType.RECORD_INFO;
|
||||
|
||||
/**
|
||||
* 命令序列号(必选)
|
||||
*/
|
||||
private String sn;
|
||||
|
||||
/**
|
||||
* 目标设备的设备编码(必选)
|
||||
*/
|
||||
private String deviceId;
|
||||
private String deviceCode;
|
||||
|
||||
@DateTimeFormat(pattern= DatePattern.NORM_DATETIME_PATTERN)
|
||||
@JsonFormat(pattern = GB28181Constant.DATETIME_FORMAT, timezone = GB28181Constant.TIME_ZONE)
|
||||
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = GB28181Constant.TIME_ZONE)
|
||||
private Date startTime;
|
||||
|
||||
@DateTimeFormat(pattern= DatePattern.NORM_DATETIME_PATTERN)
|
||||
@JsonFormat(pattern = GB28181Constant.DATETIME_FORMAT, timezone = GB28181Constant.TIME_ZONE)
|
||||
@JsonFormat(pattern = DatePattern.NORM_DATETIME_PATTERN, timezone = GB28181Constant.TIME_ZONE)
|
||||
private Date endTime;
|
||||
|
||||
private String filePath;
|
||||
|
||||
private String address;
|
||||
|
||||
|
||||
private Integer Secrecy = 0;
|
||||
|
||||
|
||||
private String type = "all";
|
||||
|
||||
|
||||
private String recorderId;
|
||||
|
||||
private Integer IndistinctQuery;
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
package cn.skcks.docking.gb28181.wvp.service.record.dto;
|
||||
|
||||
import cn.skcks.docking.gb28181.core.sip.message.processor.message.types.recordinfo.query.dto.RecordInfoRequestDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface RecordInfoDTOConvertor {
|
||||
RecordInfoDTOConvertor INSTANCE = Mappers.getMapper(RecordInfoDTOConvertor.class);
|
||||
|
||||
RecordInfoDTO convert(RecordInfoRequestDTO dto);
|
||||
|
||||
RecordInfoRequestDTO convert(RecordInfoDTO dto);
|
||||
}
|
Loading…
Reference in New Issue
Block a user