1.申请修改委托信息模块代码
master
陈江保 4 months ago
parent c39e36eacd
commit fd0fd44520
  1. 73
      src/main/java/digital/laboratory/platform/entrustment/controller/EntrustAlterApplyController.java
  2. 31
      src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyApproveDTO.java
  3. 31
      src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyDTO.java
  4. 106
      src/main/java/digital/laboratory/platform/entrustment/entity/EntrustAlterApply.java
  5. 33
      src/main/java/digital/laboratory/platform/entrustment/enums/EntrustAlterApplyStatus.java
  6. 42
      src/main/java/digital/laboratory/platform/entrustment/mapper/EntrustAlterApplyMapper.java
  7. 49
      src/main/java/digital/laboratory/platform/entrustment/query/EntrustAlterApplyQuery.java
  8. 81
      src/main/java/digital/laboratory/platform/entrustment/service/CommonFeignService.java
  9. 54
      src/main/java/digital/laboratory/platform/entrustment/service/EntrustAlterApplyService.java
  10. 207
      src/main/java/digital/laboratory/platform/entrustment/service/impl/CommonFeignServiceImpl.java
  11. 146
      src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustAlterApplyServiceImpl.java
  12. 6
      src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustmentServiceImpl.java
  13. 145
      src/main/java/digital/laboratory/platform/entrustment/vo/EntrustAlterApplyVO.java
  14. 75
      src/main/resources/mapper/EntrustAlterApplyMapper.xml

@ -0,0 +1,73 @@
package digital.laboratory.platform.entrustment.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import digital.laboratory.platform.common.core.util.R;
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyApproveDTO;
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyDTO;
import digital.laboratory.platform.entrustment.query.EntrustAlterApplyQuery;
import digital.laboratory.platform.entrustment.service.EntrustAlterApplyService;
import digital.laboratory.platform.entrustment.vo.EntrustAlterApplyVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.List;
/**
* 申请修改委托消息相关接口
*
* @author chenjiangbao
* @describe 申请修改委托消息相关接口 前端控制器
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/papp/entrustAlterApply")
@Api(tags = "016-申请修改委托消息相关接口")
public class EntrustAlterApplyController {
private final EntrustAlterApplyService entrustAlterApplyService;
@ApiOperation(value = "查询所有申请修改委托消息分页接口", notes = "查询所有申请修改委托消息分页接口")
@PostMapping("/page")
@PreAuthorize("@pms.hasPermission('EntrustAlterApplyQuery')") // 委托申请修改消息查询权限
public R page(@RequestBody EntrustAlterApplyQuery query) {
IPage<EntrustAlterApplyVO> page = entrustAlterApplyService.voPage(query);
return R.ok(page);
}
@ApiOperation(value = "保存或提交委托申请修改消息", notes = "保存委托申请修改消息")
@PostMapping("/save")
@PreAuthorize("@pms.hasPermission('EntrustAlterApplySubmit')") // 委托申请修改消息保存提交权限
public R save(@RequestBody @Valid EntrustAlterApplyDTO dto) {
EntrustAlterApplyVO vo = entrustAlterApplyService.save(dto);
return R.ok(vo);
}
@ApiOperation(value = "修改委托申请修改消息", notes = "修改委托申请修改消息")
@PutMapping("/update")
@PreAuthorize("@pms.hasPermission('EntrustAlterApplyEdit')") // 委托申请修改消息修改权限
public R update(@RequestBody @Valid EntrustAlterApplyDTO dto) {
Boolean success = entrustAlterApplyService.update(dto);
return R.ok(success).setMsg(success ? "修改成功" : "修改失败");
}
@ApiOperation(value = "审核提交委托申请修改消息", notes = "审核提交委托申请修改消息")
@PutMapping("/approve")
@PreAuthorize("@pms.hasPermission('EntrustAlterApplyApprove')") // 委托申请修改消息审核权限
public R approve(@RequestBody @Valid EntrustAlterApplyApproveDTO approveDTO) {
Boolean success = entrustAlterApplyService.approve(approveDTO);
return R.ok(success).setMsg(success ? "审核成功" : "审核失败");
}
@ApiOperation(value = "删除委托申请修改消息", notes = "删除委托申请修改消息, 只能删除为提交状态的消息")
@PostMapping("/delete")
@PreAuthorize("@pms.hasPermission('EntrustAlterApplyDelete')") // 委托申请修改消息删除权限
public R delete(@RequestBody List<String> ids) {
Boolean success = entrustAlterApplyService.delete(ids);
return R.ok(success).setMsg(success ? "审核成功" : "审核失败");
}
}

@ -0,0 +1,31 @@
package digital.laboratory.platform.entrustment.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 申请修改委托消息表 审核 DTO类
* @TableName b_entrust_alter_apply
*/
@Data
@ApiModel(value = "EntrustAlterApplyApproveDTO", description = "申请修改委托消息表 审核 DTO类, 传递参数")
public class EntrustAlterApplyApproveDTO {
/**
* 主键标识
*/
@ApiModelProperty(value = "主键标识")
@NotBlank(message = "请选择审核的记录!")
private String id;
/**
* 原因
*/
@ApiModelProperty(value = "原因")
private String reason;
@ApiModelProperty(value = " 0 不通过 | 1 通过")
private Integer opCode;
}

