|
|
@ -6,8 +6,11 @@ import com.alibaba.fastjson.JSON; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.constant.CustomerAgencyConstant; |
|
|
|
import com.epmet.constant.CustomerGridConstant; |
|
|
|
import com.epmet.dao.IcBuildingDao; |
|
|
|
import com.epmet.dto.ImportHouseGeneralDTO; |
|
|
|
import com.epmet.dto.form.ImportInfoFormDTO; |
|
|
@ -40,6 +43,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
|
List<ImportHouseGeneralDTO> gridInfoDTOs = null; |
|
|
|
Map<String, Object> neighborHoodInfos = null; |
|
|
|
List<ImportHouseGeneralDTO> neighborHoodInfoDTOs = null; |
|
|
|
ImportHouseGeneralDTO neighborHoodGeneralDTO = null; |
|
|
|
Map<String, Object> buildingInfos = null; |
|
|
|
List<ImportHouseGeneralDTO> buildingInfoDTOs = null; |
|
|
|
Map<String, Object> buildingUnitInfos = null; |
|
|
@ -63,47 +67,62 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
|
num = num + NumConstant.ONE; |
|
|
|
ImportHouseGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportHouseGeneralDTO.class); |
|
|
|
dto.setNum(num); |
|
|
|
if (formDTO.getOrgType().equals("building")){ |
|
|
|
buildingName = null == buildingName ? icBuildingDao.selectBuildingNameById(formDTO.getOrgId()) : buildingName; |
|
|
|
// 不是本楼的
|
|
|
|
if (!data.getBuildingName().equals(buildingName)){ |
|
|
|
nums.add(num); |
|
|
|
}else { |
|
|
|
/** |
|
|
|
* 1。根据楼宇查询 |
|
|
|
*/ |
|
|
|
needDisposeList.add(dto); |
|
|
|
Map<String, Object> collect = needDisposeList.stream().collect(Collectors.toMap(n -> n.getBuildingId() + "_" + n.getBuildingUnitId() + "_" + n.getDoorName(), n -> StringUtils.isNotBlank(n.getHouseId()) ? n.getHouseId() : "")); |
|
|
|
icHouseRedis.setTemporaryCacheHouse(formDTO.getCustomerId(), collect, formDTO.getUserId()); |
|
|
|
// Map<String, Object> temporaryCacheHouses = icHouseRedis.getTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId());
|
|
|
|
// TODO 等待方法
|
|
|
|
List<ImportHouseGeneralDTO> result = new ArrayList<>(); |
|
|
|
//把房屋ID不为空的行号加入nums,说明已存在
|
|
|
|
result.forEach(r -> { |
|
|
|
if (StringUtils.isNotBlank(r.getHouseId())){ |
|
|
|
nums.add(r.getNum()); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}else if (formDTO.getOrgType().equals("neighborHood")){ |
|
|
|
if (formDTO.getOrgType().equals(CustomerGridConstant.BUILDING)){ |
|
|
|
disposeBuildingHouse(dto); |
|
|
|
}else if (formDTO.getOrgType().equals(CustomerGridConstant.NEIGHBORHOOD)){ |
|
|
|
disposeNeighborHoodHouse(dto); |
|
|
|
}else if (formDTO.getOrgType().equals("grid")){ |
|
|
|
}else if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ |
|
|
|
disposeGridHouse(dto); |
|
|
|
}else if (formDTO.getOrgType().equals("agency")){ |
|
|
|
}else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ |
|
|
|
disposeAgencyHouse(dto); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void disposeNeighborHoodHouse(ImportHouseGeneralDTO dto){ |
|
|
|
neighborHoodName = null == neighborHoodName ? icBuildingDao.selectNeighborHoodNameById(formDTO.getOrgId()) : neighborHoodName; |
|
|
|
//不是本小区的
|
|
|
|
if (!dto.getNeighborHoodName().equals(neighborHoodName)){ |
|
|
|
/** |
|
|
|
* @Description 左侧树点击楼栋时调用 |
|
|
|
* @param dto |
|
|
|
* @author zxc |
|
|
|
* @date 2022/2/14 3:23 下午 |
|
|
|
*/ |
|
|
|
public void disposeBuildingHouse(ImportHouseGeneralDTO dto){ |
|
|
|
buildingName = null == buildingName ? icBuildingDao.selectBuildingNameById(formDTO.getOrgId()) : buildingName; |
|
|
|
// 排除不是本楼的
|
|
|
|
if (!dto.getBuildingName().equals(buildingName)){ |
|
|
|
nums.add(num); |
|
|
|
}else { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 左侧树点击小区时调用 |
|
|
|
* @param dto |
|
|
|
* @author zxc |
|
|
|
* @date 2022/2/14 3:23 下午 |
|
|
|
*/ |
|
|
|
public void disposeNeighborHoodHouse(ImportHouseGeneralDTO dto){ |
|
|
|
neighborHoodGeneralDTO = null == neighborHoodGeneralDTO ? icBuildingDao.selectNeighborHoodById(formDTO.getOrgId()) : neighborHoodGeneralDTO; |
|
|
|
//排除不是本小区的
|
|
|
|
if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){ |
|
|
|
nums.add(num); |
|
|
|
}else { |
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(neighborHoodGeneralDTO.getGridId()); |
|
|
|
if (null == gridInfo){ |
|
|
|
throw new EpmetException("查询网格失败..."); |
|
|
|
} |
|
|
|
// 排除网格名不一样但小区名一样
|
|
|
|
if (!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())){ |
|
|
|
nums.add(num); |
|
|
|
return; |
|
|
|
} |
|
|
|
dto.setNeighborHoodId(formDTO.getOrgId()); |
|
|
|
dto.setGridId(neighborHoodGeneralDTO.getGridId()); |
|
|
|
dto.setAgencyId(neighborHoodGeneralDTO.getAgencyId()); |
|
|
|
// 填充各种ID
|
|
|
|
fillData(dto,CustomerGridConstant.NEIGHBORHOOD); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 左侧树点击网格时调用 |
|
|
|
* @param dto |
|
|
@ -123,7 +142,14 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
|
//
|
|
|
|
dto.setGridId(formDTO.getOrgId()); |
|
|
|
dto.setAgencyId(gridInfo.getPid()); |
|
|
|
fillData(dto); |
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|
|
|
if (null == agencyInfo){ |
|
|
|
throw new EpmetException("查询组织信息失败..."); |
|
|
|
} |
|
|
|
dto.setPid(agencyInfo.getPid()); |
|
|
|
dto.setPids(agencyInfo.getPids()); |
|
|
|
// 填充各种ID
|
|
|
|
fillData(dto, CustomerGridConstant.GRID); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -154,15 +180,30 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
|
} |
|
|
|
dto.setGridId(cacheGridName.toString()); |
|
|
|
dto.setAgencyId(formDTO.getOrgId()); |
|
|
|
fillData(dto); |
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|
|
|
if (null == agencyInfo){ |
|
|
|
throw new EpmetException("查询组织信息失败..."); |
|
|
|
} |
|
|
|
dto.setPid(agencyInfo.getPid()); |
|
|
|
dto.setPids(agencyInfo.getPids()); |
|
|
|
// 填充各种ID
|
|
|
|
fillData(dto, CustomerGridConstant.AGENCY); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void fillData(ImportHouseGeneralDTO dto){ |
|
|
|
neighborHoodInfos = null == neighborHoodInfos ? getNeighborHoodInfos(Arrays.asList(formDTO.getOrgId())) : neighborHoodInfos; |
|
|
|
public void fillData(ImportHouseGeneralDTO dto,String orgType){ |
|
|
|
if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ |
|
|
|
List<String> gridIds = new ArrayList<>(); |
|
|
|
if (orgType.equals(CustomerGridConstant.GRID)){ |
|
|
|
gridIds = Arrays.asList(formDTO.getOrgId()); |
|
|
|
}else if (orgType.equals(CustomerGridConstant.AGENCY)){ |
|
|
|
gridIds = gridInfoDTOs.stream().map(m -> m.getGridId()).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
neighborHoodInfos = null == neighborHoodInfos ? getNeighborHoodInfos(gridIds) : neighborHoodInfos; |
|
|
|
Object cacheNeighBorHood = icHouseRedis.getTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId(), formDTO.getOrgId() + "_" + dto.getNeighborHoodName()); |
|
|
|
// 赋值小区ID
|
|
|
|
dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ |
|
|
|
//小区ID不为空赋值楼栋ID
|
|
|
|
buildingInfos = null == buildingInfos ? getBuildingInfos(dto.getNeighborHoodId()) : buildingInfos; |
|
|
@ -239,6 +280,17 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
|
return buildingInfos; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 根据ID获取小区信息 |
|
|
|
* @param neighborHoodId |
|
|
|
* @author zxc |
|
|
|
* @date 2022/2/14 3:24 下午 |
|
|
|
*/ |
|
|
|
public ImportHouseGeneralDTO getNeighborHoodGeneralDTO(String neighborHoodId){ |
|
|
|
neighborHoodGeneralDTO = icBuildingDao.selectNeighborHoodById(neighborHoodId); |
|
|
|
return neighborHoodGeneralDTO; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void doAfterAllAnalysed(AnalysisContext context) { |
|
|
|
|
|
|
|