yinzuomei 3 years ago
parent
commit
4ff7ff3244
  1. 52
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcFollowUpRecordDTO.java
  2. 28
      epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PageFollowUpFormDTO.java
  3. 91
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcFollowUpRecordController.java
  4. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java
  5. 4
      epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcFollowUpRecordEntity.java
  6. 9
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcFollowUpRecordService.java
  7. 35
      epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcFollowUpRecordServiceImpl.java

52
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/IcFollowUpRecordDTO.java

@ -1,8 +1,18 @@
package com.epmet.dto;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
@ -15,75 +25,115 @@ import lombok.Data;
public class IcFollowUpRecordDTO implements Serializable {
private static final long serialVersionUID = 1L;
public interface AddInternalGroup {
}
public interface AddUserRequired extends CustomerClientShowGroup {
}
/**
* 主键ID
*/
@ExcelIgnore
private String id;
/**
* 客户Id
*/
@ExcelIgnore
private String customerId;
/**
* 姓名
*/
@ColumnWidth(20)
@ExcelProperty("姓名")
@NotBlank(message = "姓名不能为空", groups = {AddUserRequired.class})
private String name;
/**
* 手机号
*/
@ColumnWidth(20)
@ExcelProperty("手机号")
@NotBlank(message = "手机号不能为空", groups = {AddUserRequired.class})
private String mobile;
/**
* 身份证号
*/
@ColumnWidth(25)
@ExcelProperty("身份证号")
@NotBlank(message = "身份证号不能为空", groups = {AddUserRequired.class})
private String idCard;
/**
* 0行程上报1疫苗接种2核酸检测
*/
@ColumnWidth(25)
@ExcelProperty("来源")
@NotBlank(message = "origin不能为空:0行程上报,1疫苗接种,2核酸检测", groups = {AddInternalGroup.class})
private String origin;
/**
* 随访时间
*/
@ColumnWidth(25)
@ExcelProperty("随访时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@NotNull(message = "随访时间不能为空", groups = {AddUserRequired.class})
private Date visitTime;
/**
* 随访内容
*/
@ColumnWidth(200)
@ExcelProperty("随访内容")
@NotBlank(message = "随访内容不能为空", groups = {AddUserRequired.class})
@Length(message = "随访内容最多输入1000字", groups = {AddUserRequired.class})
private String content;
/**
* 工作人员所属组织id
*/
@ExcelIgnore
private String agencyId;
/**
* 删除标识 1删除0未删除
*/
@ExcelIgnore
private String delFlag;
/**
* 乐观锁
*/
@ExcelIgnore
private Integer revision;
/**
* 创建人
*/
@ExcelIgnore
private String createdBy;
/**
* 创建时间
*/
@ExcelIgnore
private Date createdTime;
/**
* 更新人
*/
@ExcelIgnore
private String updatedBy;
/**
* 更新时间
*/
@ExcelIgnore
private Date updatedTime;
}

28
epmet-user/epmet-user-client/src/main/java/com/epmet/dto/form/PageFollowUpFormDTO.java

@ -0,0 +1,28 @@
package com.epmet.dto.form;
import com.epmet.commons.tools.dto.form.PageFormDTO;
import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data
public class PageFollowUpFormDTO extends PageFormDTO {
/**
* 身份证号
*/
@NotBlank(message = "身份证号不能为空", groups = {AddUserShowGroup.class})
private String idCard;
@NotBlank(message = "身份证号不能为空", groups = {AddUserShowGroup.class})
private String name;
/**
* 0行程上报1疫苗接种2核酸检测
*/
@NotBlank(message = "origin不能为空:0行程上报,1疫苗接种,2核酸检测", groups = {AddUserInternalGroup.class})
private String origin;
private String customerId;
}

91
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcFollowUpRecordController.java

@ -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();
}
}
}
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcTripReportRecordController.java

