|
|
@ -4,9 +4,12 @@ import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
|
|
import com.epmet.commons.tools.redis.common.CustomerStaffRedis; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.dao.*; |
|
|
import com.epmet.dao.*; |
|
|
import com.epmet.dto.BuildingTreeLevelDTO; |
|
|
import com.epmet.dto.BuildingTreeLevelDTO; |
|
|
import com.epmet.dto.CustomerStaffAgencyDTO; |
|
|
import com.epmet.dto.CustomerStaffAgencyDTO; |
|
|
@ -207,10 +210,23 @@ public class BuildingServiceImpl implements BuildingService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void importExcel(String customerId, List<IcBuildingExcel> list) { |
|
|
public Result importExcel(String customerId, List<IcBuildingExcel> list, String staffId) { |
|
|
|
|
|
//2021.11.9 需求变更 当前工作人员只能导致自己所属组织下数据,网格名对应不上的数据舍弃【注:需求就这样】 sun
|
|
|
|
|
|
CustomerStaffInfoCacheResult staffInfoCache = CustomerStaffRedis.getStaffInfo(customerId, staffId); |
|
|
|
|
|
//组织名称不一样的数据舍弃
|
|
|
|
|
|
Iterator<IcBuildingExcel> iterator = list.iterator(); |
|
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
|
IcBuildingExcel obj = iterator.next(); |
|
|
|
|
|
if (!obj.getAgencyName().trim().equals(staffInfoCache.getAgencyName())) { |
|
|
|
|
|
iterator.remove(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//用于存储匹配不上的数据给前端的提示 如南宁社区不存在
|
|
|
|
|
|
StringBuffer str = new StringBuffer(""); |
|
|
|
|
|
//end sun
|
|
|
//导入
|
|
|
//导入
|
|
|
if(CollectionUtils.isEmpty(list)){ |
|
|
if(CollectionUtils.isEmpty(list)){ |
|
|
return ; |
|
|
return new Result(); |
|
|
} |
|
|
} |
|
|
//查询所有组织和网格根据名字
|
|
|
//查询所有组织和网格根据名字
|
|
|
|
|
|
|
|
|
@ -235,6 +251,10 @@ public class BuildingServiceImpl implements BuildingService { |
|
|
entity.setId(uuid); |
|
|
entity.setId(uuid); |
|
|
entity.setCustomerId(customerId); |
|
|
entity.setCustomerId(customerId); |
|
|
entity.setNeighborHoodId(Optional.ofNullable(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName())).map(u->u.getId()).orElse(""));//neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId()
|
|
|
entity.setNeighborHoodId(Optional.ofNullable(neighborHoodMap.get(icBuildingExcel.getNeighborHoodName())).map(u->u.getId()).orElse(""));//neighborHoodMap.get(icBuildingExcel.getNeighborHoodName()).getId()
|
|
|
|
|
|
if ("".equals(entity.getNeighborHoodId())) { |
|
|
|
|
|
str.append("".equals(str) ? icBuildingExcel.getNeighborHoodName() : str.append("、").append(icBuildingExcel.getNeighborHoodName())); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
entity.setBuildingName(icBuildingExcel.getBuildingName()); |
|
|
entity.setBuildingName(icBuildingExcel.getBuildingName()); |
|
|
entity.setType(BuildingTypeEnums.getKeyByValue(icBuildingExcel.getType())); |
|
|
entity.setType(BuildingTypeEnums.getKeyByValue(icBuildingExcel.getType())); |
|
|
entity.setSort(0); |
|
|
entity.setSort(0); |
|
|
@ -266,6 +286,10 @@ public class BuildingServiceImpl implements BuildingService { |
|
|
icBuildingService.insertBatch(buildingEntityList); |
|
|
icBuildingService.insertBatch(buildingEntityList); |
|
|
icBuildingUnitService.insertBatch(icBuildingUnitEntityList); |
|
|
icBuildingUnitService.insertBatch(icBuildingUnitEntityList); |
|
|
|
|
|
|
|
|
|
|
|
if(!"".equals(str)){ |
|
|
|
|
|
return new Result().error(9999, str.append("不存在").toString()); |
|
|
|
|
|
} |
|
|
|
|
|
return new Result(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|