|
|
@ -1,24 +1,37 @@ |
|
|
|
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.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.commons.tools.validator.AssertUtils; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.epmet.dto.DataSyncRecordDeathDTO; |
|
|
|
import com.epmet.dto.DataSyncRecordMaritalDTO; |
|
|
|
import com.epmet.dto.form.dataSync.DataSyncRecordDeathPageFormDTO; |
|
|
|
import com.epmet.dto.form.dataSync.DataSyncRecordDisabilityFormDTO; |
|
|
|
import com.epmet.dto.form.dataSync.DataSyncRecordMaritalPageFormDTO; |
|
|
|
import com.epmet.dto.result.DataSyncRecordMaritalPageResultDTO; |
|
|
|
import com.epmet.excel.DataSyncRecordMaritalExcel; |
|
|
|
import com.epmet.service.DataSyncRecordMaritalService; |
|
|
|
import lombok.extern.log4j.Log4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@ -29,6 +42,7 @@ import java.util.Map; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2023-05-18 |
|
|
|
*/ |
|
|
|
@Log4j |
|
|
|
@RestController |
|
|
|
@RequestMapping("dataSyncRecordMarital") |
|
|
|
public class DataSyncRecordMaritalController { |
|
|
@ -76,4 +90,43 @@ public class DataSyncRecordMaritalController { |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description: 导出 |
|
|
|
* @param tokenDto: |
|
|
|
* @param formDTO: |
|
|
|
* @param response: |
|
|
|
* @Return void |
|
|
|
* @Author: lichao |
|
|
|
* @Date: 2023/5/22 16:18 |
|
|
|
*/ |
|
|
|
@PostMapping("export") |
|
|
|
public void export(@LoginUser TokenDto tokenDto, @RequestBody DataSyncRecordMaritalPageFormDTO formDTO, HttpServletResponse response) throws IOException { |
|
|
|
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), DataSyncRecordMaritalExcel.class).build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); |
|
|
|
PageData<DataSyncRecordMaritalPageResultDTO> data = null; |
|
|
|
do { |
|
|
|
data = dataSyncRecordMaritalService.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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|