49 changed files with 1588 additions and 201 deletions
@ -0,0 +1,31 @@ |
|||
package com.epmet.dto.result; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Data; |
|||
import lombok.NoArgsConstructor; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 9:25 上午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class ImportResultDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = -5817164530837181890L; |
|||
|
|||
/** |
|||
* 未导入的行号 |
|||
*/ |
|||
private List<Integer> nums; |
|||
|
|||
/** |
|||
* 总条数 |
|||
*/ |
|||
private Integer num; |
|||
} |
@ -0,0 +1,38 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 10:07 上午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class BuildingInfoModel { |
|||
|
|||
@ExcelProperty(value = "所属组织") |
|||
private String agencyName; |
|||
|
|||
@ExcelProperty(value = "所属网格") |
|||
private String gridName; |
|||
|
|||
@ExcelProperty(value = "小区名称") |
|||
private String neighborHoodName; |
|||
|
|||
@ExcelProperty(value = "楼栋名称") |
|||
private String buildingName; |
|||
|
|||
@ExcelProperty(value = "楼栋类型") |
|||
private String type; |
|||
|
|||
@ExcelProperty(value = "单元数") |
|||
private Integer totalUnitNum; |
|||
|
|||
@ExcelProperty(value = "层数") |
|||
private Integer totalFloorNum; |
|||
|
|||
@ExcelProperty(value = "户数") |
|||
private Integer totalHouseNum; |
|||
|
|||
} |
@ -1,41 +0,0 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import lombok.Data; |
|||
import org.hibernate.validator.constraints.Length; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/13 1:26 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class HouseInfoModelDTO { |
|||
|
|||
private String agencyName; |
|||
|
|||
private String gridName; |
|||
|
|||
private String neighborHoodName; |
|||
|
|||
private String buildingName; |
|||
|
|||
private Integer buildingUnit; |
|||
|
|||
private String doorName; |
|||
|
|||
private String houseType; |
|||
|
|||
private String purpose; |
|||
|
|||
private String rentFlag; |
|||
|
|||
private String ownerName; |
|||
|
|||
private String ownerPhone; |
|||
|
|||
private String ownerIdCard; |
|||
|
|||
private Integer num; |
|||
|
|||
} |
@ -0,0 +1,315 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
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.CustomerGridConstant; |
|||
import com.epmet.dao.IcBuildingDao; |
|||
import com.epmet.dto.ImportGeneralDTO; |
|||
import com.epmet.dto.form.ImportInfoFormDTO; |
|||
import com.epmet.dto.result.ImportResultDTO; |
|||
import com.epmet.enums.BuildingTypeEnums; |
|||
import com.epmet.redis.IcHouseRedis; |
|||
import com.epmet.service.IcNeighborHoodService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 10:06 上午 |
|||
* @DESC |
|||
*/ |
|||
public class ImportBuildingInfoListener extends AnalysisEventListener<BuildingInfoModel> { |
|||
|
|||
List<Integer> nums = new ArrayList<>(); |
|||
Integer num = NumConstant.ZERO; |
|||
|
|||
List<ImportGeneralDTO> needDisposeList = new ArrayList<>(); |
|||
List<ImportGeneralDTO> needInsertList = new ArrayList<>(); |
|||
|
|||
String gridName = null; |
|||
String agencyName = null; |
|||
|
|||
Map<String, Object> gridInfos = null; |
|||
List<ImportGeneralDTO> gridInfoDTOs = null; |
|||
Map<String, Object> neighborHoodInfos = null; |
|||
List<ImportGeneralDTO> neighborHoodInfoDTOs = null; |
|||
ImportGeneralDTO neighborHoodGeneralDTO = null; |
|||
Map<String, Object> buildingInfos = null; |
|||
List<ImportGeneralDTO> buildingInfoDTOs = null; |
|||
ImportGeneralDTO buildingGeneralDTO = null; |
|||
|
|||
private ImportInfoFormDTO formDTO; |
|||
private IcHouseRedis icHouseRedis; |
|||
private IcBuildingDao icBuildingDao; |
|||
private IcNeighborHoodService neighborHoodService; |
|||
|
|||
public ImportBuildingInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService){ |
|||
this.formDTO = formDTO; |
|||
this.icHouseRedis = icHouseRedis; |
|||
this.icBuildingDao = icBuildingDao; |
|||
this.neighborHoodService = neighborHoodService; |
|||
} |
|||
|
|||
@Override |
|||
public void invoke(BuildingInfoModel data, AnalysisContext context) { |
|||
if (null == data){ |
|||
return; |
|||
} |
|||
num = num + NumConstant.ONE; |
|||
ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); |
|||
dto.setNum(num); |
|||
dto.setCustomerId(formDTO.getCustomerId()); |
|||
dto.setType(BuildingTypeEnums.getKeyByValue(dto.getType())); |
|||
if (formDTO.getOrgType().equals(CustomerGridConstant.NEIGHBORHOOD)){ |
|||
disposeNeighborHoodBuilding(dto); |
|||
}else if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ |
|||
disposeGridBuilding(dto); |
|||
}else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ |
|||
disposeAgencyBuilding(dto); |
|||
} |
|||
// 数据筛选完毕,当num每满100条,处理一次
|
|||
if (num%NumConstant.ONE_HUNDRED == NumConstant.ZERO){ |
|||
finalDispose(); |
|||
} |
|||
} |
|||
|
|||
public void finalDispose(){ |
|||
Map<String, Long> groupByAllName = needDisposeList.stream().collect(Collectors.groupingBy( |
|||
n -> n.getAgencyName() + "_" + n.getGridName() + "_" + |
|||
n.getNeighborHoodName() + "_" + n.getBuildingName(), Collectors.counting())); |
|||
groupByAllName.forEach((k,v) -> { |
|||
if (Integer.valueOf(v.toString()).compareTo(1) > 0){ |
|||
for (ImportGeneralDTO r : needDisposeList) { |
|||
if (k.equals(r.getAgencyName() + "_" + r.getGridName() + "_" + |
|||
r.getNeighborHoodName() + "_" + r.getBuildingName())){ |
|||
// 集合里重复的
|
|||
r.setExistStatus(true); |
|||
nums.add(r.getNum()); |
|||
} |
|||
} |
|||
} |
|||
}); |
|||
Map<Boolean, List<ImportGeneralDTO>> groupByStatus = needDisposeList.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getExistStatus)); |
|||
List<ImportGeneralDTO> importGeneralDTOS = groupByStatus.get(false); |
|||
if (!CollectionUtils.isEmpty(importGeneralDTOS)){ |
|||
List<ImportGeneralDTO> importInfo = neighborHoodService.getImportInfo(formDTO, importGeneralDTOS); |
|||
Map<Boolean, List<ImportGeneralDTO>> groupByBuildingExistStatus = importInfo.stream().collect(Collectors.groupingBy(ImportGeneralDTO::getBuildingExistStatus)); |
|||
List<ImportGeneralDTO> existList = groupByBuildingExistStatus.get(true); |
|||
if (!CollectionUtils.isEmpty(existList)){ |
|||
existList.forEach(e -> { |
|||
nums.add(e.getNum()); |
|||
}); |
|||
} |
|||
} |
|||
// 清除
|
|||
needDisposeList = new ArrayList<>(); |
|||
needInsertList = new ArrayList<>(); |
|||
gridName = null; |
|||
agencyName = null; |
|||
gridInfos = null; |
|||
gridInfoDTOs = null; |
|||
neighborHoodInfos = null; |
|||
neighborHoodInfoDTOs = null; |
|||
neighborHoodGeneralDTO = null; |
|||
buildingInfos = null; |
|||
buildingInfoDTOs = null; |
|||
buildingGeneralDTO = null; |
|||
} |
|||
|
|||
public void fillData(ImportGeneralDTO 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; |
|||
Object cacheBuilding = icHouseRedis.getTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId(), dto.getNeighborHoodId() + "_" + dto.getBuildingName()); |
|||
dto.setBuildingId(null == cacheBuilding ? "" : cacheBuilding.toString()); |
|||
if (StringUtils.isNotBlank(dto.getBuildingId())){ |
|||
// 说明数据库已存在此楼栋,不需添加
|
|||
nums.add(num); |
|||
}else { |
|||
needDisposeList.add(dto); |
|||
} |
|||
}else { |
|||
needDisposeList.add(dto); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击小区时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 10:41 上午 |
|||
*/ |
|||
public void disposeNeighborHoodBuilding(ImportGeneralDTO 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("查询网格失败..."); |
|||
} |
|||
// 1.排除网格名不一样但小区名一样 2.排除组织不一样,网格一样,小区一样
|
|||
if ((!gridInfo.getGridName().equals(dto.getGridName()) && neighborHoodGeneralDTO.getNeighborHoodName().equals(dto.getNeighborHoodName())) || |
|||
(!gridInfo.getAgencyName().equals(dto.getAgencyName()) && 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()); |
|||
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(dto.getAgencyId()); |
|||
if (null == agencyInfo){ |
|||
throw new EpmetException("查询组织信息失败..."); |
|||
} |
|||
dto.setPid(agencyInfo.getPid()); |
|||
dto.setPids(agencyInfo.getPids()); |
|||
// 填充各种ID
|
|||
fillData(dto,CustomerGridConstant.NEIGHBORHOOD); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击网格时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 10:41 上午 |
|||
*/ |
|||
public void disposeGridBuilding(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()); |
|||
// 填充各种ID
|
|||
fillData(dto, CustomerGridConstant.GRID); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击组织时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 10:41 上午 |
|||
*/ |
|||
public void disposeAgencyBuilding(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()); |
|||
// 填充各种ID
|
|||
fillData(dto,CustomerGridConstant.AGENCY); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @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; |
|||
} |
|||
|
|||
/** |
|||
* @Description 获取小区下的楼栋 |
|||
* @param neighborHoodId |
|||
* @author zxc |
|||
* @date 2022/2/14 1:32 下午 |
|||
*/ |
|||
public Map<String,Object> getBuildingInfos(String neighborHoodId){ |
|||
buildingInfoDTOs = icBuildingDao.selectAllBuildingByNeighborHoodId(neighborHoodId); |
|||
buildingInfos = buildingInfoDTOs.stream().collect(Collectors.toMap(n -> n.getNeighborHoodId() + "_" + n.getBuildingName(), n -> n.getBuildingId())); |
|||
icHouseRedis.setTemporaryCacheBuilding(formDTO.getCustomerId(), buildingInfos, formDTO.getUserId()); |
|||
return buildingInfos; |
|||
} |
|||
|
|||
@Override |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
finalDispose(); |
|||
// 删除缓存
|
|||
icHouseRedis.delTemporaryCacheGrids(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheNeighBorHood(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheBuilding(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheBuildingUnit(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
icHouseRedis.delTemporaryCacheHouses(formDTO.getCustomerId(), formDTO.getUserId()); |
|||
// 放结果
|
|||
icHouseRedis.setImportResultDTO(formDTO.getCustomerId(), formDTO.getUserId(), new ImportResultDTO(nums,num)); |
|||
} |
|||
} |
@ -0,0 +1,191 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.context.AnalysisContext; |
|||
import com.alibaba.excel.event.AnalysisEventListener; |
|||
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.CustomerGridConstant; |
|||
import com.epmet.dao.IcBuildingDao; |
|||
import com.epmet.dto.ImportGeneralDTO; |
|||
import com.epmet.dto.form.ImportInfoFormDTO; |
|||
import com.epmet.redis.IcHouseRedis; |
|||
import com.epmet.service.IcNeighborHoodService; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 2:16 下午 |
|||
* @DESC |
|||
*/ |
|||
public class ImportNeighborHoodInfoListener extends AnalysisEventListener<NeighborHoodInfoModel> { |
|||
|
|||
List<Integer> nums = new ArrayList<>(); |
|||
Integer num = NumConstant.ZERO; |
|||
|
|||
List<ImportGeneralDTO> needDisposeList = new ArrayList<>(); |
|||
List<ImportGeneralDTO> needInsertList = new ArrayList<>(); |
|||
|
|||
String gridName = null; |
|||
String agencyName = null; |
|||
|
|||
Map<String, Object> gridInfos = null; |
|||
List<ImportGeneralDTO> gridInfoDTOs = null; |
|||
Map<String, Object> neighborHoodInfos = null; |
|||
List<ImportGeneralDTO> neighborHoodInfoDTOs = null; |
|||
ImportGeneralDTO neighborHoodGeneralDTO = null; |
|||
|
|||
private ImportInfoFormDTO formDTO; |
|||
private IcHouseRedis icHouseRedis; |
|||
private IcBuildingDao icBuildingDao; |
|||
private IcNeighborHoodService neighborHoodService; |
|||
|
|||
public ImportNeighborHoodInfoListener(ImportInfoFormDTO formDTO, IcHouseRedis icHouseRedis,IcBuildingDao icBuildingDao,IcNeighborHoodService neighborHoodService){ |
|||
this.formDTO = formDTO; |
|||
this.icHouseRedis = icHouseRedis; |
|||
this.icBuildingDao = icBuildingDao; |
|||
this.neighborHoodService = neighborHoodService; |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public void invoke(NeighborHoodInfoModel data, AnalysisContext context) { |
|||
if (null == data){ |
|||
return; |
|||
} |
|||
num = num + NumConstant.ONE; |
|||
ImportGeneralDTO dto = ConvertUtils.sourceToTarget(data, ImportGeneralDTO.class); |
|||
dto.setNum(num); |
|||
dto.setCustomerId(formDTO.getCustomerId()); |
|||
if (formDTO.getOrgType().equals(CustomerGridConstant.GRID)){ |
|||
disposeGridNeighborHood(dto); |
|||
}else if (formDTO.getOrgType().equals(CustomerGridConstant.AGENCY)){ |
|||
disposeAgencyNeighborHood(dto); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击网格时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 2:37 下午 |
|||
*/ |
|||
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); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* @Description 左侧树点击组织时调用 |
|||
* @param dto |
|||
* @author zxc |
|||
* @date 2022/2/15 2:37 下午 |
|||
*/ |
|||
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 |
|||
public void doAfterAllAnalysed(AnalysisContext context) { |
|||
|
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.epmet.model; |
|||
|
|||
import com.alibaba.excel.annotation.ExcelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @Author zxc |
|||
* @DateTime 2022/2/15 2:15 下午 |
|||
* @DESC |
|||
*/ |
|||
@Data |
|||
public class NeighborHoodInfoModel { |
|||
|
|||
@ExcelProperty(value = "所属组织") |
|||
private String agencyName; |
|||
|
|||
@ExcelProperty(value = "所属网格") |
|||
private String gridName; |
|||
|
|||
@ExcelProperty(value = "小区名称") |
|||
private String neighborHoodName; |
|||
|
|||
@ExcelProperty(value = "关联物业") |
|||
private String propertyName; |
|||
|
|||
@ExcelProperty(value = "详细地址") |
|||
private String address; |
|||
|
|||
@ExcelProperty(value = "备注") |
|||
private String remark; |
|||
|
|||
} |
@ -0,0 +1,2 @@ |
|||
ALTER TABLE `epmet_gov_org`.`ic_neighbor_hood` |
|||
MODIFY COLUMN `ADDRESS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '详细地址' AFTER `GRID_ID`; |
@ -0,0 +1,23 @@ |
|||
package com.epmet.resi.partymember.dto.partymember.form; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
|
|||
@Data |
|||
public class StyleShowListFormDTO implements Serializable { |
|||
public interface AddUserInternalGroup { |
|||
} |
|||
|
|||
@NotBlank(message = "userId不能为空", groups = AddUserInternalGroup.class) |
|||
private String userId; |
|||
@NotBlank(message = "customerId不能为空", groups = AddUserInternalGroup.class) |
|||
private String customerId; |
|||
|
|||
@NotNull(message = "pageNo不能为空", groups = AddUserInternalGroup.class) |
|||
private Integer pageNo; |
|||
@NotNull(message = "pageSize不能为空", groups = AddUserInternalGroup.class) |
|||
private Integer pageSize; |
|||
} |
@ -0,0 +1 @@ |
|||
alter table ic_partymember_style add COLUMN GRID_PIDS VARCHAR(255) comment '网格的所有上级' after GRID_ID; |
Loading…
Reference in new issue