@ -46,7 +46,7 @@ public class IcTripReportRecordController {
* @param formDTO
* @return
*/
@RequestMapping("page")
@PostMapping("page")
public Result<PageData<IcTripReportRecordDTO>> page(@LoginUser TokenDto tokenDto,@RequestBody PageTripReportFormDTO formDTO){
formDTO.setCustomerId(tokenDto.getCustomerId());
formDTO.setUserId(tokenDto.getUserId());

4
epmet-user/epmet-user-server/src/main/java/com/epmet/entity/IcFollowUpRecordEntity.java

@ -56,4 +56,8 @@ public class IcFollowUpRecordEntity extends BaseEpmetEntity {
*/
private String content;
/**
* 工作人员所属组织id
*/
private String agencyId;
}

9
epmet-user/epmet-user-server/src/main/java/com/epmet/service/IcFollowUpRecordService.java

@ -3,6 +3,7 @@ package com.epmet.service;
import com.epmet.commons.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData;
import com.epmet.dto.IcFollowUpRecordDTO;
import com.epmet.dto.form.PageFollowUpFormDTO;
import com.epmet.entity.IcFollowUpRecordEntity;
import java.util.List;
@ -17,14 +18,14 @@ import java.util.Map;
public interface IcFollowUpRecordService extends BaseService<IcFollowUpRecordEntity> {
/**
* 默认分页
* 随访记录-列表
*
* @param params
* @param formDTO
* @return PageData<IcFollowUpRecordDTO>
* @author generator
* @date 2022-03-25
*/
PageData<IcFollowUpRecordDTO> page(Map<String, Object> params);
PageData<IcFollowUpRecordDTO> page(PageFollowUpFormDTO formDTO);
/**
* 默认查询
@ -47,7 +48,7 @@ public interface IcFollowUpRecordService extends BaseService<IcFollowUpRecordEnt
IcFollowUpRecordDTO get(String id);
/**
* 默认保存
* 随访记录-新增
*
* @param dto
* @return void

35
epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcFollowUpRecordServiceImpl.java

@ -1,15 +1,22 @@
package com.epmet.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.redis.common.CustomerStaffRedis;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.dao.IcFollowUpRecordDao;
import com.epmet.dto.IcFollowUpRecordDTO;
import com.epmet.dto.form.PageFollowUpFormDTO;
import com.epmet.entity.IcFollowUpRecordEntity;
import com.epmet.service.IcFollowUpRecordService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -28,13 +35,22 @@ import java.util.Map;
public class IcFollowUpRecordServiceImpl extends BaseServiceImpl<IcFollowUpRecordDao, IcFollowUpRecordEntity> implements IcFollowUpRecordService {
/**
* 随访记录-列表
* @param formDTO
* @return
*/
@Override
public PageData<IcFollowUpRecordDTO> page(Map<String, Object> params) {
IPage<IcFollowUpRecordEntity> page = baseDao.selectPage(
getPage(params, FieldConstant.CREATED_TIME, false),
getWrapper(params)
);
return getPageData(page, IcFollowUpRecordDTO.class);
public PageData<IcFollowUpRecordDTO> page(PageFollowUpFormDTO formDTO) {
LambdaQueryWrapper<IcFollowUpRecordEntity> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(StringUtils.isNotBlank(formDTO.getIdCard()),IcFollowUpRecordEntity::getIdCard,formDTO.getIdCard())
.eq(StringUtils.isNotBlank(formDTO.getName()),IcFollowUpRecordEntity::getName,formDTO.getName())
.eq(IcFollowUpRecordEntity::getOrigin,formDTO.getOrigin())
.eq(IcFollowUpRecordEntity::getCustomerId,formDTO.getCustomerId())
.orderByDesc(IcFollowUpRecordEntity::getCreatedTime);
PageInfo<IcFollowUpRecordDTO> data = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize(), formDTO.isPage())
.doSelectPageInfo(() -> baseDao.selectList(wrapper));
return new PageData(data.getList(),data.getTotal());
}
@Override
@ -62,7 +78,12 @@ public class IcFollowUpRecordServiceImpl extends BaseServiceImpl<IcFollowUpRecor
@Override
@Transactional(rollbackFor = Exception.class)
public void save(IcFollowUpRecordDTO dto) {
CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(dto.getCustomerId(), dto.getCreatedBy());
if (null == staffInfo) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询工作人员缓存信息异常", EpmetErrorCode.SERVER_ERROR.getMsg());
}
IcFollowUpRecordEntity entity = ConvertUtils.sourceToTarget(dto, IcFollowUpRecordEntity.class);
entity.setAgencyId(staffInfo.getAgencyId());
insert(entity);
}

Loading…
Cancel
Save