@ -0,0 +1,31 @@
package digital.laboratory.platform.entrustment.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
/**
* 申请修改委托消息表 DTO类
* @TableName b_entrust_alter_apply
*/
@Data
@ApiModel(value = "EntrustAlterApplyDTO", description = "申请修改委托消息表 DTO类, 传递参数")
public class EntrustAlterApplyDTO {
/**
* 主键标识
*/
@ApiModelProperty(value = "主键标识")
private String id;
/**
* 关联的委托id
*/
@ApiModelProperty(value = "关联的委托id")
@NotBlank(message = "关联的委托id不能为空!")
private String entrustId;
@ApiModelProperty(value = " 0 保存 | 1 提交 (如果调用的是修改接口 1则是撤销操作)")
private Integer opCode;
}

@ -0,0 +1,106 @@
package digital.laboratory.platform.entrustment.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import digital.laboratory.platform.common.mybatis.base.BaseEntity;
import lombok.Data;
import java.time.LocalDate;
/**
* 申请修改委托消息表
* @TableName b_entrust_alter_apply
*/
@Data
@TableName(value ="b_entrust_alter_apply")
public class EntrustAlterApply extends BaseEntity {
/**
* 主键标识
*/
@TableId(value = "ID", type = IdType.ASSIGN_ID)
private String id;
/**
* 关联的委托id
*/
private String entrustId;
/**
* 申请人id
*/
private String applicant;
/**
* 申请日期
*/
private LocalDate applyDate;
/**
* 申请单位
*/
private String applyOrgId;
/**
* 审核人id
*/
private String reviewer;
/**
* 状态 === 0 待提交申请 1 提交申请待审核2申请通过-1 申请不通过
*/
private Integer status;
/**
* 原因
*/
private String reason;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
EntrustAlterApply other = (EntrustAlterApply) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getEntrustId() == null ? other.getEntrustId() == null : this.getEntrustId().equals(other.getEntrustId()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getEntrustId() == null) ? 0 : getEntrustId().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", entrustId=").append(entrustId);
sb.append(", applicant=").append(applicant);
sb.append(", applyDate=").append(applyDate);
sb.append(", applyOrgId=").append(applyOrgId);
sb.append(", reviewer=").append(reviewer);
sb.append(", status=").append(status);
sb.append(", reason=").append(reason);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,33 @@
package digital.laboratory.platform.entrustment.enums;
import lombok.Getter;
@Getter
public enum EntrustAlterApplyStatus {
WAIT_SUBMIT_APPLY(0, "待提交申请"),
SUBMITTED_WAIT_APPROVE(1,"提交申请待审核"),
APPLY_SUCCESS(2, "申请通过"),
APPLY_FAIL(-1, "申请不通过"),
;
private final Integer status;
private final String desc;
EntrustAlterApplyStatus(Integer status, String desc) {
this.status = status;
this.desc = desc;
}
// 根据名称获取指纹类型
public static EntrustAlterApplyStatus fromStatus(Integer status) {
for (EntrustAlterApplyStatus entrustAlterApplyStatus : values()) {
if (entrustAlterApplyStatus.getStatus().equals(status)) {
return entrustAlterApplyStatus;
}
}
throw new IllegalArgumentException("No enum constant with status: " + status);
}
}

