瀏覽代碼

新增sop申请

wangliang 1 年之前
父節點
當前提交
cc581e6038
共有 21 個文件被更改,包括 782 次插入25 次删除
  1. 9 0
      sop-business/src/main/java/com/qmth/sop/business/activiti/service/ActivitiService.java
  2. 23 0
      sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java
  3. 17 0
      sop-business/src/main/java/com/qmth/sop/business/bean/params/FlowApproveParam.java
  4. 54 0
      sop-business/src/main/java/com/qmth/sop/business/bean/params/FormWidgetMetadataParam.java
  5. 71 0
      sop-business/src/main/java/com/qmth/sop/business/bean/params/SopApplyParam.java
  6. 88 0
      sop-business/src/main/java/com/qmth/sop/business/bean/params/SopInfoListParam.java
  7. 6 1
      sop-business/src/main/java/com/qmth/sop/business/entity/TBSopInfo.java
  8. 13 0
      sop-business/src/main/java/com/qmth/sop/business/entity/TBSopInfoDetail.java
  9. 14 0
      sop-business/src/main/java/com/qmth/sop/business/mapper/TBSopInfoMapper.java
  10. 9 0
      sop-business/src/main/java/com/qmth/sop/business/service/TBQualityProblemApplyService.java
  11. 30 0
      sop-business/src/main/java/com/qmth/sop/business/service/TBSopInfoService.java
  12. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java
  13. 5 2
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBProjectExchangeServiceImpl.java
  14. 144 9
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBQualityProblemApplyServiceImpl.java
  15. 164 2
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java
  16. 53 1
      sop-business/src/main/resources/db/log/wangliang_update_log.sql
  17. 4 0
      sop-business/src/main/resources/mapper/TBSopInfoMapper.xml
  18. 19 0
      sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java
  19. 4 0
      sop-common/src/main/java/com/qmth/sop/common/enums/ExceptionResultEnum.java
  20. 11 3
      sop-server/src/main/java/com/qmth/sop/server/api/TBQualityProblemApplyController.java
  21. 43 6
      sop-server/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

+ 9 - 0
sop-business/src/main/java/com/qmth/sop/business/activiti/service/ActivitiService.java

@@ -6,6 +6,7 @@ import com.qmth.sop.business.bean.result.FlowViewResult;
 import com.qmth.sop.business.bean.result.WorkTaskResult;
 import com.qmth.sop.common.enums.FlowTaskTypeEnum;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
+import org.activiti.engine.task.Task;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.IOException;
@@ -124,4 +125,12 @@ public interface ActivitiService {
      * @return
      */
     public FlowViewResult flowView(Long flowId, String code);
+
+    /**
+     * 获取流程节点审批人员
+     *
+     * @param task
+     * @return
+     */
+    public List<Long> getTaskApprove(Task task);
 }

+ 23 - 0
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -383,6 +383,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             tfCustomFlowEntityService.saveOrUpdate(tfCustomFlowEntity);
             tfFlowApproveService.saveOrUpdate(tfFlowApprove);
             tfFlowLogService.saveBatch(tfFlowLogList);
