|
@ -3,6 +3,10 @@ package com.epmet.model; |
|
|
import com.alibaba.excel.context.AnalysisContext; |
|
|
import com.alibaba.excel.context.AnalysisContext; |
|
|
import com.alibaba.excel.event.AnalysisEventListener; |
|
|
import com.alibaba.excel.event.AnalysisEventListener; |
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
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.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.constant.CustomerGridConstant; |
|
|
import com.epmet.constant.CustomerGridConstant; |
|
|
import com.epmet.dao.IcBuildingDao; |
|
|
import com.epmet.dao.IcBuildingDao; |
|
@ -10,10 +14,13 @@ import com.epmet.dto.ImportGeneralDTO; |
|
|
import com.epmet.dto.form.ImportInfoFormDTO; |
|
|
import com.epmet.dto.form.ImportInfoFormDTO; |
|
|
import com.epmet.redis.IcHouseRedis; |
|
|
import com.epmet.redis.IcHouseRedis; |
|
|
import com.epmet.service.IcNeighborHoodService; |
|
|
import com.epmet.service.IcNeighborHoodService; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Arrays; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @Author zxc |
|
|
* @Author zxc |
|
@ -73,7 +80,26 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb |
|
|
* @date 2022/2/15 2:37 下午 |
|
|
* @date 2022/2/15 2:37 下午 |
|
|
*/ |
|
|
*/ |
|
|
public void disposeGridNeighborHood(ImportGeneralDTO dto){ |
|
|
public void disposeGridNeighborHood(ImportGeneralDTO dto){ |
|
|
|
|
|
gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; |
|
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); |
|
|
|
|
|
if (null == gridInfo){ |
|
|
|
|
|
throw new EpmetException("查询网格失败..."); |
|
|
|
|
|
} |
|
|
|
|
|
//排除不是本网格的 gridName不一样排除,gridName一样但是agencyName不一样也得排除
|
|
|
|
|
|
if (!dto.getGridName().equals(gridName) || (!dto.getAgencyName().equals(gridInfo.getAgencyName()) && dto.getGridName().equals(gridName))){ |
|
|
|
|
|
nums.add(num); |
|
|
|
|
|
}else { |
|
|
|
|
|
//
|
|
|
|
|
|
dto.setGridId(formDTO.getOrgId()); |
|
|
|
|
|
dto.setAgencyId(gridInfo.getPid()); |
|
|
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|
|
|
|
|
if (null == agencyInfo){ |
|
|
|
|
|
throw new EpmetException("查询组织信息失败..."); |
|
|
|
|
|
} |
|
|
|
|
|
dto.setPid(agencyInfo.getPid()); |
|
|
|
|
|
dto.setPids(agencyInfo.getPids()); |
|
|
|
|
|
fillData(dto,CustomerGridConstant.GRID); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -83,7 +109,79 @@ public class ImportNeighborHoodInfoListener extends AnalysisEventListener<Neighb |
|
|
* @date 2022/2/15 2:37 下午 |
|
|
* @date 2022/2/15 2:37 下午 |
|
|
*/ |
|
|
*/ |
|
|
public void disposeAgencyNeighborHood(ImportGeneralDTO dto){ |
|
|
public void disposeAgencyNeighborHood(ImportGeneralDTO dto){ |
|
|
|
|
|
agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; |
|
|
|
|
|
//排除不是本组织的
|
|
|
|
|
|
if (!dto.getAgencyName().equals(agencyName)){ |
|
|
|
|
|
nums.add(num); |
|
|
|
|
|
}else { |
|
|
|
|
|
// 根据组织查询出所有网格,甩出不是本组织下的网格
|
|
|
|
|
|
gridInfos = null == gridInfos ? getGridInfos(formDTO.getOrgId()) : gridInfos; |
|
|
|
|
|
if (null == gridInfos){ |
|
|
|
|
|
// 组织下确实不存在网格
|
|
|
|
|
|
nums.add(num); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
// 根据网格名对比,没有找到的就把行号加入到未执行成功队列中
|
|
|
|
|
|
Object cacheGridName = icHouseRedis.getTemporaryCacheGrid(formDTO.getCustomerId(), formDTO.getUserId(), dto.getGridName()); |
|
|
|
|
|
if (null == cacheGridName){ |
|
|
|
|
|
nums.add(num); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
dto.setGridId(cacheGridName.toString()); |
|
|
|
|
|
dto.setAgencyId(formDTO.getOrgId()); |
|
|
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|
|
|
|
|
if (null == agencyInfo){ |
|
|
|
|
|
throw new EpmetException("查询组织信息失败..."); |
|
|
|
|
|
} |
|
|
|
|
|
dto.setPid(agencyInfo.getPid()); |
|
|
|
|
|
dto.setPids(agencyInfo.getPids()); |
|
|
|
|
|
fillData(dto,CustomerGridConstant.AGENCY); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void fillData(ImportGeneralDTO dto,String orgType){ |
|
|
|
|
|
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(), dto.getGridId() + "_" + dto.getNeighborHoodName()); |
|
|
|
|
|
// 赋值小区ID
|
|
|
|
|
|
dto.setNeighborHoodId(null == cacheNeighBorHood ? "" : cacheNeighBorHood.toString()); |
|
|
|
|
|
if (StringUtils.isNotBlank(dto.getNeighborHoodId())){ |
|
|
|
|
|
// 小区已存在
|
|
|
|
|
|
nums.add(dto.getNum()); |
|
|
|
|
|
}else { |
|
|
|
|
|
needDisposeList.add(dto); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 获取网格信息 |
|
|
|
|
|
* @param orgId |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2022/2/14 9:57 上午 |
|
|
|
|
|
*/ |
|
|
|
|
|
public Map<String,Object> getGridInfos(String orgId){ |
|
|
|
|
|
gridInfoDTOs = icBuildingDao.selectAllGridByOrgId(orgId); |
|
|
|
|
|
gridInfos = gridInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridName(), n -> n.getGridId())); |
|
|
|
|
|
icHouseRedis.setTemporaryCacheGrid(formDTO.getCustomerId(), gridInfos, formDTO.getUserId()); |
|
|
|
|
|
return gridInfos; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Description 获取网格下的小区 |
|
|
|
|
|
* @param gridIds |
|
|
|
|
|
* @author zxc |
|
|
|
|
|
* @date 2022/2/14 10:16 上午 |
|
|
|
|
|
*/ |
|
|
|
|
|
public Map<String,Object> getNeighborHoodInfos(List<String> gridIds){ |
|
|
|
|
|
neighborHoodInfoDTOs = icBuildingDao.selectAllNeighborHoodByGridIds(gridIds); |
|
|
|
|
|
neighborHoodInfos = neighborHoodInfoDTOs.stream().collect(Collectors.toMap(n -> n.getGridId() + "_" + n.getNeighborHoodName(), n -> n.getNeighborHoodId())); |
|
|
|
|
|
icHouseRedis.setTemporaryCacheNeighBorHood(formDTO.getCustomerId(), neighborHoodInfos, formDTO.getUserId()); |
|
|
|
|
|
return neighborHoodInfos; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|