|
|
|
package com.epmet.controller;
|
|
|
|
|
|
|
|
import com.epmet.commons.tools.annotation.LoginUser;
|
|
|
|
import com.epmet.commons.tools.aop.NoRepeatSubmit;
|
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto;
|
|
|
|
import com.epmet.commons.tools.utils.Result;
|
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
|
|
import com.epmet.dto.IcNatDTO;
|
|
|
|
import com.epmet.dto.form.AddIcNatFormDTO;
|
|
|
|
import com.epmet.dto.form.MyNatListFormDTO;
|
|
|
|
import com.epmet.dto.result.MyNatListResultDTO;
|
|
|
|
import com.epmet.dto.result.NatListResultDTO;
|
|
|
|
import com.epmet.service.IcNatService;
|
|
|
|
import org.apache.commons.io.IOUtils;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStream;
|
|
|
|
import java.net.URLEncoder;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 核酸上报记录
|
|
|
|
*
|
|
|
|
* @author generator generator@elink-cn.com
|
|
|
|
* @since v1.0.0 2022-03-25
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("icNat")
|
|
|
|
public class IcNatController {
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
private IcNatService icNucleinService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author sun
|
|
|
|
* @Description 核酸检测-上报核酸记录
|
|
|
|
**/
|
|
|
|
//@NoRepeatSubmit
|
|
|
|
@PostMapping("add")
|
|
|
|
public Result add(@LoginUser TokenDto tokenDto, @RequestBody AddIcNatFormDTO formDTO) {
|
|
|
|
ValidatorUtils.validateEntity(formDTO, AddIcNatFormDTO.Nat.class);
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
|
|
icNucleinService.add(formDTO);
|
|
|
|
return new Result();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author sun
|
|
|
|
* @Description 核酸检测-居民端我的上报
|
|
|
|
**/
|
|
|
|
@NoRepeatSubmit
|
|
|
|
@PostMapping("mynatlist")
|
|
|
|
public Result<List<MyNatListResultDTO>> myNatList(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO) {
|
|
|
|
ValidatorUtils.validateEntity(formDTO, MyNatListFormDTO.MyNat.class);
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
|
|
return new Result<List<MyNatListResultDTO>>().ok(icNucleinService.myNatList(formDTO));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author sun
|
|
|
|
* @Description 【核酸】核酸检测信息列表
|
|
|
|
**/
|
|
|
|
@NoRepeatSubmit
|
|
|
|
@PostMapping("natlist")
|
|
|
|
public Result<NatListResultDTO> natList(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO) {
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
|
|
return new Result<NatListResultDTO>().ok(icNucleinService.natList(formDTO));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author sun
|
|
|
|
* @Description 【核酸】核酸检测信息详情
|
|
|
|
**/
|
|
|
|
@NoRepeatSubmit
|
|
|
|
@PostMapping("detail")
|
|
|
|
public Result<IcNatDTO> detail(@RequestBody MyNatListFormDTO formDTO) {
|
|
|
|
ValidatorUtils.validateEntity(formDTO, MyNatListFormDTO.Detail.class);
|
|
|
|
return new Result<IcNatDTO>().ok(icNucleinService.detail(formDTO));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author sun
|
|
|
|
* @Description 【核酸】核酸检测信息修改
|
|
|
|
**/
|
|
|
|
@NoRepeatSubmit
|
|
|
|
@PostMapping("edit")
|
|
|
|
public Result edit(@LoginUser TokenDto tokenDto, @RequestBody AddIcNatFormDTO formDTO) {
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
|
|
icNucleinService.edit(formDTO);
|
|
|
|
return new Result();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author sun
|
|
|
|
* @Description 【核酸】核酸检测信息删除/取消同步
|
|
|
|
**/
|
|
|
|
@NoRepeatSubmit
|
|
|
|
@PostMapping("del")
|
|
|
|
public Result del(@RequestBody MyNatListFormDTO formDTO) {
|
|
|
|
ValidatorUtils.validateEntity(formDTO, MyNatListFormDTO.Del.class);
|
|
|
|
icNucleinService.del(formDTO);
|
|
|
|
return new Result<>();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author sun
|
|
|
|
* @Description 【核酸】核酸检测信息同步
|
|
|
|
**/
|
|
|
|
@NoRepeatSubmit
|
|
|
|
@PostMapping("synchro")
|
|
|
|
public Result synchro(@LoginUser TokenDto tokenDto, @RequestBody MyNatListFormDTO formDTO) {
|
|
|
|
ValidatorUtils.validateEntity(formDTO, MyNatListFormDTO.Synchro.class);
|
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
|
|
icNucleinService.synchro(formDTO);
|
|
|
|
return new Result();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author sun
|
|
|
|
* @Description 【核酸】核酸检测信息下载模板
|
|
|
|
**/
|
|
|
|
@RequestMapping(value = "import-template-download", method = {RequestMethod.GET, RequestMethod.POST})
|
|
|
|
public void downloadTemplate(HttpServletResponse response) throws IOException {
|
|
|
|
response.setCharacterEncoding("UTF-8");
|
|
|
|
response.addHeader(HttpHeaders.ACCESS_CONTROL_EXPOSE_HEADERS, "Content-Disposition");
|
|
|
|
//response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.ms-excel");
|
|
|
|
response.setHeader(HttpHeaders.CONTENT_TYPE, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
|
|
|
response.setHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + URLEncoder.encode("社区自组织导入模板", "UTF-8") + ".xlsx");
|
|
|
|
|
|
|
|
InputStream is = this.getClass().getClassLoader().getResourceAsStream("excel/ic_nat.xlsx");
|
|
|
|
try {
|
|
|
|
ServletOutputStream os = response.getOutputStream();
|
|
|
|
IOUtils.copy(is, os);
|
|
|
|
} finally {
|
|
|
|
if (is != null) {
|
|
|
|
is.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|