From fd0fd44520d32e9e17eb38b8bd6ef5e2c0bcce4f Mon Sep 17 00:00:00 2001 From: chen <2710907404@qq.com> Date: Fri, 1 Nov 2024 11:26:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=201.=E7=94=B3=E8=AF=B7?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=A7=94=E6=89=98=E4=BF=A1=E6=81=AF=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EntrustAlterApplyController.java | 73 ++++++ .../dto/EntrustAlterApplyApproveDTO.java | 31 +++ .../entrustment/dto/EntrustAlterApplyDTO.java | 31 +++ .../entrustment/entity/EntrustAlterApply.java | 106 +++++++++ .../enums/EntrustAlterApplyStatus.java | 33 +++ .../mapper/EntrustAlterApplyMapper.java | 42 ++++ .../query/EntrustAlterApplyQuery.java | 49 +++++ .../service/CommonFeignService.java | 81 +++++++ .../service/EntrustAlterApplyService.java | 54 +++++ .../service/impl/CommonFeignServiceImpl.java | 207 ++++++++++++++++++ .../impl/EntrustAlterApplyServiceImpl.java | 146 ++++++++++++ .../service/impl/EntrustmentServiceImpl.java | 6 +- .../entrustment/vo/EntrustAlterApplyVO.java | 145 ++++++++++++ .../mapper/EntrustAlterApplyMapper.xml | 75 +++++++ 14 files changed, 1075 insertions(+), 4 deletions(-) create mode 100644 src/main/java/digital/laboratory/platform/entrustment/controller/EntrustAlterApplyController.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyApproveDTO.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyDTO.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/entity/EntrustAlterApply.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/enums/EntrustAlterApplyStatus.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/mapper/EntrustAlterApplyMapper.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/query/EntrustAlterApplyQuery.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/service/CommonFeignService.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/service/EntrustAlterApplyService.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/service/impl/CommonFeignServiceImpl.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustAlterApplyServiceImpl.java create mode 100644 src/main/java/digital/laboratory/platform/entrustment/vo/EntrustAlterApplyVO.java create mode 100644 src/main/resources/mapper/EntrustAlterApplyMapper.xml diff --git a/src/main/java/digital/laboratory/platform/entrustment/controller/EntrustAlterApplyController.java b/src/main/java/digital/laboratory/platform/entrustment/controller/EntrustAlterApplyController.java new file mode 100644 index 0000000..47360a8 --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/controller/EntrustAlterApplyController.java @@ -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 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 ids) { + Boolean success = entrustAlterApplyService.delete(ids); + return R.ok(success).setMsg(success ? "审核成功" : "审核失败"); + } +} diff --git a/src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyApproveDTO.java b/src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyApproveDTO.java new file mode 100644 index 0000000..373d9e6 --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyApproveDTO.java @@ -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; +} \ No newline at end of file diff --git a/src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyDTO.java b/src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyDTO.java new file mode 100644 index 0000000..e8f5012 --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/dto/EntrustAlterApplyDTO.java @@ -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; +} \ No newline at end of file diff --git a/src/main/java/digital/laboratory/platform/entrustment/entity/EntrustAlterApply.java b/src/main/java/digital/laboratory/platform/entrustment/entity/EntrustAlterApply.java new file mode 100644 index 0000000..ca799da --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/entity/EntrustAlterApply.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/java/digital/laboratory/platform/entrustment/enums/EntrustAlterApplyStatus.java b/src/main/java/digital/laboratory/platform/entrustment/enums/EntrustAlterApplyStatus.java new file mode 100644 index 0000000..d606b20 --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/enums/EntrustAlterApplyStatus.java @@ -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); + } +} diff --git a/src/main/java/digital/laboratory/platform/entrustment/mapper/EntrustAlterApplyMapper.java b/src/main/java/digital/laboratory/platform/entrustment/mapper/EntrustAlterApplyMapper.java new file mode 100644 index 0000000..edea73e --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/mapper/EntrustAlterApplyMapper.java @@ -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 { + + /** + * 分页查询委托变更申请列表 + * @param page + * @param query + * @return + */ + IPage getEntrustAlterApplyVOPage(IPage page, EntrustAlterApplyQuery query); + + EntrustAlterApplyVO getEntrustAlterApplyVOOne(@Param(Constants.WRAPPER) Wrapper qw); + + List getEntrustAlterApplyVOList(@Param(Constants.WRAPPER) Wrapper qw); +} + + + + diff --git a/src/main/java/digital/laboratory/platform/entrustment/query/EntrustAlterApplyQuery.java b/src/main/java/digital/laboratory/platform/entrustment/query/EntrustAlterApplyQuery.java new file mode 100644 index 0000000..b65f6fa --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/query/EntrustAlterApplyQuery.java @@ -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; +} diff --git a/src/main/java/digital/laboratory/platform/entrustment/service/CommonFeignService.java b/src/main/java/digital/laboratory/platform/entrustment/service/CommonFeignService.java new file mode 100644 index 0000000..58219e5 --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/service/CommonFeignService.java @@ -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 remoteGetFileList(String filePath); + + /** + * 远程调用-上传文件 + * @param file 上传的文件对象 + * @param path 上传到minio的位置 + * @return + */ + Map remoteUploadFile(MultipartFile file, String path); +} diff --git a/src/main/java/digital/laboratory/platform/entrustment/service/EntrustAlterApplyService.java b/src/main/java/digital/laboratory/platform/entrustment/service/EntrustAlterApplyService.java new file mode 100644 index 0000000..3d94fcb --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/service/EntrustAlterApplyService.java @@ -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 { + + /** + * 分页查询委托申请修改VO + * @param query + * @return + */ + IPage 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 ids); +} diff --git a/src/main/java/digital/laboratory/platform/entrustment/service/impl/CommonFeignServiceImpl.java b/src/main/java/digital/laboratory/platform/entrustment/service/impl/CommonFeignServiceImpl.java new file mode 100644 index 0000000..4c1d209 --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/service/impl/CommonFeignServiceImpl.java @@ -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 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 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 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 remoteGetFileList(String filePath) { + if (StrUtil.isNotBlank(filePath)) { + List fileNameList = ossFile.fileList(filePath); + List 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 remoteUploadFile(MultipartFile file, String path) { + boolean r = ossFile.fileUpload(file, path); + if (r) { + HashMap 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); + } + } +} diff --git a/src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustAlterApplyServiceImpl.java b/src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustAlterApplyServiceImpl.java new file mode 100644 index 0000000..5d4110b --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustAlterApplyServiceImpl.java @@ -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 + implements EntrustAlterApplyService{ + + @Resource + private CommonFeignService commonFeignService; + + + @Override + public IPage voPage(EntrustAlterApplyQuery query) { + IPage 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.lambdaUpdate() + .eq(EntrustAlterApply::getId, dto.getId()) + .set(EntrustAlterApply::getStatus, EntrustAlterApplyStatus.SUBMITTED_WAIT_APPROVE.getStatus()) + .set(EntrustAlterApply::getApplyDate, LocalDate.now())); + + } + EntrustAlterApplyVO entrustAlterApplyVOOne = baseMapper.getEntrustAlterApplyVOOne(Wrappers.lambdaQuery().eq(EntrustAlterApply::getId, entrustAlterApply.getId())); + fillVOInfo(entrustAlterApplyVOOne); + return entrustAlterApplyVOOne; + } + + @Override + public Boolean approve(EntrustAlterApplyApproveDTO approveDTO) { + if (approveDTO.getOpCode() == 0) { + // 拒绝 + return super.update(Wrappers.lambdaUpdate().eq(EntrustAlterApply::getId, approveDTO.getId()) + .set(EntrustAlterApply::getStatus, EntrustAlterApplyStatus.APPLY_FAIL.getStatus()) + .set(EntrustAlterApply::getReason,approveDTO.getReason())); + } else { + // 同意 + return super.update(Wrappers.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.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 ids) { + List entrustAlterAppliesVOS = baseMapper.getEntrustAlterApplyVOList(Wrappers.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.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()); + } +} + + + + diff --git a/src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustmentServiceImpl.java b/src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustmentServiceImpl.java index a031884..d6f0445 100644 --- a/src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustmentServiceImpl.java +++ b/src/main/java/digital/laboratory/platform/entrustment/service/impl/EntrustmentServiceImpl.java @@ -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; diff --git a/src/main/java/digital/laboratory/platform/entrustment/vo/EntrustAlterApplyVO.java b/src/main/java/digital/laboratory/platform/entrustment/vo/EntrustAlterApplyVO.java new file mode 100644 index 0000000..441af49 --- /dev/null +++ b/src/main/java/digital/laboratory/platform/entrustment/vo/EntrustAlterApplyVO.java @@ -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(); + } +} \ No newline at end of file diff --git a/src/main/resources/mapper/EntrustAlterApplyMapper.xml b/src/main/resources/mapper/EntrustAlterApplyMapper.xml new file mode 100644 index 0000000..fbb6e6a --- /dev/null +++ b/src/main/resources/mapper/EntrustAlterApplyMapper.xml @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + id,entrust_id,applicant, + apply_date,apply_org_id,reviewer, + status,reason,create_time, + create_by,update_time,update_by + + + + + 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 + + + + + + + +