Group.java 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. package com.genersoft.iot.vmp.gb28181.bean;
  2. import com.genersoft.iot.vmp.utils.DateUtil;
  3. import io.swagger.v3.oas.annotations.media.Schema;
  4. import lombok.Data;
  5. import org.jetbrains.annotations.NotNull;
  6. /**
  7. * 业务分组
  8. */
  9. @Data
  10. @Schema(description = "业务分组")
  11. public class Group implements Comparable<Group>{
  12. /**
  13. * 数据库自增ID
  14. */
  15. @Schema(description = "数据库自增ID")
  16. private int id;
  17. /**
  18. * 区域国标编号
  19. */
  20. @Schema(description = "区域国标编号")
  21. private String deviceId;
  22. /**
  23. * 区域名称
  24. */
  25. @Schema(description = "区域名称")
  26. private String name;
  27. /**
  28. * 父区域国标ID
  29. */
  30. @Schema(description = "父区域国标ID")
  31. private String parentDeviceId;
  32. /**
  33. * 所属的业务分组国标编号
  34. */
  35. @Schema(description = "所属的业务分组国标编号")
  36. private String businessGroup;
  37. /**
  38. * 创建时间
  39. */
  40. @Schema(description = "创建时间")
  41. private String createTime;
  42. /**
  43. * 更新时间
  44. */
  45. @Schema(description = "更新时间")
  46. private String updateTime;
  47. /**
  48. * 平台ID
  49. */
  50. @Schema(description = "平台ID")
  51. private Integer platformId;
  52. public static Group getInstance(DeviceChannel channel) {
  53. GbCode gbCode = GbCode.decode(channel.getDeviceId());
  54. if (gbCode == null || (!gbCode.getTypeCode().equals("215") && !gbCode.getTypeCode().equals("216"))) {
  55. return null;
  56. }
  57. Group group = new Group();
  58. group.setName(channel.getName());
  59. group.setDeviceId(channel.getDeviceId());
  60. group.setCreateTime(DateUtil.getNow());
  61. group.setUpdateTime(DateUtil.getNow());
  62. if (gbCode.getTypeCode().equals("215")) {
  63. group.setBusinessGroup(channel.getDeviceId());
  64. }else if (gbCode.getTypeCode().equals("216")) {
  65. group.setBusinessGroup(channel.getBusinessGroupId());
  66. group.setParentDeviceId(channel.getParentId());
  67. }
  68. if (group.getBusinessGroup() == null) {
  69. return null;
  70. }
  71. return group;
  72. }
  73. @Override
  74. public int compareTo(@NotNull Group region) {
  75. return Integer.compare(Integer.parseInt(this.deviceId), Integer.parseInt(region.getDeviceId()));
  76. }
  77. }