Browse Source

前端对接调整

陈长荣 5 months ago
parent
commit
7cf6dfc4cd
16 changed files with 178 additions and 55 deletions
  1. 3 1
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/GeneApplication.java
  2. 4 0
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/file/vo/FileVo.java
  3. 29 2
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/controller/FlowController.java
  4. 45 0
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/dto/FlowAuditDto.java
  5. 3 0
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/dto/FlowDetailDto.java
  6. 3 0
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/dto/FlowPageDto.java
  7. 8 0
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/entity/FlowAudit.java
  8. 2 1
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/service/FlowFileVersionService.java
  9. 7 0
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/service/FlowInfoService.java
  10. 10 4
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/service/impl/FlowFileVersionServiceImpl.java
  11. 45 33
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/service/impl/FlowInfoServiceImpl.java
  12. 4 1
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/vo/FlowAuditVo.java
  13. 1 2
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/form/service/StrainCustomInfoService.java
  14. 1 2
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/form/service/StrainPurificationInfoService.java
  15. 5 3
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/form/service/impl/StrainCustomInfoServiceImpl.java
  16. 8 6
      jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/form/service/impl/StrainPurificationInfoServiceImpl.java

+ 3 - 1
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/GeneApplication.java

@@ -19,7 +19,9 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
 @EnableTransactionManagement
 @MapperScan({"com.github.jfcloud.gene.*.mapper"})
 @ComponentScans(value = {
-        @ComponentScan(value = "com.github.jfcloud.common.aspect")})
+        @ComponentScan(value = "com.github.jfcloud.common.aspect"),
+        @ComponentScan(value = "com.github.jfcloud.common.exception")
+})
 public class GeneApplication {
 
     public static void main(String[] args) {

+ 4 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/file/vo/FileVo.java

@@ -1,10 +1,14 @@
 package com.github.jfcloud.gene.file.vo;
 
 import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 @Data
 @Schema(description = "附件")
+@NoArgsConstructor
+@AllArgsConstructor
 public class FileVo {
 
     @Schema(description = "附件名称")

+ 29 - 2
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/controller/FlowController.java

@@ -1,11 +1,14 @@
 package com.github.jfcloud.gene.flow.controller;
 
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.jfcloud.common.annotation.WebApiLog;
 import com.github.jfcloud.common.core.util.R;
 import com.github.jfcloud.gene.common.constant.WhetherEnum;
 import com.github.jfcloud.gene.constants.GeneStatusEnum;
+import com.github.jfcloud.gene.flow.dto.FlowAuditDto;
 import com.github.jfcloud.gene.flow.dto.FlowDetailDto;
 import com.github.jfcloud.gene.flow.dto.FlowPageDto;
 import com.github.jfcloud.gene.flow.entity.FlowAudit;
@@ -21,7 +24,10 @@ import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.*;
 
 import javax.validation.Valid;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
+import java.util.Objects;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -86,6 +92,13 @@ public class FlowController {
         return R.ok();
     }
 
+    @Operation(summary = "复制")
+    @PostMapping("/copy/{id}")
+    public R copy(@PathVariable Long id) {
+        flowInfoService.copyFlow(id);
+        return R.ok();
+    }
+
     @WebApiLog
     @Operation(summary = "审核")
     @PostMapping("/audit/{id}")
@@ -96,12 +109,26 @@ public class FlowController {
 
     @Operation(summary = "审核记录")
     @GetMapping("/audit/{id}")
-    public R<List<FlowAudit>> auditRecord(@PathVariable Long id) {
+    public R<List<FlowAuditDto>> auditRecord(@PathVariable Long id) {
         List<FlowAudit> auditList = flowAuditService.list(new LambdaQueryWrapper<>(FlowAudit.class)
                 .eq(FlowAudit::getFlowId, id)
                 .eq(FlowAudit::getDeleted, WhetherEnum.NO.getCode())
                 .orderByAsc(FlowAudit::getCreateTime));
-        return R.ok(auditList);
+        if (auditList.isEmpty()) {
+            return R.ok(Collections.emptyList());
+        }
+
+        List<FlowAuditDto> auditDtos = new ArrayList<>();
+        for (FlowAudit audit : auditList) {
+            FlowAuditDto auditDto = new FlowAuditDto();
+            if (StrUtil.isNotBlank(audit.getAdditionalData())) {
+                auditDto = BeanUtil.toBean(audit.getAdditionalData(), FlowAuditDto.class);
+            }
+            BeanUtil.copyProperties(audit, auditDto);
+            auditDto.setFlowStatusLabel(Objects.requireNonNull(GeneStatusEnum.getByStatus(audit.getFlowStatus())).getDescription());
+            auditDtos.add(auditDto);
+        }
+        return R.ok(auditDtos);
     }
 
     @Operation(summary = "执行")

+ 45 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/dto/FlowAuditDto.java

@@ -0,0 +1,45 @@
+package com.github.jfcloud.gene.flow.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class FlowAuditDto {
+
+    /**
+     * 流程状态
+     */
+    @Schema(description = "流程状态")
+    private String flowStatus;
+
+    @Schema(description = "流程状态文本")
+    private String flowStatusLabel;
+    /**
+     * 审核状态
+     */
+    @Schema(description = "审核意见,是否同意", example = "yes/no")
+    private String auditResult;
+
+    @Schema(description = "分管领导是否同意", example = "yes/no")
+    private String leaderResult;
+
+    /**
+     * 备注
+     */
+    @Schema(description = "备注")
+    private String remarks;
+
+    /**
+     * 创建人签名
+     */
+    @Schema(description = "创建人签名")
+    private String createSign;
+
+    private String createBy;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+}

+ 3 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/dto/FlowDetailDto.java

@@ -68,6 +68,9 @@ public class FlowDetailDto {
     @Schema(description = "文件下载链接")
     private String fileUrl;
 
+    @Schema(description = "文件名称")
+    private String filename;
+
     @Schema(description = "基因编辑部门负责人id")
     private Long geneEditPlId;
 

+ 3 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/dto/FlowPageDto.java

@@ -63,4 +63,7 @@ public class FlowPageDto {
 
     @Schema(description = "文件下载链接")
     private String fileUrl;
+
+    @Schema(description = "文件名称")
+    private String filename;
 }

+ 8 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/entity/FlowAudit.java

@@ -2,6 +2,7 @@ package com.github.jfcloud.gene.flow.entity;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.github.jfcloud.gene.common.entity.BaseEntity;
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
@@ -29,18 +30,25 @@ public class FlowAudit extends BaseEntity implements Serializable {
     /**
      * 流程状态
      */
+    @Schema(description = "流程状态")
     private String flowStatus;
     /**
      * 审核状态
      */
+    @Schema(description = "审核状态")
     private String auditResult;
     /**
      * 备注
      */
+    @Schema(description = "备注")
     private String remarks;
 
+    @Schema(description = "附加字段")
+    private String additionalData;
+
     /**
      * 创建人签名
      */
+    @Schema(description = "创建人签名")
     private String createSign;
 }

+ 2 - 1
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/service/FlowFileVersionService.java

@@ -1,6 +1,7 @@
 package com.github.jfcloud.gene.flow.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.github.jfcloud.gene.file.vo.FileVo;
 import com.github.jfcloud.gene.flow.entity.FlowFileVersion;
 
 public interface FlowFileVersionService extends IService<FlowFileVersion> {
@@ -11,5 +12,5 @@ public interface FlowFileVersionService extends IService<FlowFileVersion> {
      * @param flowId
      * @return
      */
-    String getLatestFileUrl(Long flowId);
+    FileVo getLatestFile(Long flowId);
 }

+ 7 - 0
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/service/FlowInfoService.java

@@ -71,4 +71,11 @@ public interface FlowInfoService extends IService<FlowInfo> {
      * @param flowInfo
      */
     void geneWord(Long flowId);
+
+    /**
+     * 复制
+     *
+     * @param id
+     */
+    void copyFlow(Long id);
 }

+ 10 - 4
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/service/impl/FlowFileVersionServiceImpl.java

@@ -2,6 +2,7 @@ package com.github.jfcloud.gene.flow.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.github.jfcloud.gene.file.vo.FileVo;
 import com.github.jfcloud.gene.flow.entity.FlowFileVersion;
 import com.github.jfcloud.gene.flow.mapper.FlowFileVersionMapper;
 import com.github.jfcloud.gene.flow.service.FlowFileVersionService;
@@ -13,11 +14,16 @@ import org.springframework.stereotype.Service;
 public class FlowFileVersionServiceImpl extends ServiceImpl<FlowFileVersionMapper, FlowFileVersion> implements FlowFileVersionService {
 
     @Override
-    public String getLatestFileUrl(Long flowId) {
+    public FileVo getLatestFile(Long flowId) {
         FlowFileVersion flowFileVersion = this.getOne(new LambdaQueryWrapper<>(FlowFileVersion.class)
-                .select(FlowFileVersion::getFilepath)
+                .select(FlowFileVersion::getFilename, FlowFileVersion::getFilepath)
                 .eq(FlowFileVersion::getFlowId, flowId)
-                .orderByDesc(FlowFileVersion::getCreateTime).last("limit 1"));
-        return flowFileVersion != null ? flowFileVersion.getFilepath() : "";
+                .orderByDesc(FlowFileVersion::getCreateTime)
+                .last("limit 1"));
+
+        if (flowFileVersion == null) {
+            return new FileVo();
+        }
+        return new FileVo(flowFileVersion.getFilename(), flowFileVersion.getFilepath());
     }
 }

+ 45 - 33
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/service/impl/FlowInfoServiceImpl.java

@@ -101,7 +101,9 @@ public class FlowInfoServiceImpl extends ServiceImpl<FlowInfoMapper, FlowInfo> i
             //补充申请人姓名
             item.setCreateByName(userIdNameCache.getNicknameByUserId(Long.parseLong(item.getCreateBy())));
             //查询下载链接
-            item.setFileUrl(fileVersionService.getLatestFileUrl(item.getId()));
+            FileVo latestFile = fileVersionService.getLatestFile(item.getId());
+            item.setFileUrl(latestFile.getUrl());
+            item.setFilename(latestFile.getName());
             item.setStatusLabel(Objects.requireNonNull(GeneStatusEnum.getByStatus(item.getStatus())).getDescription());
         });
 
@@ -125,7 +127,9 @@ public class FlowInfoServiceImpl extends ServiceImpl<FlowInfoMapper, FlowInfo> i
         detail.setPurification(Optional.ofNullable(purificationInfoDto).orElse(new StrainPurificationInfoDto()));
 
         //查询下载链接
-        detail.setFileUrl(fileVersionService.getLatestFileUrl(id));
+        FileVo latestFile = fileVersionService.getLatestFile(id);
+        detail.setFileUrl(latestFile.getUrl());
+        detail.setFilename(latestFile.getName());
 
         return detail;
     }
@@ -172,7 +176,7 @@ public class FlowInfoServiceImpl extends ServiceImpl<FlowInfoMapper, FlowInfo> i
             customInfoService.remove(new LambdaQueryWrapper<>(StrainCustomInfo.class).eq(StrainCustomInfo::getFlowId, id));
         } else {
             vo.getCustom().setFlowId(id);
-            customInfoService.updateForm(id, vo.getCustom());
+            customInfoService.updateForm(vo.getCustom());
             target.append(GeneTargetEnum.CUSTOM);
         }
 
@@ -180,7 +184,7 @@ public class FlowInfoServiceImpl extends ServiceImpl<FlowInfoMapper, FlowInfo> i
             purificationInfoService.remove(new LambdaQueryWrapper<>(StrainPurificationInfo.class).eq(StrainPurificationInfo::getFlowId, id));
         } else {
             vo.getPurification().setFlowId(id);
-            purificationInfoService.updateForm(id, vo.getPurification());
+            purificationInfoService.updateForm(vo.getPurification());
 
             if (target.length() > 0) {
                 target.append(",");
@@ -214,42 +218,19 @@ public class FlowInfoServiceImpl extends ServiceImpl<FlowInfoMapper, FlowInfo> i
         Assert.notNull(flowInfo, "基因定制流程不存在");
         Assert.isFalse(GeneStatusEnum.SUBMIT_STATUS.contains(flowInfo.getStatus()), "流程状态错误");
 
-        //审核不通过
-        if (StrConstant.NO.equals(vo.getAuditResult())) {
-            log.info("流程项目 ({}) 审核不通过", flowInfo.getProjectName());
-
-            new FlowAudit()
-                    .setFlowId(id)
-                    .setFlowStatus(flowInfo.getStatus())
-                    .setAuditResult(vo.getAuditResult())
-                    .setRemarks(vo.getRemarks())
-                    .setCreateSign(userIdNameCache.getSignPic(UserUtil.getUserId()))
-                    .insert();
-
-            new FlowInfo()
-                    .setId(id)
-                    .setStatus(GeneStatusEnum.REJECTED.getStatus())
-                    .updateById();
-
-            notifyService.notify(id);
-            return;
-        }
-
-        Assert.isTrue(StrConstant.YES.equals(vo.getAuditResult()), "审核结果错误");
-
-        //审核通过
-        log.info("流程项目 ({}) 审核通过", flowInfo.getProjectName());
-
         String nextStatus = "";
         GeneStatusEnum statusEnum = Objects.requireNonNull(GeneStatusEnum.getByStatus(flowInfo.getStatus()));
         switch (statusEnum) {
             case GENE_EDITING:
+                Assert.isTrue(UserUtil.getUserId().equals(flowInfo.getGeneEditPlId()), "抱歉,您不能审核本条记录");
                 nextStatus = GeneStatusEnum.PROJECT_LEADER.getStatus();
                 break;
             case PROJECT_LEADER:
+                Assert.isTrue(UserUtil.getUserId().equals(flowInfo.getProjectLeaderId()), "抱歉,您不能审核本条记录");
                 nextStatus = GeneStatusEnum.PROJECT_MANAGEMENT.getStatus();
                 break;
             case PROJECT_MANAGEMENT:
+                Assert.isTrue(UserUtil.getUserId().equals(flowInfo.getProjectManageId()), "抱歉,您不能审核本条记录");
                 nextStatus = GeneStatusEnum.COMPLETED.getStatus();
                 break;
             default:
@@ -257,13 +238,36 @@ public class FlowInfoServiceImpl extends ServiceImpl<FlowInfoMapper, FlowInfo> i
                 throw new IllegalArgumentException("流程状态错误");
         }
 
-        new FlowAudit()
+        //保存审批节点
+        FlowAudit flowAudit = new FlowAudit()
                 .setFlowId(id)
                 .setFlowStatus(flowInfo.getStatus())
                 .setAuditResult(vo.getAuditResult())
                 .setRemarks(vo.getRemarks())
-                .setCreateSign(userIdNameCache.getSignPic(UserUtil.getUserId()))
-                .insert();
+                .setCreateSign(userIdNameCache.getSignPic(UserUtil.getUserId()));
+        if (StrUtil.isNotBlank(vo.getLeaderResult())) {
+            JSONObject dataObj = new JSONObject().fluentPut("leaderResult", vo.getLeaderResult());
+            flowAudit.setAdditionalData(dataObj.toJSONString());
+        }
+        flowAudit.insert();
+
+        //审核不通过
+        if (StrConstant.NO.equals(vo.getAuditResult())) {
+            log.info("流程项目 ({}) 审核不通过", flowInfo.getProjectName());
+
+            new FlowInfo()
+                    .setId(id)
+                    .setStatus(GeneStatusEnum.REJECTED.getStatus())
+                    .updateById();
+
+            notifyService.notify(id);
+            return;
+        }
+
+        Assert.isTrue(StrConstant.YES.equals(vo.getAuditResult()), "审核结果错误");
+
+        //审核通过
+        log.info("流程项目 ({}) 审核通过", flowInfo.getProjectName());
 
         flowInfo = new FlowInfo();
         //更新项目批准编号、修订号等
@@ -328,4 +332,12 @@ public class FlowInfoServiceImpl extends ServiceImpl<FlowInfoMapper, FlowInfo> i
             }
         }
     }
+
+    @Override
+    public void copyFlow(Long id) {
+        FlowDetailDto detail = getDetail(id);
+        FlowDetailVo vo = BeanUtil.copyProperties(detail, FlowDetailVo.class);
+        vo.setProjectName(vo.getProjectName() + "(1)");
+        saveFlow(vo);
+    }
 }

