|  | @ -6,6 +6,9 @@ import cn.afterturn.easypoi.excel.entity.ExportParams; | 
			
		
	
		
		
			
				
					|  |  | import com.alibaba.excel.EasyExcel; |  |  | import com.alibaba.excel.EasyExcel; | 
			
		
	
		
		
			
				
					|  |  | import com.alibaba.excel.EasyExcelFactory; |  |  | import com.alibaba.excel.EasyExcelFactory; | 
			
		
	
		
		
			
				
					|  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.bean.ResiImportCategoryData; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.bean.ResiImportResiCategoryChangedCache; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.bean.ResiImportChangedData; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.ServiceConstant; |  |  | import com.epmet.commons.tools.constant.ServiceConstant; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.constant.StrConstant; |  |  | import com.epmet.commons.tools.constant.StrConstant; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.commons.tools.dto.result.OptionResultDTO; |  |  | import com.epmet.commons.tools.dto.result.OptionResultDTO; | 
			
		
	
	
		
		
			
				
					|  | @ -22,12 +25,14 @@ import com.epmet.dto.form.LoginUserDetailsFormDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.result.FormItemResult; |  |  | import com.epmet.dto.result.FormItemResult; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.result.LoginUserDetailsResultDTO; |  |  | import com.epmet.dto.result.LoginUserDetailsResultDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.dto.result.OptionDTO; |  |  | import com.epmet.dto.result.OptionDTO; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.dto.result.ResiCategoryItemResultDTO; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.entity.IcResiUserEntity; |  |  | import com.epmet.entity.IcResiUserEntity; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.enums.IcResiUserTableEnum; |  |  | import com.epmet.enums.IcResiUserTableEnum; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.excel.handler.DynamicEasyExcelListener; |  |  | import com.epmet.excel.handler.DynamicEasyExcelListener; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.feign.EpmetAdminOpenFeignClient; |  |  | import com.epmet.feign.EpmetAdminOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.feign.EpmetUserOpenFeignClient; |  |  | import com.epmet.feign.EpmetUserOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.feign.GovOrgOpenFeignClient; |  |  | import com.epmet.feign.GovOrgOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | import com.epmet.feign.OperCustomizeOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  | import com.epmet.service.IcResiUserImportService; |  |  | import com.epmet.service.IcResiUserImportService; | 
			
		
	
		
		
			
				
					|  |  | import com.google.common.cache.Cache; |  |  | import com.google.common.cache.Cache; | 
			
		
	
		
		
			
				
					|  |  | import com.google.common.cache.CacheBuilder; |  |  | import com.google.common.cache.CacheBuilder; | 
			
		
	
	
		
		
			
				
					|  | @ -61,6 +66,16 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res | 
			
		
	
		
		
			
				
					|  |  |     public static final ThreadLocal<Map<String, List<ErrorRow>>> errorRows = new ThreadLocal<>(); |  |  |     public static final ThreadLocal<Map<String, List<ErrorRow>>> errorRows = new ThreadLocal<>(); | 
			
		
	
		
		
			
				
					|  |  |     public static final ThreadLocal<Map<String, List<SkipedRow>>> skipedRows = new ThreadLocal<>(); |  |  |     public static final ThreadLocal<Map<String, List<SkipedRow>>> skipedRows = new ThreadLocal<>(); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * 类别发生变更的居民 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public static final ThreadLocal<ResiImportResiCategoryChangedCache> categoryChangedResi = new ThreadLocal<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * 居民类别items列表 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public static final ThreadLocal<List<String>> resiCategoryItemsCache = new ThreadLocal<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |      * key: itemId |  |  |      * key: itemId | 
			
		
	
		
		
			
				
					|  |  |      * value: |  |  |      * value: | 
			
		
	
	
		
		
			
				
					|  | @ -85,6 +100,9 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res | 
			
		
	
		
		
			
				
					|  |  |     @Autowired |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |     private IcResiUserDao icResiUserDao; |  |  |     private IcResiUserDao icResiUserDao; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     @Autowired | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private OperCustomizeOpenFeignClient operCustomizeOpenFeignClient; | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |      * @description 列信息封装 |  |  |      * @description 列信息封装 | 
			
		
	
		
		
			
				
					|  |  |      * |  |  |      * | 
			
		
	
	
		
		
			
				
					|  | @ -168,6 +186,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res | 
			
		
	
		
		
			
				
					|  |  |      */ |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |     @Override |  |  |     @Override | 
			
		
	
		
		
			
				
					|  |  |     public void importIcResiInfoFromExcel(List<FormItemResult> formItemList, String excelPathName, HttpServletResponse response) { |  |  |     public void importIcResiInfoFromExcel(List<FormItemResult> formItemList, String excelPathName, HttpServletResponse response) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         String loginUserId = loginUserUtil.getLoginUserId(); |  |  |         String loginUserId = loginUserUtil.getLoginUserId(); | 
			
		
	
		
		
			
				
					|  |  |         String loginUserApp = loginUserUtil.getLoginUserApp(); |  |  |         String loginUserApp = loginUserUtil.getLoginUserApp(); | 
			
		
	
		
		
			
				
					|  |  |         String loginUserClient = loginUserUtil.getLoginUserClient(); |  |  |         String loginUserClient = loginUserUtil.getLoginUserClient(); | 
			
		
	
	
		
		
			
				
					|  | @ -185,7 +204,7 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res | 
			
		
	
		
		
			
				
					|  |  |         String customerId = agencyInfo.getCustomerId(); |  |  |         String customerId = agencyInfo.getCustomerId(); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         try { |  |  |         try { | 
			
		
	
		
		
			
				
					
					|  |  |             initThreadLocalRowsStorage(); |  |  |             initImportThreadLocal(customerId); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |             // 上传主表信息
 |  |  |             // 上传主表信息
 | 
			
		
	
		
		
			
				
					|  |  |             importIcResiBaseInfoFromExcel(formItemList,excelPathName, IcResiUserTableEnum.IC_RESI_USER.getSheetNo(), IcResiUserTableEnum.IC_RESI_USER.getHeadRowNo(), |  |  |             importIcResiBaseInfoFromExcel(formItemList,excelPathName, IcResiUserTableEnum.IC_RESI_USER.getSheetNo(), IcResiUserTableEnum.IC_RESI_USER.getHeadRowNo(), | 
			
		
	
	
		
		
			
				
					|  | @ -209,11 +228,10 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res | 
			
		
	
		
		
			
				
					|  |  |                 } |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |             } |  |  |             } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |             //String errors = JSON.toJSONString(errorRows.get());
 |  |  |             // 执行人员类别变更记录
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             //String skipeds = JSON.toJSONString(skipedRows.get());
 |  |  |             Map<String, ResiImportCategoryData> newResis = categoryChangedResi.get().getNewResis(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  | 
 |  |  |             Map<String, ResiImportChangedData> categoryChangedResis = categoryChangedResi.get().getCategoryChangedResis(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             //log.error(errors);
 |  |  |             Map<String, ResiImportChangedData> transferedResis = categoryChangedResi.get().getTransferedResis(); | 
			
				
				
			
		
	
		
		
			
				
					|  |  |             //log.error(skipeds);
 |  |  |  | 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |             try { |  |  |             try { | 
			
		
	
		
		
			
				
					|  |  |                 downLoadResults(response); |  |  |                 downLoadResults(response); | 
			
		
	
	
		
		
			
				
					|  | @ -223,25 +241,42 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res | 
			
		
	
		
		
			
				
					|  |  |         } finally { |  |  |         } finally { | 
			
		
	
		
		
			
				
					|  |  |             skipedRows.remove(); |  |  |             skipedRows.remove(); | 
			
		
	
		
		
			
				
					|  |  |             errorRows.remove(); |  |  |             errorRows.remove(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             categoryChangedResi.remove(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             resiCategoryItemsCache.remove(); | 
			
		
	
		
		
			
				
					|  |  |             itemIdAndOptionsCache.invalidateAll(); |  |  |             itemIdAndOptionsCache.invalidateAll(); | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |      * 暂存rows信息初始化 |  |  |      * threadLocal初始化 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |      */ |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |     private void initThreadLocalRowsStorage() { |  |  |     private void initImportThreadLocal(String customerId) { | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         // 跳过的,不导入的行
 | 
			
		
	
		
		
			
				
					|  |  |         Map<String, List<SkipedRow>> skipedRowsMap = new LinkedHashMap<>(); |  |  |         Map<String, List<SkipedRow>> skipedRowsMap = new LinkedHashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |         for (IcResiUserTableEnum e : IcResiUserTableEnum.values()) { |  |  |         for (IcResiUserTableEnum e : IcResiUserTableEnum.values()) { | 
			
		
	
		
		
			
				
					|  |  |             skipedRowsMap.put(e.getTableName(), new LinkedList<>()); |  |  |             skipedRowsMap.put(e.getTableName(), new LinkedList<>()); | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |         skipedRows.set(skipedRowsMap); |  |  |         skipedRows.set(skipedRowsMap); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 错误信息
 | 
			
		
	
		
		
			
				
					|  |  |         Map<String, List<ErrorRow>> errorRowsMap = new LinkedHashMap<>(); |  |  |         Map<String, List<ErrorRow>> errorRowsMap = new LinkedHashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |         for (IcResiUserTableEnum e : IcResiUserTableEnum.values()) { |  |  |         for (IcResiUserTableEnum e : IcResiUserTableEnum.values()) { | 
			
		
	
		
		
			
				
					|  |  |             errorRowsMap.put(e.getTableName(), new LinkedList<>()); |  |  |             errorRowsMap.put(e.getTableName(), new LinkedList<>()); | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |         errorRows.set(errorRowsMap); |  |  |         errorRows.set(errorRowsMap); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 居民类别信息
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ResiImportResiCategoryChangedCache c = new ResiImportResiCategoryChangedCache(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         categoryChangedResi.set(c); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<ResiCategoryItemResultDTO> resiCategoryItems = getResultDataOrThrowsException(operCustomizeOpenFeignClient.listResiCategoryItems(customerId), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 ServiceConstant.OPER_CUSTOMIZE_SERVER, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 String.format("【居民信息导入】查询居民类别items失败,customerId:%s", customerId), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 "居民信息导入失败"); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<String> l = resiCategoryItems.stream().map(ResiCategoryItemResultDTO::getColumnName).collect(Collectors.toList()); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         resiCategoryItemsCache.set(l); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |     /** |  |  |     /** | 
			
		
	
	
		
		
			
				
					|  | @ -374,26 +409,45 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res | 
			
		
	
		
		
			
				
					|  |  |                 String idCard = columnAndValues.get("ID_CARD"); |  |  |                 String idCard = columnAndValues.get("ID_CARD"); | 
			
		
	
		
		
			
				
					|  |  |                 LambdaQueryWrapper<IcResiUserEntity> idCardQuery = new LambdaQueryWrapper<>(); |  |  |                 LambdaQueryWrapper<IcResiUserEntity> idCardQuery = new LambdaQueryWrapper<>(); | 
			
		
	
		
		
			
				
					|  |  |                 idCardQuery.eq(IcResiUserEntity::getIdCard, idCard); |  |  |                 idCardQuery.eq(IcResiUserEntity::getIdCard, idCard); | 
			
		
	
		
		
			
				
					
					|  |  |                 IcResiUserEntity resiBaseInfo = icResiUserDao.selectOne(idCardQuery); |  |  |                 //IcResiUserEntity resiBaseInfo = icResiUserDao.selectOne(idCardQuery);
 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 Map<String, String> existingResiMap = icResiUserDao.selectResiInfoMap(idCard); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (existingResiMap != null) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     // 修改居民信息
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     icResiUserDao.upTable(tableName, existingResiMap.get("ID"), columnAndValues); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |                 if (resiBaseInfo != null) { |  |  |                     // 任意组织维度一个发生变化,则放到调动居民缓存中
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                     icResiUserDao.upTable(tableName, resiBaseInfo.getId(), columnAndValues); |  |  |                     ResiImportChangedData transferData; | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                     if ((transferData = this.getResiImportTrasferData(existingResiMap, columnAndValues)) != null) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         categoryChangedResi.get().getTransferedResis().put(existingResiMap.get("ID"), transferData); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         // 组织维度没有发生变化,看是否有居民类型变更
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         ResiImportChangedData d = getResiImportCategoryChangedData(existingResiMap, columnAndValues); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         if (d != null) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                             categoryChangedResi.get().getCategoryChangedResis().put(existingResiMap.get("ID"), d); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     } | 
			
		
	
		
		
			
				
					|  |  |                 } else { |  |  |                 } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     // 新增居民
 | 
			
		
	
		
		
			
				
					|  |  |                     columnAndValues.put("CREATED_BY", currentUserId); |  |  |                     columnAndValues.put("CREATED_BY", currentUserId); | 
			
		
	
		
		
			
				
					|  |  |                     columnAndValues.put("ID", UUID.randomUUID().toString().replace("-", "")); |  |  |                     columnAndValues.put("ID", UUID.randomUUID().toString().replace("-", "")); | 
			
		
	
		
		
			
				
					|  |  |                     icResiUserDao.add(tableName, columnAndValues); |  |  |                     icResiUserDao.add(tableName, columnAndValues); | 
			
		
	
		
		
			
				
					|  |  |                 } |  |  |  | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |                 //if (icResiUserDao.selectCount(idCardQuery) > 0) {
 |  |  |                     Map<String, String> categories = resiCategoryItemsCache.get() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 //    //log.info("身份证号为【{}】的居民信息已存在,跳过导入", idCard);
 |  |  |                             .stream() | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 //    SkipedRow skipedRow = new SkipedRow();
 |  |  |                             .filter((categoryColumnName) -> "1".equals(columnAndValues.get(categoryColumnName))) | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 //    skipedRow.setName(columnAndValues.get("NAME"));
 |  |  |                             .collect(Collectors.toMap((k) -> k, (k) -> columnAndValues.get(k))); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 //    skipedRow.setIdCard(idCard);
 |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 //    skipedRow.setInfo("身份证号已存在,跳过导入");
 |  |  |                     categoryChangedResi.get().getNewResis().put(columnAndValues.get("ID"), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 //    skipedRow.setTableName(tableName);
 |  |  |                             new ResiImportCategoryData(columnAndValues.get("AGENCY_ID"), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 //    skipedRows.get().get(IcResiUserTableEnums.IC_RESI_USER.getTableName()).add(skipedRow);
 |  |  |                                     columnAndValues.get("GRID_ID"), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 //    continue;
 |  |  |                                     columnAndValues.get("VILLAGE_ID"), | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |                 //}
 |  |  |                                     columnAndValues.get("BUILD_ID"), | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |                                     columnAndValues.get("UNIT_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     columnAndValues.get("HOME_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                     categories)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |             } catch (Exception e) { |  |  |             } catch (Exception e) { | 
			
		
	
		
		
			
				
					|  |  |                 String errorMsg; |  |  |                 String errorMsg; | 
			
		
	
	
		
		
			
				
					|  | @ -950,4 +1004,145 @@ public class IcResiUserImportServiceImpl implements IcResiUserImportService, Res | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         workbook.write(response.getOutputStream()); |  |  |         workbook.write(response.getOutputStream()); | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     public ResiImportCategoryData generateResiImportChangeData(String agencyId, String gridId, String villageId, String buildId, String unitId, | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                                                                String homeId , Map<String, String> categories) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ResiImportCategoryData ricd = new ResiImportCategoryData(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ricd.setAgencyId(agencyId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ricd.setBuildId(buildId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ricd.setGridId(gridId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ricd.setVillageId(villageId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ricd.setUnitId(unitId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ricd.setHomeId(homeId); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ricd.setCategories(categories); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return ricd; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     ///**
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     // * 判断是否有组织维度的变化
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     // * @param existingResiMap
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     // * @param newResiMap
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     // * @return
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     // */
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     //public boolean isOrgDimChanged(Map<String, String> existingResiMap, Map<String, String> newResiMap) {
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     //    return !existingResiMap.get("AGENCY_ID").equals(newResiMap.get("AGENCY_ID"))
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     //            || !existingResiMap.get("GRID_ID").equals(newResiMap.get("GRID_ID"))
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     //            || !existingResiMap.get("VILLAGE_ID").equals(newResiMap.get("VILLAGE_ID"))
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     //            || !existingResiMap.get("BUILD_ID").equals(newResiMap.get("BUILD_ID"))
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     //            || !existingResiMap.get("UNIT_ID").equals(newResiMap.get("UNIT_ID"))
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     //            || !existingResiMap.get("HOME_ID").equals(newResiMap.get("HOME_ID"))
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     //}
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * 生成导入调动数据 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param existingResiMap | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param newResiMap | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @return | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private ResiImportChangedData getResiImportTrasferData(Map<String, String> existingResiMap, Map<String, String> newResiMap) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 维度未变化,则返回null
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (existingResiMap.get("AGENCY_ID").equals(newResiMap.get("AGENCY_ID")) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 && existingResiMap.get("GRID_ID").equals(newResiMap.get("GRID_ID")) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 && existingResiMap.get("VILLAGE_ID").equals(newResiMap.get("VILLAGE_ID")) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 && existingResiMap.get("BUILD_ID").equals(newResiMap.get("BUILD_ID")) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 && existingResiMap.get("UNIT_ID").equals(newResiMap.get("UNIT_ID")) | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 && existingResiMap.get("HOME_ID").equals(newResiMap.get("HOME_ID"))) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return null; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         HashMap<String, String> existingResiCategories = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         HashMap<String, String> newResiCategories = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         for (String categoryColumnName : resiCategoryItemsCache.get()) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             String oldCategoryValue = existingResiMap.get(categoryColumnName); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             String newCategoryValue = newResiMap.get(categoryColumnName); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (StringUtils.isNotBlank(oldCategoryValue) && "1".equals(oldCategoryValue)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiCategories.put(categoryColumnName, oldCategoryValue); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (StringUtils.isNotBlank(newCategoryValue) && "1".equals(newCategoryValue)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiCategories.put(categoryColumnName, newResiMap.get(categoryColumnName)); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ResiImportCategoryData oldOne = new ResiImportCategoryData( | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("AGENCY_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("GRID_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("VILLAGE_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("BUILD_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("UNIT_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("HOME_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiCategories); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ResiImportCategoryData newOne = new ResiImportCategoryData(existingResiMap.get("AGENCY_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("GRID_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("VILLAGE_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("BUILD_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("UNIT_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("HOME_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiCategories); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return new ResiImportChangedData(oldOne, newOne); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * 类别变更的居民信息封装 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param existingResiMap | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @param newResiMap | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      * @return | 
			
		
	
		
		
			
				
					|  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     private ResiImportChangedData getResiImportCategoryChangedData(Map<String, String> existingResiMap, Map<String, String> newResiMap) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         // 发生变化的类别列明
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         HashMap<String, String> oldCategories = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         HashMap<String, String> newCategories = new HashMap<>(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         List<String> categoryColumnNames = resiCategoryItemsCache.get(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         for (String categoryColumnName : categoryColumnNames) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             String existingColumnValue = existingResiMap.get(categoryColumnName); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             String newColumnValue = newResiMap.get(categoryColumnName); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             if (StringUtils.isAllBlank(existingColumnValue, newColumnValue)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 // 都为空,则没发生变化
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 continue; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } else if (StringUtils.isNoneBlank(existingColumnValue, newColumnValue)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 // 都不为空,则执行比较
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 if (!existingColumnValue.equals(newColumnValue)) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     oldCategories.put(categoryColumnName, existingColumnValue); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     newCategories.put(categoryColumnName, newColumnValue); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                     continue; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } else { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 // 一个为空一个不为空,则发生变化
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 oldCategories.put(categoryColumnName, existingColumnValue); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newCategories.put(categoryColumnName, newColumnValue); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if (oldCategories.size() == 0) { | 
			
		
	
		
		
			
				
					|  |  |  |  |  |             return null; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ResiImportCategoryData oldOne = new ResiImportCategoryData( | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("AGENCY_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("GRID_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("VILLAGE_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("BUILD_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("UNIT_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 existingResiMap.get("HOME_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 oldCategories); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         ResiImportCategoryData newOne = new ResiImportCategoryData(existingResiMap.get("AGENCY_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("GRID_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("VILLAGE_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("BUILD_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("UNIT_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newResiMap.get("HOME_ID"), | 
			
		
	
		
		
			
				
					|  |  |  |  |  |                 newCategories); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         return new ResiImportChangedData(oldOne, newOne); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					|  |  | } |  |  | } | 
			
		
	
	
		
		
			
				
					|  | 
 |