You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
246 lines
11 KiB
246 lines
11 KiB
package com.epmet.controller;
|
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
|
|
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.dto.form.PageFormDTO;
|
|
import com.epmet.commons.tools.exception.EpmetException;
|
|
import com.epmet.commons.tools.page.PageData;
|
|
import com.epmet.commons.tools.security.dto.TokenDto;
|
|
import com.epmet.commons.tools.utils.ExcelPoiUtils;
|
|
import com.epmet.commons.tools.utils.ExcelUtils;
|
|
import com.epmet.commons.tools.utils.Result;
|
|
import com.epmet.commons.tools.validator.ValidatorUtils;
|
|
import com.epmet.constants.ImportTaskConstants;
|
|
import com.epmet.dto.IcEpidemicSpecialAttentionDTO;
|
|
import com.epmet.dto.SysDictDataDTO;
|
|
import com.epmet.dto.form.*;
|
|
import com.epmet.dto.result.ImportTaskCommonResultDTO;
|
|
import com.epmet.dto.result.NatPieResultDTO;
|
|
import com.epmet.dto.result.VaccinationListResultDTO;
|
|
import com.epmet.excel.*;
|
|
import com.epmet.feign.EpmetAdminOpenFeignClient;
|
|
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
|
|
import com.epmet.service.IcEpidemicSpecialAttentionService;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.io.FilenameUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.InputStream;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
* 疫情特别关注
|
|
*
|
|
* @author generator generator@elink-cn.com
|
|
* @since v1.0.0 2022-03-28
|
|
*/
|
|
@RestController
|
|
@RequestMapping("icEpidemicSpecialAttention")
|
|
@Slf4j
|
|
public class IcEpidemicSpecialAttentionController {
|
|
|
|
@Autowired
|
|
private IcEpidemicSpecialAttentionService icEpidemicSpecialAttentionService;
|
|
@Autowired
|
|
private EpmetCommonServiceOpenFeignClient commonServiceOpenFeignClient;
|
|
@Autowired
|
|
private EpmetAdminOpenFeignClient epmetAdminOpenFeignClient;
|
|
|
|
/**
|
|
* Desc: 【疫苗接种关注名单,疫苗接种关注名单】列表
|
|
* @param formDTO
|
|
* @author zxc
|
|
* @date 2022/3/28 10:29
|
|
*/
|
|
@PostMapping("list")
|
|
@MaskResponse(fieldNames = { "mobile", "idCard" }, fieldsMaskType = { MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD })
|
|
public Result<PageData> vaccinationList(@RequestBody VaccinationListFormDTO formDTO, @LoginUser TokenDto tokenDto){
|
|
ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class, VaccinationListFormDTO.VaccinationListForm.class);
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
return new Result<PageData>().ok(icEpidemicSpecialAttentionService.vaccinationList(formDTO));
|
|
}
|
|
|
|
@PostMapping("historyList")
|
|
@MaskResponse(fieldNames = { "mobile", "idCard" }, fieldsMaskType = { MaskResponse.MASK_TYPE_MOBILE, MaskResponse.MASK_TYPE_ID_CARD })
|
|
public Result<PageData> historyList(@RequestBody VaccinationListFormDTO formDTO, @LoginUser TokenDto tokenDto){
|
|
ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class, VaccinationListFormDTO.VaccinationListForm.class);
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
return new Result<PageData>().ok(icEpidemicSpecialAttentionService.historyList(formDTO));
|
|
}
|
|
|
|
/**
|
|
* Desc: 【疫苗接种关注名单,疫苗接种关注名单】详情
|
|
* @param formDTO
|
|
* @author zxc
|
|
* @date 2022/4/27 15:47
|
|
*/
|
|
@PostMapping("detail")
|
|
public Result<VaccinationListResultDTO> detail(@RequestBody AttentionDetailFormDTO formDTO){
|
|
ValidatorUtils.validateEntity(formDTO,VaccinationListFormDTO.VaccinationListForm.class);
|
|
return new Result<VaccinationListResultDTO>().ok(icEpidemicSpecialAttentionService.detail(formDTO));
|
|
}
|
|
|
|
/**
|
|
* Desc:【疫苗接种关注名单,核酸检测关注名单】新增
|
|
* @param formDTO
|
|
* @param tokenDto
|
|
* @author zxc
|
|
* @date 2022/3/28 13:35
|
|
*/
|
|
@PostMapping("vaccination-add")
|
|
@NoRepeatSubmit
|
|
public Result vaccinationAdd(@RequestBody VaccinationAddFormDTO formDTO,@LoginUser TokenDto tokenDto){
|
|
ValidatorUtils.validateEntity(formDTO, IcEpidemicSpecialAttentionDTO.IcEpidemicSpecialAttentionAdd.class);
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
icEpidemicSpecialAttentionService.vaccinationAdd(formDTO);
|
|
return new Result();
|
|
}
|
|
|
|
/**
|
|
* Desc:【疫苗接种关注名单,核酸检测关注名单】修改
|
|
* @param formDTO
|
|
* @author zxc
|
|
* @date 2022/3/28 13:45
|
|
*/
|
|
@PostMapping("vaccination-update")
|
|
@NoRepeatSubmit
|
|
public Result vaccinationUpdate(@RequestBody IcEpidemicSpecialAttentionDTO formDTO,@LoginUser TokenDto tokenDto){
|
|
ValidatorUtils.validateEntity(formDTO, IcEpidemicSpecialAttentionDTO.IcEpidemicSpecialAttentionUpdate.class);
|
|
icEpidemicSpecialAttentionService.vaccinationUpdate(formDTO,tokenDto);
|
|
return new Result();
|
|
}
|
|
|
|
/**
|
|
* Desc: 取消关注
|
|
* @param formDTO
|
|
* @author zxc
|
|
* @date 2022/3/28 13:51
|
|
*/
|
|
@PostMapping("cancel-attention")
|
|
@NoRepeatSubmit
|
|
public Result cancelAttention(@RequestBody CancelAttentionPackageFormDTO formDTO){
|
|
ValidatorUtils.validateEntity(formDTO, CancelAttentionPackageFormDTO.CancelAttentionPackageForm.class);
|
|
icEpidemicSpecialAttentionService.cancelAttention(formDTO);
|
|
return new Result();
|
|
}
|
|
|
|
/**
|
|
* Desc: 【疫苗接种关注名单,核酸检测关注名单】导入
|
|
* @param
|
|
* @author zxc
|
|
* @date 2022/3/28 13:40
|
|
*/
|
|
@PostMapping("vaccination-import")
|
|
public Result vaccinationImport(@LoginUser TokenDto tokenDto, @RequestParam("file") MultipartFile file,@RequestParam("attentionType")Integer attentionType){
|
|
if (file.isEmpty()) {
|
|
throw new EpmetException("请上传文件");
|
|
}
|
|
// 校验文件类型
|
|
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
|
if (!"xls".equals(extension) && !"xlsx".equals(extension)) {
|
|
throw new EpmetException("文件类型不匹配");
|
|
}
|
|
// 关注类型,核酸检测:2,疫苗接种:1,行程上报:0
|
|
ImportTaskCommonFormDTO importTaskForm = new ImportTaskCommonFormDTO();
|
|
importTaskForm.setOriginFileName(file.getOriginalFilename());
|
|
importTaskForm.setOperatorId(tokenDto.getUserId());
|
|
if (attentionType.equals(NumConstant.ONE)){
|
|
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_ATTENTION_VACCINATION);
|
|
}else if (attentionType.equals(NumConstant.TWO)){
|
|
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_ATTENTION_NAT);
|
|
}else if (attentionType.equals(NumConstant.ZERO)){
|
|
importTaskForm.setBizType(ImportTaskConstants.BIZ_TYPE_ATTENTION_TRIP_REPORT);
|
|
}
|
|
Result<ImportTaskCommonResultDTO> result = commonServiceOpenFeignClient.createImportTask(importTaskForm);
|
|
if (!result.success()) {
|
|
throw new EpmetException(9999,"存在进行中的导入");
|
|
}
|
|
InputStream inputStream = null;
|
|
try {
|
|
inputStream = file.getInputStream();
|
|
}catch (Exception e){
|
|
ImportTaskCommonFormDTO input = new ImportTaskCommonFormDTO();
|
|
input.setOperatorId(tokenDto.getUserId());
|
|
input.setTaskId(result.getData().getTaskId());
|
|
input.setProcessStatus(ImportTaskConstants.PROCESS_STATUS_FINISHED_FAIL);
|
|
commonServiceOpenFeignClient.finishImportTask(input);
|
|
log.error("读取文件失败");
|
|
}
|
|
icEpidemicSpecialAttentionService.importFile(tokenDto,inputStream,attentionType,result.getData().getTaskId());
|
|
return new Result();
|
|
}
|
|
|
|
/**
|
|
* Desc: 【疫苗接种关注名单,核酸检测关注名单】导出
|
|
* @param response
|
|
* @param formDTO
|
|
* @param tokenDto
|
|
* @author zxc
|
|
* @date 2022/3/28 13:57
|
|
*/
|
|
@PostMapping("vaccination-export")
|
|
public void vaccinationExport(HttpServletResponse response,@RequestBody VaccinationListFormDTO formDTO, @LoginUser TokenDto tokenDto) throws Exception {
|
|
ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserInternalGroup.class);
|
|
formDTO.setCustomerId(tokenDto.getCustomerId());
|
|
formDTO.setUserId(tokenDto.getUserId());
|
|
formDTO.setIsPage(false);
|
|
PageData<VaccinationListResultDTO> pageData = icEpidemicSpecialAttentionService.vaccinationList(formDTO);
|
|
// 关注类型,核酸检测:2,疫苗接种:1,行程上报:0,历史核酸检测关注:99
|
|
if (formDTO.getAttentionType().equals(NumConstant.ONE)){
|
|
ExcelUtils.exportExcelToTarget(response, null, pageData.getList(), VaccinationExportExcel.class);
|
|
}else {
|
|
Result<List<SysDictDataDTO>> isolatedState = epmetAdminOpenFeignClient.dictDataList("isolatedState");
|
|
if (!isolatedState.success()){
|
|
throw new EpmetException("查询字典表数据失败..."+"isolatedState");
|
|
}
|
|
Map<String, String> dictMap = isolatedState.getData().stream().collect(Collectors.toMap(SysDictDataDTO::getDictValue, SysDictDataDTO::getDictLabel));
|
|
pageData.getList().forEach(l -> {
|
|
l.setIsolatedState(dictMap.get(l.getIsolatedState()));
|
|
});
|
|
if (formDTO.getIsHistory().equals(NumConstant.ONE_STR)){
|
|
ExcelUtils.exportExcelToTarget(response, null, pageData.getList(), NatHistoryExportExcel.class);
|
|
}else {
|
|
ExcelUtils.exportExcelToTarget(response, null, pageData.getList(), NatExportExcel.class);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
@PostMapping("export-template")
|
|
public void exportTemplate(HttpServletResponse response, @RequestBody VaccinationListFormDTO formDTO) throws Exception {
|
|
TemplateExportParams templatePath = new TemplateExportParams();
|
|
String fileName = "";
|
|
Map<String,Object> map = new HashMap<>();
|
|
// 关注类型,核酸检测:2,疫苗接种:1,行程上报:0
|
|
if (formDTO.getAttentionType().equals(NumConstant.ONE)){
|
|
templatePath.setTemplateUrl("excel/attention_vaccination_template.xlsx");
|
|
fileName = "疫苗接种关注名单导入模板";
|
|
map.put("maplist",new ArrayList<VaccinationImportExcel>());
|
|
}else if (formDTO.getAttentionType().equals(NumConstant.TWO)){
|
|
templatePath.setTemplateUrl("excel/attention_nat_template.xlsx");
|
|
fileName = "核酸检测关注名单导入模板";
|
|
map.put("maplist",new ArrayList<NatImportExcel>());
|
|
}
|
|
ExcelPoiUtils.exportExcel(templatePath ,map,fileName,response);
|
|
}
|
|
|
|
@PostMapping("pie")
|
|
public Result<NatPieResultDTO> pie(@LoginUser TokenDto tokenDto){
|
|
return new Result<NatPieResultDTO>().ok(icEpidemicSpecialAttentionService.pie(tokenDto));
|
|
}
|
|
|
|
}
|
|
|