Răsfoiți Sursa

新增sop发布

wangliang 1 an în urmă
părinte
comite
b3488594eb

+ 1 - 0
sop-business/src/main/java/com/qmth/sop/business/activiti/listener/ProcessEventListener.java

@@ -337,6 +337,7 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
             Optional.ofNullable(flowTaskSmsResult).orElseThrow(() -> ExceptionResultEnum.USER_NO_EXISTS.exception());
             Map<String, Object> templateParam = new HashMap<>();
             templateParam.put("userName", flowTaskSmsResult.getRealName());
+            templateParam.put("serviceName", flowTaskSmsResult.getServiceName());
             templateParam.put("customName", flowTaskSmsResult.getCustomName());
             templateParam.put("flowName", type.getTitle() + "【" + taskName + "】");
             smsSendUtil.sendSms(flowTaskSmsResult.getMobileNumber(), SystemConstant.SMS_SOP_DONE_CODE, templateParam);

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

@@ -1,11 +1,8 @@
 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;
 
 /**
@@ -22,21 +19,6 @@ public class SopApplyParam extends FlowApproveParam implements Serializable {
     @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;
     }
@@ -44,28 +26,4 @@ public class SopApplyParam extends FlowApproveParam implements Serializable {
     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;
-    }
 }

+ 29 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/SopPublishParam.java

@@ -0,0 +1,29 @@
+package com.qmth.sop.business.bean.params;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+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 SopPublishParam extends FlowApproveParam implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "sop单号")
+    private String sopNo;
+
+    public String getSopNo() {
+        return sopNo;
+    }
+
+    public void setSopNo(String sopNo) {
+        this.sopNo = sopNo;
+    }
+}

+ 25 - 1
sop-business/src/main/java/com/qmth/sop/business/entity/TBSopInfoDetail.java

@@ -29,6 +29,10 @@ public class TBSopInfoDetail implements Serializable {
     @JsonSerialize(using = ToStringSerializer.class)
     private Long sopInfoId;
 
+    @ApiModelProperty(value = "大区经理id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long leadId;
+
     @ApiModelProperty(value = "区域负责人id")
     @JsonSerialize(using = ToStringSerializer.class)
     private Long regionUserId;
@@ -44,14 +48,34 @@ public class TBSopInfoDetail implements Serializable {
 
     }
 
-    public TBSopInfoDetail(Long sopInfoId, Long regionUserId, Long engineerUserId, String assistantEngineerUserIds) {
+    public TBSopInfoDetail(Long sopInfoId, Long leadId) {
         this.id = SystemConstant.getDbUuid();
         this.sopInfoId = sopInfoId;
+        this.leadId = leadId;
+    }
+
+    public TBSopInfoDetail(Long leadId, Long regionUserId, Long engineerUserId, String assistantEngineerUserIds) {
+        this.id = SystemConstant.getDbUuid();
+        this.leadId = leadId;
+        this.regionUserId = regionUserId;
+        this.engineerUserId = engineerUserId;
+        this.assistantEngineerUserIds = assistantEngineerUserIds;
+    }
+
+    public void updateUserIdInfo(Long regionUserId, Long engineerUserId, String assistantEngineerUserIds) {
         this.regionUserId = regionUserId;
         this.engineerUserId = engineerUserId;
         this.assistantEngineerUserIds = assistantEngineerUserIds;
     }
 
+    public Long getLeadId() {
+        return leadId;
+    }
+
+    public void setLeadId(Long leadId) {
+        this.leadId = leadId;
+    }
+
     public Long getId() {
         return id;
     }

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

@@ -5,9 +5,11 @@ 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.params.SopPublishParam;
 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.common.enums.FlowApprovePassEnum;
 
 import java.util.Map;
 
@@ -51,6 +53,14 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      */
     int selectDynamicSop(String tableName, String flowDeploymentId, Long flowId);
 
+    /**
+     * sop发布信息
+     *
+     * @param sopPublishParam
+     * @return
+     */
+    Boolean sopPublish(SopPublishParam sopPublishParam) throws InterruptedException;
+
     /**
      * sop申请信息
      *
@@ -74,4 +84,17 @@ public interface TBSopInfoService extends IService<TBSopInfo> {
      * @return
      */
     IPage<Map> list(SopInfoListParam sopInfoListParam);
