| 
						
						
							
								
							
						
						
					 | 
					@ -29,6 +29,7 @@ import com.alibaba.fastjson.JSON; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.annotation.LoginUser; | 
					 | 
					 | 
					import com.epmet.commons.tools.annotation.LoginUser; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.aop.NoRepeatSubmit; | 
					 | 
					 | 
					import com.epmet.commons.tools.aop.NoRepeatSubmit; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.constant.NumConstant; | 
					 | 
					 | 
					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.dto.result.CustomerStaffInfoCacheResult; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.exception.EpmetErrorCode; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.EpmetErrorCode; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.exception.ExceptionUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.ExceptionUtils; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -123,6 +124,8 @@ public class IcResiUserController { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                log.error("创建数字赋能平台上传目录失败"); | 
					 | 
					 | 
					                log.error("创建数字赋能平台上传目录失败"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            } | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        IC_RESI_UPLOAD_DIR = importDir; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        Path exportDir = Paths.get(home, "epmet_files", "ic_user_export"); | 
					 | 
					 | 
					        Path exportDir = Paths.get(home, "epmet_files", "ic_user_export"); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (Files.notExists(exportDir)) { | 
					 | 
					 | 
					        if (Files.notExists(exportDir)) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            try { | 
					 | 
					 | 
					            try { | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -355,16 +358,14 @@ public class IcResiUserController { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); | 
					 | 
					 | 
					        CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        String staffOrgPath = null; | 
					 | 
					 | 
					        String staffOrgPath = null; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { | 
					 | 
					 | 
					        if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); | 
					 | 
					 | 
					            staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(StrConstant.COLON).concat(staffInfoCacheResult.getAgencyId()); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					        } else { | 
					 | 
					 | 
					        } else { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            staffOrgPath = staffInfoCacheResult.getAgencyId(); | 
					 | 
					 | 
					            staffOrgPath = staffInfoCacheResult.getAgencyId(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        pageFormDTO.setCustomerId(customerId); | 
					 | 
					 | 
					        pageFormDTO.setCustomerId(customerId); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        pageFormDTO.setPageFlag(false); | 
					 | 
					 | 
					        pageFormDTO.setPageFlag(false); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        List<FormItemResult> resiFormAllItems = icResiUserService.listFormItems(customerId, IC_RESI_FORM_CODE); | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					        Map<String, Map<String, FormItemResult>> otherSheetItems = resiFormAllItems.stream() | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                .collect(Collectors.groupingBy(FormItemResult::getTableName, Collectors.toMap(FormItemResult::getColumnName, o -> o))); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        //获取模版文件
 | 
					 | 
					 | 
					        //获取模版文件
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        File file = getExportTemplateFile(customerId); | 
					 | 
					 | 
					        File file = getExportTemplateFile(customerId); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
					@ -376,27 +377,35 @@ public class IcResiUserController { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            pageFormDTO.setPageNo(NumConstant.ONE); | 
					 | 
					 | 
					            pageFormDTO.setPageNo(NumConstant.ONE); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            //子表是否停止查询
 | 
					 | 
					 | 
					            //子表是否停止查询
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Set<String> stopSearchSet = new HashSet<>(); | 
					 | 
					 | 
					            Set<String> stopSearchSet = new HashSet<>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            Map<String, WriteSheet> childTableWriteSheetMap = new HashMap<>(); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            //获取表单项
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            List<FormItemResult> resiFormAllItems = icResiUserService.listFormItems(customerId, IC_RESI_FORM_CODE); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            //每个表对应的 item ;key:表名,value:<字段名:item对象>
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            Map<String, Map<String, FormItemResult>> tableItemMap = resiFormAllItems.stream() | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    .collect(Collectors.groupingBy(FormItemResult::getTableName, | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                            Collectors.toMap(o->o.getColumnName().concat(NumConstant.ZERO == o.getColumnNum()? StrConstant.EPMETY_STR:o.getColumnNum().toString()), o -> o))); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            Map<String, WriteSheet> childTableWriteSheetMap = new HashMap<>(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            //表数据写入
 | 
					 | 
					 | 
					            //表数据写入
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            //通过枚举获取相关表并按照sheetNo排序
 | 
					 | 
					 | 
					            //通过枚举获取相关表并按照sheetNo排序
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					            List<IcResiUserTableEnum> resiTableList = Arrays.stream(IcResiUserTableEnum.values()).sorted(Comparator.comparing(IcResiUserTableEnum::getSheetNo)).collect(Collectors.toList()); | 
					 | 
					 | 
					            List<IcResiUserTableEnum> resiTableList = Arrays.stream(IcResiUserTableEnum.values()) | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    .sorted(Comparator.comparing(IcResiUserTableEnum::getSheetNo)) | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                    .collect(Collectors.toList()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					            for (IcResiUserTableEnum tableEnum : resiTableList) { | 
					 | 
					 | 
					            for (IcResiUserTableEnum tableEnum : resiTableList) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                String tableName = tableEnum.getTableName(); | 
					 | 
					 | 
					                String tableName = tableEnum.getTableName(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                pageFormDTO.setPageNo(NumConstant.ONE); | 
					 | 
					 | 
					                pageFormDTO.setPageNo(NumConstant.ONE); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                //循环一次 写入每个sheet
 | 
					 | 
					 | 
					                //循环一次 写入每个sheet
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                do { | 
					 | 
					 | 
					                do { | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    Map<String, FormItemResult> itemMap1 = otherSheetItems.get(tableName); | 
					 | 
					 | 
					                    Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(tableItemMap.get(tableName), tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); | 
				
			
			
				
				
			
		
	
		
		
			
				
					 | 
					 | 
					                    Map<String, Map<String, Object>> resiChildMap = icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath); | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                    //如果 返回的条数小于每页显示的数 则退出查询
 | 
					 | 
					 | 
					                    //如果 返回的条数小于每页显示的数 则退出查询
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    if (resiChildMap.keySet().size() < pageFormDTO.getPageSize()) { | 
					 | 
					 | 
					                    if (resiChildMap.keySet().size() < pageFormDTO.getPageSize()) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                        stopSearchSet.add(tableName); | 
					 | 
					 | 
					                        stopSearchSet.add(tableName); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    } | 
					 | 
					 | 
					                    } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    //构建新的sheet
 | 
					 | 
					 | 
					                    //如果没有 构建新的writeSheet
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    WriteSheet childWriteSheet = childTableWriteSheetMap.getOrDefault(tableName,EasyExcel.writerSheet(tableEnum.getSheetNo()).build()); | 
					 | 
					 | 
					                    WriteSheet writeSheet = childTableWriteSheetMap.getOrDefault(tableName,EasyExcel.writerSheet(tableEnum.getSheetNo()).build()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    childTableWriteSheetMap.put(tableName, childWriteSheet); | 
					 | 
					 | 
					                    childTableWriteSheetMap.putIfAbsent(tableName, writeSheet); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                    //写入数据
 | 
					 | 
					 | 
					                    //写入数据
 | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					                    excelWriter.fill(new FillWrapper("t" + (tableEnum.getSheetNo() + NumConstant.ONE), resiChildMap.values()), childWriteSheet); | 
					 | 
					 | 
					                    excelWriter.fill(new FillWrapper("t" + (tableEnum.getSheetNo() + NumConstant.ONE), resiChildMap.values()), writeSheet); | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					                    pageFormDTO.setPageNo(pageFormDTO.getPageNo() + NumConstant.ONE); | 
					 | 
					 | 
					                    pageFormDTO.setPageNo(pageFormDTO.getPageNo() + NumConstant.ONE); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    //重置数据
 | 
					 | 
					 | 
					                    //重置数据
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					                    resiChildMap.clear(); | 
					 | 
					 | 
					                    resiChildMap.clear(); | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |