|  |  | @ -1,17 +1,28 @@ | 
			
		
	
		
			
				
					|  |  |  | package com.epmet.controller; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.excel.EasyExcel; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.excel.ExcelWriter; | 
			
		
	
		
			
				
					|  |  |  | import com.alibaba.excel.write.metadata.WriteSheet; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.annotation.LoginUser; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.annotation.MaskResponse; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.aop.NoRepeatSubmit; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.constant.NumConstant; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.page.PageData; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.security.dto.TokenDto; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.DateUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.ExcelUtils; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.Result; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.DataSyncRecordDeathDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.dto.form.dataSync.DataSyncRecordDeathPageFormDTO; | 
			
		
	
		
			
				
					|  |  |  | import com.epmet.service.DataSyncRecordDeathService; | 
			
		
	
		
			
				
					|  |  |  | import lombok.extern.slf4j.Slf4j; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.util.CollectionUtils; | 
			
		
	
		
			
				
					|  |  |  | import org.springframework.web.bind.annotation.*; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | import javax.servlet.http.HttpServletResponse; | 
			
		
	
		
			
				
					|  |  |  | import java.util.Date; | 
			
		
	
		
			
				
					|  |  |  | import java.util.List; | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
	
		
			
				
					|  |  | @ -21,6 +32,7 @@ import java.util.List; | 
			
		
	
		
			
				
					|  |  |  |  * @author generator generator@elink-cn.com | 
			
		
	
		
			
				
					|  |  |  |  * @since v1.0.0 2022-10-11 | 
			
		
	
		
			
				
					|  |  |  |  */ | 
			
		
	
		
			
				
					|  |  |  | @Slf4j | 
			
		
	
		
			
				
					|  |  |  | @RestController | 
			
		
	
		
			
				
					|  |  |  | @RequestMapping("dataSyncRecordDeath") | 
			
		
	
		
			
				
					|  |  |  | public class DataSyncRecordDeathController { | 
			
		
	
	
		
			
				
					|  |  | @ -68,5 +80,40 @@ public class DataSyncRecordDeathController { | 
			
		
	
		
			
				
					|  |  |  |         return new Result(); | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |     /** | 
			
		
	
		
			
				
					|  |  |  |      * pc:数据比对-死亡人员数据-导出 | 
			
		
	
		
			
				
					|  |  |  |      * @param tokenDto | 
			
		
	
		
			
				
					|  |  |  |      * @param formDTO | 
			
		
	
		
			
				
					|  |  |  |      * @param response | 
			
		
	
		
			
				
					|  |  |  |      */ | 
			
		
	
		
			
				
					|  |  |  |     @NoRepeatSubmit | 
			
		
	
		
			
				
					|  |  |  |     @PostMapping("export") | 
			
		
	
		
			
				
					|  |  |  |     public void export(@LoginUser TokenDto tokenDto, @RequestBody DataSyncRecordDeathPageFormDTO formDTO, HttpServletResponse response) { | 
			
		
	
		
			
				
					|  |  |  |         formDTO.setCustomerId(tokenDto.getCustomerId()); | 
			
		
	
		
			
				
					|  |  |  |         formDTO.setStaffId(tokenDto.getUserId()); | 
			
		
	
		
			
				
					|  |  |  |         formDTO.setIsPage(false); | 
			
		
	
		
			
				
					|  |  |  |         ExcelWriter excelWriter = null; | 
			
		
	
		
			
				
					|  |  |  |         formDTO.setPageSize(NumConstant.TEN_THOUSAND); | 
			
		
	
		
			
				
					|  |  |  |         int pageNo = formDTO.getPageNo(); | 
			
		
	
		
			
				
					|  |  |  |         try { | 
			
		
	
		
			
				
					|  |  |  |             String today = DateUtils.format(new Date(), DateUtils.DATE_PATTERN_MMDD); | 
			
		
	
		
			
				
					|  |  |  |             String fileName = "数据比对-死亡人员数据".concat(today); | 
			
		
	
		
			
				
					|  |  |  |             excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), DataSyncRecordDeathDTO.class).build(); | 
			
		
	
		
			
				
					|  |  |  |             WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); | 
			
		
	
		
			
				
					|  |  |  |             PageData<DataSyncRecordDeathDTO> data = null; | 
			
		
	
		
			
				
					|  |  |  |             do { | 
			
		
	
		
			
				
					|  |  |  |                 data = dataSyncRecordDeathService.page(formDTO); | 
			
		
	
		
			
				
					|  |  |  |                 formDTO.setPageNo(++pageNo); | 
			
		
	
		
			
				
					|  |  |  |                 excelWriter.write(data.getList(), writeSheet); | 
			
		
	
		
			
				
					|  |  |  |             } while (org.apache.commons.collections4.CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize()); | 
			
		
	
		
			
				
					|  |  |  | 
 | 
			
		
	
		
			
				
					|  |  |  |         } catch (Exception e) { | 
			
		
	
		
			
				
					|  |  |  |             log.error("export exception", e); | 
			
		
	
		
			
				
					|  |  |  |         } finally { | 
			
		
	
		
			
				
					|  |  |  |             // 千万别忘记finish 会帮忙关闭流
 | 
			
		
	
		
			
				
					|  |  |  |             if (excelWriter != null) { | 
			
		
	
		
			
				
					|  |  |  |                 excelWriter.finish(); | 
			
		
	
		
			
				
					|  |  |  |             } | 
			
		
	
		
			
				
					|  |  |  |         } | 
			
		
	
		
			
				
					|  |  |  |     } | 
			
		
	
		
			
				
					|  |  |  | } | 
			
		
	
	
		
			
				
					|  |  | 
 |