CommonGBChannel.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. package com.genersoft.iot.vmp.gb28181.bean;
  2. import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
  3. import io.swagger.v3.oas.annotations.media.Schema;
  4. import lombok.Data;
  5. @Data
  6. @Schema(description = "国标通道")
  7. public class CommonGBChannel {
  8. @Schema(description = "国标-数据库自增ID")
  9. private int gbId;
  10. @Schema(description = "国标-编码")
  11. private String gbDeviceId;
  12. @Schema(description = "国标-名称")
  13. private String gbName;
  14. @Schema(description = "国标-设备厂商")
  15. private String gbManufacturer;
  16. @Schema(description = "国标-设备型号")
  17. private String gbModel;
  18. // 2016
  19. @Schema(description = "国标-设备归属")
  20. private String gbOwner;
  21. @Schema(description = "国标-行政区域")
  22. private String gbCivilCode;
  23. @Schema(description = "国标-警区")
  24. private String gbBlock;
  25. @Schema(description = "国标-安装地址")
  26. private String gbAddress;
  27. @Schema(description = "国标-是否有子设备")
  28. private Integer gbParental;
  29. @Schema(description = "国标-父节点ID")
  30. private String gbParentId;
  31. // 2016
  32. @Schema(description = "国标-信令安全模式")
  33. private Integer gbSafetyWay;
  34. @Schema(description = "国标-注册方式")
  35. private Integer gbRegisterWay;
  36. // 2016
  37. @Schema(description = "国标-证书序列号")
  38. private Integer gbCertNum;
  39. // 2016
  40. @Schema(description = "国标-证书有效标识")
  41. private Integer gbCertifiable;
  42. // 2016
  43. @Schema(description = "国标-无效原因码(有证书且证书无效的设备必选)")
  44. private Integer gbErrCode;
  45. // 2016
  46. @Schema(description = "国标-证书终止有效期(有证书且证书无效的设备必选)")
  47. private Integer gbEndTime;
  48. // 2022
  49. @Schema(description = "国标-摄像机安全能力等级代码")
  50. private String gbSecurityLevelCode;
  51. @Schema(description = "国标-保密属性(必选)缺省为0;0-不涉密,1-涉密")
  52. private Integer gbSecrecy;
  53. @Schema(description = "国标-设备/系统IPv4/IPv6地址")
  54. private String gbIpAddress;
  55. @Schema(description = "国标-设备/系统端口")
  56. private Integer gbPort;
  57. @Schema(description = "国标-设备口令")
  58. private String gbPassword;
  59. @Schema(description = "国标-设备状态")
  60. private String gbStatus;
  61. @Schema(description = "国标-经度 WGS-84坐标系")
  62. private Double gbLongitude;
  63. @Schema(description = "国标-纬度 WGS-84坐标系")
  64. private Double gbLatitude;
  65. @Schema(description = "国标-虚拟组织所属的业务分组ID")
  66. private String gbBusinessGroupId;
  67. @Schema(description = "国标-摄像机结构类型,标识摄像机类型: 1-球机; 2-半球; 3-固定枪机; 4-遥控枪机;5-遥控半球;6-多目设备的全景/拼接通道;7-多目设备的分割通道")
  68. private Integer gbPtzType;
  69. // 2016
  70. @Schema(description = "-摄像机位置类型扩展。1-省际检查站、2-党政机关、3-车站码头、4-中心广场、5-体育场馆、6-商业中心、7-宗教场所、" +
  71. "8-校园周边、9-治安复杂区域、10-交通干线。当目录项为摄像机时可选。")
  72. private Integer gbPositionType;
  73. @Schema(description = "国标-摄像机光电成像类型。1-可见光成像;2-热成像;3-雷达成像;4-X光成像;5-深度光场成像;9-其他。可多值,")
  74. private String gbPhotoelectricImagingTyp;
  75. @Schema(description = "国标-摄像机采集部位类型")
  76. private String gbCapturePositionType;
  77. @Schema(description = "国标-摄像机安装位置室外、室内属性。1-室外、2-室内。")
  78. private Integer gbRoomType;
  79. // 2016
  80. @Schema(description = "国标-用途属性")
  81. private Integer gbUseType;
  82. @Schema(description = "国标-摄像机补光属性。1-无补光;2-红外补光;3-白光补光;4-激光补光;9-其他")
  83. private Integer gbSupplyLightType;
  84. @Schema(description = "国标-摄像机监视方位(光轴方向)属性。1-东(西向东)、2-西(东向西)、3-南(北向南)、4-北(南向北)、" +
  85. "5-东南(西北到东南)、6-东北(西南到东北)、7-西南(东北到西南)、8-西北(东南到西北)")
  86. private Integer gbDirectionType;
  87. @Schema(description = "国标-摄像机支持的分辨率,可多值")
  88. private String gbResolution;
  89. // 2022
  90. @Schema(description = "国标-摄像机支持的码流编号列表,用于实时点播时指定码流编号(可选)")
  91. private String gbStreamNumberList;
  92. @Schema(description = "国标-下载倍速(可选),可多值")
  93. private String gbDownloadSpeed;
  94. @Schema(description = "国标-空域编码能力,取值0-不支持;1-1级增强(1个增强层);2-2级增强(2个增强层);3-3级增强(3个增强层)")
  95. private Integer gbSvcSpaceSupportMod;
  96. @Schema(description = "国标-时域编码能力,取值0-不支持;1-1级增强;2-2级增强;3-3级增强(可选)")
  97. private Integer gbSvcTimeSupportMode;
  98. // 2022
  99. @Schema(description = "国标- SSVC增强层与基本层比例能力 ")
  100. private String gbSsvcRatioSupportList;
  101. // 2022
  102. @Schema(description = "国标-移动采集设备类型(仅移动采集设备适用,必选);1-移动机器人载摄像机;2-执法记录仪;3-移动单兵设备;" +
  103. "4-车载视频记录设备;5-无人机载摄像机;9-其他")
  104. private Integer gbMobileDeviceType;
  105. // 2022
  106. @Schema(description = "国标-摄像机水平视场角(可选),取值范围大于0度小于等于360度")
  107. private Double gbHorizontalFieldAngle;
  108. // 2022
  109. @Schema(description = "国标-摄像机竖直视场角(可选),取值范围大于0度小于等于360度 ")
  110. private Double gbVerticalFieldAngle;
  111. // 2022
  112. @Schema(description = "国标-摄像机可视距离(可选),单位:米")
  113. private Double gbMaxViewDistance;
  114. // 2022
  115. @Schema(description = "国标-基层组织编码(必选,非基层建设时为“000000”)")
  116. private String gbGrassrootsCode;
  117. // 2022
  118. @Schema(description = "国标-监控点位类型(当为摄像机时必选),1-一类视频监控点;2-二类视频监控点;3-三类视频监控点;9-其他点位。")
  119. private Integer gbPoType;
  120. // 2022
  121. @Schema(description = "国标-点位俗称")
  122. private String gbPoCommonName;
  123. // 2022
  124. @Schema(description = "国标-设备MAC地址(可选),用“XX-XX-XX-XX-XX-XX”格式表达")
  125. private String gbMac;
  126. // 2022
  127. @Schema(description = "国标-摄像机卡口功能类型,01-人脸卡口;02-人员卡口;03-机动车卡口;04-非机动车卡口;05-物品卡口;99-其他")
  128. private String gbFunctionType;
  129. // 2022
  130. @Schema(description = "国标-摄像机视频编码格式")
  131. private String gbEncodeType;
  132. // 2022
  133. @Schema(description = "国标-摄像机安装使用时间")
  134. private String gbInstallTime;
  135. // 2022
  136. @Schema(description = "国标-摄像机所属管理单位名称")
  137. private String gbManagementUnit;
  138. // 2022
  139. @Schema(description = "国标-摄像机所属管理单位联系人的联系方式(电话号码,可多值,用英文半角“/”分割)")
  140. private String gbContactInfo;
  141. // 2022
  142. @Schema(description = "国标-录像保存天数(可选)")
  143. private Integer gbRecordSaveDays;
  144. // 2022
  145. @Schema(description = "国标-国民经济行业分类代码(可选)")
  146. private String gbIndustrialClassification;
  147. @Schema(description = "关联的国标设备数据库ID")
  148. private Integer gbDeviceDbId;
  149. @Schema(description = "关联的推流Id(流来源是推流时有效)")
  150. private Integer streamPushId;
  151. @Schema(description = "关联的拉流代理Id(流来源是拉流代理时有效)")
  152. private Integer streamProxyId;
  153. @Schema(description = "创建时间")
  154. private String createTime;
  155. @Schema(description = "更新时间")
  156. private String updateTime;
  157. public String encode(String serverDeviceId) {
  158. return encode(null, serverDeviceId);
  159. }
  160. public String encode(String event,String serverDeviceId) {
  161. String content;
  162. if (event == null) {
  163. return getFullContent(null, serverDeviceId);
  164. }
  165. switch (event) {
  166. case CatalogEvent.DEL:
  167. case CatalogEvent.DEFECT:
  168. case CatalogEvent.VLOST:
  169. content = "<Item>\n" +
  170. "<DeviceID>" + this.getGbDeviceId() + "</DeviceID>\n" +
  171. "<Event>" + event + "</Event>\n" +
  172. "</Item>\n";
  173. break;
  174. case CatalogEvent.ON:
  175. case CatalogEvent.OFF:
  176. content = "<Item>\n" +
  177. "<DeviceID>" + this.getGbDeviceId() + "</DeviceID>\n" +
  178. "<Event>" + event + "</Event>\r\n" +
  179. "</Item>\n";
  180. break;
  181. case CatalogEvent.ADD:
  182. case CatalogEvent.UPDATE:
  183. content = getFullContent(event, serverDeviceId);
  184. break;
  185. default:
  186. content = null;
  187. break;
  188. }
  189. return content;
  190. }
  191. private String getFullContent(String event, String serverDeviceId) {
  192. StringBuilder content = new StringBuilder();
  193. // 行政区划目录项
  194. content.append("<Item>\n")
  195. .append("<DeviceID>" + this.getGbDeviceId() + "</DeviceID>\n")
  196. .append("<Name>" + this.getGbName() + "</Name>\n");
  197. if (this.getGbDeviceId().length() > 8) {
  198. String type = this.getGbDeviceId().substring(10, 13);
  199. if (type.equals("200")) {
  200. // 业务分组目录项
  201. if (this.getGbManufacturer() != null) {
  202. content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n");
  203. }
  204. if (this.getGbModel() != null) {
  205. content.append("<Model>" + this.getGbModel() + "</Model>\n");
  206. }
  207. if (this.getGbOwner() != null) {
  208. content.append("<Owner>" + this.getGbOwner() + "</Owner>\n");
  209. }
  210. if (this.getGbCivilCode() != null) {
  211. content.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n");
  212. }
  213. if (this.getGbAddress() != null) {
  214. content.append("<Address>" + this.getGbAddress() + "</Address>\n");
  215. }
  216. if (this.getGbRegisterWay() != null) {
  217. content.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n");
  218. }
  219. if (this.getGbSecrecy() != null) {
  220. content.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n");
  221. }
  222. } else if (type.equals("215")) {
  223. // 业务分组
  224. if (this.getGbCivilCode() != null) {
  225. content.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n");
  226. }
  227. content.append("<ParentID>" + serverDeviceId + "</ParentID>\n");
  228. } else if (type.equals("216")) {
  229. // 虚拟组织目录项
  230. if (this.getGbCivilCode() != null) {
  231. content.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n");
  232. }
  233. content.append("<ParentID>" + this.getGbParentId() + "</ParentID>\n")
  234. .append("<BusinessGroupID>" + this.getGbBusinessGroupId() + "</BusinessGroupID>\n");
  235. } else {
  236. if (this.getGbManufacturer() != null) {
  237. content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n");
  238. }
  239. if (this.getGbModel() != null) {
  240. content.append("<Model>" + this.getGbModel() + "</Model>\n");
  241. }
  242. if (this.getGbOwner() != null) {
  243. content.append("<Owner>" + this.getGbOwner() + "</Owner>\n");
  244. }
  245. if (this.getGbCivilCode() != null) {
  246. content.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n");
  247. }
  248. if (this.getGbAddress() != null) {
  249. content.append("<Address>" + this.getGbAddress() + "</Address>\n");
  250. }
  251. if (this.getGbRegisterWay() != null) {
  252. content.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n");
  253. }
  254. if (this.getGbSecrecy() != null) {
  255. content.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n");
  256. }
  257. if (this.getGbParentId() != null) {
  258. content.append("<ParentID>" + this.getGbParentId() + "</ParentID>\n");
  259. }
  260. if (this.getGbParental() != null) {
  261. content.append("<Parental>" + this.getGbParental() + "</Parental>\n");
  262. }
  263. if (this.getGbSafetyWay() != null) {
  264. content.append("<SafetyWay>" + this.getGbSafetyWay() + "</SafetyWay>\n");
  265. }
  266. if (this.getGbRegisterWay() != null) {
  267. content.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n");
  268. }
  269. if (this.getGbCertNum() != null) {
  270. content.append("<CertNum>" + this.getGbCertNum() + "</CertNum>\n");
  271. }
  272. if (this.getGbCertifiable() != null) {
  273. content.append("<Certifiable>" + this.getGbCertifiable() + "</Certifiable>\n");
  274. }
  275. if (this.getGbErrCode() != null) {
  276. content.append("<ErrCode>" + this.getGbErrCode() + "</ErrCode>\n");
  277. }
  278. if (this.getGbEndTime() != null) {
  279. content.append("<EndTime>" + this.getGbEndTime() + "</EndTime>\n");
  280. }
  281. if (this.getGbSecrecy() != null) {
  282. content.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n");
  283. }
  284. if (this.getGbIpAddress() != null) {
  285. content.append("<IPAddress>" + this.getGbIpAddress() + "</IPAddress>\n");
  286. }
  287. if (this.getGbPort() != null) {
  288. content.append("<Port>" + this.getGbPort() + "</Port>\n");
  289. }
  290. if (this.getGbPassword() != null) {
  291. content.append("<Password>" + this.getGbPassword() + "</Password>\n");
  292. }
  293. if (this.getGbStatus() != null) {
  294. content.append("<Status>" + this.getGbStatus() + "</Status>\n");
  295. }
  296. if (this.getGbLongitude() != null) {
  297. content.append("<Longitude>" + this.getGbLongitude() + "</Longitude>\n");
  298. }
  299. if (this.getGbLatitude() != null) {
  300. content.append("<Latitude>" + this.getGbLatitude() + "</Latitude>\n");
  301. }
  302. content.append("<Info>\n");
  303. if (this.getGbPtzType() != null) {
  304. content.append(" <PTZType>" + this.getGbPtzType() + "</PTZType>\n");
  305. }
  306. if (this.getGbPositionType() != null) {
  307. content.append(" <PositionType>" + this.getGbPositionType() + "</PositionType>\n");
  308. }
  309. if (this.getGbRoomType() != null) {
  310. content.append(" <RoomType>" + this.getGbRoomType() + "</RoomType>\n");
  311. }
  312. if (this.getGbUseType() != null) {
  313. content.append(" <UseType>" + this.getGbUseType() + "</UseType>\n");
  314. }
  315. if (this.getGbSupplyLightType() != null) {
  316. content.append(" <SupplyLightType>" + this.getGbSupplyLightType() + "</SupplyLightType>\n");
  317. }
  318. if (this.getGbDirectionType() != null) {
  319. content.append(" <DirectionType>" + this.getGbDirectionType() + "</DirectionType>\n");
  320. }
  321. if (this.getGbResolution() != null) {
  322. content.append(" <Resolution>" + this.getGbResolution() + "</Resolution>\n");
  323. }
  324. if (this.getGbBusinessGroupId() != null) {
  325. content.append(" <BusinessGroupID>" + this.getGbBusinessGroupId() + "</BusinessGroupID>\n");
  326. }
  327. if (this.getGbDownloadSpeed() != null) {
  328. content.append(" <DownloadSpeed>" + this.getGbDownloadSpeed() + "</DownloadSpeed>\n");
  329. }
  330. if (this.getGbSvcSpaceSupportMod() != null) {
  331. content.append(" <SVCSpaceSupportMode>" + this.getGbSvcSpaceSupportMod() + "</SVCSpaceSupportMode>\n");
  332. }
  333. if (this.getGbSvcTimeSupportMode() != null) {
  334. content.append(" <SVCTimeSupportMode>" + this.getGbSvcTimeSupportMode() + "</SVCTimeSupportMode>\n");
  335. }
  336. content.append("</Info>\n");
  337. }
  338. }
  339. if (event != null) {
  340. content.append("<Event>" + event + "</Event>\n");
  341. }
  342. content.append("</Item>\n");
  343. return content.toString();
  344. }
  345. public static CommonGBChannel build(Group group) {
  346. GbCode gbCode = GbCode.decode(group.getDeviceId());
  347. CommonGBChannel channel = new CommonGBChannel();
  348. if (gbCode.getTypeCode().equals("215")) {
  349. // 业务分组
  350. channel.setGbName(group.getName());
  351. channel.setGbDeviceId(group.getDeviceId());
  352. } else {
  353. // 虚拟组织
  354. channel.setGbName(group.getName());
  355. channel.setGbDeviceId(group.getDeviceId());
  356. channel.setGbParentId(group.getParentDeviceId());
  357. channel.setGbBusinessGroupId(group.getBusinessGroup());
  358. }
  359. return channel;
  360. }
  361. public static CommonGBChannel build(Platform platform) {
  362. CommonGBChannel commonGBChannel = new CommonGBChannel();
  363. commonGBChannel.setGbDeviceId(platform.getDeviceGBId());
  364. commonGBChannel.setGbName(platform.getName());
  365. commonGBChannel.setGbManufacturer(platform.getManufacturer());
  366. commonGBChannel.setGbModel(platform.getModel());
  367. commonGBChannel.setGbCivilCode(platform.getCivilCode());
  368. commonGBChannel.setGbAddress(platform.getAddress());
  369. commonGBChannel.setGbRegisterWay(platform.getRegisterWay());
  370. commonGBChannel.setGbSecrecy(platform.getSecrecy());
  371. commonGBChannel.setGbStatus(platform.isStatus() ? "ON" : "OFF");
  372. return commonGBChannel;
  373. }
  374. public static CommonGBChannel build(Region region) {
  375. CommonGBChannel commonGBChannel = new CommonGBChannel();
  376. commonGBChannel.setGbDeviceId(region.getDeviceId());
  377. commonGBChannel.setGbName(region.getName());
  378. return commonGBChannel;
  379. }
  380. }