临时提交
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.controller;
|
||||
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IRegionService;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
@@ -53,7 +54,7 @@ public class RegionController {
|
||||
@Parameter(name = "parent", description = "所属行政区划编号", required = true)
|
||||
@ResponseBody
|
||||
@GetMapping("/tree/list")
|
||||
public List<Region> queryForTree(
|
||||
public List<RegionTree> queryForTree(
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = false) String parent
|
||||
){
|
||||
@@ -121,7 +122,7 @@ public class RegionController {
|
||||
@ResponseBody
|
||||
@GetMapping("/base/child/list")
|
||||
public List<Region> getAllChild(@RequestParam(required = false) String parent){
|
||||
if (ObjectUtils.isEmpty(parent.trim())) {
|
||||
if (ObjectUtils.isEmpty(parent)) {
|
||||
parent = null;
|
||||
}
|
||||
return regionService.getAllChild(parent);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.provider.ChannelProvider;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -305,4 +306,17 @@ public interface CommonGBChannelMapper {
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryList")
|
||||
List<CommonGBChannel> queryList(String query, Boolean online);
|
||||
|
||||
@Select("<script>" +
|
||||
" select " +
|
||||
" coalesce(gb_device_id, device_id) as id," +
|
||||
" coalesce(gb_name, name) as label, " +
|
||||
" 1 as type, " +
|
||||
" true as is_leaf " +
|
||||
" from wvp_device_channel " +
|
||||
" where coalesce(gb_civil_code, civil_code) = #{parent} " +
|
||||
" <if test='query != null'> AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') " +
|
||||
" OR coalesce(gb_name, name) LIKE concat('%',#{query},'%'))</if> " +
|
||||
" </script>")
|
||||
List<RegionTree> queryForRegionTreeByCivilCode(@Param("query") String query, @Param("parent") String parent);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
@@ -65,11 +66,17 @@ public interface RegionMapper {
|
||||
int batchAdd(List<Region> regionList);
|
||||
|
||||
@Select(" <script>" +
|
||||
" SELECT * from wvp_common_region " +
|
||||
" SELECT " +
|
||||
" device_id as id," +
|
||||
" name as label, " +
|
||||
" parent_device_id," +
|
||||
" 0 as type," +
|
||||
" false as is_leaf" +
|
||||
" from wvp_common_region " +
|
||||
" where " +
|
||||
" <if test='parentId != null'> parent_device_id = #{parentId} </if> " +
|
||||
" <if test='parentId == null'> parent_device_id is null </if> " +
|
||||
" <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
|
||||
" </script>")
|
||||
List<Region> queryForTree(@Param("query") String query, @Param("parentId") String parentId);
|
||||
List<RegionTree> queryForTree(@Param("query") String query, @Param("parentId") String parentId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import java.util.List;
|
||||
@@ -31,7 +32,7 @@ public interface IRegionService {
|
||||
|
||||
Region queryRegionByDeviceId(String regionDeviceId);
|
||||
|
||||
List<Region> queryForTree(String query, String parent);
|
||||
List<RegionTree> queryForTree(String query, String parent);
|
||||
|
||||
void syncFromChannel();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.RegionMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IRegionService;
|
||||
import com.genersoft.iot.vmp.utils.CivilCodeUtil;
|
||||
@@ -28,7 +30,7 @@ public class RegionServiceImpl implements IRegionService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private GbChannelServiceImpl gbChannelService;
|
||||
private CommonGBChannelMapper commonGBChannelMapper;
|
||||
|
||||
|
||||
@Autowired
|
||||
@@ -87,8 +89,13 @@ public class RegionServiceImpl implements IRegionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Region> queryForTree(String query, String parent) {
|
||||
return regionMapper.queryForTree(query, parent);
|
||||
public List<RegionTree> queryForTree(String query, String parent) {
|
||||
List<RegionTree> regionList = regionMapper.queryForTree(query, parent);
|
||||
if (parent != null) {
|
||||
List<RegionTree> channelList = commonGBChannelMapper.queryForRegionTreeByCivilCode(query, parent);
|
||||
regionList.addAll(channelList);
|
||||
}
|
||||
return regionList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user