@ -0,0 +1,42 @@
package digital.laboratory.platform.entrustment.mapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
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.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import digital.laboratory.platform.entrustment.entity.EntrustAlterApply;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import digital.laboratory.platform.entrustment.entity.Entrustment;
import digital.laboratory.platform.entrustment.query.EntrustAlterApplyQuery;
import digital.laboratory.platform.entrustment.vo.EntrustAlterApplyVO;
import digital.laboratory.platform.entrustment.vo.EntrustmentVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author ChenJiangBao
* @description 针对表b_entrust_alter_apply(申请修改委托消息表)的数据库操作Mapper
* @createDate 2024-10-31 17:35:01
* @Entity digital.laboratory.platform.entrustment.entity.EntrustAlterApply
*/
public interface EntrustAlterApplyMapper extends BaseMapper<EntrustAlterApply> {
/**
* 分页查询委托变更申请列表
* @param page
* @param query
* @return
*/
IPage<EntrustAlterApplyVO> getEntrustAlterApplyVOPage(IPage<EntrustAlterApplyVO> page, EntrustAlterApplyQuery query);
EntrustAlterApplyVO getEntrustAlterApplyVOOne(@Param(Constants.WRAPPER) Wrapper<EntrustAlterApply> qw);
List<EntrustAlterApplyVO> getEntrustAlterApplyVOList(@Param(Constants.WRAPPER) Wrapper<EntrustAlterApply> qw);
}