+            map.put(SystemConstant.FLOW_CUSTOM, tfCustomFlow);
             map.put(SystemConstant.FLOW_APPROVE, tfFlowApprove);
             map.put(SystemConstant.FLOW_ENTITY, tfCustomFlowEntity);
         } catch (Exception e) {
@@ -733,6 +734,28 @@ public class ActivitiServiceImpl implements ActivitiService {
         return new FlowViewResult(flowId, tfFlowApprove.getStatus(), String.valueOf(tfFlowApprove.getId()), taskIdList, flowTaskHistoryList, currFlowTaskResult, flowApproveHistoryList);
     }
 
+    /**
+     * 获取流程节点审批人员
+     *
+     * @param task
+     * @return
+     */
+    @Override
+    public List<Long> getTaskApprove(Task task) {
+        List<Long> taskApproveUserList = new ArrayList<>();
+        if (Objects.nonNull(task.getAssignee())) {
+            taskApproveUserList.add(Long.parseLong(task.getAssignee()));
+        } else {
+            List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
+            if (!CollectionUtils.isEmpty(identityLinkList)) {
+                for (IdentityLink i : identityLinkList) {
+                    taskApproveUserList.add(Long.parseLong(i.getUserId()));
+                }
+            }
+        }
+        return taskApproveUserList;
+    }
+
     /**
      * 获取表单属性
      *

+ 17 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/FlowApproveParam.java

@@ -48,6 +48,14 @@ public class FlowApproveParam implements Serializable {
 
     }
 
+    public FlowApproveParam(String flowDeploymentId, FlowApprovePassEnum approve, List<String> approveUserIds, String crmNo, String formProperties) {
+        this.flowDeploymentId = flowDeploymentId;
+        this.approve = approve;
+        this.approveUserIds = approveUserIds;
+        this.crmNo = crmNo;
+        this.formProperties = formProperties;
+    }
+
     public FlowApproveParam(String flowDeploymentId, FlowApprovePassEnum approve, List<String> approveUserIds, String crmNo) {
         this.flowDeploymentId = flowDeploymentId;
         this.approve = approve;
@@ -71,6 +79,15 @@ public class FlowApproveParam implements Serializable {
         this.approveRemark = approveRemark;
     }
 
+    public FlowApproveParam(Long taskId, FlowApprovePassEnum approve, List<String> approveUserIds, String crmNo, String approveRemark, String formProperties) {
+        this.taskId = taskId;
+        this.approve = approve;
+        this.approveUserIds = approveUserIds;
+        this.crmNo = crmNo;
+        this.approveRemark = approveRemark;
+        this.formProperties = formProperties;
+    }
+
     public String getCrmNo() {
         return crmNo;
     }

+ 54 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/FormWidgetMetadataParam.java

@@ -0,0 +1,54 @@
+package com.qmth.sop.business.bean.params;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: sop元数据param
+ * @Param:
+ * @return:
+ * @Author: wngliang
+ * @Date: 2023/9/4
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class FormWidgetMetadataParam implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @JsonSerialize(using = ToStringSerializer.class)
+    @ApiModelProperty(value = "主键")
+    private Long id;
+
+    @ApiModelProperty(value = "字段id")
+    private String fieldId;
+
+    @ApiModelProperty(value = "字段值")
+    private String fieldValue;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getFieldId() {
+        return fieldId;
+    }
+
+    public void setFieldId(String fieldId) {
+        this.fieldId = fieldId;
+    }
+
+    public String getFieldValue() {
+        return fieldValue;
+    }
+
+    public void setFieldValue(String fieldValue) {
+        this.fieldValue = fieldValue;
+    }
+}

+ 71 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopApplyParam.java

@@ -0,0 +1,71 @@
+package com.qmth.sop.business.bean.params;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @Description: sop申请param
+ * @Param:
+ * @return:
+ * @Author: wngliang
+ * @Date: 2023/9/4
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class SopApplyParam extends FlowApproveParam implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "sop单号")
+    private String sopNo;
+
+    @ApiModelProperty(value = "服务单元id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    @NotNull(message = "服务单元id不能为空")
+    private Long serviceId;
+
+    @ApiModelProperty(value = "客户id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    @NotNull(message = "客户id不能为空")
+    private Long customId;
+
+    @ApiModelProperty(value = "产品id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    @NotNull(message = "产品id不能为空")
+    private Long productId;
+
+    public String getSopNo() {
+        return sopNo;
+    }
+
+    public void setSopNo(String sopNo) {
+        this.sopNo = sopNo;
+    }
+
+    public Long getServiceId() {
+        return serviceId;
+    }
+
+    public void setServiceId(Long serviceId) {
+        this.serviceId = serviceId;
+    }
+
+    public Long getCustomId() {
+        return customId;
+    }
+
+    public void setCustomId(Long customId) {
+        this.customId = customId;
+    }
+
+    public Long getProductId() {
+        return productId;
+    }
+
+    public void setProductId(Long productId) {
+        this.productId = productId;
+    }
+}

+ 88 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopInfoListParam.java

@@ -0,0 +1,88 @@
+package com.qmth.sop.business.bean.params;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.qmth.sop.business.entity.TBSopInfo;
+import com.qmth.sop.common.contant.SystemConstant;
+import io.swagger.annotations.ApiModelProperty;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @Description: sop列表param
+ * @Param:
+ * @return:
+ * @Author: wngliang
+ * @Date: 2023/9/4
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class SopInfoListParam extends TBSopInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "流程类型str")
+    private String typeStr;
+
+    @ApiModelProperty(value = "版本号")
+    private Integer version = 1;
+
+    @ApiModelProperty(value = "元数据数组")
+    private List<FormWidgetMetadataParam> formWidgetMetadataList;
+
+    @ApiModelProperty(value = "页码")
+    @NotNull(message = "页码不能为空")
+    @Min(SystemConstant.PAGE_NUMBER_MIN)
+    private Integer pageNumber;
+
+    @ApiModelProperty(value = "页数")
+    @NotNull(message = "页数不能为空")
+    @Max(SystemConstant.PAGE_SIZE_MAX)
+    private Integer pageSize;
+
+    public String getTypeStr() {
+        if (Objects.nonNull(this.getType())) {
+            return this.getType().getTitle();
+        } else {
+            return typeStr;
+        }
+    }
+
+    public void setTypeStr(String typeStr) {
+        this.typeStr = typeStr;
+    }
+
+    public Integer getVersion() {
+        return version;
+    }
+
+    public void setVersion(Integer version) {
+        this.version = version;
+    }
+
+    public List<FormWidgetMetadataParam> getFormWidgetMetadataList() {
+        return formWidgetMetadataList;
+    }
+
+    public void setFormWidgetMetadataList(List<FormWidgetMetadataParam> formWidgetMetadataList) {
+        this.formWidgetMetadataList = formWidgetMetadataList;
+    }
+
+    public Integer getPageNumber() {
+        return pageNumber;
+    }
+
+    public void setPageNumber(Integer pageNumber) {
+        this.pageNumber = pageNumber;
+    }
+
+    public Integer getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(Integer pageSize) {
+        this.pageSize = pageSize;
+    }
+}

+ 6 - 1
sop-business/src/main/java/com/qmth/sop/business/entity/TBSopInfo.java

@@ -3,10 +3,12 @@ package com.qmth.sop.business.entity;
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.sop.common.base.BaseEntity;
+import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
@@ -41,14 +43,17 @@ public class TBSopInfo extends BaseEntity implements Serializable {
     private Long productId;
 
     @ApiModelProperty(value = "流程类型,OFFICE_SOP_FLOW:教务处SOP,CLOUD_MARK_SOP_FLOW:研究生SOP")
+    @NotNull(message = "流程类型不能为空")
     private TFCustomTypeEnum type;
 
     public TBSopInfo() {
 
     }
 
-    public TBSopInfo(String crmNo, Long serviceId, Long customId, Long productId, TFCustomTypeEnum type, Long userId) {
+    public TBSopInfo(String crmNo, String sopNo, Long serviceId, Long customId, Long productId, TFCustomTypeEnum type, Long userId) {
+        setId(SystemConstant.getDbUuid());
         this.crmNo = crmNo;
+        this.sopNo = sopNo;
         this.serviceId = serviceId;
         this.customId = customId;
         this.productId = productId;

+ 13 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBSopInfoDetail.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.entity;
 
 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import com.qmth.sop.common.contant.SystemConstant;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
@@ -39,6 +40,18 @@ public class TBSopInfoDetail implements Serializable {
     @ApiModelProperty(value = "助理实施工程师id数组")
     private String assistantEngineerUserIds;
 
+    public TBSopInfoDetail() {
+
+    }
+
+    public TBSopInfoDetail(Long sopInfoId, Long regionUserId, Long engineerUserId, String assistantEngineerUserIds) {
+        this.id = SystemConstant.getDbUuid();
+        this.sopInfoId = sopInfoId;
+        this.regionUserId = regionUserId;
+        this.engineerUserId = engineerUserId;
+        this.assistantEngineerUserIds = assistantEngineerUserIds;
+    }
+
     public Long getId() {
         return id;
     }

+ 14 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBSopInfoMapper.java

@@ -1,6 +1,8 @@
 package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.bean.params.FormWidgetMetadataParam;
 import com.qmth.sop.business.entity.TBSopInfo;
 import org.apache.ibatis.annotations.Param;
 
@@ -63,5 +65,17 @@ public interface TBSopInfoMapper extends BaseMapper<TBSopInfo> {
      * @param tableName
      * @return
      */
+    @SuppressWarnings("MybatisXMapperMethodInspection")
     List<Map<String, String>> selectDynamicSopAll(@Param("tableName") String tableName);
+
+    /**
+     * sop列表接口
+     *
+     * @param iPage
+     * @param serviceId
+     * @param formWidgetMetadataList
+     * @return
+     */
+    @SuppressWarnings("MybatisXMapperMethodInspection")
+    IPage<Map> list(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("formWidgetMetadataList") List<FormWidgetMetadataParam> formWidgetMetadataList);
 }