+
+    /**
+     * sop申请或发布
+     *
+     * @param sopNo
+     * @param crmNo
+     * @param flowDeploymentId
+     * @param approve
+     * @param formProperties
+     * @return
+     * @throws InterruptedException
+     */
+    public Boolean sopApplyOrPublish(String sopNo, String crmNo, String flowDeploymentId, FlowApprovePassEnum approve, String formProperties) throws InterruptedException;
 }

Fișier diff suprimat deoarece este prea mare
+ 0 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBQualityProblemApplyServiceImpl.java


+ 130 - 38
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -2,7 +2,6 @@ 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;
@@ -10,17 +9,19 @@ 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.params.SopPublishParam;
+import com.qmth.sop.business.bean.result.CrmProjectResult;
 import com.qmth.sop.business.bean.result.FlowFormWidgetResult;
 import com.qmth.sop.business.bean.result.FlowTaskResult;
 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.business.service.*;
 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.TFCustomTypeEnum;
 import com.qmth.sop.common.enums.WidgetCodeEnum;
+import com.qmth.sop.common.util.JacksonUtil;
 import com.qmth.sop.common.util.ServletUtil;
 import org.activiti.engine.TaskService;
 import org.activiti.engine.task.Task;
@@ -61,6 +62,12 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     @Resource
     TBSopInfoService tbSopInfoService;
 