@ -0,0 +1,49 @@
package digital.laboratory.platform.entrustment.query;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDate;
/**
* 申请修改委托消息 查询对象分页查询列表查询
*
* @author Chen
* @since 1.0.0 2024-08-14
*/
@Data
@ApiModel(description = "申请修改委托消息 查询对象(分页查询、列表查询)")
public class EntrustAlterApplyQuery {
@ApiModelProperty(value = "分页参数,每页多少条, 默认10")
private Long size = 10L;
@ApiModelProperty(value = "分页参数, 当前页, 默认1")
private Long current = 1L;
@ApiModelProperty(value = "关键字,支持 案件名称查询")
private String keywords;
@ApiModelProperty(value = "申请人id查询")
private String applicant;
@ApiModelProperty(value = "开始日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate startDate;
@ApiModelProperty(value = "结束日期")
@JsonFormat(pattern = "yyyy-MM-dd")
private LocalDate endDate;
@ApiModelProperty(value = "状态")
private Integer status;
// 是否是员工
private Boolean isStaff;
// 非实验室人员的机构id
private String clientOrgId;
}

@ -0,0 +1,81 @@
package digital.laboratory.platform.entrustment.service;
import com.deepoove.poi.XWPFTemplate;
import digital.laboratory.platform.sys.entity.SysOrg;
import digital.laboratory.platform.sys.entity.SysUser;
import digital.laboratory.platform.sys.vo.UserVO;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.util.List;
import java.util.Map;
/**
* 通用的feign请求封装接口服务层接口
*/
public interface CommonFeignService {
/**
* 远程调用获取用户机构
* @param orgId
* @return
*/
SysOrg remoteGetSysOrg(String orgId);
/**
* 远程调用获取用户信息
* @param username
* @return
*/
SysUser remoteGetUserByUsername(String username);
/**
* 远程调用获取用户信息
* @param userId
* @return
*/
SysUser remoteGetUserById(String userId);
/**
* 远程调用生成word,并转成pdf
*
* @param template
* @param originalFilename 文件名
* @param savePath 保存到minio路径
* @return
* @throws Exception
*/
boolean remoteGenerateWord2PDF(XWPFTemplate template, String originalFilename, String savePath) throws Exception;
/**
* 远程调用根据文件路径获取文件
* @param filePath minio上的文件路径
* @return
* @throws Exception
*/
ByteArrayInputStream remoteGetFile(String filePath) throws Exception;
/**
* 远程调用根据文件路径获取文件
* @param filePath minio上的文件路径
* @param fileName 名称
* @param httpServletResponse
* @throws Exception
*/
void remoteGetFile(String filePath, String fileName, HttpServletResponse httpServletResponse) throws Exception;
/**
* 远程调用根据文件路径获取文件列表
* @param filePath minio上的文件路径
*/
List<String> remoteGetFileList(String filePath);
/**
* 远程调用-上传文件
* @param file 上传的文件对象
* @param path 上传到minio的位置
* @return
*/
Map<String, String> remoteUploadFile(MultipartFile file, String path);
}

@ -0,0 +1,54 @@
package digital.laboratory.platform.entrustment.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyApproveDTO;
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyDTO;
import digital.laboratory.platform.entrustment.entity.EntrustAlterApply;
import com.baomidou.mybatisplus.extension.service.IService;
import digital.laboratory.platform.entrustment.query.EntrustAlterApplyQuery;
import digital.laboratory.platform.entrustment.vo.EntrustAlterApplyVO;
import java.util.List;
/**
* @author ChenJiangBao
* @description 针对表b_entrust_alter_apply(申请修改委托消息表)的数据库操作Service
* @createDate 2024-10-31 17:35:01
*/
public interface EntrustAlterApplyService extends IService<EntrustAlterApply> {
/**
* 分页查询委托申请修改VO
* @param query
* @return
*/
IPage<EntrustAlterApplyVO> voPage(EntrustAlterApplyQuery query);
/**
* 保存委托申请修改
* @param dto
* @return
*/
EntrustAlterApplyVO save(EntrustAlterApplyDTO dto);
/**
* 审批委托申请修改
* @param approveDTO
* @return
*/
Boolean approve(EntrustAlterApplyApproveDTO approveDTO);
/**
* 修改委托申请修改消息
* @param dto
* @return
*/
Boolean update(EntrustAlterApplyDTO dto);
/**
* 删除委托申请修改消息
* @param ids
* @return
*/
Boolean delete(List<String> ids);
}

@ -0,0 +1,207 @@
package digital.laboratory.platform.entrustment.service.impl;
import cn.hutool.core.io.IoUtil;
import cn.hutool.core.io.file.FileNameUtil;
import cn.hutool.core.util.StrUtil;
import com.deepoove.poi.XWPFTemplate;
import digital.laboratory.platform.common.core.constant.CommonConstants;
import digital.laboratory.platform.common.core.util.R;
import digital.laboratory.platform.common.feign.RemoteWord2PDFService;
import digital.laboratory.platform.common.oss.service.OssFile;
import digital.laboratory.platform.entrustment.service.CommonFeignService;
import digital.laboratory.platform.sys.dto.UserInfo;
import digital.laboratory.platform.sys.entity.SysOrg;
import digital.laboratory.platform.sys.entity.SysUser;
import digital.laboratory.platform.sys.feign.RemoteOrgService;
import digital.laboratory.platform.sys.feign.RemoteUserService;
import digital.laboratory.platform.sys.vo.UserVO;
import feign.Response;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.output.ByteArrayOutputStream;
import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.util.Base64;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 通用的feign请求封装接口服务层接口 实现类
*/
@Slf4j
@Service
public class CommonFeignServiceImpl implements CommonFeignService {
@Resource
private RemoteOrgService remoteOrgService;
@Resource
private RemoteUserService remoteUserService;
@Resource
private RemoteWord2PDFService remoteWord2PDFService;
@Resource
private OssFile ossFile;
/**
* 根据用户获取远程系统机构信息
*
* @param orgId 用户信息
* @return 对应的远程系统机构信息
* @throws RuntimeException 如果未找到对应的机构信息则抛出运行时异常
*/
@Override
public SysOrg remoteGetSysOrg(String orgId) {
SysOrg sysOrg = null;
R<SysOrg> r = remoteOrgService.getById(orgId);
if (r != null && r.getCode() == CommonConstants.SUCCESS) {
sysOrg = r.getData();
} else {
throw new RuntimeException(String.format("没有找到 orgId 为 %s 的机构, 请确认用户所属机构的正确性!", orgId));
}
return sysOrg;
}
/**
* 远程调用或者用户信息
* @param username
* @return
*/
@Override
public SysUser remoteGetUserByUsername(String username){
R<UserInfo> info = remoteUserService.innerGetUserInfoByUsername(username);
if (info != null && info.getCode() == CommonConstants.FAIL) {
throw new RuntimeException(String.format("获取用户名为 %s 的用户信息失败!", username));
}
return info.getData().getSysUser();
}
/**
* 远程调用获取用户信息
* @param userId
* @return
*/
@Override
public SysUser remoteGetUserById(String userId){
R<SysUser> info = remoteUserService.innerGetById(userId);
if (info != null && info.getCode() == CommonConstants.FAIL) {
throw new RuntimeException(String.format("获取用户名id为 %s 的用户信息失败!", userId));
}
return info.getData();
}
@Override
public boolean remoteGenerateWord2PDF(XWPFTemplate template, String originalFilename, String savePath) throws Exception{
ByteArrayOutputStream fosWord = new ByteArrayOutputStream();
template.write(fosWord);
template.close();
//------------
ByteArrayInputStream fisWord = new ByteArrayInputStream(fosWord.toByteArray());
fosWord.close();
MockMultipartFile mockMultipartFile = new MockMultipartFile("file", originalFilename + ".docx", "image/jpg", fisWord);
Response response = remoteWord2PDFService.word2pdf(mockMultipartFile);
fisWord.close();
ByteArrayOutputStream outPDF = new ByteArrayOutputStream();
IoUtil.copy(response.body().asInputStream(), outPDF, IoUtil.DEFAULT_MIDDLE_BUFFER_SIZE);
ByteArrayInputStream isPDF = new ByteArrayInputStream(outPDF.toByteArray());
outPDF.close();
boolean b = ossFile.fileSave(savePath, isPDF);
isPDF.close();
log.info("转换为 PDF 结束");
return b;
}
/**
* 远程调用根据文件路径获取文件
* @param filePath minio上的文件路径
* @return
* @throws Exception
*/
@Override
public ByteArrayInputStream remoteGetFile(String filePath) throws Exception {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ossFile.fileGet(filePath, bos);
byte[] templateArray = bos.toByteArray();
ByteArrayInputStream bis = new ByteArrayInputStream(templateArray);
bos.close();
return bis;
}
/**
* 远程调用根据文件路径获取文件
* @param filePath minio上的文件路径
* @param fileName 名称
* @param httpServletResponse
* @throws Exception
*/
@Override
public void remoteGetFile(String filePath, String fileName, HttpServletResponse httpServletResponse) throws Exception {
ossFile.fileGet(filePath, httpServletResponse.getOutputStream());
if (StrUtil.isNotBlank(fileName)) {
httpServletResponse.setContentType(fileName);
}
}
/**
* 远程调用根据文件路径获取文件列表
* @param filePath minio上的文件路径
*/
@Override
public List<String> remoteGetFileList(String filePath) {
if (StrUtil.isNotBlank(filePath)) {
List<String> fileNameList = ossFile.fileList(filePath);
List<String> fileList = fileNameList.stream().map(fileName -> {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try {
ossFile.fileGet(filePath + "/" + fileName, byteArrayOutputStream);
return Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray());
} catch (Exception e) {
e.printStackTrace();
log.error("文件获取失败, 文件路径为: {}", filePath + "/" + fileName);
}
return null;
}).collect(Collectors.toList());
return fileList;
} else {
throw new RuntimeException("文件路径不能为空!");
}
}
/**
* 远程调用-上传文件
* @param file 上传的文件对象
* @param path 上传到minio的位置
* @return
*/
@Override
public Map<String, String> remoteUploadFile(MultipartFile file, String path) {
boolean r = ossFile.fileUpload(file, path);
if (r) {
HashMap<String, String> resultData = new HashMap<>();
resultData.put("fileName", FileNameUtil.getName(file.getOriginalFilename()));
resultData.put("path", path);
log.info("文件上传成功!");
return resultData;
} else {
String failMsg = String.format("文件名为 %s 的文件上传失败!", file.getOriginalFilename());
log.error(failMsg);
throw new RuntimeException(failMsg);
}
}
}