+ 9 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBQualityProblemApplyService.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.result.TBQualityProblemApplyResult;
 import com.qmth.sop.business.entity.TBQualityProblemApply;
 import com.qmth.sop.common.enums.InfluenceDegreeEnum;
@@ -36,6 +37,14 @@ public interface TBQualityProblemApplyService extends IService<TBQualityProblemA
      */
     Boolean saveTBQualityProblemApply(TBQualityProblemApply tbQualityProblemApply) throws InterruptedException;
 
+    /**
+     * 质量问题反馈审核
+     *
+     * @param flowApproveParam
+     * @return
+     */
+    Boolean flowApprove(FlowApproveParam flowApproveParam) throws InterruptedException;
+
     /**
      * 删除质量问题反馈表
      *

+ 30 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBSopInfoService.java

@@ -1,10 +1,16 @@
 package com.qmth.sop.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.bean.params.FlowApproveParam;
+import com.qmth.sop.business.bean.params.SopApplyParam;
+import com.qmth.sop.business.bean.params.SopInfoListParam;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.entity.TBSopInfo;
 import com.qmth.sop.business.entity.TFCustomFlow;
 
+import java.util.Map;
+
 /**
  * <p>
  * sop表 服务类
@@ -44,4 +50,28 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @return
      */
     int selectDynamicSop(String tableName, String flowDeploymentId, Long flowId);
+
+    /**
+     * sop申请信息
+     *
+     * @param sopApplyParam
+     * @return
+     */
+    Boolean sopApply(SopApplyParam sopApplyParam) throws InterruptedException;
+
+    /**
+     * sop填报信息
+     *
+     * @param flowApproveParam
+     * @return
+     */
+    Boolean sopApprove(FlowApproveParam flowApproveParam) throws InterruptedException;
+
+    /**
+     * sop管理列表
+     *
+     * @param sopInfoListParam
+     * @return
+     */
+    IPage<Map> list(SopInfoListParam sopInfoListParam);
 }

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -80,7 +80,7 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         tbDingApply.setCode(tfCustomFlowEntity.getCode(), tbDingApply.getAttachmentIdList(), sysUser.getId());
         tfCustomFlowEntity.setObjId(tbDingApply.getId());
         tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
