|
|
@ -6,7 +6,6 @@ import com.alibaba.excel.ExcelReader; |
|
|
|
import com.alibaba.excel.read.metadata.ReadSheet; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
|
import com.epmet.commons.tools.enums.OrgTypeEnum; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
@ -14,7 +13,6 @@ import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
|
import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
@ -35,7 +33,6 @@ import com.epmet.dto.result.ImportTaskCommonResultDTO; |
|
|
|
import com.epmet.dto.result.NeighborHoodManageDelResultDTO; |
|
|
|
import com.epmet.entity.IcHouseEntity; |
|
|
|
import com.epmet.enums.HousePurposeEnums; |
|
|
|
import com.epmet.enums.HouseRentFlagEnums; |
|
|
|
import com.epmet.enums.HouseTypeEnums; |
|
|
|
import com.epmet.excel.IcHouseExcel; |
|
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient; |
|
|
@ -163,92 +160,6 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
allDelete(formDTO); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public List<Integer> importExcel(String customerId, List<IcHouseExcel> list, String staffId, List<Integer> numList) { |
|
|
|
//2021.11.10 需求变更 当前工作人员只能导致自己所属组织下数据,对应不上的数据舍弃【注:需求就这样】 sun
|
|
|
|
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId); |
|
|
|
//组织名称不一样的数据舍弃
|
|
|
|
Iterator<IcHouseExcel> iterator = list.iterator(); |
|
|
|
while (iterator.hasNext()) { |
|
|
|
IcHouseExcel obj = iterator.next(); |
|
|
|
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) { |
|
|
|
numList.add(obj.getRowNum()); |
|
|
|
iterator.remove(); |
|
|
|
} |
|
|
|
} |
|
|
|
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
|
|
|
|
//StringBuffer str = new StringBuffer("");
|
|
|
|
//end sun
|
|
|
|
//导入
|
|
|
|
if(CollectionUtils.isEmpty(list)){ |
|
|
|
return numList; |
|
|
|
} |
|
|
|
//获取所有小区 list
|
|
|
|
// List<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toList());
|
|
|
|
// List<IcNeighborHoodEntity> neighborHoodList = icNeighborHoodDao.selectList(new QueryWrapper<IcNeighborHoodEntity>().lambda().in(IcNeighborHoodEntity::getNeighborHoodName, neighborNameList));
|
|
|
|
// Map<String,IcNeighborHoodEntity> neighborHoodMap = neighborHoodList.stream().collect(Collectors.toMap(IcNeighborHoodEntity::getNeighborHoodName, Function.identity(),(key1, key2)->key1));
|
|
|
|
|
|
|
|
//获取所有楼宇 list
|
|
|
|
// List<String> buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
// icBuildingDao.selectList(new QueryWrapper<IcBuildingEntity>().lambda().in(IcBuildingEntity::getBuildingName, buildingNameList).in();
|
|
|
|
Set<String> neighborNameList = list.stream().map(item -> item.getNeighborHoodName()).collect(Collectors.toSet()); |
|
|
|
Set<String> buildingNameList = list.stream().map(item -> item.getBuildingName()).collect(Collectors.toSet()); |
|
|
|
Set<Integer> buildingUnitList = list.stream().map(item -> item.getBuildingUnit()).collect(Collectors.toSet()); |
|
|
|
List<Map<String,Object>> buildMapList = icBuildingDao.selectListByName(customerId, new ArrayList<String>(neighborNameList),new ArrayList<String>(buildingNameList),new ArrayList<Integer>(buildingUnitList)); |
|
|
|
//转Map
|
|
|
|
Map<String,Map<String,Object>> buildMap = new HashMap<>(); |
|
|
|
buildMapList.forEach(item->{ |
|
|
|
buildMap.put(item.get("neighborName")+","+item.get("buildingName")+","+item.get("unitNum"),item); |
|
|
|
}); |
|
|
|
//封装数据
|
|
|
|
List<IcHouseEntity> houseEntityList = new ArrayList<>(); |
|
|
|
Iterator<IcHouseExcel> iterator1 = list.iterator(); |
|
|
|
while (iterator1.hasNext()) { |
|
|
|
IcHouseExcel icHouseExcel = iterator1.next(); |
|
|
|
IcHouseEntity entity = new IcHouseEntity(); |
|
|
|
String uuid = UUID.randomUUID().toString().replace("-", ""); |
|
|
|
entity.setId(uuid); |
|
|
|
entity.setCustomerId(customerId); |
|
|
|
Map<String,Object> item = buildMap.get(icHouseExcel.getNeighborHoodName()+","+icHouseExcel.getBuildingName()+","+icHouseExcel.getBuildingUnit()); |
|
|
|
|
|
|
|
entity.setNeighborHoodId(String.valueOf(Optional.ofNullable(item).map(u->u.get("neighborId")).orElse(""))); |
|
|
|
entity.setBuildingId(String.valueOf(Optional.ofNullable(item).map(u->u.get("buildingId")).orElse(""))); |
|
|
|
entity.setBuildingUnitId(String.valueOf(Optional.ofNullable(item).map(u->u.get("buildingUnitId")).orElse(""))); |
|
|
|
entity.setHouseName(icHouseExcel.getBuildingName()+"-"+icHouseExcel.getBuildingUnit()+"-"+icHouseExcel.getDoorName()); |
|
|
|
if ("".equals(entity.getNeighborHoodId()) || "".equals(entity.getBuildingId()) || "".equals(entity.getBuildingUnitId())) { |
|
|
|
//str.append("".equals(str) ? icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit() : str.append("、").append(icHouseExcel.getBuildingName() + icHouseExcel.getBuildingUnit()));
|
|
|
|
numList.add(icHouseExcel.getRowNum()); |
|
|
|
iterator1.remove(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
entity.setDoorName(icHouseExcel.getDoorName()); |
|
|
|
entity.setHouseType(HouseTypeEnums.getKeyByValue(icHouseExcel.getHouseType())); |
|
|
|
entity.setPurpose(HousePurposeEnums.getKeyByValue(icHouseExcel.getPurpose())); |
|
|
|
entity.setRentFlag(HouseRentFlagEnums.getCodeByName(icHouseExcel.getRentFlag())); |
|
|
|
entity.setOwnerName(icHouseExcel.getOwnerName()); |
|
|
|
entity.setOwnerPhone(icHouseExcel.getOwnerPhone()); |
|
|
|
entity.setOwnerIdCard(icHouseExcel.getOwnerIdCard()); |
|
|
|
//同一楼栋,单元内,房屋名称唯一
|
|
|
|
Integer count = icHouseDao.checkDoorNameUq(entity.getNeighborHoodId(), entity.getBuildingId(), entity.getBuildingUnitId(), entity.getDoorName(),null); |
|
|
|
if (null != count && count > 0) { |
|
|
|
//throw new RenException(EpmetErrorCode.DOOR_NAME_EXITED.getCode(), EpmetErrorCode.DOOR_NAME_EXITED.getMsg());
|
|
|
|
log.error(EpmetErrorCode.DOOR_NAME_EXITED.getMsg()); |
|
|
|
numList.add(icHouseExcel.getRowNum()); |
|
|
|
iterator1.remove(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
houseEntityList.add(entity); |
|
|
|
} |
|
|
|
//3.保存
|
|
|
|
icHouseService.insertBatch(houseEntityList); |
|
|
|
|
|
|
|
|
|
|
|
return numList; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<IcHouseListResultDTO> getHouseList(IcHouseListFormDTO formDTO) { |
|
|
|
|
|
|
@ -293,50 +204,14 @@ public class HouseServiceImpl implements HouseService, ResultDataResolver { |
|
|
|
public void exportBuildinginfo(IcHouseListFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
|
//如果类型是house 查房屋
|
|
|
|
//导出房屋
|
|
|
|
|
|
|
|
List<IcHouseExcel> icHouseExcels = searchAllHouse(formDTO); |
|
|
|
PageData<IcHouseListResultDTO> icHouseExcels = getHouseList(formDTO); |
|
|
|
TemplateExportParams templatePath = new TemplateExportParams("excel/house_export.xlsx"); |
|
|
|
Map<String,Object> map = new HashMap<>(); |
|
|
|
map.put("maplist",icHouseExcels); |
|
|
|
map.put("maplist",icHouseExcels.getList()); |
|
|
|
ExcelPoiUtils.exportExcel(templatePath ,map,"房屋信息录入表",response); |
|
|
|
|
|
|
|
return ; |
|
|
|
} |
|
|
|
private List<IcHouseExcel> searchAllHouse(IcHouseListFormDTO formDTO) { |
|
|
|
|
|
|
|
//IcNeighborHoodEntity neighbor = ConvertUtils.sourceToTarget(formDTO, IcNeighborHoodEntity.class);
|
|
|
|
//
|
|
|
|
//IcBuildingEntity building = ConvertUtils.sourceToTarget(formDTO, IcBuildingEntity.class);
|
|
|
|
|
|
|
|
|
|
|
|
IcHouseEntity house = ConvertUtils.sourceToTarget(formDTO, IcHouseEntity.class); |
|
|
|
house.setDelFlag("0"); |
|
|
|
|
|
|
|
List<IcHouseExcel> icHouseExcels = icHouseDao.searchAllHouse(house); |
|
|
|
icHouseExcels.forEach(item->{ |
|
|
|
item.setHouseType(HouseTypeEnums.getTypeValue(item.getHouseType())); |
|
|
|
item.setPurpose(HousePurposeEnums.getTypeValue(item.getPurpose())); |
|
|
|
}); |
|
|
|
return icHouseExcels; |
|
|
|
} |
|
|
|
|
|
|
|
/*private IPage<Map<String, Object>> searchHouse(String buildingId, |
|
|
|
String ownerName, |
|
|
|
String ownerPhone, |
|
|
|
String neighborHoodName, |
|
|
|
String buildingName, |
|
|
|
Integer pageNo, |
|
|
|
Integer pageSize) { |
|
|
|
IPage<IcHouseEntity> page = new Page<IcHouseEntity>(pageNo,pageSize); |
|
|
|
|
|
|
|
IPage<Map<String, Object>> mapIPage = icHouseDao.searchHouseByPage(page, buildingId, ownerName, ownerPhone, neighborHoodName, buildingName); |
|
|
|
List<Map<String, Object>> records = mapIPage.getRecords(); |
|
|
|
records.forEach(item->{ |
|
|
|
item.put("houseType", HouseTypeEnums.getTypeValue(item.get("houseTypeKey"))); |
|
|
|
item.put("purpose", HousePurposeEnums.getTypeValue(item.get("purposeKey"))); |
|
|
|
}); |
|
|
|
return mapIPage; |
|
|
|
}*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<HouseInfoDTO> queryListHouseInfo(Set<String> houseIdList, String customerId) { |
|
|
|