|
@ -1,8 +1,14 @@ |
|
|
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.page.PageData; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
|
|
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.validator.ValidatorUtils; |
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
import com.epmet.dto.IcNatDTO; |
|
|
import com.epmet.dto.IcNatDTO; |
|
@ -11,6 +17,8 @@ import com.epmet.dto.form.MyNatListFormDTO; |
|
|
import com.epmet.dto.result.MyNatListResultDTO; |
|
|
import com.epmet.dto.result.MyNatListResultDTO; |
|
|
import com.epmet.dto.result.NatListResultDTO; |
|
|
import com.epmet.dto.result.NatListResultDTO; |
|
|
import com.epmet.service.IcNatService; |
|
|
import com.epmet.service.IcNatService; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
import org.apache.commons.io.IOUtils; |
|
|
import org.apache.commons.io.IOUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.http.HttpHeaders; |
|
|
import org.springframework.http.HttpHeaders; |
|
@ -30,6 +38,7 @@ import java.util.List; |
|
|
* @author generator generator@elink-cn.com |
|
|
* @author generator generator@elink-cn.com |
|
|
* @since v1.0.0 2022-03-25 |
|
|
* @since v1.0.0 2022-03-25 |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
@Slf4j |
|
|
@RestController |
|
|
@RestController |
|
|
@RequestMapping("icNat") |
|
|
@RequestMapping("icNat") |
|
|
public class IcNatController { |
|
|
public class IcNatController { |
|
@ -69,10 +78,10 @@ public class IcNatController { |
|
|
**/ |
|
|
**/ |
|
|
@NoRepeatSubmit |
|
|
@NoRepeatSubmit |
|
|
@PostMapping("natlist") |
|
|
@PostMapping("natlist") |
|
|
public Result<NatListResultDTO> natList(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO) { |
|
|
public Result<PageData<NatListResultDTO>> natList(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO) { |
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
formDTO.setUserId(tokenDto.getUserId()); |
|
|
formDTO.setUserId(tokenDto.getUserId()); |
|
|
return new Result<NatListResultDTO>().ok(icNucleinService.natList(formDTO)); |
|
|
return new Result<PageData<NatListResultDTO>>().ok(icNucleinService.natList(formDTO)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -148,5 +157,45 @@ public class IcNatController { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @Author sun |
|
|
|
|
|
* @Description 【核酸】核酸检测信息列表 |
|
|
|
|
|
**/ |
|
|
|
|
|
@NoRepeatSubmit |
|
|
|
|
|
@PostMapping("export") |
|
|
|
|
|
public void export(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO, HttpServletResponse response) { |
|
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
|
|
formDTO.setUserId(tokenDto.getUserId()); |
|
|
|
|
|
|
|
|
|
|
|
//formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc");
|
|
|
|
|
|
//formDTO.setUserId("73ae6280e46a6653a5605d51d5462725");
|
|
|
|
|
|
|
|
|
|
|
|
formDTO.setPage(false); |
|
|
|
|
|
|
|
|
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
|
|
formDTO.setPageSize(NumConstant.TEN_THOUSAND); |
|
|
|
|
|
int pageNo = formDTO.getPageNo(); |
|
|
|
|
|
try { |
|
|
|
|
|
// 这里 需要指定写用哪个class去写
|
|
|
|
|
|
String fileName = "核酸检测信息.xlsx"; |
|
|
|
|
|
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response),NatListResultDTO.class).build(); |
|
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet().build(); |
|
|
|
|
|
PageData<NatListResultDTO> data = null; |
|
|
|
|
|
do { |
|
|
|
|
|
data = icNucleinService.natList(formDTO); |
|
|
|
|
|
formDTO.setPageNo(++pageNo); |
|
|
|
|
|
excelWriter.write(data.getList(), 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(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|