-        return this.saveOrUpdate(tbDingApply);
+        return tbDingApplyService.save(tbDingApply);
     }
 
     /**

+ 5 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBProjectExchangeServiceImpl.java

@@ -47,6 +47,9 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
     @Resource
     TaskService taskService;
 
+    @Resource
+    TBProjectExchangeService tbProjectExchangeService;
+
     /**
      * 新增项目变更计划申请
      *
@@ -63,7 +66,7 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
         tbProjectExchange.setCode(tfCustomFlowEntity.getCode(), sysUser.getId());
         tfCustomFlowEntity.setObjId(tbProjectExchange.getId());
         tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
-        return this.saveOrUpdate(tbProjectExchange);
+        return tbProjectExchangeService.save(tbProjectExchange);
     }
 
     /**
@@ -115,7 +118,7 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
 
         tbProjectExchange.setResult(projectExchangeApprove);
         tbProjectExchange.setRemark(remark);
-        return this.updateById(tbProjectExchange);
+        return tbProjectExchangeService.updateById(tbProjectExchange);
     }
 
     /**

+ 144 - 9
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBQualityProblemApplyServiceImpl.java

@@ -1,9 +1,14 @@
 package com.qmth.sop.business.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
+import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
+import com.qmth.sop.business.bean.result.FlowResult;
+import com.qmth.sop.business.bean.result.FlowTaskResult;
 import com.qmth.sop.business.bean.result.TBQualityProblemApplyResult;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBQualityProblemApply;
@@ -12,19 +17,18 @@ import com.qmth.sop.business.mapper.TBQualityProblemApplyMapper;
 import com.qmth.sop.business.service.TBQualityProblemApplyService;
 import com.qmth.sop.business.service.TFCustomFlowEntityService;
 import com.qmth.sop.common.contant.SystemConstant;
-import com.qmth.sop.common.enums.FlowApprovePassEnum;
-import com.qmth.sop.common.enums.InfluenceDegreeEnum;
-import com.qmth.sop.common.enums.QualityProblemReasonEnum;
-import com.qmth.sop.common.enums.QualityProblemTypeEnum;
+import com.qmth.sop.common.enums.*;
+import com.qmth.sop.common.util.GsonUtil;
 import com.qmth.sop.common.util.ServletUtil;
+import org.activiti.engine.TaskService;
+import org.activiti.engine.task.Task;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -45,6 +49,12 @@ public class TBQualityProblemApplyServiceImpl extends ServiceImpl<TBQualityProbl
     @Resource
     ActivitiService activitiService;
 
+    @Resource
+    TBQualityProblemApplyService tbQualityProblemApplyService;
+
+    @Resource
+    TaskService taskService;
+
     /**
      * 查询列表
      *
@@ -64,13 +74,75 @@ public class TBQualityProblemApplyServiceImpl extends ServiceImpl<TBQualityProbl
     @Override
     @Transactional
     public Boolean saveTBQualityProblemApply(TBQualityProblemApply tbQualityProblemApply) throws InterruptedException {
+        if (tbQualityProblemApply.getFlowApprove() != FlowApprovePassEnum.START && tbQualityProblemApply.getFlowApprove() != FlowApprovePassEnum.DRAFT) {
+            throw ExceptionResultEnum.PARAMS_ERROR.exception("流程审批只能为提交或草稿");
+        }
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+
+        FlowTaskResult currFlowTaskResult = JSONObject.parseObject(tbQualityProblemApply.getFormProperties(), FlowTaskResult.class);
+        tbQualityProblemApply = this.updateFieldValue(currFlowTaskResult, tbQualityProblemApply);
+
         Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(tbQualityProblemApply.getFlowDeploymentId(), FlowApprovePassEnum.START, tbQualityProblemApply.getFormProperties(), Arrays.asList(String.valueOf(sysUser.getId())), tbQualityProblemApply.getCrmNo()));
         TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
         tbQualityProblemApply.setCode(tfCustomFlowEntity.getCode(), tbQualityProblemApply.getAttachmentIdList(), tbQualityProblemApply.getUserIdList(), sysUser.getId());
         tfCustomFlowEntity.setObjId(tbQualityProblemApply.getId());
         tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
-        return this.saveOrUpdate(tbQualityProblemApply);
+        return tbQualityProblemApplyService.save(tbQualityProblemApply);
+    }
+
+    /**
+     * 质量问题反馈审核
+     *
+     * @param flowApproveParam
+     * @return
+     */
+    @Override
+    public Boolean flowApprove(FlowApproveParam flowApproveParam) throws InterruptedException {
+        if (Objects.isNull(flowApproveParam.getTaskId())) {
+            throw ExceptionResultEnum.PARAMS_ERROR.exception("流程节点id不能为空");
+        }
+        if (flowApproveParam.getApprove() != FlowApprovePassEnum.PASS && flowApproveParam.getApprove() != FlowApprovePassEnum.REJECT && flowApproveParam.getApprove() != FlowApprovePassEnum.DRAFT) {
+            throw ExceptionResultEnum.PARAMS_ERROR.exception("sop填报只能为通过或驳回或草稿");
+        }
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        Task task = taskService.createTaskQuery().taskId(String.valueOf(flowApproveParam.getTaskId())).singleResult();
+        Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
+
+        List<Long> taskApproveUserList = activitiService.getTaskApprove(task);
+        if (flowApproveParam.getApprove() != FlowApprovePassEnum.DRAFT && !CollectionUtils.isEmpty(taskApproveUserList) && !taskApproveUserList.contains(sysUser.getId())) {
+            throw ExceptionResultEnum.ERROR.exception("不能审批他人的sop数据");
+        }
+
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, Long.parseLong(task.getProcessInstanceId())));
+        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+
+        FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
+        LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
+        FlowTaskResult currFlowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(setupMap.get(task.getTaskDefinitionKey())), FlowTaskResult.class);
+
+        String approveUserId = null;
+        if (Objects.nonNull(currFlowTaskResult) && currFlowTaskResult.getSetup().intValue() > 1) {
+            FlowTaskResult flowTaskResultTemp = null;
+            for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
+                flowTaskResultTemp = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
+                if (flowTaskResultTemp.getSetup().intValue() == 2) {
+                    break;
+                }
+            }
+            this.getApproveUserIds(flowTaskResultTemp, currFlowTaskResult.getSetup(), approveUserId);
+        } else {
+            approveUserId = task.getAssignee();
+        }
+        TBQualityProblemApply tbQualityProblemApply = this.getOne(new QueryWrapper<TBQualityProblemApply>().lambda().eq(TBQualityProblemApply::getProblemNo, tfCustomFlowEntity.getCode()));
+        Optional.ofNullable(tbQualityProblemApply).orElseThrow(() -> ExceptionResultEnum.QUALITY_PROBLEM_APPLY_NO_DATA.exception());
+
+        tbQualityProblemApply = this.updateFieldValue(currFlowTaskResult, tbQualityProblemApply);
+        List<String> approveUserIds = Objects.nonNull(approveUserId) ? Arrays.asList(approveUserId) : Arrays.asList(String.valueOf(sysUser.getId()));
+        flowApproveParam.setApproveUserIds(approveUserIds);
+        activitiService.taskApprove(flowApproveParam);
+
+        tbQualityProblemApply.updateInfo(sysUser.getId());
+        return this.updateById(tbQualityProblemApply);
     }
 
     /**
@@ -85,4 +157,67 @@ public class TBQualityProblemApplyServiceImpl extends ServiceImpl<TBQualityProbl
         return this.removeByIds(idList);
     }
 
+    /**
+     * 获取审批人
+     *
+     * @param flowTaskResult
+     * @param setup
+     * @param approveUserId
+     */
+    public void getApproveUserIds(FlowTaskResult flowTaskResult, Integer setup, String approveUserId) {
+        List<FlowFormWidgetResult> formProperty = flowTaskResult.getFormProperty();
+        for (FlowFormWidgetResult f : formProperty) {
+            if (setup.intValue() == 2 && f.getFormId().contains(SystemConstant.APPROVE_CHECK_USERS) && Objects.nonNull(f.getValue())) {//获取甲方复核人员
+                String string = f.getValue().replaceAll("\\[", "").replaceAll("\\]", "");
+                approveUserId = StringUtils.join(Arrays.asList(string), SystemConstant.LIST_JOIN_SPLIT);
+                break;
+            } else if (setup.intValue() == 3 && f.getFormId().contains(SystemConstant.APPROVE_CHECK_THIRD_USERS) && Objects.nonNull(f.getValue())) {//获取已方复核人员
+                String string = f.getValue().replaceAll("\\[", "").replaceAll("\\]", "");
+                approveUserId = StringUtils.join(Arrays.asList(string), SystemConstant.LIST_JOIN_SPLIT);
+                break;
+            }
+        }
+        if (setup.intValue() == 2 && Objects.isNull(approveUserId)) {
+            throw ExceptionResultEnum.ERROR.exception("甲方复核人不能为空");
+        } else if (setup.intValue() == 3 && Objects.isNull(approveUserId)) {
+            throw ExceptionResultEnum.ERROR.exception("已方复核人不能为空");
+        }
+    }
+
+    /**
+     * 更新字段
+     *
+     * @param currFlowTaskResult
+     * @param tbQualityProblemApply
+     * @return
+     */
+    public TBQualityProblemApply updateFieldValue(FlowTaskResult currFlowTaskResult, TBQualityProblemApply tbQualityProblemApply) {
+        List<FlowFormWidgetResult> formWidgetResultList = currFlowTaskResult.getFormProperty();
+        if (!CollectionUtils.isEmpty(formWidgetResultList)) {//更新字段
+            for (FlowFormWidgetResult t : formWidgetResultList) {
+                if (t.getFormId().contains(SystemConstant.PROBLEM_POINT)) {//问题简要
+                    tbQualityProblemApply.setSummary(t.getValue());
+                }
+                if (t.getFormId().contains(SystemConstant.PROBLEM_REMARK)) {//问题情况说明
+                    tbQualityProblemApply.setRemark(t.getValue());
+                }
+                if (t.getFormId().contains(SystemConstant.ATTACHMENT_INFO)) {//附件id数组
+                    tbQualityProblemApply.setAttachmentIds(t.getValue());
+                }
+                if (t.getFormId().contains(SystemConstant.PROBLEM_TYPE)) {//质量问题类型
+                    tbQualityProblemApply.setType(QualityProblemTypeEnum.valueOf(t.getValue()));
+                }
+                if (t.getFormId().contains(SystemConstant.PROBLEM_REASON_RADIO)) {//问题归因
+                    tbQualityProblemApply.setReason(QualityProblemReasonEnum.valueOf(t.getValue()));
+                }
+                if (t.getFormId().contains(SystemConstant.PROBLEM_DEGREE_RADIO)) {//问题影响度
+                    tbQualityProblemApply.setInfluenceDegree(InfluenceDegreeEnum.valueOf(t.getValue()));
+                }
+                if (t.getFormId().contains(SystemConstant.PROBLEM_USERS)) {//责任人
+                    tbQualityProblemApply.setUserIds(t.getValue());
+                }
+            }
+        }
+        return tbQualityProblemApply;
+    }
 }

