临时提交

This commit is contained in:
648540858
2024-07-25 18:02:22 +08:00
parent 5a812e7f08
commit a2b00a4f4e
13 changed files with 646 additions and 78 deletions

View File

@@ -2,11 +2,13 @@ package com.genersoft.iot.vmp.gb28181.bean;
import com.genersoft.iot.vmp.gb28181.utils.MessageElement;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.utils.CivilCodeUtil;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Element;
import org.springframework.util.ObjectUtils;
import java.lang.reflect.InvocationTargetException;
@@ -218,7 +220,18 @@ public class DeviceChannel extends CommonGBChannel {
}
public static DeviceChannel decode(Element element) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
return XmlUtil.elementDecode(element, DeviceChannel.class);
DeviceChannel deviceChannel = XmlUtil.elementDecode(element, DeviceChannel.class);
if(deviceChannel.getCivilCode() != null ) {
if (ObjectUtils.isEmpty(deviceChannel.getCivilCode())
|| deviceChannel.getCivilCode().length() > 8 ){
deviceChannel.setCivilCode(null);
}else {
if (CivilCodeUtil.INSTANCE.getCivilCodePo(deviceChannel.getCivilCode()) == null) {
deviceChannel.setCivilCode(null);
}
}
}
return XmlUtil.elementDecode(element, DeviceChannel.class);
}
public static DeviceChannel decodeWithOnlyDeviceId(Element element) {

View File

@@ -0,0 +1,64 @@
package com.genersoft.iot.vmp.gb28181.bean;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* 区域
*/
@Data
@Schema(description = "区域树")
public class RegionTree {
/**
* 区域国标编号
*/
@Schema(description = "区域国标编号")
private String id;
/**
* 区域名称
*/
@Schema(description = "区域名称")
private String label;
/**
* 父区域国标ID
*/
@Schema(description = "父区域国标ID")
private String parentDeviceId;
@Schema(description = "是否有子节点")
private boolean isLeaf;
@Schema(description = "类型, 行政区划:0 摄像头: 1")
private int type;
public static RegionTree getInstance(Region region) {
RegionTree regionTree = new RegionTree();
regionTree.setId(region.getDeviceId());
regionTree.setLabel(region.getName());
regionTree.setParentDeviceId(region.getParentDeviceId());
regionTree.setType(0);
if (region.getDeviceId().length() < 8) {
regionTree.setLeaf(false);
}else {
regionTree.setLeaf(true);
}
return regionTree;
}
public static RegionTree getInstance(CommonGBChannel channel) {
RegionTree regionTree = new RegionTree();
regionTree.setId(channel.getGbDeviceId());
regionTree.setLabel(channel.getGbName());
regionTree.setParentDeviceId(channel.getGbCivilCode());
regionTree.setType(1);
regionTree.setLeaf(true);
return regionTree;
}
}