+    @Resource
+    TBCrmService tbCrmService;
+
+    @Resource
+    TFCustomFlowService tfCustomFlowService;
+
     /**
      * 查询动态sop表名是否存在
      *
@@ -168,6 +175,23 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         return this.baseMapper.selectDynamicSop(tableName, flowDeploymentId, flowId);
     }
 
+    /**
+     * sop发布信息
+     *
+     * @param sopPublishParam
+     * @return
+     * @throws InterruptedException
+     */
+    @Override
+    @Transactional
+    public Boolean sopPublish(SopPublishParam sopPublishParam) throws InterruptedException {
+        Optional.ofNullable(sopPublishParam.getCrmNo()).orElseThrow(() -> ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空"));
+        if (sopPublishParam.getApprove() != FlowApprovePassEnum.DRAFT) {
+            throw ExceptionResultEnum.PARAMS_ERROR.exception("sop发布只能为草稿");
+        }
+        return tbSopInfoService.sopApplyOrPublish(sopPublishParam.getSopNo(), sopPublishParam.getCrmNo(), sopPublishParam.getFlowDeploymentId(), sopPublishParam.getApprove(), sopPublishParam.getFormProperties());
+    }
+
     /**
      * sop申请信息
      *
@@ -177,31 +201,16 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     @Override
     @Transactional
     public Boolean sopApply(SopApplyParam sopApplyParam) throws InterruptedException {
-        if (Objects.isNull(sopApplyParam.getCrmNo())) {
-            throw ExceptionResultEnum.PARAMS_ERROR.exception("crm编号不能为空");
-        }
+        Optional.ofNullable(sopApplyParam.getCrmNo()).orElseThrow(() -> 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);
-        Map<String, Object> mapVar = this.getApproveUserIds(flowTaskResult);
-        Long regionUserId = (Long) mapVar.get(SystemConstant.REGION_USER_ID);
-        Long engineerUserId = (Long) mapVar.get(SystemConstant.ENGINEER_USER_ID);
-        String assistantEngineerUserIds = (String) mapVar.get(SystemConstant.ASSISTANT_ENGINEER_USER_ID);
-
-        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);
+        return tbSopInfoService.sopApplyOrPublish(sopApplyParam.getSopNo(), sopApplyParam.getCrmNo(), sopApplyParam.getFlowDeploymentId(), sopApplyParam.getApprove(), sopApplyParam.getFormProperties());
+    }
 
-        tfCustomFlowEntity.setObjId(tbSopInfo.getId());
-        tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
-        return tbSopInfoService.save(tbSopInfo);
+    public static void main(String[] args) {
+        String s = "{\"taskName\":\"项目内审\",\"taskKey\":\"f_usertask_office_inside_approve_3\",\"setup\":3,\"formKey\":\"office_sop_inside_approve.form\",\"formProperty\":[{\"id\":\"51\",\"code\":\"FORM_GROUP_TITLE\",\"type\":\"FORM\",\"formId\":\"inside_title_3\",\"formName\":\"inside_title_3\",\"title\":\"项目内审(请于24小时内完成内审\",\"inputType\":\"STRING\",\"required\":false,\"readable\":true,\"writable\":false,\"visable\":true,\"name\":\"带虚线分割线的标题\",\"span\":12},{\"id\":\"52\",\"code\":\"RADIO\",\"type\":\"FORM\",\"formId\":\"approve_radio_3\",\"formName\":\"approve_radio_3\",\"title\":\"我对以上项目关键信息已审核,确认内容无误:\",\"inputType\":\"STRING\",\"required\":true,\"readable\":false,\"writable\":true,\"visable\":true,\"name\":\"单选框\",\"span\":12,\"options\":\"[{\\\"value\\\":\\\"1\\\",\\\"label\\\":\\\"同意\\\"},{\\\"value\\\":\\\"0\\\",\\\"label\\\":\\\"不同意\\\"}]\",\"value\":1},{\"id\":\"53\",\"code\":\"SIGN\",\"type\":\"FORM\",\"formId\":\"sign_3\",\"formName\":\"sign_3\",\"title\":\"添加签名\",\"inputType\":\"STRING\",\"required\":true,\"readable\":false,\"writable\":true,\"visable\":true,\"name\":\"签名\",\"span\":6,\"value\":\"呵呵\"},{\"id\":\"54\",\"code\":\"TEXTAREA\",\"type\":\"FORM\",\"formId\":\"approve_ramark_3\",\"formName\":\"approve_ramark_3\",\"title\":\"审批意见\",\"inputType\":\"STRING\",\"required\":false,\"readable\":false,\"writable\":true,\"visable\":true,\"name\":\"文本域\",\"span\":12,\"value\":\"1233456\"}],\"approveRejectList\":[{\"afterFlowTaskKey\":\"f_usertask_office_information_2\",\"beforeFlowTaskKey\":null,\"setup\":2}]}";
+        System.out.println(JacksonUtil.parseJson(s));
     }
 
     /**
@@ -233,9 +242,16 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         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());
 
+        TFCustomFlow tfCustomFlow = tfCustomFlowService.getById(tfCustomFlowEntity.gettFCustomFlowId());
+        Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_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());
 
+        TBSopInfoDetail tbSopInfoDetail = tbSopInfoDetailService.getOne(new QueryWrapper<TBSopInfoDetail>().lambda().eq(TBSopInfoDetail::getSopInfoId, tbSopInfo.getId()));
+        Optional.ofNullable(tbSopInfoDetail).orElseThrow(() -> ExceptionResultEnum.SOP_DETAIL_INFO_NO_DATA.exception());
+
+        //更新表单信息
         FlowTaskResult flowTaskResult = JSONObject.parseObject(flowApproveParam.getFormProperties(), FlowTaskResult.class);
         Long engineerUserId = null;
         if (flowTaskResult.getSetup().intValue() == 1) {
@@ -246,16 +262,12 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             engineerUserId = (Long) map.get(SystemConstant.ENGINEER_USER_ID);
             assistantEngineerUserIds = (String) map.get(SystemConstant.ASSISTANT_ENGINEER_USER_ID);
 
-            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);
+            tbSopInfoDetail.updateUserIdInfo(regionUserId, engineerUserId, assistantEngineerUserIds);
+            tbSopInfoDetailService.updateById(tbSopInfoDetail);
         } else {
             engineerUserId = Long.parseLong(taskApproveUserList.get(0));
         }
-        List<String> approveUserIds = Objects.nonNull(engineerUserId) ? Arrays.asList(String.valueOf(engineerUserId)) : Arrays.asList(String.valueOf(sysUser.getId()));
+        List<String> approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResult, tbSopInfoDetail);
         flowApproveParam.setApproveUserIds(approveUserIds);
         activitiService.taskApprove(flowApproveParam);
         tbSopInfo.updateInfo(sysUser.getId());
@@ -273,6 +285,34 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         return this.baseMapper.list(new Page<>(sopInfoListParam.getPageNumber(), sopInfoListParam.getPageSize()), sopInfoListParam.getServiceId(), sopInfoListParam.getFormWidgetMetadataList());
     }
 
+    /**
+     * 获取下一级审批人
+     *
+     * @param type
+     * @param flowTaskResult
+     * @param tbSopInfoDetail
+     * @return
+     */
+    public List<String> getNextApproveUserIds(TFCustomTypeEnum type, FlowTaskResult flowTaskResult, TBSopInfoDetail tbSopInfoDetail) {
+        List<String> approveUserIds = null;
+        if (type == TFCustomTypeEnum.OFFICE_SOP_FLOW) {//教务处sop流程待审核人
+            if (flowTaskResult.getSetup().intValue() == 1) {
+                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getRegionUserId()));
+            } else if (flowTaskResult.getSetup().intValue() == 2) {
+                approveUserIds = new ArrayList<>(2);
+                approveUserIds.add(String.valueOf(tbSopInfoDetail.getLeadId()));
+                approveUserIds.add(String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+            } else if (flowTaskResult.getSetup().intValue() == 3) {
+                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getLeadId()));
+            } else {
+                approveUserIds = Arrays.asList(String.valueOf(tbSopInfoDetail.getEngineerUserId()));
+            }
+        } else if (type == TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW) {//研究生sop流程待审核人
+
+        }
+        return approveUserIds;
+    }
+
     /**
      * 获取审批人
      *
@@ -299,15 +339,67 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
                 break;
             }
         }
-        if (Objects.isNull(regionUserId)) {
-            throw ExceptionResultEnum.ERROR.exception("区域协调人不能为空");
-        }
-        if (Objects.isNull(engineerUserId)) {
-            throw ExceptionResultEnum.ERROR.exception("实施工程师不能为空");
-        }
+        Optional.ofNullable(regionUserId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("区域协调人不能为空"));
+        Optional.ofNullable(engineerUserId).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("实施工程师不能为空"));
         map.put(SystemConstant.REGION_USER_ID, regionUserId);
         map.put(SystemConstant.ENGINEER_USER_ID, engineerUserId);
         map.put(SystemConstant.ASSISTANT_ENGINEER_USER_ID, assistantEngineerUserIds);
         return map;
     }
+
+    /**
+     * sop申请或发布
+     *
+     * @param sopNo
+     * @param crmNo
+     * @param flowDeploymentId
+     * @param approve
+     * @param formProperties
+     * @return
+     * @throws InterruptedException
+     */
+    @Override
+    @Transactional
+    public Boolean sopApplyOrPublish(String sopNo, String crmNo, String flowDeploymentId, FlowApprovePassEnum approve, String formProperties) throws InterruptedException {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(sopNo, crmNo);
+        Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("crm数据为空"));
+        Optional.ofNullable(crmProjectResult.getRegionManagerId()).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("crm大区经理数据为空"));
+
+        TFCustomFlow tfCustomFlow = null;
+        TBSopInfoDetail tbSopInfoDetail = null;
+        List<String> approveUserIds = new ArrayList<>();
+        if (approve == FlowApprovePassEnum.DRAFT) {
+            approveUserIds.add(String.valueOf(crmProjectResult.getRegionManagerId()));
+        } else if (approve == FlowApprovePassEnum.START) {
+            Optional.ofNullable(formProperties).orElseThrow(() -> ExceptionResultEnum.FLOW_FORM_PROPERTIES_IS_NULL.exception());
+
+            tfCustomFlow = tfCustomFlowService.getOne(new QueryWrapper<TFCustomFlow>().lambda().eq(TFCustomFlow::getFlowDeploymentId, flowDeploymentId));
+            Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
+
+            FlowTaskResult flowTaskResult = JSONObject.parseObject(formProperties, FlowTaskResult.class);
+            Map<String, Object> map = this.getApproveUserIds(flowTaskResult);
+            Long regionUserId = (Long) map.get(SystemConstant.REGION_USER_ID);
+            Long engineerUserId = (Long) map.get(SystemConstant.ENGINEER_USER_ID);
+            String assistantEngineerUserIds = (String) map.get(SystemConstant.ASSISTANT_ENGINEER_USER_ID);
+            tbSopInfoDetail = new TBSopInfoDetail(crmProjectResult.getRegionManagerId(), regionUserId, engineerUserId, assistantEngineerUserIds);
+            approveUserIds = this.getNextApproveUserIds(tfCustomFlow.getType(), flowTaskResult, tbSopInfoDetail);
+        }
+
+        Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(flowDeploymentId, approve, approveUserIds, crmNo, formProperties));
+        tfCustomFlow = Objects.isNull(tfCustomFlow) ? (TFCustomFlow) map.get(SystemConstant.FLOW_CUSTOM) : tfCustomFlow;
+        TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
+
+        TBSopInfo tbSopInfo = new TBSopInfo(crmNo, tfCustomFlowEntity.getCode(), crmProjectResult.getServiceUnitId(), crmProjectResult.getCustomId(), crmProjectResult.getProductId(), tfCustomFlow.getType(), sysUser.getId());
+        if (Objects.isNull(tbSopInfoDetail)) {
+            tbSopInfoDetail = new TBSopInfoDetail(tbSopInfo.getId(), crmProjectResult.getRegionManagerId());
+        } else {
+            tbSopInfoDetail.setSopInfoId(tbSopInfo.getId());
+        }
+        tbSopInfoDetailService.save(tbSopInfoDetail);
+
+        tfCustomFlowEntity.setObjId(tbSopInfo.getId());
+        tfCustomFlowEntityService.updateById(tfCustomFlowEntity);
+        return tbSopInfoService.save(tbSopInfo);
+    }
 }