@ -0,0 +1,146 @@
package digital.laboratory.platform.entrustment.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import digital.laboratory.platform.common.mybatis.security.service.DLPUser;
import digital.laboratory.platform.common.security.util.SecurityUtils;
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyApproveDTO;
import digital.laboratory.platform.entrustment.dto.EntrustAlterApplyDTO;
import digital.laboratory.platform.entrustment.entity.EntrustAlterApply;
import digital.laboratory.platform.entrustment.enums.EntrustAlterApplyStatus;
import digital.laboratory.platform.entrustment.query.EntrustAlterApplyQuery;
import digital.laboratory.platform.entrustment.service.CommonFeignService;
import digital.laboratory.platform.entrustment.service.EntrustAlterApplyService;
import digital.laboratory.platform.entrustment.mapper.EntrustAlterApplyMapper;
import digital.laboratory.platform.entrustment.vo.EntrustAlterApplyVO;
import digital.laboratory.platform.sys.feign.RemoteUserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;
/**
* @author ChenJiangBao
* @description 针对表b_entrust_alter_apply(申请修改委托消息表)的数据库操作Service实现
* @createDate 2024-10-31 17:35:01
*/
@Service
public class EntrustAlterApplyServiceImpl extends ServiceImpl<EntrustAlterApplyMapper, EntrustAlterApply>
implements EntrustAlterApplyService{
@Resource
private CommonFeignService commonFeignService;
@Override
public IPage<EntrustAlterApplyVO> voPage(EntrustAlterApplyQuery query) {
IPage<EntrustAlterApplyVO> entrustAlterApplyVOPage = baseMapper.getEntrustAlterApplyVOPage(new Page<>(query.getCurrent(), query.getSize()), query);
entrustAlterApplyVOPage.getRecords().forEach(e -> {
fillVOInfo(e);
});
return entrustAlterApplyVOPage;
}
/**
* 保存消息
* @param dto
* @return
*/
@Override
public EntrustAlterApplyVO save(EntrustAlterApplyDTO dto) {
EntrustAlterApply entrustAlterApply = new EntrustAlterApply();
if (StrUtil.isBlank(dto.getId())) {
entrustAlterApply.setEntrustId(dto.getEntrustId());
DLPUser user = SecurityUtils.getUser();
entrustAlterApply.setApplicant(user.getId());
entrustAlterApply.setApplyOrgId(user.getOrgId());
if (dto.getOpCode() == 0) {
entrustAlterApply.setStatus(EntrustAlterApplyStatus.WAIT_SUBMIT_APPLY.getStatus());
} else if (dto.getOpCode() == 1) {
entrustAlterApply.setApplyDate(LocalDate.now());
entrustAlterApply.setStatus(EntrustAlterApplyStatus.SUBMITTED_WAIT_APPROVE.getStatus());
}
super.save(entrustAlterApply);
} else {
entrustAlterApply.setId(dto.getId());
super.update(Wrappers.<EntrustAlterApply>lambdaUpdate()
.eq(EntrustAlterApply::getId, dto.getId())
.set(EntrustAlterApply::getStatus, EntrustAlterApplyStatus.SUBMITTED_WAIT_APPROVE.getStatus())
.set(EntrustAlterApply::getApplyDate, LocalDate.now()));
}
EntrustAlterApplyVO entrustAlterApplyVOOne = baseMapper.getEntrustAlterApplyVOOne(Wrappers.<EntrustAlterApply>lambdaQuery().eq(EntrustAlterApply::getId, entrustAlterApply.getId()));
fillVOInfo(entrustAlterApplyVOOne);
return entrustAlterApplyVOOne;
}
@Override
public Boolean approve(EntrustAlterApplyApproveDTO approveDTO) {
if (approveDTO.getOpCode() == 0) {
// 拒绝
return super.update(Wrappers.<EntrustAlterApply>lambdaUpdate().eq(EntrustAlterApply::getId, approveDTO.getId())
.set(EntrustAlterApply::getStatus, EntrustAlterApplyStatus.APPLY_FAIL.getStatus())
.set(EntrustAlterApply::getReason,approveDTO.getReason()));
} else {
// 同意
return super.update(Wrappers.<EntrustAlterApply>lambdaUpdate().eq(EntrustAlterApply::getId, approveDTO.getId())
.set(EntrustAlterApply::getStatus, EntrustAlterApplyStatus.APPLY_SUCCESS.getStatus())
.set(EntrustAlterApply::getReason,approveDTO.getReason()));
}
}
/**
* 修改消息
* @param dto
* @return
*/
@Override
public Boolean update(EntrustAlterApplyDTO dto) {
if(StrUtil.isBlank(dto.getId())){
throw new RuntimeException("修改的记录id不能为空");
}
EntrustAlterApply oldInfo = super.getById(dto.getId());
if (dto.getOpCode() == 1 && oldInfo.getStatus().equals(EntrustAlterApplyStatus.SUBMITTED_WAIT_APPROVE.getStatus())) {
throw new RuntimeException("该条记录不在可撤销的状态范围内!");
}
return super.update(Wrappers.<EntrustAlterApply>lambdaUpdate().eq(EntrustAlterApply::getId, dto.getId())
.set(EntrustAlterApply::getEntrustId, dto.getEntrustId())
.set(dto.getOpCode() == 1,
EntrustAlterApply::getStatus, EntrustAlterApplyStatus.WAIT_SUBMIT_APPLY.getStatus()));
}
/**
* 删除委托申请修改消息
* @param ids
* @return
*/
@Override
public Boolean delete(List<String> ids) {
List<EntrustAlterApplyVO> entrustAlterAppliesVOS = baseMapper.getEntrustAlterApplyVOList(Wrappers.<EntrustAlterApply>lambdaQuery().in(EntrustAlterApply::getId,ids));
entrustAlterAppliesVOS.forEach(e -> {
if (e.getStatus().equals(EntrustAlterApplyStatus.WAIT_SUBMIT_APPLY.getStatus())) {
throw new RuntimeException(String.format("案件名称为 %s 的记录不在可删除的状态,无法删除!", e.getCaseName()));
}
});
return super.remove(Wrappers.<EntrustAlterApply>lambdaUpdate().in(EntrustAlterApply::getId,ids));
}
/**
* 填充VO信息
* @param e
*/
private void fillVOInfo(EntrustAlterApplyVO e) {
e.setStatusName(EntrustAlterApplyStatus.fromStatus(e.getStatus()).getDesc());
e.setApplicantName(commonFeignService.remoteGetUserById(e.getApplicant()).getName());
e.setReviewerName(commonFeignService.remoteGetUserById(e.getReviewer()).getName());
e.setApplyOrgName(commonFeignService.remoteGetSysOrg(e.getApplyOrgId()).getName());
}
}

