|
@ -53,10 +53,7 @@ import org.springframework.util.CollectionUtils; |
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import java.io.InputStream; |
|
|
import java.io.InputStream; |
|
|
import java.util.ArrayList; |
|
|
import java.util.*; |
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.concurrent.ExecutorService; |
|
|
import java.util.concurrent.ExecutorService; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
@ -181,7 +178,7 @@ public class BuildingServiceImpl implements BuildingService { |
|
|
// agency.setAgencyId("77f6bc7f07064bf4c09ef848139a344c");
|
|
|
// agency.setAgencyId("77f6bc7f07064bf4c09ef848139a344c");
|
|
|
//1.获取所在组织及下级组织
|
|
|
//1.获取所在组织及下级组织
|
|
|
CustomerAgencyEntity customerAgency = customerAgencyDao.selectById(agency.getAgencyId()); |
|
|
CustomerAgencyEntity customerAgency = customerAgencyDao.selectById(agency.getAgencyId()); |
|
|
List<CustomerAgencyEntity> customerAgencyList = icBuildingDao.selectAgencyChildrenList(agency.getAgencyId()); |
|
|
List<CustomerAgencyEntity> customerAgencyList = icBuildingDao.selectAgencyChildrenList(customerId,agency.getAgencyId(),null); |
|
|
customerAgencyList.add(customerAgency); |
|
|
customerAgencyList.add(customerAgency); |
|
|
|
|
|
|
|
|
if (CollectionUtils.isEmpty(customerAgencyList)) { |
|
|
if (CollectionUtils.isEmpty(customerAgencyList)) { |
|
@ -313,6 +310,184 @@ public class BuildingServiceImpl implements BuildingService { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 房屋信息左侧树 |
|
|
|
|
|
* |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return 逐级展开,用户点击树节点去查询 |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public BuildingTreeLevelDTO treeInit(HouseManageTreeFormDTO formDTO) { |
|
|
|
|
|
CustomerStaffInfoCacheResult staffInfoCacheResult=CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(),formDTO.getStaffId()); |
|
|
|
|
|
BuildingTreeLevelDTO resultDto = customerAgencyDao.selectAgencyTree(staffInfoCacheResult.getAgencyId()); |
|
|
|
|
|
if (null != resultDto) { |
|
|
|
|
|
int showNum = customerAgencyDao.selectTotalNext(staffInfoCacheResult.getAgencyId()); |
|
|
|
|
|
resultDto.setShowNum(String.valueOf(showNum)); |
|
|
|
|
|
resultDto.setShowName(String.format("%s(%s)", resultDto.getLabel(), showNum)); |
|
|
|
|
|
List<BuildingTreeLevelDTO> children = customerAgencyDao.selectNextOrg(staffInfoCacheResult.getAgencyId()); |
|
|
|
|
|
for (BuildingTreeLevelDTO dto : children) { |
|
|
|
|
|
if ("agency".equals(dto.getOrgType())) { |
|
|
|
|
|
dto.setShowNum(String.valueOf(customerAgencyDao.selectTotalNext(dto.getId()))); |
|
|
|
|
|
dto.setShowName(String.format("%s(%s)", dto.getLabel(), dto.getShowNum())); |
|
|
|
|
|
} else if ("grid".equals(dto.getOrgType())) { |
|
|
|
|
|
LambdaQueryWrapper<IcNeighborHoodEntity> queryWrapper = new QueryWrapper<IcNeighborHoodEntity>().lambda() |
|
|
|
|
|
.eq(IcNeighborHoodEntity::getGridId, dto.getId()); |
|
|
|
|
|
dto.setShowNum(String.valueOf(icNeighborHoodDao.selectCount(queryWrapper))); |
|
|
|
|
|
dto.setShowName(String.format("%s(%s)", dto.getLabel(), dto.getShowNum())); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
resultDto.setChildren(children); |
|
|
|
|
|
} |
|
|
|
|
|
return resultDto; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 房屋信息左侧树 |
|
|
|
|
|
* 点击树上节点,查询下一级列表 |
|
|
|
|
|
* |
|
|
|
|
|
* @param formDTO |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
|
|
|
@Override |
|
|
|
|
|
public List<BuildingTreeLevelDTO> nextTreeNode(HouseManageTreeFormDTO formDTO) { |
|
|
|
|
|
/** |
|
|
|
|
|
* level:::: |
|
|
|
|
|
* 省级:province |
|
|
|
|
|
* 市级: city |
|
|
|
|
|
* 区县级: district, |
|
|
|
|
|
* 乡(镇、街道)级:street, |
|
|
|
|
|
* 社区级:community, |
|
|
|
|
|
* 网格:grid |
|
|
|
|
|
* 小区:neighborHood |
|
|
|
|
|
* 楼栋:building |
|
|
|
|
|
*/ |
|
|
|
|
|
List<BuildingTreeLevelDTO> resultList = new ArrayList<>(); |
|
|
|
|
|
if ("province".equals(formDTO.getLevel()) |
|
|
|
|
|
|| "city".equals(formDTO.getLevel()) |
|
|
|
|
|
|| "district".equals(formDTO.getLevel()) |
|
|
|
|
|
|| "street".equals(formDTO.getLevel())) { |
|
|
|
|
|
List<BuildingTreeLevelDTO> list = customerAgencyDao.selectNextOrg(formDTO.getId()); |
|
|
|
|
|
for (BuildingTreeLevelDTO dto : list) { |
|
|
|
|
|
if ("agency".equals(dto.getOrgType())) { |
|
|
|
|
|
dto.setShowNum(String.valueOf(customerAgencyDao.selectTotalNext(dto.getId()))); |
|
|
|
|
|
dto.setShowName(String.format("%s(%s)", dto.getLabel(), dto.getShowNum())); |
|
|
|
|
|
} else if ("grid".equals(dto.getOrgType())) { |
|
|
|
|
|
LambdaQueryWrapper<IcNeighborHoodEntity> queryWrapper = new QueryWrapper<IcNeighborHoodEntity>().lambda() |
|
|
|
|
|
.eq(IcNeighborHoodEntity::getGridId, dto.getId()); |
|
|
|
|
|
dto.setShowNum(String.valueOf(icNeighborHoodDao.selectCount(queryWrapper))); |
|
|
|
|
|
dto.setShowName(String.format("%s(%s)", dto.getLabel(), dto.getShowNum())); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
resultList.addAll(list); |
|
|
|
|
|
} else if ("community".equals(formDTO.getLevel())) { |
|
|
|
|
|
// 网格列表,需要计算网格下小区数量
|
|
|
|
|
|
resultList.addAll(getGridTreeNode(formDTO.getId())); |
|
|
|
|
|
} else if ("grid".equals(formDTO.getLevel())) { |
|
|
|
|
|
// 小区列表,需要计算小区下楼栋数量
|
|
|
|
|
|
resultList.addAll(getNeighborHoodTreeNode(formDTO.getId())); |
|
|
|
|
|
} else if ("neighborHood".equals(formDTO.getLevel())) { |
|
|
|
|
|
// 楼栋列表,需要计算楼栋下 实有房屋数/楼栋总户数
|
|
|
|
|
|
resultList.addAll(getBuildTreeNode(formDTO.getId())); |
|
|
|
|
|
} else if ("building".equals(formDTO.getLevel())) { |
|
|
|
|
|
// 直接返回
|
|
|
|
|
|
return resultList; |
|
|
|
|
|
} |
|
|
|
|
|
return resultList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<BuildingTreeLevelDTO> getGridTreeNode(String agencyId) { |
|
|
|
|
|
List<BuildingTreeLevelDTO> list = new ArrayList<>(); |
|
|
|
|
|
LambdaQueryWrapper<CustomerGridEntity> gridWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
|
gridWrapper.eq(CustomerGridEntity::getPid, agencyId); |
|
|
|
|
|
gridWrapper.last("ORDER BY sort,CAST(GRID_NAME AS SIGNED),CONVERT(GRID_NAME using gbk)"); |
|
|
|
|
|
List<CustomerGridEntity> customerGridList = customerGridDao.selectList(gridWrapper); |
|
|
|
|
|
customerGridList.forEach(gridEntity -> { |
|
|
|
|
|
BuildingTreeLevelDTO resultDto = new BuildingTreeLevelDTO(); |
|
|
|
|
|
resultDto.setId(gridEntity.getId()); |
|
|
|
|
|
resultDto.setLabel(gridEntity.getGridName()); |
|
|
|
|
|
resultDto.setLevel("grid"); |
|
|
|
|
|
resultDto.setPId(gridEntity.getPid()); |
|
|
|
|
|
resultDto.setLongitude(gridEntity.getLongitude()); |
|
|
|
|
|
resultDto.setLatitude(gridEntity.getLatitude()); |
|
|
|
|
|
resultDto.setChildren(new ArrayList<>()); |
|
|
|
|
|
// 当前网格下有几个小区
|
|
|
|
|
|
LambdaQueryWrapper<IcNeighborHoodEntity> neighborhoodWrapper = new QueryWrapper<IcNeighborHoodEntity>().lambda() |
|
|
|
|
|
.eq(IcNeighborHoodEntity::getGridId, resultDto.getId()); |
|
|
|
|
|
resultDto.setShowNum(String.valueOf(icNeighborHoodDao.selectCount(neighborhoodWrapper))); |
|
|
|
|
|
resultDto.setShowName(String.format("%s(%s)", resultDto.getLabel(), resultDto.getShowNum())); |
|
|
|
|
|
list.add(resultDto); |
|
|
|
|
|
}); |
|
|
|
|
|
return list; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<BuildingTreeLevelDTO> getNeighborHoodTreeNode(String gridId) { |
|
|
|
|
|
List<BuildingTreeLevelDTO> list = new ArrayList<>(); |
|
|
|
|
|
// 当前网格下有几个小区
|
|
|
|
|
|
LambdaQueryWrapper<IcNeighborHoodEntity> neighborhoodWrapper = new QueryWrapper<IcNeighborHoodEntity>().lambda() |
|
|
|
|
|
.eq(IcNeighborHoodEntity::getGridId, gridId) |
|
|
|
|
|
.last("ORDER BY CAST(NEIGHBOR_HOOD_NAME AS SIGNED),CONVERT(NEIGHBOR_HOOD_NAME using gbk)"); |
|
|
|
|
|
; |
|
|
|
|
|
List<IcNeighborHoodEntity> neighborHoodEntityList = icNeighborHoodDao.selectList(neighborhoodWrapper); |
|
|
|
|
|
neighborHoodEntityList.forEach(item -> { |
|
|
|
|
|
BuildingTreeLevelDTO neighborHood = new BuildingTreeLevelDTO(); |
|
|
|
|
|
neighborHood.setId(item.getId()); |
|
|
|
|
|
neighborHood.setPId(item.getGridId()); |
|
|
|
|
|
neighborHood.setLabel(item.getNeighborHoodName()); |
|
|
|
|
|
neighborHood.setLevel("neighborHood"); |
|
|
|
|
|
neighborHood.setLongitude(item.getLongitude()); |
|
|
|
|
|
neighborHood.setLatitude(item.getLatitude()); |
|
|
|
|
|
neighborHood.setChildren(new ArrayList<>()); |
|
|
|
|
|
// 当前小区下,有几栋楼
|
|
|
|
|
|
LambdaQueryWrapper<IcBuildingEntity> buildingQueryWrapper = new QueryWrapper<IcBuildingEntity>().lambda() |
|
|
|
|
|
.eq(IcBuildingEntity::getNeighborHoodId, neighborHood.getId()); |
|
|
|
|
|
neighborHood.setShowNum(String.valueOf(icBuildingDao.selectCount(buildingQueryWrapper))); |
|
|
|
|
|
neighborHood.setShowName(String.format("%s(%s)", neighborHood.getLabel(), neighborHood.getShowNum())); |
|
|
|
|
|
list.add(neighborHood); |
|
|
|
|
|
}); |
|
|
|
|
|
return list; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<BuildingTreeLevelDTO> getBuildTreeNode(String neighborHoodId) { |
|
|
|
|
|
List<BuildingTreeLevelDTO> list = new ArrayList<>(); |
|
|
|
|
|
LambdaQueryWrapper<IcBuildingEntity> buildingQueryWrapper = new QueryWrapper<IcBuildingEntity>().lambda() |
|
|
|
|
|
.in(IcBuildingEntity::getNeighborHoodId, neighborHoodId) |
|
|
|
|
|
.last("ORDER BY SORT, CAST(BUILDING_NAME AS SIGNED),CONVERT(BUILDING_NAME USING gbk)"); |
|
|
|
|
|
List<IcBuildingEntity> icBuildingList = icBuildingDao.selectList(buildingQueryWrapper); |
|
|
|
|
|
|
|
|
|
|
|
// 获取楼里已经有多少个房屋
|
|
|
|
|
|
LambdaQueryWrapper<IcHouseEntity> icHouseEntityWrapper = new QueryWrapper<IcHouseEntity>().lambda() |
|
|
|
|
|
.eq(IcHouseEntity::getNeighborHoodId, neighborHoodId) |
|
|
|
|
|
.select(IcHouseEntity::getId) |
|
|
|
|
|
.select(IcHouseEntity::getBuildingId); |
|
|
|
|
|
List<IcHouseEntity> buildingHouseCount = icHouseDao.selectList(icHouseEntityWrapper); |
|
|
|
|
|
Map<String, Long> buildingHouseCountMap = buildingHouseCount.stream().collect(Collectors.groupingBy(IcHouseEntity::getBuildingId, Collectors.counting())); |
|
|
|
|
|
|
|
|
|
|
|
icBuildingList.forEach(item -> { |
|
|
|
|
|
BuildingTreeLevelDTO building = new BuildingTreeLevelDTO(); |
|
|
|
|
|
building.setId(item.getId()); |
|
|
|
|
|
building.setPId(item.getNeighborHoodId()); |
|
|
|
|
|
building.setLabel(item.getBuildingName()); |
|
|
|
|
|
building.setLevel("building"); |
|
|
|
|
|
building.setLongitude(item.getLongitude()); |
|
|
|
|
|
building.setLatitude(item.getLatitude()); |
|
|
|
|
|
building.setChildren(new ArrayList<>()); |
|
|
|
|
|
// 当前楼栋共有多少户,有多少户有人住
|
|
|
|
|
|
building.setShowNum(StrConstant.EPMETY_STR); |
|
|
|
|
|
// 楼栋总户数
|
|
|
|
|
|
Integer total = null == item.getTotalHouseNum() ? NumConstant.ZERO : item.getTotalHouseNum(); |
|
|
|
|
|
// 实际已录入的总房屋数
|
|
|
|
|
|
int count = buildingHouseCountMap.getOrDefault(item.getId(), NumConstant.ZERO_L).intValue(); |
|
|
|
|
|
if (NumConstant.ZERO == total) { |
|
|
|
|
|
building.setShowNum(String.format("%s/%s", count, count)); |
|
|
|
|
|
} else { |
|
|
|
|
|
building.setShowNum(String.format("%s/%s", count, total)); |
|
|
|
|
|
} |
|
|
|
|
|
building.setShowName(String.format("%s(%s)", building.getLabel(), building.getShowNum())); |
|
|
|
|
|
list.add(building); |
|
|
|
|
|
}); |
|
|
|
|
|
return list; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* Desc: |
|
|
* Desc: |
|
|
* 2022-06-06 需求变动,只返回当前组织下级ID |
|
|
* 2022-06-06 需求变动,只返回当前组织下级ID |
|
@ -441,6 +616,7 @@ public class BuildingServiceImpl implements BuildingService { |
|
|
private List<BuildingTreeLevelDTO> covertToTree(CustomerAgencyEntity customerAgency, List<BuildingTreeLevelDTO> agencyList) { |
|
|
private List<BuildingTreeLevelDTO> covertToTree(CustomerAgencyEntity customerAgency, List<BuildingTreeLevelDTO> agencyList) { |
|
|
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); |
|
|
BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); |
|
|
buildingTreeLevelDTO.setId(customerAgency.getId()); |
|
|
buildingTreeLevelDTO.setId(customerAgency.getId()); |
|
|
|
|
|
buildingTreeLevelDTO.setPId(customerAgency.getPid()); |
|
|
buildingTreeLevelDTO.setLabel(customerAgency.getOrganizationName()); |
|
|
buildingTreeLevelDTO.setLabel(customerAgency.getOrganizationName()); |
|
|
buildingTreeLevelDTO.setLevel(customerAgency.getLevel()); |
|
|
buildingTreeLevelDTO.setLevel(customerAgency.getLevel()); |
|
|
buildingTreeLevelDTO.setLongitude(customerAgency.getLongitude()); |
|
|
buildingTreeLevelDTO.setLongitude(customerAgency.getLongitude()); |
|
|