+ 4 - 1
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/flow/vo/FlowAuditVo.java

@@ -6,9 +6,12 @@ import lombok.Data;
 @Data
 public class FlowAuditVo {
 
-    @Schema(description = "审核意见", example = "yes/no")
+    @Schema(description = "审核意见,是否同意", example = "yes/no")
     private String auditResult;
 
+    @Schema(description = "分管领导是否同意", example = "yes/no")
+    private String leaderResult;
+
     @Schema(description = "批准编号")
     private String approvalNo;
 

+ 1 - 2
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/form/service/StrainCustomInfoService.java

@@ -18,10 +18,9 @@ public interface StrainCustomInfoService extends IService<StrainCustomInfo> {
     /**
      * 更新基因定制表单
      *
-     * @param id
      * @param vo
      */
-    void updateForm(Long id, StrainCustomVo vo);
+    void updateForm(StrainCustomVo vo);
 
     /**
      * 根据流程id查询基因定制表单

+ 1 - 2
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/form/service/StrainPurificationInfoService.java

@@ -17,10 +17,9 @@ public interface StrainPurificationInfoService extends IService<StrainPurificati
     /**
      * 更新净化扩繁表单
      *
-     * @param id
      * @param vo
      */
-    void updateForm(Long id, StrainPurificationInfoVo vo);
+    void updateForm(StrainPurificationInfoVo vo);
 
     /**
      * 根据流程id查询净化扩繁表单

+ 5 - 3
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/form/service/impl/StrainCustomInfoServiceImpl.java

@@ -49,15 +49,17 @@ public class StrainCustomInfoServiceImpl extends ServiceImpl<StrainCustomInfoMap
     }
 
     @Override
-    public void updateForm(Long id, StrainCustomVo vo) {
-        StrainCustomInfo info = getById(id);
+    public void updateForm(StrainCustomVo vo) {
+        StrainCustomInfo info = getOne(new LambdaQueryWrapper<>(StrainCustomInfo.class)
+                .eq(StrainCustomInfo::getFlowId, vo.getFlowId())
+                .eq(StrainCustomInfo::getDeleted, WhetherEnum.NO.getCode()));
         Assert.notNull(info, "品系定制不存在");
 
         BeanUtil.copyProperties(vo, info);
         info.updateById();
 
         //先删除总表,再保存总表
-        strainCustomDetailService.remove(new LambdaQueryWrapper<StrainCustomDetail>().eq(StrainCustomDetail::getStrainCustomBasicId, id));
+        strainCustomDetailService.remove(new LambdaQueryWrapper<StrainCustomDetail>().eq(StrainCustomDetail::getStrainCustomBasicId, info.getId()));
         if (!vo.getDetailList().isEmpty()) {
             List<StrainCustomDetail> detailList = vo.getDetailList().stream()
                     .map(x -> {

+ 8 - 6
jfcloud-gene-biz/src/main/java/com/github/jfcloud/gene/form/service/impl/StrainPurificationInfoServiceImpl.java

@@ -87,19 +87,21 @@ public class StrainPurificationInfoServiceImpl extends ServiceImpl<StrainPurific
     }
 
     @Override
-    public void updateForm(Long id, StrainPurificationInfoVo vo) {
-        StrainPurificationInfo info = getById(id);
+    public void updateForm(StrainPurificationInfoVo vo) {
+        StrainPurificationInfo info = getOne(new LambdaQueryWrapper<>(StrainPurificationInfo.class)
+                .eq(StrainPurificationInfo::getFlowId, vo.getFlowId())
+                .eq(StrainPurificationInfo::getDeleted, WhetherEnum.NO.getCode()));
         Assert.notNull(info, "品系净化扩繁不存在");
 
         BeanUtil.copyProperties(vo, info);
         info.updateById();
 
         //先删除附件等,再进行保存
-        cageDemandService.remove(new LambdaQueryWrapper<>(CageDemand.class).eq(CageDemand::getPurificationId, id));
-        animalDemandService.remove(new LambdaQueryWrapper<>(AnimalDemand.class).eq(AnimalDemand::getPurificationId, id));
-        fileInfoService.remove(new LambdaQueryWrapper<>(FileInfo.class).eq(FileInfo::getRelateId, id));
+        cageDemandService.remove(new LambdaQueryWrapper<>(CageDemand.class).eq(CageDemand::getPurificationId, info.getId()));
+        animalDemandService.remove(new LambdaQueryWrapper<>(AnimalDemand.class).eq(AnimalDemand::getPurificationId, info.getId()));
+        fileInfoService.remove(new LambdaQueryWrapper<>(FileInfo.class).eq(FileInfo::getRelateId, info.getId()));
 
-        saveDetailList(id, vo);
+        saveDetailList(info.getId(), vo);
     }
 
     @Override