|
|
@ -1,19 +1,30 @@ |
|
|
|
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.dto.form.PageFormDTO; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
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.validator.AssertUtils; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.commons.tools.validator.group.AddGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.DefaultGroup; |
|
|
|
import com.epmet.commons.tools.validator.group.UpdateGroup; |
|
|
|
import com.epmet.dto.IcFollowUpRecordDTO; |
|
|
|
import com.epmet.dto.form.PageFollowUpFormDTO; |
|
|
|
import com.epmet.dto.result.NatListResultDTO; |
|
|
|
import com.epmet.service.IcFollowUpRecordService; |
|
|
|
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 java.util.Map; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
@ -22,6 +33,7 @@ import java.util.Map; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2022-03-25 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@RestController |
|
|
|
@RequestMapping("followup") |
|
|
|
public class IcFollowUpRecordController { |
|
|
@ -29,9 +41,16 @@ public class IcFollowUpRecordController { |
|
|
|
@Autowired |
|
|
|
private IcFollowUpRecordService icFollowUpRecordService; |
|
|
|
|
|
|
|
@RequestMapping("page") |
|
|
|
public Result<PageData<IcFollowUpRecordDTO>> page(@RequestParam Map<String, Object> params){ |
|
|
|
PageData<IcFollowUpRecordDTO> page = icFollowUpRecordService.page(params); |
|
|
|
/** |
|
|
|
* 随访记录-列表 |
|
|
|
* @param formDTO |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@PostMapping("page") |
|
|
|
public Result<PageData<IcFollowUpRecordDTO>> page(@LoginUser TokenDto tokenDto, @RequestBody PageFollowUpFormDTO formDTO){ |
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
ValidatorUtils.validateEntity(formDTO, PageFormDTO.AddUserShowGroup.class,PageFormDTO.AddUserInternalGroup.class); |
|
|
|
PageData<IcFollowUpRecordDTO> page = icFollowUpRecordService.page(formDTO); |
|
|
|
return new Result<PageData<IcFollowUpRecordDTO>>().ok(page); |
|
|
|
} |
|
|
|
|
|
|
@ -41,11 +60,17 @@ public class IcFollowUpRecordController { |
|
|
|
return new Result<IcFollowUpRecordDTO>().ok(data); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 随访记录-新增 |
|
|
|
* @param dto |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("save") |
|
|
|
public Result save(@RequestBody IcFollowUpRecordDTO dto){ |
|
|
|
//效验数据
|
|
|
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|
|
|
public Result save(@LoginUser TokenDto tokenDto, @RequestBody IcFollowUpRecordDTO dto){ |
|
|
|
dto.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
dto.setCreatedBy(tokenDto.getUserId()); |
|
|
|
ValidatorUtils.validateEntity(dto, IcFollowUpRecordDTO.AddUserRequired.class,IcFollowUpRecordDTO.AddInternalGroup.class); |
|
|
|
icFollowUpRecordService.save(dto); |
|
|
|
return new Result(); |
|
|
|
} |
|
|
@ -67,6 +92,56 @@ public class IcFollowUpRecordController { |
|
|
|
return new Result(); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 随访记录-导出 |
|
|
|
* 目前是导出个人 |
|
|
|
* @param tokenDto |
|
|
|
* @param formDTO |
|
|
|
* @param response |
|
|
|
*/ |
|
|
|
@NoRepeatSubmit |
|
|
|
@PostMapping("export") |
|
|
|
public void export(@LoginUser TokenDto tokenDto, @RequestBody PageFollowUpFormDTO formDTO, HttpServletResponse response) { |
|
|
|
formDTO.setCustomerId(tokenDto.getCustomerId()); |
|
|
|
//formDTO.setCustomerId("45687aa479955f9d06204d415238f7cc");
|
|
|
|
formDTO.setPage(false); |
|
|
|
|
|
|
|
ExcelWriter excelWriter = null; |
|
|
|
formDTO.setPageSize(NumConstant.TEN_THOUSAND); |
|
|
|
int pageNo = formDTO.getPageNo(); |
|
|
|
try { |
|
|
|
//导出文件名:张三随访记录0330
|
|
|
|
String fileName = "随访记录.xlsx"; |
|
|
|
excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), NatListResultDTO.class).build(); |
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").build(); |
|
|
|
PageData<IcFollowUpRecordDTO> data = null; |
|
|
|
do { |
|
|
|
data = icFollowUpRecordService.page(formDTO); |
|
|
|
data.getList().forEach(o->{ |
|
|
|
//0行程上报,1疫苗接种,2核酸检测
|
|
|
|
switch(o.getOrigin()){ |
|
|
|
case NumConstant.ZERO_STR: |
|
|
|
o.setOrigin("行程上报"); |
|
|
|
break; |
|
|
|
case NumConstant.ONE_STR: |
|
|
|
o.setOrigin("疫苗接种"); |
|
|
|
break; |
|
|
|
case NumConstant.TWO_STR: |
|
|
|
o.setOrigin("核酸检测"); |
|
|
|
break; |
|
|
|
} |
|
|
|
}); |
|
|
|
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(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|