@ -20,7 +20,6 @@ import com.deepoove.poi.config.Configure;
import com.deepoove.poi.config.ConfigureBuilder;
import com.deepoove.poi.data.PictureType;
import com.deepoove.poi.data.Pictures;
import com.deepoove.poi.plugin.table.LoopRowTableRenderPolicy;
import com.deepoove.poi.plugin.table.MultipleRowTableRenderPolicy;
import digital.laboratory.platform.common.core.constant.CommonConstants;
import digital.laboratory.platform.common.core.constant.OSSDirectoryConstants;
@ -46,14 +45,14 @@ import digital.laboratory.platform.entrustment.vo.MaterialListForBookVo;
import digital.laboratory.platform.sewage.dto.StatisticsDiffStatusJobDTO;
import digital.laboratory.platform.sewage.entity.UpdateInfo;
import digital.laboratory.platform.sewage.feign.RemoteSewageJobService;
import digital.laboratory.platform.sewage.utils.QRCodeUtils;
import digital.laboratory.platform.sys.entity.Deliverer;
import digital.laboratory.platform.sys.entity.DrugLite;
import digital.laboratory.platform.sys.entity.SysOrg;
import digital.laboratory.platform.sys.entity.SysUser;
import digital.laboratory.platform.sewage.utils.QRCodeUtils;
import digital.laboratory.platform.sys.entity.entrustment.Sample;
import digital.laboratory.platform.sys.feign.*;
import digital.laboratory.platform.sys.vo.entrustment.MarkersVO;
import digital.laboratory.platform.sys.entity.entrustment.Sample;
import feign.Response;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
@ -75,7 +74,6 @@ import java.math.RoundingMode;
import java.security.Principal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;

