From fb7a911c6f9871d4697a797e145650d93f7157bf Mon Sep 17 00:00:00 2001 From: shikong <919411476@qq.com> Date: Tue, 22 Aug 2023 17:21:15 +0800 Subject: [PATCH] =?UTF-8?q?RecordInfoResponseDTO=20=E5=AE=9E=E4=BD=93?= =?UTF-8?q?=E7=B1=BB=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../query}/dto/RecordInfoRequestDTO.java | 15 +++++-- .../reponse/dto/RecordInfoItemDTO.java | 39 +++++++++++++++++++ .../reponse/dto/RecordInfoResponseDTO.java | 38 ++++++++++++++++++ .../gb28181/service/record/RecordService.java | 3 +- .../gb28181/core/sip/message/dto/DTOTest.java | 39 ++++++++++++++++++- 5 files changed, 127 insertions(+), 7 deletions(-) rename gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/{record => message/types/recordinfo/query}/dto/RecordInfoRequestDTO.java (76%) create mode 100644 gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/reponse/dto/RecordInfoItemDTO.java create mode 100644 gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/reponse/dto/RecordInfoResponseDTO.java diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/record/dto/RecordInfoRequestDTO.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/query/dto/RecordInfoRequestDTO.java similarity index 76% rename from gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/record/dto/RecordInfoRequestDTO.java rename to gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/query/dto/RecordInfoRequestDTO.java index e50883d..6908a40 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/record/dto/RecordInfoRequestDTO.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/query/dto/RecordInfoRequestDTO.java @@ -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; diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/reponse/dto/RecordInfoItemDTO.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/reponse/dto/RecordInfoItemDTO.java new file mode 100644 index 0000000..5197701 --- /dev/null +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/reponse/dto/RecordInfoItemDTO.java @@ -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; +} diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/reponse/dto/RecordInfoResponseDTO.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/reponse/dto/RecordInfoResponseDTO.java new file mode 100644 index 0000000..aaf5c73 --- /dev/null +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/core/sip/message/processor/message/types/recordinfo/reponse/dto/RecordInfoResponseDTO.java @@ -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 recordList; +} diff --git a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/record/RecordService.java b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/record/RecordService.java index 17c5437..75a5ec7 100644 --- a/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/record/RecordService.java +++ b/gb28181-service/src/main/java/cn/skcks/docking/gb28181/service/record/RecordService.java @@ -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; diff --git a/gb28181-service/src/test/java/cn/skcks/docking/gb28181/core/sip/message/dto/DTOTest.java b/gb28181-service/src/test/java/cn/skcks/docking/gb28181/core/sip/message/dto/DTOTest.java index 93d0d8d..ca295fb 100644 --- a/gb28181-service/src/test/java/cn/skcks/docking/gb28181/core/sip/message/dto/DTOTest.java +++ b/gb28181-service/src/test/java/cn/skcks/docking/gb28181/core/sip/message/dto/DTOTest.java @@ -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 = "\n" + + "\n" + + "RecordInfo\n" + + "100000\n" + + "44050100001110000009\n" + + "Happytimesoft\n" + + "10\n" + + "\n" + + "\n" + + "44050100001110000009\n" + + "Happytimesoft\n" + + "
\n" + + "2023-08-22T00:00:00\n" + + "2023-08-22T00:10:00\n" + + "0\n" + + "time\n" + + "10485760\n" + + "
\n" + + "\n" + + "44050100001110000009\n" + + "Happytimesoft\n" + + "
\n" + + "2023-08-22T00:10:00\n" + + "2023-08-22T00:20:00\n" + + "0\n" + + "time\n" + + "10485760\n" + + "
\n" + + "
\n" + + "
"; + RecordInfoResponseDTO responseDTO = XmlUtils.parse(response, RecordInfoResponseDTO.class); + log.info("{}", responseDTO); + log.info("\n{}", JsonUtils.toJson(responseDTO)); } }