+ 9 - 0
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -1074,3 +1074,12 @@ VALUES(3044, '质量问题反馈审核', '/api/admin/tb/quality/problem/apply/ap
 
 --2023.9.5update
 ALTER TABLE t_b_project_exchange MODIFY COLUMN enable tinyint DEFAULT 1 NOT NULL COMMENT '是否启用,0:停用,1:启用';
+
+--2023.9.6update
+ALTER TABLE t_b_sop_info_detail ADD lead_id BIGINT COMMENT '大区经理id' NOT NULL after sop_info_id;
+
+ALTER TABLE t_b_sop_info_detail CHANGE COLUMN region_user_id region_user_id BIGINT
+    COMMENT '区域负责人id' NULL;
+
+ALTER TABLE t_b_sop_info_detail CHANGE COLUMN engineer_user_id engineer_user_id BIGINT
+    COMMENT '实施工程师id' NULL;

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

@@ -91,6 +91,8 @@ public enum ExceptionResultEnum {
 
     FLOW_REJECT_SETUP_IS_NULL(HttpStatus.INTERNAL_SERVER_ERROR, 5000032, "驳回步骤未填写"),
 
+    SOP_DETAIL_INFO_NO_DATA(HttpStatus.INTERNAL_SERVER_ERROR, 5000033, "没有sop明细数据"),
+
     /**
      * 401
      */

+ 11 - 0
sop-server/src/main/java/com/qmth/sop/server/api/TBSopInfoController.java

@@ -5,6 +5,7 @@ import com.qmth.boot.api.constant.ApiConstant;
 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.params.SopPublishParam;
 import com.qmth.sop.business.entity.TDFormWidgetMetadata;
 import com.qmth.sop.business.service.TBSopInfoService;
 import com.qmth.sop.business.service.TDFormWidgetMetadataService;
@@ -55,6 +56,16 @@ public class TBSopInfoController {
         return ResultUtil.ok(tdFormWidgetMetadataService.save(formWidgetMetadataList));
     }
 
+    @ApiOperation(value = "sop发布")
+    @RequestMapping(value = "/publish", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
+    public Result publish(@Valid @ApiParam(value = "sop发布信息", required = true) @RequestBody SopPublishParam sopPublishParam, BindingResult bindingResult) throws InterruptedException {
+        if (bindingResult.hasErrors()) {
+            return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
+        }
+        return ResultUtil.ok(tbSopInfoService.sopPublish(sopPublishParam));
+    }
+
     @ApiOperation(value = "sop申请")
     @RequestMapping(value = "/apply", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})

+ 5 - 1
sop-server/src/main/resources/officeSopFlow.bpmn

@@ -1,7 +1,11 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" xmlns:tns="http://www.activiti.org/test" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test" id="m1626068475250" name="">
   <process id="OFFICE_SOP_FLOW" isExecutable="true" isClosed="false" processType="None">
-    <userTask id="f_usertask_office_inside_approve_3" name="项目内审" activiti:candidateUsers="${assigneeList3}" activiti:formKey="office_sop_inside_approve.form"></userTask>
+    <userTask id="f_usertask_office_inside_approve_3" name="项目内审" activiti:assignee="${assignee3}" activiti:formKey="office_sop_inside_approve.form">
+      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${assigneeList3}" activiti:elementVariable="assignee3">
+        <completionCondition>${nrOfCompletedInstances/nrOfInstances==1 || reject3==1}</completionCondition>
+      </multiInstanceLoopCharacteristics>
+    </userTask>
     <endEvent id="f_usertask_office_end_0" name="结束"></endEvent>
     <userTask id="f_usertask_office_information_2" name="项目关键信息" activiti:candidateUsers="${assigneeList2}" activiti:formKey="office_sop_information.form"></userTask>
     <startEvent id="startevent1" name="Start" activiti:formKey="office_sop_start.form"></startEvent>

BIN
sop-server/src/main/resources/officeSopFlow.zip


Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff