行政区划支持异常数据补充行政区划节点以及清理异常行政区划节点使通道可被挂载
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user