|
|
@ -1,12 +1,18 @@ |
|
|
|
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.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
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; |
|
|
@ -18,10 +24,13 @@ import com.epmet.dto.form.IcMoveInListFormDTO; |
|
|
|
import com.epmet.dto.result.IcMoveInListResultDTO; |
|
|
|
import com.epmet.excel.IcMoveInRecordExcel; |
|
|
|
import com.epmet.service.IcMoveInRecordService; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
@ -33,6 +42,7 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
@RestController |
|
|
|
@RequestMapping("icMoveIn") |
|
|
|
@Slf4j |
|
|
|
public class IcMoveInRecordController { |
|
|
|
|
|
|
|
@Autowired |
|
|
@ -79,12 +89,46 @@ public class IcMoveInRecordController { |
|
|
|
} |
|
|
|
|
|
|
|
@PostMapping("export") |
|
|
|
public void export(@LoginUser TokenDto tokenDto, @RequestBody IcMoveInListFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
formDTO.setIsPage(true); |
|
|
|
public void export(@RequestBody IcMoveInListFormDTO formDTO, HttpServletResponse response) throws Exception { |
|
|
|
formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc"); |
|
|
|
/* formDTO.setIsPage(true); |
|
|
|
IcMoveInListResultDTO resultDTO = icMoveInRecordService.list(formDTO); |
|
|
|
List<IcMoveInRecordExcel> list = ConvertUtils.sourceToTarget(resultDTO.getList(), IcMoveInRecordExcel.class); |
|
|
|
ExcelUtils.exportExcelToTarget(response, null, list, IcMoveInRecordExcel.class); |
|
|
|
ExcelUtils.exportExcelToTarget(response, null, list, IcMoveInRecordExcel.class);*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
formDTO.setPageSize(NumConstant.TEN_THOUSAND); |
|
|
|
int pageNo = NumConstant.ONE; |
|
|
|
try { |
|
|
|
String fileName = "迁入管理"+DateUtils.format(new Date())+".xlsx"; |
|
|
|
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), IcMoveInRecordExcel.class).build(); |
|
|
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); |
|
|
|
List<IcMoveInRecordExcel> list = null; |
|
|
|
do { |
|
|
|
IcMoveInListResultDTO data = icMoveInRecordService.list(formDTO); |
|
|
|
list = ConvertUtils.sourceToTarget(data.getList(), IcMoveInRecordExcel.class); |
|
|
|
formDTO.setPageNo(++pageNo); |
|
|
|
excelWriter.write(list, writeSheet); |
|
|
|
} while (CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()); |
|
|
|
}catch (Exception e){ |
|
|
|
log.error("export exception", e); |
|
|
|
}finally { |
|
|
|
if (excelWriter != null) { |
|
|
|
excelWriter.finish(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
@RequestMapping("detail") |
|
|
|