+ 164 - 2
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -1,14 +1,29 @@
 package com.qmth.sop.business.service.impl;
 
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.activiti.service.ActivitiService;
+import com.qmth.sop.business.bean.params.FlowApproveParam;
+import com.qmth.sop.business.bean.params.SopApplyParam;
+import com.qmth.sop.business.bean.params.SopInfoListParam;
 import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
-import com.qmth.sop.business.entity.TBSopInfo;
-import com.qmth.sop.business.entity.TFCustomFlow;
+import com.qmth.sop.business.entity.*;
 import com.qmth.sop.business.mapper.TBSopInfoMapper;
+import com.qmth.sop.business.service.TBSopInfoDetailService;
 import com.qmth.sop.business.service.TBSopInfoService;
+import com.qmth.sop.business.service.TFCustomFlowEntityService;
 import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.ExceptionResultEnum;
+import com.qmth.sop.common.enums.FlowApprovePassEnum;
 import com.qmth.sop.common.enums.WidgetCodeEnum;
+import com.qmth.sop.common.util.ServletUtil;
+import org.activiti.engine.TaskService;
+import org.activiti.engine.task.Task;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -31,6 +46,21 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     @Resource
     TBSopInfoMapper tbSopInfoMapper;
 
+    @Resource
+    ActivitiService activitiService;
+
+    @Resource
+    TFCustomFlowEntityService tfCustomFlowEntityService;
+
+    @Resource
+    TaskService taskService;
+
+    @Resource
+    TBSopInfoDetailService tbSopInfoDetailService;
+
+    @Resource
+    TBSopInfoService tbSopInfoService;
+
     /**
      * 查询动态sop表名是否存在
      *
@@ -137,4 +167,136 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     public int selectDynamicSop(String tableName, String flowDeploymentId, Long flowId) {
         return this.baseMapper.selectDynamicSop(tableName, flowDeploymentId, flowId);
     }
+
+    /**
+     * sop申请信息
+     *
+     * @param sopApplyParam
+     * @return
+     */
+    @Override
+    @Transactional
+    public Boolean sopApply(SopApplyParam sopApplyParam) throws InterruptedException {
+        if (Objects.isNull(sopApplyParam.getCrmNo())) {
+            throw ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空");
+        }
+        if (sopApplyParam.getApprove() != FlowApprovePassEnum.START && sopApplyParam.getApprove() != FlowApprovePassEnum.DRAFT) {
+            throw ExceptionResultEnum.PARAMS_ERROR.exception("sop申请只能为提交或草稿");
+        }
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        FlowTaskResult flowTaskResult = JSONObject.parseObject(sopApplyParam.getFormProperties(), FlowTaskResult.class);
+        Long regionUserId = null, engineerUserId = null;
+        String assistantEngineerUserIds = null;
+        this.getApproveUserIds(flowTaskResult, regionUserId, engineerUserId, assistantEngineerUserIds);
+
+        List<String> approveUserIds = Objects.nonNull(engineerUserId) ? Arrays.asList(String.valueOf(engineerUserId)) : Arrays.asList(String.valueOf(sysUser.getId()));
+        Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(sopApplyParam.getFlowDeploymentId(), sopApplyParam.getApprove(), approveUserIds, sopApplyParam.getCrmNo(), sopApplyParam.getFormProperties()));
+        TFCustomFlow tfCustomFlow = (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM);
+        TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
+
+        TBSopInfo tbSopInfo = new TBSopInfo(sopApplyParam.getCrmNo(), tfCustomFlowEntity.getCode(), sopApplyParam.getServiceId(), sopApplyParam.getCustomId(), sopApplyParam.getProductId(), tfCustomFlow.getType(), sysUser.getId());
+        TBSopInfoDetail tbSopInfoDetail = new TBSopInfoDetail(tbSopInfo.getId(), regionUserId, engineerUserId, assistantEngineerUserIds);
+        tbSopInfoDetailService.save(tbSopInfoDetail);
+
+        tfCustomFlowEntity.setObjId(tbSopInfo.getId());
+        tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
+        return tbSopInfoService.save(tbSopInfo);
+    }
+
+    /**
+     * sop填报信息
+     *
+     * @param flowApproveParam
+     * @return
+     */
+    @Override
+    @Transactional
+    public Boolean sopApprove(FlowApproveParam flowApproveParam) throws InterruptedException {
+        if (Objects.isNull(flowApproveParam.getTaskId())) {
+            throw ExceptionResultEnum.PARAMS_ERROR.exception("流程节点id不能为空");
+        }
+        if (flowApproveParam.getApprove() != FlowApprovePassEnum.PASS && flowApproveParam.getApprove() != FlowApprovePassEnum.REJECT && flowApproveParam.getApprove() != FlowApprovePassEnum.DRAFT) {
+            throw ExceptionResultEnum.PARAMS_ERROR.exception("sop填报只能为通过或驳回或草稿");
+        }
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        Task task = taskService.createTaskQuery().taskId(String.valueOf(flowApproveParam.getTaskId())).singleResult();
+        Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
+
+        List<Long> taskApproveUserList = activitiService.getTaskApprove(task);
+        if (flowApproveParam.getApprove() != FlowApprovePassEnum.DRAFT && !CollectionUtils.isEmpty(taskApproveUserList) && !taskApproveUserList.contains(sysUser.getId())) {
+            throw ExceptionResultEnum.ERROR.exception("不能审批他人的sop数据");
+        }
+
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, Long.parseLong(task.getProcessInstanceId())));
+        Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
+
+        TBSopInfo tbSopInfo = this.getOne(new QueryWrapper<TBSopInfo>().lambda().eq(TBSopInfo::getSopNo, tfCustomFlowEntity.getCode()));
+        Optional.ofNullable(tbSopInfo).orElseThrow(() -> ExceptionResultEnum.SOP_INFO_NO_DATA.exception());
+
+        FlowTaskResult flowTaskResult = JSONObject.parseObject(flowApproveParam.getFormProperties(), FlowTaskResult.class);
+        Long engineerUserId = null;
+        if (flowTaskResult.getSetup().intValue() == 1) {
+            Long regionUserId = null;
+            String assistantEngineerUserIds = null;
+            this.getApproveUserIds(flowTaskResult, regionUserId, engineerUserId, assistantEngineerUserIds);
+
+            UpdateWrapper<TBSopInfoDetail> updateWrapper = new UpdateWrapper<>();
+            updateWrapper.lambda().eq(TBSopInfoDetail::getSopInfoId, tbSopInfo.getId())
+                    .set(TBSopInfoDetail::getRegionUserId, regionUserId)
+                    .set(TBSopInfoDetail::getEngineerUserId, engineerUserId)
+                    .set(TBSopInfoDetail::getAssistantEngineerUserIds, assistantEngineerUserIds);
+            tbSopInfoDetailService.update(updateWrapper);
+        } else {
+            engineerUserId = taskApproveUserList.get(0);
+        }
+        List<String> approveUserIds = Objects.nonNull(engineerUserId) ? Arrays.asList(String.valueOf(engineerUserId)) : Arrays.asList(String.valueOf(sysUser.getId()));
+        flowApproveParam.setApproveUserIds(approveUserIds);
+        activitiService.taskApprove(flowApproveParam);
+        tbSopInfo.updateInfo(sysUser.getId());
+        return this.updateById(tbSopInfo);
+    }
+
+    /**
+     * sop管理列表
+     *
+     * @param sopInfoListParam
+     * @return
+     */
+    @Override
+    public IPage<Map> list(SopInfoListParam sopInfoListParam) {
+        return this.baseMapper.list(new Page<>(sopInfoListParam.getPageNumber(), sopInfoListParam.getPageSize()), sopInfoListParam.getServiceId(), sopInfoListParam.getFormWidgetMetadataList());
+    }
+
+    /**
+     * 获取审批人
+     *
+     * @param flowTaskResult
+     * @param regionUserId
+     * @param engineerUserId
+     * @param assistantEngineerUserIds
+     */
+    public void getApproveUserIds(FlowTaskResult flowTaskResult, Long regionUserId, Long engineerUserId, String assistantEngineerUserIds) {
+        List<FlowFormWidgetResult> formProperty = flowTaskResult.getFormProperty();
+        for (FlowFormWidgetResult f : formProperty) {
+            if (f.getFormId().contains(SystemConstant.REGION_USER_ID) && Objects.nonNull(f.getValue())) {
+                regionUserId = Long.parseLong(f.getValue());
+            }
+            if (f.getFormId().contains(SystemConstant.ENGINEER_USER_ID) && Objects.nonNull(f.getValue())) {
+                engineerUserId = Long.parseLong(f.getValue());
+            }
+            if (f.getFormId().contains(SystemConstant.ASSISTANT_ENGINEER_USER_ID) && Objects.nonNull(f.getValue())) {
+                String string = f.getValue().replaceAll("\\[", "").replaceAll("\\]", "");
+                assistantEngineerUserIds = StringUtils.join(Arrays.asList(string), SystemConstant.LIST_JOIN_SPLIT);
+            }
+            if (Objects.nonNull(regionUserId) && Objects.nonNull(engineerUserId) && Objects.nonNull(assistantEngineerUserIds)) {
+                break;
+            }
+        }
+        if (Objects.isNull(regionUserId)) {
+            throw ExceptionResultEnum.ERROR.exception("区域协调人不能为空");
+        }
+        if (Objects.isNull(engineerUserId)) {
+            throw ExceptionResultEnum.ERROR.exception("实施工程师不能为空");
+        }
+    }
 }

