行政区划支持异常数据补充行政区划节点以及清理异常行政区划节点使通道可被挂载

This commit is contained in:
lin
2025-03-14 14:53:47 +08:00
parent d5dc0f9afd
commit 4dce850aea
12 changed files with 200 additions and 22 deletions

View File

@@ -91,4 +91,6 @@ public interface IGbChannelService {
void queryRecordInfo(CommonGBChannel channel, String startTime, String endTime, ErrorCallback<RecordInfo> callback);
PageInfo<CommonGBChannel> queryListByCivilCodeForUnusual(int page, int count, String query, Boolean online, Integer channelType);
void clearChannelCivilCode(Boolean all, List<Integer> channelIds);
}

View File

@@ -36,4 +36,8 @@ public interface IRegionService {
boolean batchAdd(List<Region> regionList);
List<Region> getPath(String deviceId);
String getDescription(String civilCode);
void addByCivilCode(String civilCode);
}

View File

@@ -762,4 +762,16 @@ public class GbChannelServiceImpl implements IGbChannelService {
List<CommonGBChannel> all = commonGBChannelMapper.queryListByCivilCodeForUnusual(query, online, channelType);
return new PageInfo<>(all);
}
@Override
public void clearChannelCivilCode(Boolean all, List<Integer> channelIds) {
List<Integer> channelIdsForClear;
if (all != null && all) {
channelIdsForClear = commonGBChannelMapper.queryAllForUnusual();
}else {
channelIdsForClear = channelIds;
}
commonGBChannelMapper.removeCivilCodeByChannelIds(channelIdsForClear);
}
}

View File

@@ -262,4 +262,66 @@ public class RegionServiceImpl implements IRegionService {
regionList.addAll(allParent);
return regionList;
}
@Override
public String getDescription(String civilCode) {
CivilCodePo civilCodePo = CivilCodeUtil.INSTANCE.getCivilCodePo(civilCode);
Assert.notNull(civilCodePo, String.format("节点%s未查询到", civilCode));
StringBuilder sb = new StringBuilder();
sb.append(civilCodePo.getName());
List<CivilCodePo> civilCodePoList = CivilCodeUtil.INSTANCE.getAllParentCode(civilCode);
if (civilCodePoList.isEmpty()) {
return sb.toString();
}
for (int i = 0; i < civilCodePoList.size(); i++) {
CivilCodePo item = civilCodePoList.get(i);
sb.insert(0, item.getName());
if (i != civilCodePoList.size() - 1) {
sb.insert(0, "/");
}
}
return sb.toString();
}
@Override
@Transactional
public void addByCivilCode(String civilCode) {
CivilCodePo civilCodePo = CivilCodeUtil.INSTANCE.getCivilCodePo(civilCode);
// 查询是否已经存在此节点
Assert.notNull(civilCodePo, String.format("节点%s未查询到", civilCode));
List<CivilCodePo> civilCodePoList = CivilCodeUtil.INSTANCE.getAllParentCode(civilCode);
civilCodePoList.add(civilCodePo);
Set<String> civilCodeSet = regionMapper.queryInCivilCodePoList(civilCodePoList);
if (!civilCodeSet.isEmpty()) {
civilCodePoList.removeIf(item -> civilCodeSet.contains(item.getCode()));
}
if (civilCodePoList.isEmpty()) {
return;
}
int parentId = -1;
for (int i = civilCodePoList.size() - 1; i > -1; i--) {
CivilCodePo codePo = civilCodePoList.get(i);
Region region = new Region();
region.setDeviceId(codePo.getCode());
region.setParentDeviceId(codePo.getParentCode());
region.setName(civilCodePo.getName());
region.setCreateTime(DateUtil.getNow());
region.setUpdateTime(DateUtil.getNow());
if (parentId == -1 && codePo.getParentCode() != null) {
Region parentRegion = regionMapper.queryByDeviceId(codePo.getParentCode());
if (parentRegion == null){
log.error(String.format("行政区划%sy已存在但查询错误", codePo.getParentCode()));
throw new ControllerException(ErrorCode.ERROR100.getCode(), String.format("行政区划%sy已存在但查询错误", codePo.getParentCode()));
}
region.setParentId(parentRegion.getId());
}else {
region.setParentId(parentId);
}
regionMapper.add(region);
parentId = region.getId();
}
}
}