RecordInfoResponseDTO 实体类定义

This commit is contained in:
shikong 2023-08-22 17:21:15 +08:00
parent 3d4cb4d9e2
commit fb7a911c6f
5 changed files with 127 additions and 7 deletions

View File

@ -1,6 +1,7 @@
package cn.skcks.docking.gb28181.core.sip.message.processor.record.dto;
package cn.skcks.docking.gb28181.core.sip.message.processor.message.types.recordinfo.query.dto;
import cn.hutool.core.date.DatePattern;
import cn.skcks.docking.gb28181.core.sip.gb28181.constant.CmdType;
import cn.skcks.docking.gb28181.core.sip.gb28181.constant.GB28181Constant;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
@ -20,16 +21,24 @@ import java.util.Date;
@NoArgsConstructor
@Builder
public class RecordInfoRequestDTO {
/**
* 命令类型:设备信息查询(必选)
*/
@Builder.Default
private String cmdType = "RecordInfo";
private String cmdType = CmdType.RECORD_INFO;
/**
* 命令序列号(必选)
*/
@JacksonXmlProperty(localName = "SN")
private String sn;
/**
* 目标设备的设备编码(必选)
*/
@JacksonXmlProperty(localName = "DeviceID")
private String deviceId;
@NotNull
@JsonFormat(pattern = DatePattern.UTC_SIMPLE_PATTERN, timezone = GB28181Constant.TIME_ZONE)
private Date startTime;

View File

@ -0,0 +1,39 @@
package cn.skcks.docking.gb28181.core.sip.message.processor.message.types.recordinfo.reponse.dto;
import cn.hutool.core.date.DatePattern;
import cn.skcks.docking.gb28181.core.sip.gb28181.constant.GB28181Constant;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import jakarta.validation.constraints.Min;
import lombok.Builder;
import lombok.Data;
import java.util.Date;
@Data
@JacksonXmlRootElement(localName = "Item")
public class RecordInfoItemDTO {
/**
* 目标设备的设备编码(必选)
*/
@JacksonXmlProperty(localName = "DeviceID")
private String deviceId;
private String name;
private String address;
@JsonFormat(pattern = DatePattern.UTC_SIMPLE_PATTERN, timezone = GB28181Constant.TIME_ZONE)
private Date startTime;
@JsonFormat(pattern = DatePattern.UTC_SIMPLE_PATTERN, timezone = GB28181Constant.TIME_ZONE)
private Date endTime;
@Min(value = 0)
private Integer Secrecy = 0;
private String type = "all";
private Long fileSize;
}

View File

@ -0,0 +1,38 @@
package cn.skcks.docking.gb28181.core.sip.message.processor.message.types.recordinfo.reponse.dto;
import cn.skcks.docking.gb28181.core.sip.gb28181.constant.CmdType;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import lombok.Builder;
import lombok.Data;
import java.util.List;
@Data
@JacksonXmlRootElement(localName = "Response")
public class RecordInfoResponseDTO {
/**
* 命令类型:设备信息查询(必选)
*/
private String cmdType = CmdType.RECORD_INFO;
/**
* 命令序列号(必选)
*/
@JacksonXmlProperty(localName = "SN")
private String sn;
/**
* 目标设备的设备编码(必选)
*/
@JacksonXmlProperty(localName = "DeviceID")
private String deviceId;
private String name;
private Long sumNum;
@JacksonXmlElementWrapper
private List<RecordInfoItemDTO> recordList;
}

View File

@ -1,9 +1,8 @@
package cn.skcks.docking.gb28181.service.record;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import cn.skcks.docking.gb28181.common.xml.XmlUtils;
import cn.skcks.docking.gb28181.core.sip.message.processor.record.dto.RecordInfoRequestDTO;
import cn.skcks.docking.gb28181.core.sip.message.processor.message.types.recordinfo.query.dto.RecordInfoRequestDTO;
import cn.skcks.docking.gb28181.core.sip.message.request.SipRequestBuilder;
import cn.skcks.docking.gb28181.core.sip.message.sender.SipMessageSender;
import cn.skcks.docking.gb28181.core.sip.service.SipService;

View File

@ -3,14 +3,15 @@ package cn.skcks.docking.gb28181.core.sip.message.dto;
import cn.hutool.core.date.DateUtil;
import cn.skcks.docking.gb28181.common.json.JsonUtils;
import cn.skcks.docking.gb28181.common.xml.XmlUtils;
import cn.skcks.docking.gb28181.core.sip.message.processor.record.dto.RecordInfoRequestDTO;
import cn.skcks.docking.gb28181.core.sip.message.processor.message.types.recordinfo.query.dto.RecordInfoRequestDTO;
import cn.skcks.docking.gb28181.core.sip.message.processor.message.types.recordinfo.reponse.dto.RecordInfoResponseDTO;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
@Slf4j
public class DTOTest {
@Test
void test(){
void recordInfoTest(){
RecordInfoRequestDTO dto = new RecordInfoRequestDTO();
dto.setCmdType("RecordInfo");
dto.setDeviceId("44050100001310000006");
@ -21,5 +22,39 @@ public class DTOTest {
log.info("\n{}", xml);
log.info("{}", XmlUtils.parse(xml,RecordInfoRequestDTO.class));
log.info("\n{}", JsonUtils.toJson(dto));
String response = "<?xml version=\"1.0\" encoding=\"GB2312\"?>\n" +
"<Response>\n" +
"<CmdType>RecordInfo</CmdType>\n" +
"<SN>100000</SN>\n" +
"<DeviceID>44050100001110000009</DeviceID>\n" +
"<Name>Happytimesoft</Name>\n" +
"<SumNum>10</SumNum>\n" +
"<RecordList Num=\"2\">\n" +
"<Item>\n" +
"<DeviceID>44050100001110000009</DeviceID>\n" +
"<Name>Happytimesoft</Name>\n" +
"<Address></Address>\n" +
"<StartTime>2023-08-22T00:00:00</StartTime>\n" +
"<EndTime>2023-08-22T00:10:00</EndTime>\n" +
"<Secrecy>0</Secrecy>\n" +
"<Type>time</Type>\n" +
"<FileSize>10485760</FileSize>\n" +
"</Item>\n" +
"<Item>\n" +
"<DeviceID>44050100001110000009</DeviceID>\n" +
"<Name>Happytimesoft</Name>\n" +
"<Address></Address>\n" +
"<StartTime>2023-08-22T00:10:00</StartTime>\n" +
"<EndTime>2023-08-22T00:20:00</EndTime>\n" +
"<Secrecy>0</Secrecy>\n" +
"<Type>time</Type>\n" +
"<FileSize>10485760</FileSize>\n" +
"</Item>\n" +
"</RecordList>\n" +
"</Response>";
RecordInfoResponseDTO responseDTO = XmlUtils.parse(response, RecordInfoResponseDTO.class);
log.info("{}", responseDTO);
log.info("\n{}", JsonUtils.toJson(responseDTO));
}
}