临时提交
parent
aeb3cd6a22
commit
635458d19a
|
@ -1,6 +1,7 @@
|
|||
package com.genersoft.iot.vmp.gb28181.bean;
|
||||
|
||||
import com.genersoft.iot.vmp.common.CivilCodePo;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.request.Re;
|
||||
import com.genersoft.iot.vmp.utils.CivilCodeUtil;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
@ -88,4 +89,29 @@ public class Region implements Comparable<Region>{
|
|||
public int compareTo(@NotNull Region region) {
|
||||
return Integer.compare(Integer.parseInt(this.deviceId), Integer.parseInt(region.getDeviceId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj instanceof Region) {
|
||||
Region region = (Region) obj;
|
||||
|
||||
// 比较每个属性的值一致时才返回true
|
||||
if (region.getId() == this.id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写hashcode方法,返回的hashCode一样才再去比较每个属性的值
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,14 +164,19 @@ public interface GroupMapper {
|
|||
|
||||
@Select(" <script>" +
|
||||
" SELECT " +
|
||||
" device_id as gb_device_id," +
|
||||
" name as gb_name," +
|
||||
" business_group as gb_business_group," +
|
||||
" 1 as gb_parental," +
|
||||
" parent_device_id as gb_parent_id" +
|
||||
" * " +
|
||||
" from wvp_common_group " +
|
||||
" where (device_id, business_group) in " +
|
||||
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > (#{item.gbParentId}, #{item.gbBusinessGroupId})</foreach>" +
|
||||
" </script>")
|
||||
List<CommonGBChannel> queryInChannelList(List<CommonGBChannel> channelList);
|
||||
Set<Group> queryInChannelList(List<CommonGBChannel> channelList);
|
||||
|
||||
@Select(" <script>" +
|
||||
" SELECT " +
|
||||
" * " +
|
||||
" from wvp_common_group " +
|
||||
" where device_id in " +
|
||||
" <foreach collection='regionChannelList' item='item' open='(' separator=',' close=')' > #{item.parentDeviceId}</foreach>" +
|
||||
" </script>")
|
||||
Set<Group> queryParentInChannelList(Set<Group> regionChannelList);
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ public interface RegionMapper {
|
|||
" where device_id in " +
|
||||
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbCivilCode}</foreach>" +
|
||||
" </script>")
|
||||
List<Region> queryInChannelList(List<CommonGBChannel> channelList);
|
||||
Set<Region> queryInChannelList(List<CommonGBChannel> channelList);
|
||||
|
||||
|
||||
@Select(" <script>" +
|
||||
|
@ -115,5 +115,5 @@ public interface RegionMapper {
|
|||
" where device_id in " +
|
||||
" <foreach collection='regionChannelList' item='item' open='(' separator=',' close=')' > #{item.parentDeviceId}</foreach>" +
|
||||
" </script>")
|
||||
List<Region> queryParentInChannelList(List<Region> regionChannelList);
|
||||
Set<Region> queryParentInChannelList(Set<Region> regionChannelList);
|
||||
}
|
||||
|
|
|
@ -20,10 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
|
@ -328,10 +325,10 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
|
||||
// 是否包含行政区划信息
|
||||
if (platform.getCatalogWithRegion()) {
|
||||
List<Region> regionChannelList = regionMapper.queryInChannelList(commonGBChannelList);
|
||||
Set<Region> regionChannelList = regionMapper.queryInChannelList(commonGBChannelList);
|
||||
if (!regionChannelList.isEmpty()) {
|
||||
// 获取这些节点的所有父节点
|
||||
List<Region> allRegion = getAllRegion(regionChannelList);
|
||||
// 获取这些节点的所有父节点, 使用set滤重
|
||||
Set<Region> allRegion = getAllRegion(regionChannelList);
|
||||
for (Region region : allRegion) {
|
||||
channelList.add(CommonGBChannel.build(region));
|
||||
}
|
||||
|
@ -339,25 +336,41 @@ public class GbChannelServiceImpl implements IGbChannelService {
|
|||
}
|
||||
// 是否包含分组信息
|
||||
if (platform.getCatalogWithGroup()) {
|
||||
List<CommonGBChannel> groupChannelList = groupMapper.queryInChannelList(commonGBChannelList);
|
||||
Set<Group> groupChannelList = groupMapper.queryInChannelList(commonGBChannelList);
|
||||
if (!groupChannelList.isEmpty()) {
|
||||
// 获取这些节点的所有父节点
|
||||
channelList.addAll(groupChannelList);
|
||||
Set<Group> allGroup = getAllGroup(groupChannelList);
|
||||
for (Group group : allGroup) {
|
||||
channelList.add(CommonGBChannel.build(group));
|
||||
}
|
||||
}
|
||||
}
|
||||
channelList.addAll(commonGBChannelList);
|
||||
return channelList;
|
||||
}
|
||||
|
||||
private List<Region> getAllRegion(List<Region> regionChannelList ) {
|
||||
private Set<Region> getAllRegion(Set<Region> regionChannelList ) {
|
||||
if (regionChannelList.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
return new HashSet<>();
|
||||
}
|
||||
List<Region> channelList = regionMapper.queryParentInChannelList(regionChannelList);
|
||||
Set<Region> channelList = regionMapper.queryParentInChannelList(regionChannelList);
|
||||
if (channelList.isEmpty()) {
|
||||
return channelList;
|
||||
}
|
||||
List<Region> allParentRegion = getAllRegion(channelList);
|
||||
Set<Region> allParentRegion = getAllRegion(channelList);
|
||||
channelList.addAll(allParentRegion);
|
||||
return channelList;
|
||||
}
|
||||
|
||||
private Set<Group> getAllGroup(Set<Group> regionChannelList ) {
|
||||
if (regionChannelList.isEmpty()) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
Set<Group> channelList = groupMapper.queryParentInChannelList(regionChannelList);
|
||||
if (channelList.isEmpty()) {
|
||||
return channelList;
|
||||
}
|
||||
Set<Group> allParentRegion = getAllGroup(channelList);
|
||||
channelList.addAll(allParentRegion);
|
||||
return channelList;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue