| 
						
						
							
								
							
						
						
					 | 
					@ -17,15 +17,21 @@ | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					package com.epmet.controller; | 
					 | 
					 | 
					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.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.exception.ExceptionUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.ExceptionUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.exception.RenException; | 
					 | 
					 | 
					import com.epmet.commons.tools.exception.RenException; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.page.PageData; | 
					 | 
					 | 
					import com.epmet.commons.tools.page.PageData; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.security.dto.TokenDto; | 
					 | 
					 | 
					import com.epmet.commons.tools.security.dto.TokenDto; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.ConvertUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.utils.DateUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.DateUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.utils.ExcelUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.ExcelUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.utils.Result; | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.Result; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.validator.ValidatorUtils; | 
					 | 
					 | 
					import com.epmet.commons.tools.validator.ValidatorUtils; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.validator.group.AddGroup; | 
					 | 
					 | 
					import com.epmet.commons.tools.validator.group.AddGroup; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import com.epmet.commons.tools.validator.group.DefaultGroup; | 
					 | 
					 | 
					import com.epmet.commons.tools.validator.group.DefaultGroup; | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -53,11 +59,9 @@ import javax.servlet.http.HttpServletResponse; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.io.IOException; | 
					 | 
					 | 
					import java.io.IOException; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.io.InputStream; | 
					 | 
					 | 
					import java.io.InputStream; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.net.URLEncoder; | 
					 | 
					 | 
					import java.net.URLEncoder; | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					import java.util.ArrayList; | 
					 | 
					 | 
					import java.util.Date; | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					import java.util.List; | 
					 | 
					 | 
					import java.util.List; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.concurrent.CompletableFuture; | 
					 | 
					 | 
					import java.util.concurrent.CompletableFuture; | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.concurrent.atomic.AtomicInteger; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					import java.util.stream.Collectors; | 
					 | 
					 | 
					 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					/** | 
					 | 
					 | 
					/** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
					@ -116,23 +120,36 @@ public class IcPartyActivityController { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    @PostMapping("export") | 
					 | 
					 | 
					    @PostMapping("export") | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					    public void export(@RequestBody PartyActivityFormDTO formDTO, HttpServletResponse response) throws Exception { | 
					 | 
					 | 
					    public void export(@LoginUser TokenDto tokenDto, @RequestBody PartyActivityFormDTO formDTO, HttpServletResponse response) throws Exception { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        List<IcPartyActivityDTO> list = icPartyActivityService.list(formDTO); | 
					 | 
					 | 
					        formDTO.setCustomerId(tokenDto.getCustomerId()); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        List<IcPartyActivityExcel> excelList = new ArrayList<>(); | 
					 | 
					 | 
					        formDTO.setIsPage(false); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        AtomicInteger i = new AtomicInteger(1); | 
					 | 
					 | 
					        ExcelWriter excelWriter = null; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					        if (CollectionUtils.isNotEmpty(list)) { | 
					 | 
					 | 
					        formDTO.setPageSize(NumConstant.TEN_THOUSAND); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            excelList = list.stream().map(item -> { | 
					 | 
					 | 
					        int pageNo = formDTO.getPageNo(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                IcPartyActivityExcel excel = new IcPartyActivityExcel(); | 
					 | 
					 | 
					        try { | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                excel.setIndex(i.getAndIncrement()); | 
					 | 
					 | 
					            // 这里 需要指定写用哪个class去写
 | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                excel.setUnitName(item.getUnitName()); | 
					 | 
					 | 
					            String today= DateUtils.format(new Date(),DateUtils.DATE_PATTERN_MMDD); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                excel.setTitle(item.getTitle()); | 
					 | 
					 | 
					            String fileName = "联建活动".concat(today); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                excel.setAddress(item.getAddress()); | 
					 | 
					 | 
					            excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcPartyActivityExcel.class).build(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                excel.setPeopleCount(item.getPeopleCount()); | 
					 | 
					 | 
					            WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                excel.setActivityTime(DateUtils.format(item.getActivityTime(), DateUtils.DATE_TIME_PATTERN)); | 
					 | 
					 | 
					            PageData<IcPartyActivityDTO> data = null; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					                return excel; | 
					 | 
					 | 
					            List<IcPartyActivityExcel> list = null; | 
				
			
			
				
				
			
		
	
		
		
			
				
					
					 | 
					 | 
					            }).collect(Collectors.toList()); | 
					 | 
					 | 
					            do { | 
				
			
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                data = icPartyActivityService.search(formDTO); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                list = ConvertUtils.sourceToTarget(data.getList(), IcPartyActivityExcel.class); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                formDTO.setPageNo(++pageNo); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                excelWriter.write(list, writeSheet); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } while (CollectionUtils.isNotEmpty(data.getList()) && data.getList().size() == formDTO.getPageSize()); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } catch (Exception e) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            log.error("export exception", e); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					        } finally { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            // 千万别忘记finish 会帮忙关闭流
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            if (excelWriter != null) { | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					                excelWriter.finish(); | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					 | 
					 | 
					 | 
					            } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					        } | 
					 | 
					 | 
					        } | 
				
			
			
		
	
		
		
			
				
					
					 | 
					 | 
					        ExcelUtils.exportExcelToTarget(response, null, excelList, IcPartyActivityExcel.class); | 
					 | 
					 | 
					
 | 
				
			
			
				
				
			
		
	
		
		
	
		
		
			
				
					 | 
					 | 
					    } | 
					 | 
					 | 
					    } | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					
 | 
					 | 
					 | 
					
 | 
				
			
			
		
	
		
		
			
				
					 | 
					 | 
					    /** | 
					 | 
					 | 
					    /** | 
				
			
			
		
	
	
		
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
					
  |