package com.ard.gb28181.api.domain;
import com.ard.gb28181.api.common.CatalogEvent;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
@Data
@Schema(description = "国标通道")
public class CommonGBChannel implements Serializable {
@Schema(description = "国标-数据库自增ID")
private int gbId;
@Schema(description = "国标-编码")
private String gbDeviceId;
@Schema(description = "国标-名称")
private String gbName;
@Schema(description = "国标-设备厂商")
private String gbManufacturer;
@Schema(description = "国标-设备型号")
private String gbModel;
// 2016
@Schema(description = "国标-设备归属")
private String gbOwner;
@Schema(description = "国标-行政区域")
private String gbCivilCode;
@Schema(description = "国标-警区")
private String gbBlock;
@Schema(description = "国标-安装地址")
private String gbAddress;
@Schema(description = "国标-是否有子设备")
private Integer gbParental;
@Schema(description = "国标-父节点ID")
private String gbParentId;
// 2016
@Schema(description = "国标-信令安全模式")
private Integer gbSafetyWay;
@Schema(description = "国标-注册方式")
private Integer gbRegisterWay;
// 2016
@Schema(description = "国标-证书序列号")
private String gbCertNum;
// 2016
@Schema(description = "国标-证书有效标识")
private Integer gbCertifiable;
// 2016
@Schema(description = "国标-无效原因码(有证书且证书无效的设备必选)")
private Integer gbErrCode;
// 2016
@Schema(description = "国标-证书终止有效期(有证书且证书无效的设备必选)")
private String gbEndTime;
@Schema(description = "国标-保密属性(必选)缺省为0;0-不涉密,1-涉密")
private Integer gbSecrecy;
@Schema(description = "国标-设备/系统IPv4/IPv6地址")
private String gbIpAddress;
@Schema(description = "国标-设备/系统端口")
private Integer gbPort;
@Schema(description = "国标-设备口令")
private String gbPassword;
@Schema(description = "国标-设备状态")
private String gbStatus;
@Schema(description = "国标-经度 WGS-84坐标系")
private Double gbLongitude;
@Schema(description = "国标-纬度 WGS-84坐标系")
private Double gbLatitude;
private Double gpsAltitude;
private Double gpsSpeed;
private Double gpsDirection;
private String gpsTime;
@Schema(description = "国标-虚拟组织所属的业务分组ID")
private String gbBusinessGroupId;
@Schema(description = "国标-摄像机结构类型,标识摄像机类型: 1-球机; 2-半球; 3-固定枪机; 4-遥控枪机;5-遥控半球;6-多目设备的全景/拼接通道;" +
"7-多目设备的分割通道; 99-移动设备(非标)98-会议设备(非标)")
private Integer gbPtzType;
// 2016
@Schema(description = "-摄像机位置类型扩展。1-省际检查站、2-党政机关、3-车站码头、4-中心广场、5-体育场馆、6-商业中心、7-宗教场所、" +
"8-校园周边、9-治安复杂区域、10-交通干线。当目录项为摄像机时可选。")
private Integer gbPositionType;
@Schema(description = "国标-摄像机安装位置室外、室内属性。1-室外、2-室内。")
private Integer gbRoomType;
// 2016
@Schema(description = "国标-用途属性")
private Integer gbUseType;
@Schema(description = "国标-摄像机补光属性。1-无补光;2-红外补光;3-白光补光;4-激光补光;9-其他")
private Integer gbSupplyLightType;
@Schema(description = "国标-摄像机监视方位(光轴方向)属性。1-东(西向东)、2-西(东向西)、3-南(北向南)、4-北(南向北)、" +
"5-东南(西北到东南)、6-东北(西南到东北)、7-西南(东北到西南)、8-西北(东南到西北)")
private Integer gbDirectionType;
@Schema(description = "国标-摄像机支持的分辨率,可多值")
private String gbResolution;
@Schema(description = "国标-下载倍速(可选),可多值")
private String gbDownloadSpeed;
@Schema(description = "国标-空域编码能力,取值0-不支持;1-1级增强(1个增强层);2-2级增强(2个增强层);3-3级增强(3个增强层)")
private Integer gbSvcSpaceSupportMod;
@Schema(description = "国标-时域编码能力,取值0-不支持;1-1级增强;2-2级增强;3-3级增强(可选)")
private Integer gbSvcTimeSupportMode;
@Schema(description = "二进制保存的录制计划, 每一位表示每个小时的前半个小时")
private Long recordPLan;
@Schema(description = "关联的数据类型")
private Integer dataType;
@Schema(description = "关联的设备ID")
private Integer dataDeviceId;
@Schema(description = "创建时间")
private String createTime;
@Schema(description = "更新时间")
private String updateTime;
@Schema(description = "流唯一编号,存在表示正在直播")
private String streamId;
@Schema(description = "是否支持对讲 1支持,0不支持")
private Integer enableBroadcast;
@Schema(description = "抽稀后的图层层级")
private Integer mapLevel;
public String encode(String serverDeviceId) {
return encode(null, serverDeviceId);
}
public String encode(String event,String serverDeviceId) {
String content;
if (event == null) {
return getFullContent(null, serverDeviceId);
}
switch (event) {
case CatalogEvent.DEL:
case CatalogEvent.DEFECT:
case CatalogEvent.VLOST:
content = "- \n" +
"" + this.getGbDeviceId() + "\n" +
"" + event + "\n" +
"
\n";
break;
case CatalogEvent.ON:
case CatalogEvent.OFF:
content = "- \n" +
"" + this.getGbDeviceId() + "\n" +
"" + event + "\r\n" +
"
\n";
break;
case CatalogEvent.ADD:
case CatalogEvent.UPDATE:
content = getFullContent(event, serverDeviceId);
break;
default:
content = null;
break;
}
return content;
}
private String getFullContent(String event, String serverDeviceId) {
StringBuilder content = new StringBuilder();
// 行政区划目录项
content.append("- \n")
.append("" + this.getGbDeviceId() + "\n")
.append("" + this.getGbName() + "\n");
if (this.getGbDeviceId().length() > 8) {
String type = this.getGbDeviceId().substring(10, 13);
if (type.equals("200")) {
// 业务分组目录项
if (this.getGbManufacturer() != null) {
content.append("" + this.getGbManufacturer() + "\n");
}
if (this.getGbModel() != null) {
content.append("" + this.getGbModel() + "\n");
}
if (this.getGbOwner() != null) {
content.append("" + this.getGbOwner() + "\n");
}
if (this.getGbCivilCode() != null) {
content.append("" + this.getGbCivilCode() + "\n");
}
if (this.getGbAddress() != null) {
content.append("" + this.getGbAddress() + "\n");
}
if (this.getGbRegisterWay() != null) {
content.append("" + this.getGbRegisterWay() + "\n");
}
if (this.getGbSecrecy() != null) {
content.append("" + this.getGbSecrecy() + "\n");
}
} else if (type.equals("215")) {
// 业务分组
if (this.getGbCivilCode() != null) {
content.append("" + this.getGbCivilCode() + "\n");
}
content.append("" + serverDeviceId + "\n");
} else if (type.equals("216")) {
// 虚拟组织目录项
if (this.getGbCivilCode() != null) {
content.append("" + this.getGbCivilCode() + "\n");
}
if (this.getGbParentId() != null) {
content.append("" + this.getGbParentId() + "\n");
}
content.append("" + this.getGbBusinessGroupId() + "\n");
} else {
if (this.getGbManufacturer() != null) {
content.append("" + this.getGbManufacturer() + "\n");
}
if (this.getGbModel() != null) {
content.append("" + this.getGbModel() + "\n");
}
if (this.getGbOwner() != null) {
content.append("" + this.getGbOwner() + "\n");
}
if (this.getGbCivilCode() != null) {
content.append("" + this.getGbCivilCode() + "\n");
}
if (this.getGbAddress() != null) {
content.append("" + this.getGbAddress() + "\n");
}
if (this.getGbRegisterWay() != null) {
content.append("" + this.getGbRegisterWay() + "\n");
}
if (this.getGbSecrecy() != null) {
content.append("" + this.getGbSecrecy() + "\n");
}
if (this.getGbParentId() != null) {
content.append("" + this.getGbParentId() + "\n");
}
if (this.getGbParental() != null) {
content.append("" + this.getGbParental() + "\n");
}
if (this.getGbSafetyWay() != null) {
content.append("" + this.getGbSafetyWay() + "\n");
}
if (this.getGbRegisterWay() != null) {
content.append("" + this.getGbRegisterWay() + "\n");
}
if (this.getGbCertNum() != null) {
content.append("" + this.getGbCertNum() + "\n");
}
if (this.getGbCertifiable() != null) {
content.append("" + this.getGbCertifiable() + "\n");
}
if (this.getGbErrCode() != null) {
content.append("" + this.getGbErrCode() + "\n");
}
if (this.getGbEndTime() != null) {
content.append("" + this.getGbEndTime() + "\n");
}
if (this.getGbSecrecy() != null) {
content.append("" + this.getGbSecrecy() + "\n");
}
if (this.getGbIpAddress() != null) {
content.append("" + this.getGbIpAddress() + "\n");
}
if (this.getGbPort() != null) {
content.append("" + this.getGbPort() + "\n");
}
if (this.getGbPassword() != null) {
content.append("" + this.getGbPassword() + "\n");
}
if (this.getGbStatus() != null) {
content.append("" + this.getGbStatus() + "\n");
}
if (this.getGbLongitude() != null) {
content.append("" + this.getGbLongitude() + "\n");
}
if (this.getGbLatitude() != null) {
content.append("" + this.getGbLatitude() + "\n");
}
content.append("\n");
if (this.getGbPtzType() != null) {
content.append(" " + this.getGbPtzType() + "\n");
}
if (this.getGbPositionType() != null) {
content.append(" " + this.getGbPositionType() + "\n");
}
if (this.getGbRoomType() != null) {
content.append(" " + this.getGbRoomType() + "\n");
}
if (this.getGbUseType() != null) {
content.append(" " + this.getGbUseType() + "\n");
}
if (this.getGbSupplyLightType() != null) {
content.append(" " + this.getGbSupplyLightType() + "\n");
}
if (this.getGbDirectionType() != null) {
content.append(" " + this.getGbDirectionType() + "\n");
}
if (this.getGbResolution() != null) {
content.append(" " + this.getGbResolution() + "\n");
}
if (this.getGbBusinessGroupId() != null) {
content.append(" " + this.getGbBusinessGroupId() + "\n");
}
if (this.getGbDownloadSpeed() != null) {
content.append(" " + this.getGbDownloadSpeed() + "\n");
}
if (this.getGbSvcSpaceSupportMod() != null) {
content.append(" " + this.getGbSvcSpaceSupportMod() + "\n");
}
if (this.getGbSvcTimeSupportMode() != null) {
content.append(" " + this.getGbSvcTimeSupportMode() + "\n");
}
if (this.getEnableBroadcast() != null) {
content.append(" " + this.getEnableBroadcast() + "\n");
}
content.append("\n");
}
}
if (event != null) {
content.append("" + event + "\n");
}
content.append("
\n");
return content.toString();
}
}