+ 53 - 1
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -1001,4 +1001,56 @@ ALTER TABLE t_d_form_widget_metadata ADD CONSTRAINT pkt_d_form_widget_metadata
 
 INSERT INTO sys_privilege
 (id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
-VALUES(3036, '获取流程版本信息接口', '/api/admin/flow/version/list', 'URL', 64, 31, 'SYS', NULL, 1, 1, 0);
+VALUES(3036, '获取流程版本信息接口', '/api/admin/flow/version/list', 'URL', 64, 31, 'SYS', NULL, 1, 1, 0);
+
+--2023.9.4update
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3037, '编辑', 'Edit', 'LINK', 41, 6, 'AUTH', NULL, 1, 0, 1);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3038, '作废', 'Cancel', 'LINK', 41, 7, 'AUTH', NULL, 1, 0, 1);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3039, '编辑', 'Edit', 'LINK', 42, 6, 'AUTH', NULL, 1, 0, 1);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3040, '作废', 'Cancel', 'LINK', 42, 7, 'AUTH', NULL, 1, 0, 1);
+
+UPDATE sys_privilege
+SET name='列表', url='List', `type`='LIST', parent_id=41, `sequence`=1, property='AUTH', related='3034,3035,3043', enable=1, default_auth=0, front_display=1
+WHERE id=171;
+UPDATE sys_privilege
+SET name='查询条件', url='Condition', `type`='CONDITION', parent_id=41, `sequence`=1, property='AUTH', related='3034,3035,3043', enable=1, default_auth=0, front_display=1
+WHERE id=172;
+UPDATE sys_privilege
+SET name='查询', url='Select', `type`='BUTTON', parent_id=41, `sequence`=2, property='AUTH', related='3034,3035,3043', enable=1, default_auth=0, front_display=1
+WHERE id=174;
+UPDATE sys_privilege
+SET name='填报', url='Fill', `type`='LINK', parent_id=41, `sequence`=1, property='AUTH', related='3042', enable=1, default_auth=0, front_display=1
+WHERE id=175;
+UPDATE sys_privilege
+SET name='新增SOP', url='AddSop', `type`='LINK', parent_id=41, `sequence`=3, property='AUTH', related='3041', enable=1, default_auth=0, front_display=1
+WHERE id=177;
+UPDATE sys_privilege
+SET name='列表', url='List', `type`='LIST', parent_id=42, `sequence`=1, property='AUTH', related='3034,3035,3043', enable=1, default_auth=0, front_display=1
+WHERE id=180;
+UPDATE sys_privilege
+SET name='查询条件', url='Condition', `type`='CONDITION', parent_id=42, `sequence`=1, property='AUTH', related='3034,3035,3043', enable=1, default_auth=0, front_display=1
+WHERE id=181;
+UPDATE sys_privilege
+SET name='查询', url='Select', `type`='BUTTON', parent_id=42, `sequence`=2, property='AUTH', related='3034,3035,3043', enable=1, default_auth=0, front_display=1
+WHERE id=183;
+UPDATE sys_privilege
+SET name='填报', url='Fill', `type`='LINK', parent_id=42, `sequence`=1, property='AUTH', related='3042', enable=1, default_auth=0, front_display=1
+WHERE id=184;
+
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3041, 'sop申请接口', '/api/admin/sop/apply', 'URL', 40, 6, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3042, 'sop填报接口', '/api/admin/sop/approve', 'URL', 40, 7, 'AUTH', NULL, 1, 1, 0);
+INSERT INTO sys_privilege
+(id, name, url, `type`, parent_id, `sequence`, property, related, enable, default_auth, front_display)
+VALUES(3043, 'sop列表接口', '/api/admin/sop/list', 'URL', 40, 8, 'AUTH', NULL, 1, 1, 0);