@ -0,0 +1,145 @@
package digital.laboratory.platform.entrustment.vo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import digital.laboratory.platform.common.mybatis.base.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.time.LocalDate;
/**
* 申请修改委托消息表 vo类
* @TableName b_entrust_alter_apply
*/
@Data
@ApiModel(value = "EntrustAlterApplyVO", description = "申请修改委托消息表 vo类, 返回到前台显示")
public class EntrustAlterApplyVO {
/**
* 主键标识
*/
@ApiModelProperty(value = "主键标识")
private String id;
/**
* 关联的委托id
*/
@ApiModelProperty(value = "关联的委托id")
private String entrustId;
/**
* 关联的委托案件名称
*/
@ApiModelProperty(value = "关联的委托案件名称")
private String caseName;
/**
* 申请人id
*/
@ApiModelProperty(value = "申请人id")
private String applicant;
/**
* 申请人名称
*/
@ApiModelProperty(value = "申请人名称")
private String applicantName;
/**
* 申请日期
*/
@ApiModelProperty(value = "申请日期")
private LocalDate applyDate;
/**
* 申请单位
*/
@ApiModelProperty(value = "申请单位")
private String applyOrgId;
/**
* 申请单位名称
*/
@ApiModelProperty(value = "申请单位名称")
private String applyOrgName;
/**
* 审核人id
*/
@ApiModelProperty(value = "审核人id ")
private String reviewer;
/**
* 审核人名字
*/
@ApiModelProperty(value = "审核人名字 ")
private String reviewerName;
/**
* 状态 === 0 待提交申请 1 提交申请待审核2申请通过-1 申请不通过
*/
@ApiModelProperty(value = "状态 === 0 待提交申请, 1 提交申请待审核,2申请通过,-1 申请不通过")
private Integer status;
/**
* 状态名称 === 0 待提交申请 1 提交申请待审核2申请通过-1 申请不通过
*/
@ApiModelProperty(value = "状态名称 === 0 待提交申请, 1 提交申请待审核,2申请通过,-1 申请不通过")
private String statusName;
/**
* 原因
*/
@ApiModelProperty(value = "原因")
private String reason;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
@Override
public boolean equals(Object that) {
if (this == that) {
return true;
}
if (that == null) {
return false;
}
if (getClass() != that.getClass()) {
return false;
}
EntrustAlterApplyVO other = (EntrustAlterApplyVO) that;
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getEntrustId() == null ? other.getEntrustId() == null : this.getEntrustId().equals(other.getEntrustId()));
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getEntrustId() == null) ? 0 : getEntrustId().hashCode());
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getSimpleName());
sb.append(" [");
sb.append("Hash = ").append(hashCode());
sb.append(", id=").append(id);
sb.append(", entrustId=").append(entrustId);
sb.append(", applicant=").append(applicant);
sb.append(", applyDate=").append(applyDate);
sb.append(", applyOrgId=").append(applyOrgId);
sb.append(", reviewer=").append(reviewer);
sb.append(", status=").append(status);
sb.append(", reason=").append(reason);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
return sb.toString();
}
}

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="digital.laboratory.platform.entrustment.mapper.EntrustAlterApplyMapper">
<resultMap id="BaseResultMap" type="digital.laboratory.platform.entrustment.entity.EntrustAlterApply">
<id property="id" column="id" jdbcType="VARCHAR"/>
<result property="entrustId" column="entrust_id" jdbcType="VARCHAR"/>
<result property="applicant" column="applicant" jdbcType="VARCHAR"/>
<result property="applyDate" column="apply_date" jdbcType="TIMESTAMP"/>
<result property="applyOrgId" column="apply_org_id" jdbcType="VARCHAR"/>
<result property="reviewer" column="reviewer" jdbcType="VARCHAR"/>
<result property="status" column="status" jdbcType="TINYINT"/>
<result property="reason" column="reason" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
id,entrust_id,applicant,
apply_date,apply_org_id,reviewer,
status,reason,create_time,
create_by,update_time,update_by
</sql>
<!-- 连接委托表查询委托案件名称-->
<sql id="getVOSQL">
SELECT eaa.*, ce.case_name FROM
b_entrust_alter_apply eaa
LEFT JOIN b_entrustment e ON eaa.entrust_id = e.id
LEFT JOIN b_case_event ce ON ce.id = e.case_id
</sql>
<select id="getEntrustAlterApplyVOPage"
parameterType="digital.laboratory.platform.entrustment.query.EntrustAlterApplyQuery"
resultType="digital.laboratory.platform.entrustment.vo.EntrustAlterApplyVO">
<include refid="getVOSQL"/>
<where>
<if test="query.keywords != null and query.keywords != ''">
AND case_name LIKE CONCAT('%', #{keywords}, '%')
</if>
<if test="query.applicant != null and query.applicant != ''">
AND applicant_id = #{applicant}
</if>
<if test="query.startDate != null">
AND apply_date &gt;= #{startDate}
</if>
<if test="query.endDate != null">
AND apply_date &lt;= #{endDate}
</if>
<if test="query.status != null">
AND status &lt;= #{status}
</if>
<if test="query.isStaff != null and !query.isStaff and query.clientOrgId != null and query.clientOrgId != ''">
AND apply_org_id = #{query.clientOrgId}
</if>
</where>
ORDER BY apply_date DESC
</select>
<select id="getEntrustAlterApplyVOOne"
resultType="digital.laboratory.platform.entrustment.vo.EntrustAlterApplyVO">
<include refid="getVOSQL"/>
${ew.customSqlSegment}
</select>
<select id="getEntrustAlterApplyVOList"
resultType="digital.laboratory.platform.entrustment.vo.EntrustAlterApplyVO">
<include refid="getVOSQL"/>
${ew.customSqlSegment}
</select>
</mapper>
Loading…
Cancel
Save