临时提交
This commit is contained in:
@@ -11,7 +11,7 @@ import lombok.Data;
|
||||
public class GbCode {
|
||||
|
||||
@Schema(description = "中心编码,由监控中心所在地的行政区划代码确定,符合GB/T2260—2007的要求")
|
||||
private String civilCode;
|
||||
private String centerCode;
|
||||
|
||||
@Schema(description = "行业编码")
|
||||
private String industryCode;
|
||||
@@ -34,7 +34,7 @@ public class GbCode {
|
||||
}
|
||||
code = code.trim();
|
||||
GbCode gbCode = new GbCode();
|
||||
gbCode.setCivilCode(code.substring(0, 8));
|
||||
gbCode.setCenterCode(code.substring(0, 8));
|
||||
gbCode.setIndustryCode(code.substring(9, 10));
|
||||
gbCode.setTypeCode(code.substring(11, 13));
|
||||
gbCode.setNetCode(code.substring(14, 15));
|
||||
@@ -43,6 +43,6 @@ public class GbCode {
|
||||
}
|
||||
|
||||
public String ecode(){
|
||||
return civilCode + industryCode + typeCode + netCode + sn;
|
||||
return centerCode + industryCode + typeCode + netCode + sn;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,11 +94,12 @@ public class CommonChannelController {
|
||||
public PageInfo<CommonGBChannel> queryList(int page, int count,
|
||||
@RequestParam(required = false) String query,
|
||||
@RequestParam(required = false) Boolean online,
|
||||
@RequestParam(required = false) Boolean hasCivilCode){
|
||||
@RequestParam(required = false) Boolean hasCivilCode,
|
||||
@RequestParam(required = false) Boolean hasGroup){
|
||||
if (ObjectUtils.isEmpty(query)){
|
||||
query = null;
|
||||
}
|
||||
return channelService.queryList(page, count, query, online, hasCivilCode);
|
||||
return channelService.queryList(page, count, query, online, hasCivilCode, hasGroup);
|
||||
}
|
||||
|
||||
@Operation(summary = "通道设置行政区划", security = @SecurityRequirement(name = JwtUtils.HEADER))
|
||||
|
||||
@@ -73,21 +73,21 @@ public class GroupController {
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "根据分组Id查询分组")
|
||||
@Parameter(name = "groupDeviceId", description = "分组节点编号", required = true)
|
||||
@ResponseBody
|
||||
@GetMapping("/one")
|
||||
public Group queryGroupByDeviceId(
|
||||
@RequestParam(required = true) String deviceId
|
||||
){
|
||||
Assert.hasLength(deviceId, "");
|
||||
return groupService.queryGroupByDeviceId(deviceId);
|
||||
}
|
||||
// @Operation(summary = "根据分组Id查询分组")
|
||||
// @Parameter(name = "groupDeviceId", description = "分组节点编号", required = true)
|
||||
// @ResponseBody
|
||||
// @GetMapping("/one")
|
||||
// public Group queryGroupByDeviceId(
|
||||
// @RequestParam(required = true) String deviceId
|
||||
// ){
|
||||
// Assert.hasLength(deviceId, "");
|
||||
// return groupService.queryGroupByDeviceId(deviceId);
|
||||
// }
|
||||
|
||||
@Operation(summary = "从通道中同步分组")
|
||||
@ResponseBody
|
||||
@GetMapping("/sync")
|
||||
public void sync(){
|
||||
groupService.syncFromChannel();
|
||||
}
|
||||
// @Operation(summary = "从通道中同步分组")
|
||||
// @ResponseBody
|
||||
// @GetMapping("/sync")
|
||||
// public void sync(){
|
||||
// groupService.syncFromChannel();
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -305,7 +305,9 @@ public interface CommonGBChannelMapper {
|
||||
CommonGBChannel queryByStreamProxyId(@Param("streamProxyId") Integer streamProxyId);
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryList")
|
||||
List<CommonGBChannel> queryList(@Param("query") String query, @Param("online") Boolean online, @Param("hasCivilCode") Boolean hasCivilCode);
|
||||
List<CommonGBChannel> queryList(@Param("query") String query, @Param("online") Boolean online,
|
||||
@Param("hasCivilCode") Boolean hasCivilCode,
|
||||
@Param("hasGroup") Boolean hasGroup);
|
||||
|
||||
@Select("<script>" +
|
||||
" select " +
|
||||
|
||||
@@ -99,8 +99,8 @@ public interface GroupMapper {
|
||||
" false as is_leaf" +
|
||||
" from wvp_common_group " +
|
||||
" where device_id=business_group" +
|
||||
" <if test='platformId != null'> platform_id = #{platformId} </if> " +
|
||||
" <if test='platformId == null'> platform_id is null </if> " +
|
||||
" <if test='platformId != null'> AND platform_id = #{platformId} </if> " +
|
||||
" <if test='platformId == null'> AND platform_id is null </if> " +
|
||||
" <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
|
||||
" </script>")
|
||||
List<GroupTree> queryBusinessGroupForTree(String query, Integer platformId);
|
||||
|
||||
@@ -94,6 +94,12 @@ public class ChannelProvider {
|
||||
if (params.get("hasCivilCode") != null && !(Boolean)params.get("hasCivilCode")) {
|
||||
sqlBuild.append(" AND gb_civil_code is null");
|
||||
}
|
||||
if (params.get("hasGroup") != null && (Boolean)params.get("hasGroup")) {
|
||||
sqlBuild.append(" AND gb_business_group_id is not null");
|
||||
}
|
||||
if (params.get("hasGroup") != null && !(Boolean)params.get("hasGroup")) {
|
||||
sqlBuild.append(" AND gb_business_group_id is null");
|
||||
}
|
||||
return sqlBuild.toString();
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public interface IGbChannelService {
|
||||
|
||||
void reset(int id);
|
||||
|
||||
PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, Boolean hasCivilCode);
|
||||
PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, Boolean hasCivilCode, Boolean hasGroup);
|
||||
|
||||
void removeCivilCode(List<Region> allChildren);
|
||||
|
||||
|
||||
@@ -322,9 +322,10 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, Boolean hasCivilCode) {
|
||||
public PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online, Boolean hasCivilCode,
|
||||
Boolean hasGroup) {
|
||||
PageHelper.startPage(page, count);
|
||||
List<CommonGBChannel> all = commonGBChannelMapper.queryList(query, online, hasCivilCode);
|
||||
List<CommonGBChannel> all = commonGBChannelMapper.queryList(query, online, hasCivilCode, hasGroup);
|
||||
return new PageInfo<>(all);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GbCode;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Group;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GroupTree;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.GroupMapper;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGroupService;
|
||||
import com.genersoft.iot.vmp.utils.CivilCodeUtil;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -17,7 +18,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 区域管理类
|
||||
@@ -149,45 +150,7 @@ public class GroupServiceImpl implements IGroupService {
|
||||
|
||||
@Override
|
||||
public void syncFromChannel() {
|
||||
// 获取未初始化的业务分组
|
||||
List<String> civilCodeList = regionMapper.getUninitializedCivilCode();
|
||||
if (civilCodeList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<Region> regionList = new ArrayList<>();
|
||||
// 收集节点的父节点,用于验证哪些节点的父节点不存在,方便一并存入
|
||||
Map<String, Region> regionMapForVerification = new HashMap<>();
|
||||
civilCodeList.forEach(civilCode->{
|
||||
CivilCodePo civilCodePo = CivilCodeUtil.INSTANCE.getCivilCodePo(civilCode);
|
||||
if (civilCodePo != null) {
|
||||
Region region = Region.getInstance(civilCodePo);
|
||||
regionList.add(region);
|
||||
// 获取全部的父节点
|
||||
List<CivilCodePo> civilCodePoList = CivilCodeUtil.INSTANCE.getAllParentCode(civilCode);
|
||||
if (!civilCodePoList.isEmpty()) {
|
||||
for (CivilCodePo codePo : civilCodePoList) {
|
||||
regionMapForVerification.put(codePo.getCode(), Region.getInstance(codePo));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (regionList.isEmpty()){
|
||||
return;
|
||||
}
|
||||
if (!regionMapForVerification.isEmpty()) {
|
||||
// 查询数据库中已经存在的.
|
||||
List<String> civilCodesInDb = regionMapper.queryInList(regionMapForVerification.keySet());
|
||||
if (!civilCodesInDb.isEmpty()) {
|
||||
for (String code : civilCodesInDb) {
|
||||
regionMapForVerification.remove(code);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (Region region : regionList) {
|
||||
regionMapForVerification.put(region.getDeviceId(), region);
|
||||
}
|
||||
|
||||
regionMapper.batchAdd(new ArrayList<>(regionMapForVerification.values()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user