+ 4 - 0
sop-business/src/main/resources/mapper/TBSopInfoMapper.xml

@@ -40,4 +40,8 @@
     <select id="selectDynamicSopAll" resultType="java.util.Map">
         SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME=#{tableName}
     </select>
+
+    <select id="list" resultType="java.util.Map">
+
+    </select>
 </mapper>

+ 19 - 0
sop-common/src/main/java/com/qmth/sop/common/contant/SystemConstant.java

@@ -98,11 +98,30 @@ public class SystemConstant {
     public static final String ERROR_METHOD = "method";
     public static final String LIST_JOIN_SPLIT = ",";
     public static final String JOB_DATA = "jobData";
+
+    /**
+     * 流程动态表单字段
+     */
+    //SOP
     public static final String SOP_DYNAMIC_TABLE_FILE_NAME = "db/dynamic_create_sop_table.sql";
     public static final String FLOW_DEPLOYMENT_ID_FIELD = "flow_deployment_id";
     public static final String VERSION = "version";
     public static final String CODE = "code";
     public static final String FLOW_ID = "flow_id";
+    public static final String REGION_USER_ID = "region_user_id";
+    public static final String ENGINEER_USER_ID = "engineer_user_id";
+    public static final String ASSISTANT_ENGINEER_USER_ID = "assistant_engineer_user_id";
+
+    //质量问题反馈
+    public static final String PROBLEM_POINT = "problem_point";
+    public static final String PROBLEM_REMARK = "problem_remark";
+    public static final String ATTACHMENT_INFO = "attachments_info";
+    public static final String PROBLEM_TYPE = "problem_type";
+    public static final String PROBLEM_REASON_RADIO = "problem_reason_radio";
+    public static final String PROBLEM_DEGREE_RADIO = "problem_degree_radio";
+    public static final String PROBLEM_USERS = "problem_users";
+    public static final String APPROVE_CHECK_USERS = "approve_check_users";
+    public static final String APPROVE_CHECK_THIRD_USERS = "approve_check_third_users";
 
     /**
      * 表达式

+ 4 - 0
sop-common/src/main/java/com/qmth/sop/common/enums/ExceptionResultEnum.java

@@ -79,6 +79,10 @@ public enum ExceptionResultEnum {
 
     PROJECT_EXCHANGE_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000026, "没有项目计划变更申请数据"),
 
+    SOP_INFO_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000027, "没有sop数据"),
+
+    QUALITY_PROBLEM_APPLY_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000027, "没有质量问题反馈申请数据"),
+
     /**
      * 401
      */

+ 11 - 3
sop-server/src/main/java/com/qmth/sop/server/api/TBQualityProblemApplyController.java

@@ -3,6 +3,7 @@ package com.qmth.sop.server.api;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.boot.api.constant.ApiConstant;
+import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.result.TBQualityProblemApplyResult;
 import com.qmth.sop.business.entity.TBQualityProblemApply;
 import com.qmth.sop.business.service.TBQualityProblemApplyService;
@@ -62,12 +63,19 @@ public class TBQualityProblemApplyController {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        if (tbQualityProblemApply.getFlowApprove() != FlowApprovePassEnum.START && tbQualityProblemApply.getFlowApprove() != FlowApprovePassEnum.DRAFT) {
-            throw ExceptionResultEnum.PARAMS_ERROR.exception("流程审批只能为提交或草稿");
-        }
         return ResultUtil.ok(tBQualityProblemApplyService.saveTBQualityProblemApply(tbQualityProblemApply));
     }
 
+    @ApiOperation(value = "质量问题反馈表审核接口")
+    @RequestMapping(value = "/approve", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result submit(@Valid @ApiParam(value = "sop填报信息", required = true) @RequestBody FlowApproveParam flowApproveParam, BindingResult bindingResult) throws InterruptedException {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok(tBQualityProblemApplyService.flowApprove(flowApproveParam));
+    }
+
     @ApiOperation(value = "质量问题反馈表删除接口")
     @RequestMapping(value = "/delete", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})

+ 43 - 6
sop-server/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -2,8 +2,11 @@ package com.qmth.sop.server.api;
 
 
 import com.qmth.boot.api.constant.ApiConstant;
-import com.qmth.sop.business.bean.dto.UserDto;
+import com.qmth.sop.business.bean.params.FlowApproveParam;
+import com.qmth.sop.business.bean.params.SopApplyParam;
+import com.qmth.sop.business.bean.params.SopInfoListParam;
 import com.qmth.sop.business.entity.TDFormWidgetMetadata;
+import com.qmth.sop.business.service.TBSopInfoService;
 import com.qmth.sop.business.service.TDFormWidgetMetadataService;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.TFCustomTypeEnum;
@@ -16,6 +19,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.validation.Valid;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * <p>
@@ -33,18 +37,51 @@ public class TBSopInfoController {
     @Resource
     TDFormWidgetMetadataService tdFormWidgetMetadataService;
 
+    @Resource
+    TBSopInfoService tbSopInfoService;
+
     @ApiOperation(value = "sop元数据查询")
     @RequestMapping(value = "/metadata/list", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = TDFormWidgetMetadata.class)})
     public Result list(@ApiParam(value = "sop流程类型", required = true) @RequestParam TFCustomTypeEnum type,
-                       @ApiParam(value = "sop流程版本", required = true) @RequestParam Integer version) {
-        return ResultUtil.ok(tdFormWidgetMetadataService.selectAll(type, version));
+                       @ApiParam(value = "sop流程版本") @RequestParam(required = false) Integer version) {
+        return ResultUtil.ok(tdFormWidgetMetadataService.selectAll(type, Objects.isNull(version) ? 1 : version));
     }
 
     @ApiOperation(value = "sop元数据修改")
     @RequestMapping(value = "/metadata/save", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = UserDto.class)})
