diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java index 394448e623..fca09fe069 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/BuildingController.java @@ -29,7 +29,6 @@ import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.constant.ImportErrorMsgConstants; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.IcBuildingUnitDao; import com.epmet.dto.BuildingTreeLevelDTO; @@ -42,8 +41,6 @@ import com.epmet.entity.IcBuildingUnitEntity; import com.epmet.excel.IcBuildingExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.BuildingService; -import com.epmet.service.IcBuildingService; -import com.epmet.service.NeighborHoodService; import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -118,7 +115,7 @@ public class BuildingController { @PostMapping("treelist") public Result treeList(@LoginUser TokenDto tokenDTO){ - List buildingTreeLevelDTOS =buildingService.treeList(tokenDTO.getUserId()); + List buildingTreeLevelDTOS =buildingService.treeList(tokenDTO.getCustomerId(), tokenDTO.getUserId()); return new Result().ok(buildingTreeLevelDTOS); } /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java index 0ba2aeb492..81a9f10390 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/BuildingService.java @@ -27,7 +27,6 @@ import com.epmet.dto.result.BuildingResultPagedDTO; import com.epmet.dto.result.IcNeighborHoodResultDTO; import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.excel.IcBuildingExcel; -import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -57,7 +56,7 @@ public interface BuildingService { void addBuilding(String customerId, IcBulidingFormDTO formDTO); - List treeList(String customerId); + List treeList(String customerId, String staffId); List importExcel(String customerId, List list, String staffId, List numList); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java index 28baadf38f..04670fde28 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/BuildingServiceImpl.java @@ -13,45 +13,37 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; -import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; -import com.epmet.constant.ImportErrorMsgConstants; import com.epmet.constants.ImportTaskConstants; import com.epmet.dao.*; import com.epmet.dto.BuildingTreeLevelDTO; -import com.epmet.dto.CustomerStaffAgencyDTO; import com.epmet.dto.IcBuildingDTO; import com.epmet.dto.form.IcBulidingFormDTO; import com.epmet.dto.form.ImportInfoFormDTO; import com.epmet.dto.form.ImportTaskCommonFormDTO; import com.epmet.dto.form.ListIcNeighborHoodFormDTO; -import com.epmet.dto.result.*; +import com.epmet.dto.result.BuildingResultDTO; +import com.epmet.dto.result.BuildingResultPagedDTO; +import com.epmet.dto.result.IcNeighborHoodResultDTO; +import com.epmet.dto.result.ImportTaskCommonResultDTO; import com.epmet.entity.*; import com.epmet.enums.BuildingTypeEnums; import com.epmet.excel.IcBuildingExcel; import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.model.BuildingInfoModel; -import com.epmet.model.HouseInfoModel; import com.epmet.model.ImportBuildingInfoListener; import com.epmet.redis.IcHouseRedis; import com.epmet.service.*; -import com.epmet.service.BuildingService; -import com.epmet.service.IcBuildingService; -import com.epmet.service.IcBuildingUnitService; -import com.epmet.service.IcHouseService; import com.epmet.util.ExcelPoiUtils; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -128,8 +120,8 @@ public class BuildingServiceImpl implements BuildingService { } @Override - public List treeList(String staffId) { - CustomerStaffAgencyDTO agency = customerStaffAgencyDao.selectLatestCustomerByStaff(staffId); + public List treeList(String customerId, String staffId) { + CustomerStaffInfoCacheResult agency = CustomerStaffRedis.getStaffInfo(customerId, staffId); if(null == agency || StringUtils.isBlank(agency.getAgencyId())){ log.error("com.epmet.service.impl.BuildingServiceImpl.treeList,没有找到工作人员所属的机关信息,用户Id:{}",staffId); return new ArrayList<>(); @@ -163,7 +155,7 @@ public class BuildingServiceImpl implements BuildingService { //2.获取组织所在网格 - List agencyIdList = customerAgencyList.stream().map(a->a.getId()).collect(Collectors.toList()); + List agencyIdList = customerAgencyList.stream().map(BaseEpmetEntity::getId).collect(Collectors.toList()); // agencyIdList.add(customerAgency.getId()); List customerGridList = customerGridDao.selectList(new QueryWrapper().lambda().in(CustomerGridEntity::getPid, agencyIdList)); @@ -222,8 +214,12 @@ public class BuildingServiceImpl implements BuildingService { agencyList.addAll(neighbourHoodList); return covertToTree(customerAgency,agencyList); } + //获取楼里已经有多少个房屋 + LambdaQueryWrapper icHouseEntityWrapper = new QueryWrapper().lambda() + .in(IcHouseEntity::getNeighborHoodId, neighborHoodIdList); + List buildingHouseCount = icHouseDao.selectList(icHouseEntityWrapper); + Map buildingHouseCountMap = buildingHouseCount.stream().collect(Collectors.groupingBy(IcHouseEntity::getBuildingId, Collectors.counting())); //组合封装 - List buildingList = icBuildingList.stream().map(item -> { BuildingTreeLevelDTO buildingTreeLevelDTO = new BuildingTreeLevelDTO(); buildingTreeLevelDTO.setId(item.getId()); @@ -246,9 +242,10 @@ public class BuildingServiceImpl implements BuildingService { //02.11 之前录入的户数概念改为总户数,无需计算直接用就可以了 Integer total = null == item.getTotalHouseNum() ? NumConstant.ZERO : item.getTotalHouseNum(); //已经添加了多少户 - LambdaQueryWrapper icHouseEntityWrapper = new QueryWrapper().lambda() - .in(IcHouseEntity::getBuildingId, item.getId()); - int count= icHouseDao.selectCount(icHouseEntityWrapper); +// LambdaQueryWrapper icHouseEntityWrapper = new QueryWrapper().lambda() +// .in(IcHouseEntity::getBuildingId, item.getId()); +// int count= icHouseDao.selectCount(icHouseEntityWrapper); + int count = buildingHouseCountMap.getOrDefault(item.getId(), NumConstant.ZERO_L).intValue(); if(NumConstant.ZERO==total){ buildingTreeLevelDTO.setShowNum(String.format("%s/%s",count,count)); }else{