DeviceChannel.java 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. package com.genersoft.iot.vmp.gb28181.bean;
  2. import com.genersoft.iot.vmp.gb28181.utils.MessageElement;
  3. import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
  4. import com.genersoft.iot.vmp.utils.CivilCodeUtil;
  5. import io.swagger.v3.oas.annotations.media.Schema;
  6. import lombok.Data;
  7. import lombok.EqualsAndHashCode;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.dom4j.Element;
  10. import org.springframework.util.ObjectUtils;
  11. import java.lang.reflect.InvocationTargetException;
  12. @Data
  13. @Slf4j
  14. @Schema(description = "通道信息")
  15. @EqualsAndHashCode(callSuper = true)
  16. public class DeviceChannel extends CommonGBChannel {
  17. @Schema(description = "数据库自增ID")
  18. private int id;
  19. @Schema(description = "设备的数据库自增ID")
  20. private Integer deviceDbId;
  21. @MessageElement("DeviceID")
  22. @Schema(description = "编码")
  23. private String deviceId;
  24. @MessageElement("Name")
  25. @Schema(description = "名称")
  26. private String name;
  27. @MessageElement("Manufacturer")
  28. @Schema(description = "设备厂商")
  29. private String manufacturer;
  30. @MessageElement("Model")
  31. @Schema(description = "设备型号")
  32. private String model;
  33. // 2016
  34. @MessageElement("Owner")
  35. @Schema(description = "设备归属")
  36. private String owner;
  37. @MessageElement("CivilCode")
  38. @Schema(description = "行政区域")
  39. private String civilCode;
  40. @MessageElement("Block")
  41. @Schema(description = "警区")
  42. private String block;
  43. @MessageElement("Address")
  44. @Schema(description = "安装地址")
  45. private String address;
  46. @MessageElement("Parental")
  47. @Schema(description = "是否有子设备(必选)1有,0没有")
  48. private Integer parental;
  49. @MessageElement("ParentID")
  50. @Schema(description = "父节点ID")
  51. private String parentId;
  52. // 2016
  53. @MessageElement("SafetyWay")
  54. @Schema(description = "信令安全模式")
  55. private Integer safetyWay;
  56. @MessageElement("RegisterWay")
  57. @Schema(description = "注册方式")
  58. private Integer registerWay;
  59. // 2016
  60. @MessageElement("CertNum")
  61. @Schema(description = "证书序列号")
  62. private String certNum;
  63. // 2016
  64. @MessageElement("Certifiable")
  65. @Schema(description = "证书有效标识, 缺省为0;证书有效标识:0:无效 1:有效")
  66. private Integer certifiable;
  67. // 2016
  68. @MessageElement("ErrCode")
  69. @Schema(description = "无效原因码(有证书且证书无效的设备必选)")
  70. private Integer errCode;
  71. // 2016
  72. @MessageElement("EndTime")
  73. @Schema(description = "证书终止有效期(有证书且证书无效的设备必选)")
  74. private String endTime;
  75. @MessageElement("Secrecy")
  76. @Schema(description = "保密属性(必选)缺省为0;0-不涉密,1-涉密")
  77. private Integer secrecy;
  78. @MessageElement("IPAddress")
  79. @Schema(description = "设备/系统IPv4/IPv6地址")
  80. private String ipAddress;
  81. @MessageElement("Port")
  82. @Schema(description = "设备/系统端口")
  83. private Integer port;
  84. @MessageElement("Password")
  85. @Schema(description = "设备口令")
  86. private String password;
  87. @MessageElement("Status")
  88. @Schema(description = "设备状态")
  89. private String status;
  90. @MessageElement("Longitude")
  91. @Schema(description = "经度 WGS-84坐标系")
  92. private Double longitude;
  93. @MessageElement("Latitude")
  94. @Schema(description = ",纬度 WGS-84坐标系")
  95. private Double latitude;
  96. @MessageElement("Info.PTZType")
  97. @Schema(description = "摄像机结构类型,标识摄像机类型: 1-球机; 2-半球; 3-固定枪机; 4-遥控枪机;5-遥控半球;6-多目设备的全景/拼接通道;7-多目设备的分割通道")
  98. private Integer ptzType;
  99. @MessageElement("Info.PositionType")
  100. @Schema(description = "摄像机位置类型扩展。1-省际检查站、2-党政机关、3-车站码头、4-中心广场、5-体育场馆、" +
  101. "6-商业中心、7-宗教场所、8-校园周边、9-治安复杂区域、10-交通干线")
  102. private Integer positionType;
  103. @MessageElement("Info.RoomType")
  104. @Schema(description = "摄像机安装位置室外、室内属性。1-室外、2-室内。")
  105. private Integer roomType;
  106. @MessageElement("Info.UseType")
  107. @Schema(description = "用途属性, 1-治安、2-交通、3-重点。")
  108. private Integer useType;
  109. @MessageElement("Info.SupplyLightType")
  110. @Schema(description = "摄像机补光属性。1-无补光;2-红外补光;3-白光补光;4-激光补光;9-其他")
  111. private Integer supplyLightType;
  112. @MessageElement("Info.DirectionType")
  113. @Schema(description = "摄像机监视方位(光轴方向)属性。1-东(西向东)、2-西(东向西)、3-南(北向南)、4-北(南向北)、" +
  114. "5-东南(西北到东南)、6-东北(西南到东北)、7-西南(东北到西南)、8-西北(东南到西北)")
  115. private Integer directionType;
  116. @MessageElement("Info.Resolution")
  117. @Schema(description = "摄像机支持的分辨率,可多值")
  118. private String resolution;
  119. @MessageElement("Info.BusinessGroupID")
  120. @Schema(description = "虚拟组织所属的业务分组ID")
  121. private String businessGroupId;
  122. @MessageElement("Info.DownloadSpeed")
  123. @Schema(description = "下载倍速(可选),可多值")
  124. private String downloadSpeed;
  125. @MessageElement("Info.SVCSpaceSupportMode")
  126. @Schema(description = "空域编码能力,取值0-不支持;1-1级增强(1个增强层);2-2级增强(2个增强层);3-3级增强(3个增强层)")
  127. private Integer svcSpaceSupportMod;
  128. @MessageElement("Info.SVCTimeSupportMode")
  129. @Schema(description = "时域编码能力,取值0-不支持;1-1级增强;2-2级增强;3-3级增强(可选)")
  130. private Integer svcTimeSupportMode;
  131. @Schema(description = "云台类型描述字符串")
  132. private String ptzTypeText;
  133. @Schema(description = "子设备数")
  134. private int subCount;
  135. @Schema(description = "流唯一编号,存在表示正在直播")
  136. private String streamId;
  137. @Schema(description = "是否含有音频")
  138. private boolean hasAudio;
  139. @Schema(description = "GPS的更新时间")
  140. private String gpsTime;
  141. @Schema(description = "码流标识,优先级高于设备中码流标识," +
  142. "用于选择码流时组成码流标识。默认为null,不设置。可选值: stream/streamnumber/streamprofile/streamMode")
  143. private String streamIdentification;
  144. public void setPtzType(int ptzType) {
  145. this.ptzType = ptzType;
  146. switch (ptzType) {
  147. case 0:
  148. this.ptzTypeText = "未知";
  149. break;
  150. case 1:
  151. this.ptzTypeText = "球机";
  152. break;
  153. case 2:
  154. this.ptzTypeText = "半球";
  155. break;
  156. case 3:
  157. this.ptzTypeText = "固定枪机";
  158. break;
  159. case 4:
  160. this.ptzTypeText = "遥控枪机";
  161. break;
  162. case 5:
  163. this.ptzTypeText = "遥控半球";
  164. break;
  165. case 6:
  166. this.ptzTypeText = "多目设备的全景/拼接通道";
  167. break;
  168. case 7:
  169. this.ptzTypeText = "多目设备的分割通道";
  170. break;
  171. }
  172. }
  173. public static DeviceChannel decode(Element element) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
  174. DeviceChannel deviceChannel = XmlUtil.elementDecode(element, DeviceChannel.class);
  175. if(deviceChannel.getCivilCode() != null ) {
  176. if (ObjectUtils.isEmpty(deviceChannel.getCivilCode())
  177. || deviceChannel.getCivilCode().length() > 8 ){
  178. deviceChannel.setCivilCode(null);
  179. }else {
  180. if (CivilCodeUtil.INSTANCE.getCivilCodePo(deviceChannel.getCivilCode()) == null) {
  181. deviceChannel.setCivilCode(null);
  182. }
  183. }
  184. }
  185. return XmlUtil.elementDecode(element, DeviceChannel.class);
  186. }
  187. public static DeviceChannel decodeWithOnlyDeviceId(Element element) {
  188. Element deviceElement = element.element("DeviceID");
  189. DeviceChannel deviceChannel = new DeviceChannel();
  190. deviceChannel.setDeviceId(deviceElement.getText());
  191. return deviceChannel;
  192. }
  193. }