|
@ -2,26 +2,22 @@ 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.alibaba.fastjson.JSON; |
|
|
|
|
|
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.exception.EpmetException; |
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
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.AgencyInfoCache; |
|
|
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; |
|
|
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.CustomerAgencyConstant; |
|
|
|
|
|
import com.epmet.constant.CustomerGridConstant; |
|
|
import com.epmet.constant.CustomerGridConstant; |
|
|
import com.epmet.dao.IcBuildingDao; |
|
|
import com.epmet.dao.IcBuildingDao; |
|
|
import com.epmet.dto.ImportHouseGeneralDTO; |
|
|
import com.epmet.dto.ImportGeneralDTO; |
|
|
import com.epmet.dto.form.ImportInfoFormDTO; |
|
|
import com.epmet.dto.form.ImportInfoFormDTO; |
|
|
import com.epmet.dto.result.ImportResultDTO; |
|
|
import com.epmet.dto.result.ImportResultDTO; |
|
|
import com.epmet.entity.IcHouseEntity; |
|
|
import com.epmet.entity.IcHouseEntity; |
|
|
import com.epmet.enums.HousePurposeEnums; |
|
|
import com.epmet.enums.HousePurposeEnums; |
|
|
import com.epmet.enums.HouseRentFlagEnums; |
|
|
import com.epmet.enums.HouseRentFlagEnums; |
|
|
import com.epmet.enums.HouseTypeEnums; |
|
|
import com.epmet.enums.HouseTypeEnums; |
|
|
import com.epmet.excel.IcNeighborHoodExcel; |
|
|
|
|
|
import com.epmet.redis.IcHouseRedis; |
|
|
import com.epmet.redis.IcHouseRedis; |
|
|
import com.epmet.service.HouseService; |
|
|
|
|
|
import com.epmet.service.IcHouseService; |
|
|
import com.epmet.service.IcHouseService; |
|
|
import com.epmet.service.IcNeighborHoodService; |
|
|
import com.epmet.service.IcNeighborHoodService; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
@ -41,22 +37,22 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
List<Integer> nums = new ArrayList<>(); |
|
|
List<Integer> nums = new ArrayList<>(); |
|
|
Integer num = NumConstant.ZERO; |
|
|
Integer num = NumConstant.ZERO; |
|
|
|
|
|
|
|
|
List<ImportHouseGeneralDTO> needDisposeList = new ArrayList<>(); |
|
|
List<ImportGeneralDTO> needDisposeList = new ArrayList<>(); |
|
|
List<ImportHouseGeneralDTO> needInsertList = new ArrayList<>(); |
|
|
List<ImportGeneralDTO> needInsertList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
String gridName = null; |
|
|
String gridName = null; |
|
|
String agencyName = null; |
|
|
String agencyName = null; |
|
|
|
|
|
|
|
|
Map<String, Object> gridInfos = null; |
|
|
Map<String, Object> gridInfos = null; |
|
|
List<ImportHouseGeneralDTO> gridInfoDTOs = null; |
|
|
List<ImportGeneralDTO> gridInfoDTOs = null; |
|
|
Map<String, Object> neighborHoodInfos = null; |
|
|
Map<String, Object> neighborHoodInfos = null; |
|
|
List<ImportHouseGeneralDTO> neighborHoodInfoDTOs = null; |
|
|
List<ImportGeneralDTO> neighborHoodInfoDTOs = null; |
|
|
ImportHouseGeneralDTO neighborHoodGeneralDTO = null; |
|
|
ImportGeneralDTO neighborHoodGeneralDTO = null; |
|
|
Map<String, Object> buildingInfos = null; |
|
|
Map<String, Object> buildingInfos = null; |
|
|
List<ImportHouseGeneralDTO> buildingInfoDTOs = null; |
|
|
List<ImportGeneralDTO> buildingInfoDTOs = null; |
|
|
ImportHouseGeneralDTO buildingGeneralDTO = null; |
|
|
ImportGeneralDTO buildingGeneralDTO = null; |
|
|
Map<String, Object> buildingUnitInfos = null; |
|
|
Map<String, Object> buildingUnitInfos = null; |
|
|
List<ImportHouseGeneralDTO> buildingUnitInfoDTOs = null; |
|
|
List<ImportGeneralDTO> buildingUnitInfoDTOs = null; |
|
|
|
|
|
|
|
|
private ImportInfoFormDTO formDTO; |
|
|
private ImportInfoFormDTO formDTO; |
|
|
private IcBuildingDao icBuildingDao; |
|
|
private IcBuildingDao icBuildingDao; |
|
@ -78,7 +74,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
num = num + NumConstant.ONE; |
|
|
num = num + NumConstant.ONE; |
|
|
ImportHouseGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportHouseGeneralDTO.class); |
|
|
ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); |
|
|
dto.setNum(num); |
|
|
dto.setNum(num); |
|
|
dto.setCustomerId(formDTO.getCustomerId()); |
|
|
dto.setCustomerId(formDTO.getCustomerId()); |
|
|
dto.setHouseType(HouseTypeEnums.getKeyByValue(dto.getHouseType())); |
|
|
dto.setHouseType(HouseTypeEnums.getKeyByValue(dto.getHouseType())); |
|
@ -101,12 +97,12 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void finalDispose(){ |
|
|
public void finalDispose(){ |
|
|
List<ImportHouseGeneralDTO> importInfo = neighborHoodService.getImportInfo(formDTO, needDisposeList); |
|
|
List<ImportGeneralDTO> importInfo = neighborHoodService.getImportInfo(formDTO, needDisposeList); |
|
|
needInsertList.addAll(importInfo); |
|
|
needInsertList.addAll(importInfo); |
|
|
Map<String, Long> collect = needInsertList.stream().collect(Collectors.groupingBy(n -> n.getBuildingUnitId() + "_" + n.getDoorName(), Collectors.counting())); |
|
|
Map<String, Long> collect = needInsertList.stream().collect(Collectors.groupingBy(n -> n.getBuildingUnitId() + "_" + n.getDoorName(), Collectors.counting())); |
|
|
collect.forEach((k,v) -> { |
|
|
collect.forEach((k,v) -> { |
|
|
if (Integer.valueOf(v.toString()).compareTo(1) > 0){ |
|
|
if (Integer.valueOf(v.toString()).compareTo(1) > 0){ |
|
|
for (ImportHouseGeneralDTO r : needInsertList) { |
|
|
for (ImportGeneralDTO r : needInsertList) { |
|
|
if (k.equals(r.getBuildingUnitId()+"_"+r.getDoorName())){ |
|
|
if (k.equals(r.getBuildingUnitId()+"_"+r.getDoorName())){ |
|
|
// 集合里重复的
|
|
|
// 集合里重复的
|
|
|
r.setExistStatus(true); |
|
|
r.setExistStatus(true); |
|
@ -119,7 +115,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
List<String> ids = needInsertList.stream().map(m -> m.getBuildingUnitId() + "_" + m.getDoorName()).distinct().collect(Collectors.toList()); |
|
|
List<String> ids = needInsertList.stream().map(m -> m.getBuildingUnitId() + "_" + m.getDoorName()).distinct().collect(Collectors.toList()); |
|
|
List<String> existHouses = icBuildingDao.selectExistHouse(ids); |
|
|
List<String> existHouses = icBuildingDao.selectExistHouse(ids); |
|
|
existHouses.forEach(e -> { |
|
|
existHouses.forEach(e -> { |
|
|
for (ImportHouseGeneralDTO n : needInsertList) { |
|
|
for (ImportGeneralDTO n : needInsertList) { |
|
|
if ((n.getBuildingUnitId()+"_"+n.getDoorName()).equals(e)){ |
|
|
if ((n.getBuildingUnitId()+"_"+n.getDoorName()).equals(e)){ |
|
|
// 库里存在的
|
|
|
// 库里存在的
|
|
|
n.setExistStatus(true); |
|
|
n.setExistStatus(true); |
|
@ -128,9 +124,9 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
// 根据存在状态分组
|
|
|
// 根据存在状态分组
|
|
|
Map<Boolean, List<ImportHouseGeneralDTO>> groupByExistStatus = needInsertList.stream().collect(Collectors.groupingBy(ImportHouseGeneralDTO::getExistStatus)); |
|
|
Map<Boolean, List<ImportGeneralDTO>> groupByExistStatus = needInsertList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); |
|
|
List<ImportHouseGeneralDTO> importHouseGeneralDTOS = groupByExistStatus.get(false); |
|
|
List<ImportGeneralDTO> importGeneralDTOS = groupByExistStatus.get(false); |
|
|
houseInsert(importHouseGeneralDTOS); |
|
|
houseInsert(importGeneralDTOS); |
|
|
// 清除
|
|
|
// 清除
|
|
|
needDisposeList = new ArrayList<>(); |
|
|
needDisposeList = new ArrayList<>(); |
|
|
needInsertList = new ArrayList<>(); |
|
|
needInsertList = new ArrayList<>(); |
|
@ -154,7 +150,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
* @date 2022/2/14 3:23 下午 |
|
|
* @date 2022/2/14 3:23 下午 |
|
|
*/ |
|
|
*/ |
|
|
public void disposeBuildingHouse(ImportHouseGeneralDTO dto){ |
|
|
public void disposeBuildingHouse(ImportGeneralDTO dto){ |
|
|
buildingGeneralDTO = null == buildingGeneralDTO ? icBuildingDao.selectBuildingById(formDTO.getOrgId()) : buildingGeneralDTO; |
|
|
buildingGeneralDTO = null == buildingGeneralDTO ? icBuildingDao.selectBuildingById(formDTO.getOrgId()) : buildingGeneralDTO; |
|
|
// 排除不是本楼的
|
|
|
// 排除不是本楼的
|
|
|
if (!dto.getBuildingName().equals(buildingGeneralDTO.getBuildingName())){ |
|
|
if (!dto.getBuildingName().equals(buildingGeneralDTO.getBuildingName())){ |
|
@ -204,7 +200,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
* @date 2022/2/14 3:23 下午 |
|
|
* @date 2022/2/14 3:23 下午 |
|
|
*/ |
|
|
*/ |
|
|
public void disposeNeighborHoodHouse(ImportHouseGeneralDTO dto){ |
|
|
public void disposeNeighborHoodHouse(ImportGeneralDTO dto){ |
|
|
neighborHoodGeneralDTO = null == neighborHoodGeneralDTO ? icBuildingDao.selectNeighborHoodById(formDTO.getOrgId()) : neighborHoodGeneralDTO; |
|
|
neighborHoodGeneralDTO = null == neighborHoodGeneralDTO ? icBuildingDao.selectNeighborHoodById(formDTO.getOrgId()) : neighborHoodGeneralDTO; |
|
|
//排除不是本小区的
|
|
|
//排除不是本小区的
|
|
|
if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){ |
|
|
if (!dto.getNeighborHoodName().equals(neighborHoodGeneralDTO.getNeighborHoodName())){ |
|
@ -240,7 +236,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
* @date 2022/2/14 2:14 下午 |
|
|
* @date 2022/2/14 2:14 下午 |
|
|
*/ |
|
|
*/ |
|
|
public void disposeGridHouse(ImportHouseGeneralDTO dto){ |
|
|
public void disposeGridHouse(ImportGeneralDTO dto){ |
|
|
gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; |
|
|
gridName = null == gridName ? icBuildingDao.selectGridNameById(formDTO.getOrgId()) : gridName; |
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); |
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(formDTO.getOrgId()); |
|
|
if (null == gridInfo){ |
|
|
if (null == gridInfo){ |
|
@ -270,7 +266,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
* @author zxc |
|
|
* @author zxc |
|
|
* @date 2022/2/14 1:35 下午 |
|
|
* @date 2022/2/14 1:35 下午 |
|
|
*/ |
|
|
*/ |
|
|
public void disposeAgencyHouse(ImportHouseGeneralDTO dto){ |
|
|
public void disposeAgencyHouse(ImportGeneralDTO dto){ |
|
|
agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; |
|
|
agencyName = null == agencyName ? icBuildingDao.selectAgencyNameById(formDTO.getOrgId()) : agencyName; |
|
|
//排除不是本组织的
|
|
|
//排除不是本组织的
|
|
|
if (!dto.getAgencyName().equals(agencyName)){ |
|
|
if (!dto.getAgencyName().equals(agencyName)){ |
|
@ -302,7 +298,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void fillData(ImportHouseGeneralDTO dto,String orgType){ |
|
|
public void fillData(ImportGeneralDTO dto, String orgType){ |
|
|
if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ |
|
|
if (orgType.equals(CustomerGridConstant.GRID) || orgType.equals(CustomerGridConstant.AGENCY)){ |
|
|
List<String> gridIds = new ArrayList<>(); |
|
|
List<String> gridIds = new ArrayList<>(); |
|
|
if (orgType.equals(CustomerGridConstant.GRID)){ |
|
|
if (orgType.equals(CustomerGridConstant.GRID)){ |
|
@ -412,7 +408,7 @@ public class ImportHouseInfoListener extends AnalysisEventListener<HouseInfoMode |
|
|
* @date 2022/2/14 5:21 下午 |
|
|
* @date 2022/2/14 5:21 下午 |
|
|
*/ |
|
|
*/ |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void houseInsert(List<ImportHouseGeneralDTO> houses){ |
|
|
public void houseInsert(List<ImportGeneralDTO> houses){ |
|
|
if (!CollectionUtils.isEmpty(houses)){ |
|
|
if (!CollectionUtils.isEmpty(houses)){ |
|
|
icHouseService.insertBatch(ConvertUtils.sourceToTarget(houses, IcHouseEntity.class)); |
|
|
icHouseService.insertBatch(ConvertUtils.sourceToTarget(houses, IcHouseEntity.class)); |
|
|
} |
|
|
} |
|
|