diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java index da97859fb9..0e556df1ea 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/HouseController.java @@ -569,4 +569,14 @@ public class HouseController implements ResultDataResolver { return houseService.getHomeInfoByHouseCode(dto); } + /** + * 初始化房屋的组织ID路径 + * @return + */ + @PostMapping("orgIdPathInit") + public Result orgIdPathInit() { + houseService.orgIdPathInit(); + return new Result(); + } + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcEnterpriseExcelImportListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcEnterpriseExcelImportListener.java index 5263746016..65b5cda5f0 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcEnterpriseExcelImportListener.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/handler/IcEnterpriseExcelImportListener.java @@ -12,7 +12,6 @@ import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.entity.IcEnterpriseEntity; import com.epmet.excel.EnterpriseImportExcelDTO; import com.epmet.service.impl.IcEnterpriseServiceImpl; -import lombok.Data; import lombok.extern.slf4j.Slf4j; import java.util.ArrayList; @@ -57,19 +56,20 @@ public class IcEnterpriseExcelImportListener implements ReadListener query = new LambdaQueryWrapper<>(); + query.eq(IcHouseEntity::getId, "1508686441788137474"); + //query.isNull(IcHouseEntity::getOrgIdPath); + //query.last(" limit 1000 "); + + while (true) { + List houses2Dispose = icHouseDao.selectList(query); + + if (org.apache.commons.collections4.CollectionUtils.isEmpty(houses2Dispose)) { + break; + } + + houses2Dispose.stream().forEach(h -> { + IcNeighborHoodDTO neighborhood = neighborHoodService.get(h.getNeighborHoodId()); + ArrayList pidList = new ArrayList<>(); + recureAppendParentAgencyId(neighborhood.getAgencyId(), pidList); + String orgIdPath = String.join(":", pidList); + + // 更新 + IcHouseEntity house = new IcHouseEntity(); + house.setId(h.getId()); + house.setOrgIdPath(orgIdPath); + + icHouseDao.updateById(house); + }); + } + } + /** + * 递归拼接orgIdPath + * @param agencyId + * @param result + */ + private void recureAppendParentAgencyId(String agencyId, List result) { + result.add(0, agencyId); + CustomerAgencyEntity agency = customerAgencyDao.selectById(agencyId); + String pid = agency.getPid(); + if (StringUtils.isBlank(pid) || "0".equals(pid)) { + return; + } + recureAppendParentAgencyId(pid, result); + } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java index 9b0fbb171c..77065e457e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcEnterpriseServiceImpl.java @@ -300,9 +300,9 @@ public class IcEnterpriseServiceImpl extends BaseServiceImpl gridMap=gridList.stream().collect(Collectors.toMap(GridListResultDTO::getGridName,GridListResultDTO::getGridId)); - IcEnterpriseExcelImportListener listener = new IcEnterpriseExcelImportListener(customerId,staffInfo, this,placeTypeMap,scaleMap,gridMap); - EasyExcel.read(filePath.toFile(), EnterpriseImportExcelDTO.class, listener).headRowNumber(2).sheet(0).doRead(); + IcEnterpriseExcelImportListener listener = new IcEnterpriseExcelImportListener(customerId,staffInfo, this,placeTypeMap,scaleMap,gridMap); + EasyExcel.read(filePath.toFile(), EnterpriseImportExcelDTO.class, listener).headRowNumber(1).sheet(0).doRead(); Path errorDescFile = null; String errorDesFileUrl = null;