|  |  | @ -17,15 +17,10 @@ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | package com.epmet.controller; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import cn.afterturn.easypoi.excel.ExcelExportUtil; | 
			
		
	
		
			
				
					|  |  |  | import cn.afterturn.easypoi.excel.entity.TemplateExportParams; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.excel.EasyExcel; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.excel.ExcelWriter; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.excel.enums.WriteDirectionEnum; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.excel.write.metadata.WriteSheet; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.excel.write.metadata.fill.FillConfig; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.excel.write.metadata.fill.FillWrapper; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.fastjson.JSON; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.rocketmq.messages.IcResiUserAddMQMsg; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.annotation.LoginUser; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.aop.NoRepeatSubmit; | 
			
		
	
	
		
			
				
					|  |  | @ -40,12 +35,11 @@ import com.epmet.commons.tools.redis.RedisKeys; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.redis.RedisUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.redis.common.CustomerStaffRedis; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.security.dto.TokenDto; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.ConvertUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.ExcelUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.HttpClientManager; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.IpUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.validator.ValidatorUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.IcResiUserConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.constant.SystemMessageType; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.IcResiUserDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.*; | 
			
		
	
	
		
			
				
					|  |  | @ -62,20 +56,20 @@ import org.apache.commons.io.FileUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.io.FilenameUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.io.IOUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.commons.lang3.StringUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.apache.poi.ss.usermodel.Workbook; | 
			
		
	
		
			
				
					|  |  |  | import org.jetbrains.annotations.NotNull; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.web.bind.annotation.*; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.web.multipart.MultipartFile; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import javax.servlet.http.HttpServletResponse; | 
			
		
	
		
			
				
					|  |  |  | import java.io.*; | 
			
		
	
		
			
				
					|  |  |  | import java.net.URLEncoder; | 
			
		
	
		
			
				
					|  |  |  | import java.io.File; | 
			
		
	
		
			
				
					|  |  |  | import java.io.FileOutputStream; | 
			
		
	
		
			
				
					|  |  |  | import java.io.IOException; | 
			
		
	
		
			
				
					|  |  |  | import java.io.InputStream; | 
			
		
	
		
			
				
					|  |  |  | import java.nio.file.Files; | 
			
		
	
		
			
				
					|  |  |  | import java.nio.file.Path; | 
			
		
	
		
			
				
					|  |  |  | import java.nio.file.Paths; | 
			
		
	
		
			
				
					|  |  |  | import java.util.*; | 
			
		
	
		
			
				
					|  |  |  | import java.util.concurrent.atomic.AtomicInteger; | 
			
		
	
		
			
				
					|  |  |  | import java.util.stream.Collectors; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -234,155 +228,6 @@ public class IcResiUserController { | 
			
		
	
		
			
				
					|  |  |  |         return new Result().ok(icResiUserService.queryIcResiDetail(pageFormDTO)); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc :备用 easypoi | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
		
			
				
					|  |  |  |      * @param customerId | 
			
		
	
		
			
				
					|  |  |  |      * @param pageFormDTO | 
			
		
	
		
			
				
					|  |  |  |      * @param response | 
			
		
	
		
			
				
					|  |  |  |      * @throws Exception | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @RequestMapping(value = "/exportExcel2") | 
			
		
	
		
			
				
					|  |  |  |     public void exportExcel(@RequestHeader String customerId, @LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { | 
			
		
	
		
			
				
					|  |  |  |         //tokenDto.setUserId("9e37adcce6472152e6508a19d3683e02");
 | 
			
		
	
		
			
				
					|  |  |  |         CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         String staffOrgPath = null; | 
			
		
	
		
			
				
					|  |  |  |         if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { | 
			
		
	
		
			
				
					|  |  |  |             staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |             staffOrgPath = staffInfoCacheResult.getAgencyId(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         pageFormDTO.setCustomerId(customerId); | 
			
		
	
		
			
				
					|  |  |  |         pageFormDTO.setPageFlag(false); | 
			
		
	
		
			
				
					|  |  |  |         CustomerFormResultDTO resiFormItems = getResiFormAddItems(pageFormDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         Map<String, Map<String, FormItemResult>> otherSheetItems = buildItemMap(resiFormItems); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         Map<String, Map<String, Object>> resiMainList = null;//icResiUserService.getDataForExport(otherSheetItems.get(IcResiUserConstant.IC_RESI_USER), IcResiUserConstant.IC_RESI_USER, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
 | 
			
		
	
		
			
				
					|  |  |  |         //resiMainList = (List<Map<String, Object>>)JSON.parse("[{\"IS_BDHJ\":\"1\",\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest2\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":null,\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":null,\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":null,\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"},{\"IS_SPECIAL\":\"1\",\"IS_XFRY\":\"0\",\"REMARKS\":\"beizhu\",\"IS_PARTY\":\"1\",\"icResiUserId\":\"yzmtest\",\"HOME_ID\":\"中海国际社区一里城1号楼1单元101\",\"HOUSE_TYPE\":\"平房\",\"UNIT_NAME\":\"1单元\",\"GRID_ID\":\"市北区-市北区第三网格3\",\"IS_DB\":\"0\",\"GENDER\":\"男\",\"BIRTHDAY\":\"2021-10-04\",\"IS_VETERANS\":\"0\",\"IS_MB\":\"0\",\"IS_UNEMPLOYED\":\"0\",\"DEMAND_NAME\":\"心理咨询\",\"IS_KC\":\"0\",\"IS_ENSURE_HOUSE\":\"0\",\"IS_SD\":\"0\",\"NAME\":\"尹作梅\",\"RDSJ\":\"2021-10-28 00:00:00\",\"IS_VOLUNTEER\":\"1\",\"GRID_ID_VALUE\":\"e74829ffc43d5470eba6b5e060c11e63\",\"IS_SZ\":\"0\",\"IS_CJ\":\"0\",\"HOME_ID_VALUE\":\"200\",\"DEMAND_CATEGORY_IDS\":\"10180002\",\"VILLAGE_NAME\":\"中海国际社区一里城\",\"IS_DBH\":\"0\",\"IS_SN\":\"0\",\"BUILD_NAME\":\"1号楼\",\"IS_YLFN\":\"0\",\"IS_UNITED_FRONT\":\"0\",\"ID_CARD\":\"371325199310260529\",\"MOBILE\":\"15764229697\",\"IS_OLD_PEOPLE\":\"0\",\"DOOR_NAME\":\"101\"}]");
 | 
			
		
	
		
			
				
					|  |  |  |         log.info("resiMainList:{}", JSON.toJSONString(resiMainList)); | 
			
		
	
		
			
				
					|  |  |  |         String templatePath = "excel/ic_resi_info_cid.xls"; | 
			
		
	
		
			
				
					|  |  |  |         TemplateExportParams params = new TemplateExportParams(templatePath, true); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         Map<Integer, Map<String, Object>> sheetMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         Map<String, Object> mapData = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         mapData.put("list", resiMainList.values()); | 
			
		
	
		
			
				
					|  |  |  |         System.out.println("===resiMainList===" + "  " + JSON.toJSONString(resiMainList.values())); | 
			
		
	
		
			
				
					|  |  |  |         sheetMap.put(0, mapData); | 
			
		
	
		
			
				
					|  |  |  |         AtomicInteger n = new AtomicInteger(); | 
			
		
	
		
			
				
					|  |  |  |         for (FormItemResult item : resiFormItems.getItemList()) { | 
			
		
	
		
			
				
					|  |  |  |             //如果 childGroup是空 或者是主表 则跳过 继续下次循环
 | 
			
		
	
		
			
				
					|  |  |  |             if (item.getChildGroup() == null || IcResiUserConstant.IC_RESI_USER.equals(item.getChildGroup().getTableName())) { | 
			
		
	
		
			
				
					|  |  |  |                 continue; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             String tableName = item.getChildGroup().getTableName(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             Map<String, FormItemResult> itemMap1 = otherSheetItems.get(tableName); | 
			
		
	
		
			
				
					|  |  |  |             Map<String, Map<String, Object>> resiChildMap = null;//icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
 | 
			
		
	
		
			
				
					|  |  |  |             //resiChildMap.forEach((key, value) -> value.putAll(resiMainList.get(key)));
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             Map<String, Object> mapData2 = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |             mapData2.put("list", resiChildMap.values()); | 
			
		
	
		
			
				
					|  |  |  |             System.out.println("===resiChildMap===" + tableName + "  " + JSON.toJSONString(resiChildMap.values())); | 
			
		
	
		
			
				
					|  |  |  |             sheetMap.put(n.incrementAndGet(), mapData2); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         Workbook workbook = ExcelExportUtil.exportExcel(sheetMap, params); | 
			
		
	
		
			
				
					|  |  |  |         workbook.setActiveSheet(0); | 
			
		
	
		
			
				
					|  |  |  |         workbook.write(getOutputStream("居民基本信息.xls", response)); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @RequestMapping(value = "/exportExcel3") | 
			
		
	
		
			
				
					|  |  |  |     public void exportExcelByEasyExcel3(@RequestHeader String customerId,@LoginUser TokenDto tokenDto, @RequestBody IcResiUserPageFormDTO pageFormDTO, HttpServletResponse response) throws Exception { | 
			
		
	
		
			
				
					|  |  |  |         //tokenDto.setUserId("9e37adcce6472152e6508a19d3683e02");
 | 
			
		
	
		
			
				
					|  |  |  |         CustomerStaffInfoCacheResult staffInfoCacheResult = CustomerStaffRedis.getStaffInfo(customerId, tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         String staffOrgPath = null; | 
			
		
	
		
			
				
					|  |  |  |         if (StringUtils.isNotBlank(staffInfoCacheResult.getAgencyPIds()) && !NumConstant.ZERO_STR.equals(staffInfoCacheResult.getAgencyPIds())) { | 
			
		
	
		
			
				
					|  |  |  |             staffOrgPath = staffInfoCacheResult.getAgencyPIds().concat(":").concat(staffInfoCacheResult.getAgencyId()); | 
			
		
	
		
			
				
					|  |  |  |         } else { | 
			
		
	
		
			
				
					|  |  |  |             staffOrgPath = staffInfoCacheResult.getAgencyId(); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         pageFormDTO.setCustomerId(customerId); | 
			
		
	
		
			
				
					|  |  |  |         pageFormDTO.setPageFlag(false); | 
			
		
	
		
			
				
					|  |  |  |         CustomerFormResultDTO resiFormItems = getResiFormAddItems(pageFormDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         Map<String, Map<String, FormItemResult>> otherSheetItems = buildItemMap(resiFormItems); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         /*List<FormItemResult> resiFormAllItems = getResiFormAllItems(pageFormDTO.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         resiFormAllItems.stream().collect(Collectors.groupingBy(e ->e.get));*/ | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //获取模版文件
 | 
			
		
	
		
			
				
					|  |  |  |         File file = getExportTemplateFile(customerId); | 
			
		
	
		
			
				
					|  |  |  |         ExcelWriter excelWriter = EasyExcel.write(getOutputStream("居民基本信息.xlsx", response)).withTemplate(file).build(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         FillConfig fillConfig = FillConfig.builder().direction(WriteDirectionEnum.VERTICAL).build(); | 
			
		
	
		
			
				
					|  |  |  |         IcResiUserTableEnum tableEnums = IcResiUserTableEnum.getObjectByTableName(IcResiUserConstant.IC_RESI_USER); | 
			
		
	
		
			
				
					|  |  |  |         WriteSheet fistSheet = EasyExcel.writerSheet(tableEnums.getSheetNo()).build(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         pageFormDTO.setPageSize(NumConstant.FIVE_HUNDRED); | 
			
		
	
		
			
				
					|  |  |  |         pageFormDTO.setPageNo(NumConstant.ONE); | 
			
		
	
		
			
				
					|  |  |  |         //子表是否停止查询
 | 
			
		
	
		
			
				
					|  |  |  |         Set<String> stopSearchSet = new HashSet<>(); | 
			
		
	
		
			
				
					|  |  |  |         Map<String, WriteSheet> childTableWriteSheetMap = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  |         Map<String, Map<String, Object>> resiMainTableMap = null; | 
			
		
	
		
			
				
					|  |  |  |         do { | 
			
		
	
		
			
				
					|  |  |  |             resiMainTableMap = null;//icResiUserService.getDataForExport(otherSheetItems.get(IcResiUserConstant.IC_RESI_USER), IcResiUserConstant.IC_RESI_USER, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
 | 
			
		
	
		
			
				
					|  |  |  |             //如果 返回的条数小于每页显示的数 则退出查询
 | 
			
		
	
		
			
				
					|  |  |  |             if (resiMainTableMap.keySet().size() < pageFormDTO.getPageSize()) { | 
			
		
	
		
			
				
					|  |  |  |                 stopSearchSet.add(IcResiUserConstant.IC_RESI_USER); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             //写入数据
 | 
			
		
	
		
			
				
					|  |  |  |             excelWriter.fill(new FillWrapper("t1", resiMainTableMap.values()), fillConfig, fistSheet); | 
			
		
	
		
			
				
					|  |  |  |             pageFormDTO.setPageNo(pageFormDTO.getPageNo() + 1); | 
			
		
	
		
			
				
					|  |  |  |             //重置数据
 | 
			
		
	
		
			
				
					|  |  |  |             resiMainTableMap.clear(); | 
			
		
	
		
			
				
					|  |  |  |         } while (!stopSearchSet.contains(IcResiUserConstant.IC_RESI_USER)); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //子表数据写入
 | 
			
		
	
		
			
				
					|  |  |  |         AtomicInteger n = new AtomicInteger(); | 
			
		
	
		
			
				
					|  |  |  |         for (FormItemResult item : resiFormItems.getItemList()) { | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             //如果 childGroup是空 或者是主表 则跳过 继续下次循环
 | 
			
		
	
		
			
				
					|  |  |  |             if (item.getChildGroup() == null || IcResiUserConstant.IC_RESI_USER.equals(item.getChildGroup().getTableName())) { | 
			
		
	
		
			
				
					|  |  |  |                 continue; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             String tableName = item.getChildGroup().getTableName(); | 
			
		
	
		
			
				
					|  |  |  |             pageFormDTO.setPageNo(NumConstant.ONE); | 
			
		
	
		
			
				
					|  |  |  |             //循环一次 写入每个sheet
 | 
			
		
	
		
			
				
					|  |  |  |             do { | 
			
		
	
		
			
				
					|  |  |  |                 //如果包含则说明子表的数据 已经查询完毕 无需再继续查询了
 | 
			
		
	
		
			
				
					|  |  |  |                 boolean contains = stopSearchSet.contains(tableName); | 
			
		
	
		
			
				
					|  |  |  |                 if (contains) { | 
			
		
	
		
			
				
					|  |  |  |                     continue; | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 Map<String, FormItemResult> itemMap1 = otherSheetItems.get(tableName); | 
			
		
	
		
			
				
					|  |  |  |                 Map<String, Map<String, Object>> resiChildMap = null;//icResiUserService.getDataForExport(itemMap1, tableName, pageFormDTO, staffInfoCacheResult.getAgencyId(), staffOrgPath);
 | 
			
		
	
		
			
				
					|  |  |  |                 //如果 返回的条数小于每页显示的数 则退出查询
 | 
			
		
	
		
			
				
					|  |  |  |                 if (resiChildMap.keySet().size() < pageFormDTO.getPageSize()) { | 
			
		
	
		
			
				
					|  |  |  |                     stopSearchSet.add(tableName); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 tableEnums = IcResiUserTableEnum.getObjectByTableName(tableName); | 
			
		
	
		
			
				
					|  |  |  |                 if (tableEnums == null) { | 
			
		
	
		
			
				
					|  |  |  |                     continue; | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 //构建新的sheet
 | 
			
		
	
		
			
				
					|  |  |  |                 WriteSheet childWriteSheet = childTableWriteSheetMap.get(tableName); | 
			
		
	
		
			
				
					|  |  |  |                 if (childWriteSheet == null) { | 
			
		
	
		
			
				
					|  |  |  |                     childWriteSheet = EasyExcel.writerSheet(tableEnums.getSheetNo()).build(); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 childTableWriteSheetMap.put(tableName, childWriteSheet); | 
			
		
	
		
			
				
					|  |  |  |                 //写入数据
 | 
			
		
	
		
			
				
					|  |  |  |                 excelWriter.fill(new FillWrapper("t" + (tableEnums.getSheetNo() + NumConstant.ONE), resiChildMap.values()), childWriteSheet); | 
			
		
	
		
			
				
					|  |  |  |                 pageFormDTO.setPageNo(pageFormDTO.getPageNo() + NumConstant.ONE); | 
			
		
	
		
			
				
					|  |  |  |                 //重置数据
 | 
			
		
	
		
			
				
					|  |  |  |                 resiChildMap.clear(); | 
			
		
	
		
			
				
					|  |  |  |             } while (!stopSearchSet.contains(tableName)); | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         excelWriter.finish(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * desc: 导出居民信息 | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
	
		
			
				
					|  |  | @ -412,7 +257,7 @@ public class IcResiUserController { | 
			
		
	
		
			
				
					|  |  |  |         File file = getExportTemplateFile(customerId); | 
			
		
	
		
			
				
					|  |  |  |         ExcelWriter excelWriter = null; | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |             excelWriter = EasyExcel.write(getOutputStream("居民基本信息.xlsx", response)).withTemplate(file).build(); | 
			
		
	
		
			
				
					|  |  |  |             excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel("居民基本信息.xlsx", response)).withTemplate(file).build(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             //子表是否停止查询
 | 
			
		
	
		
			
				
					|  |  |  |             Set<String> stopSearchSet = new HashSet<>(); | 
			
		
	
	
		
			
				
					|  |  | @ -519,66 +364,6 @@ public class IcResiUserController { | 
			
		
	
		
			
				
					|  |  |  |         return file; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     @NotNull | 
			
		
	
		
			
				
					|  |  |  |     private Map<String, Map<String, FormItemResult>> buildItemMap(CustomerFormResultDTO resiFormItems) { | 
			
		
	
		
			
				
					|  |  |  |         Map<String, Map<String, FormItemResult>> otherSheetItems = new HashMap<>(); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         //主表的
 | 
			
		
	
		
			
				
					|  |  |  |         for (FormItemResult formItemResult : resiFormItems.getItemList()) { | 
			
		
	
		
			
				
					|  |  |  |             if (StringUtils.isBlank(formItemResult.getColumnName())) { | 
			
		
	
		
			
				
					|  |  |  |                 continue; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             Map<String, FormItemResult> itemMap = otherSheetItems.getOrDefault(formItemResult.getTableName(), new HashMap<>()); | 
			
		
	
		
			
				
					|  |  |  |             otherSheetItems.putIfAbsent(formItemResult.getTableName(), itemMap); | 
			
		
	
		
			
				
					|  |  |  |             if (formItemResult.getItemType().equals("checkbox") || formItemResult.getItemType().equals("select") || formItemResult.getItemType().equals("radio")) { | 
			
		
	
		
			
				
					|  |  |  |                 itemMap.put(formItemResult.getColumnName().concat(formItemResult.getColumnNum() == 0 ? "" : formItemResult.getColumnNum().toString()), formItemResult); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             if (formItemResult.getChildGroup() != null) { | 
			
		
	
		
			
				
					|  |  |  |                 itemMap = otherSheetItems.getOrDefault(formItemResult.getChildGroup().getTableName(), new HashMap<>()); | 
			
		
	
		
			
				
					|  |  |  |                 otherSheetItems.putIfAbsent(formItemResult.getChildGroup().getTableName(), itemMap); | 
			
		
	
		
			
				
					|  |  |  |                 for (FormItemResult2 item2 : formItemResult.getChildGroup().getItemList()) { | 
			
		
	
		
			
				
					|  |  |  |                     if (StringUtils.isBlank(item2.getColumnName())) { | 
			
		
	
		
			
				
					|  |  |  |                         continue; | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |                     if ("checkbox".equals(item2.getItemType()) || "select".equals(item2.getItemType()) || "radio".equals(item2.getItemType())) { | 
			
		
	
		
			
				
					|  |  |  |                         itemMap.put(item2.getColumnName().concat(item2.getColumnNum() == 0 ? "" : item2.getColumnNum().toString()), ConvertUtils.sourceToTarget(item2, FormItemResult.class)); | 
			
		
	
		
			
				
					|  |  |  |                     } | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         //其他sheet
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         for (FormGroupDTO groupItem : resiFormItems.getGroupList()) { | 
			
		
	
		
			
				
					|  |  |  |             if (groupItem.getItemList() == null) { | 
			
		
	
		
			
				
					|  |  |  |                 continue; | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |             Map<String, FormItemResult> itemMap = otherSheetItems.getOrDefault(groupItem.getTableName(), new HashMap<>()); | 
			
		
	
		
			
				
					|  |  |  |             otherSheetItems.putIfAbsent(groupItem.getTableName(), itemMap); | 
			
		
	
		
			
				
					|  |  |  |             for (FormItemResult2 formItemResult2 : groupItem.getItemList()) { | 
			
		
	
		
			
				
					|  |  |  |                 if (StringUtils.isBlank(formItemResult2.getColumnName())) { | 
			
		
	
		
			
				
					|  |  |  |                     continue; | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |                 if ("checkbox".equals(formItemResult2.getItemType()) || "select".equals(formItemResult2.getItemType()) || "radio".equals(formItemResult2.getItemType())) { | 
			
		
	
		
			
				
					|  |  |  |                     itemMap.put(formItemResult2.getColumnName().concat(formItemResult2.getColumnNum() == 0 ? "" : formItemResult2.getColumnNum().toString()), ConvertUtils.sourceToTarget(formItemResult2, FormItemResult.class)); | 
			
		
	
		
			
				
					|  |  |  |                 } | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |         return otherSheetItems; | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     private static OutputStream getOutputStream(String fileName, HttpServletResponse response) throws Exception { | 
			
		
	
		
			
				
					|  |  |  |         fileName = URLEncoder.encode(fileName, "UTF-8"); | 
			
		
	
		
			
				
					|  |  |  |         response.setContentType("application/vnd.ms-excel"); | 
			
		
	
		
			
				
					|  |  |  |         response.setCharacterEncoding("utf8"); | 
			
		
	
		
			
				
					|  |  |  |         response.setHeader("Content-Disposition", "attachment;filename=" + fileName); | 
			
		
	
		
			
				
					|  |  |  |         response.addHeader("Access-Control-Expose-Headers", "Content-disposition"); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         return response.getOutputStream(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * excel导入居民基本信息 | 
			
		
	
		
			
				
					|  |  |  |      * | 
			
		
	
	
		
			
				
					|  |  | 
 |