-    public Result list(@Valid @ApiParam(value = "元数据保存信息", required = true) @RequestBody List<TDFormWidgetMetadata> tdFormWidgetMetadataList, BindingResult bindingResult) {
-        return ResultUtil.ok(tdFormWidgetMetadataService.save(tdFormWidgetMetadataList));
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result list(@Valid @ApiParam(value = "元数据保存信息", required = true) @RequestBody List<TDFormWidgetMetadata> formWidgetMetadataList, BindingResult bindingResult) {
+        return ResultUtil.ok(tdFormWidgetMetadataService.save(formWidgetMetadataList));
+    }
+
+    @ApiOperation(value = "sop申请")
+    @RequestMapping(value = "/apply", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result apply(@Valid @ApiParam(value = "sop申请信息", required = true) @RequestBody SopApplyParam sopApplyParam, BindingResult bindingResult) throws InterruptedException {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok(tbSopInfoService.sopApply(sopApplyParam));
+    }
+
+    @ApiOperation(value = "sop填报")
+    @RequestMapping(value = "/approve", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result approve(@Valid @ApiParam(value = "sop填报信息", required = true) @RequestBody FlowApproveParam flowApproveParam, BindingResult bindingResult) throws InterruptedException {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok(tbSopInfoService.sopApprove(flowApproveParam));
+    }
+
+    @ApiOperation(value = "sop列表接口")
+    @RequestMapping(value = "/list", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result list(@Valid @ApiParam(value = "sop列表信息", required = true) @RequestBody SopInfoListParam sopInfoListParam, BindingResult bindingResult) {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok(tbSopInfoService.list(sopInfoListParam));
     }
 }