wangliang пре 1 година
родитељ
комит
326b40fa6c

+ 10 - 3
sop-business/src/main/java/com/qmth/sop/business/activiti/listener/ProcessEventListener.java

@@ -20,6 +20,7 @@ import org.activiti.engine.delegate.event.ActivitiEntityEvent;
 import org.activiti.engine.delegate.event.ActivitiEvent;
 import org.activiti.engine.delegate.event.ActivitiEventListener;
 import org.activiti.engine.impl.persistence.entity.ResourceEntity;
+import org.activiti.engine.task.IdentityLink;
 import org.activiti.engine.task.Task;
 import org.dom4j.*;
 import org.slf4j.Logger;
@@ -80,10 +81,16 @@ public class ProcessEventListener implements ActivitiEventListener, Serializable
                         if (tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.DRAFT
                                 && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.END
                                 && tfFlowLog.getApproveOperation() != FlowApproveOperationEnum.FINISH) {
-                            String[] strs = tfFlowLog.getPendApproveId().split(SystemConstant.LIST_JOIN_SPLIT);
                             List<TSJobRemind> tsJobRemindArrayList = new ArrayList<>();
-                            for (int i = 0; i < strs.length; i++) {
-                                tsJobRemindArrayList.add(new TSJobRemind(tfCustomFlowEntity.getCode(), Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle(), JobTypeEnum.AFTER, Long.parseLong(strs[i]), tfFlowLog.getApproveOperation(), sysUser.getId()));
+                            if (Objects.nonNull(task.getAssignee())) {
+                                tsJobRemindArrayList.add(new TSJobRemind(tfCustomFlowEntity.getCode(), Long.parseLong(task.getId()), tfCustomFlow.getType().getTitle(), JobTypeEnum.AFTER, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(), sysUser.getId()));
+                            } else {
+                                List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
+                                if (!CollectionUtils.isEmpty(identityLinkList)) {
+                                    for (IdentityLink i : identityLinkList) {
+                                        tsJobRemindArrayList.add(new TSJobRemind(tfCustomFlowEntity.getCode(), Long.parseLong(i.getUserId()), tfCustomFlow.getType().getTitle(), JobTypeEnum.AFTER, Long.parseLong(task.getAssignee()), tfFlowLog.getApproveOperation(), sysUser.getId()));
+                                    }
+                                }
                             }
                             jobRemindService.saveJobRemind(tsJobRemindArrayList);
                         }

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

@@ -31,6 +31,7 @@ import org.activiti.engine.history.HistoricTaskInstance;
 import org.activiti.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior;
 import org.activiti.engine.repository.DeploymentBuilder;
 import org.activiti.engine.runtime.ProcessInstance;
+import org.activiti.engine.task.IdentityLink;
 import org.activiti.engine.task.Task;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -185,7 +186,7 @@ public class ActivitiServiceImpl implements ActivitiService {
             Optional.ofNullable(tfCustomFlow).orElseThrow(() -> ExceptionResultEnum.FLOW_CUSTOM_NO_DATA.exception());
             Optional.ofNullable(tfCustomFlow.getFlowProcessVar()).orElseThrow(() -> ExceptionResultEnum.FLOW_PROCESS_VAR_NO_DATA.exception());
 
-            map.put(SystemConstant.DEFAULT_ASSIGNEE_LIST + 1, approveUserIds);
+            map.put(SystemConstant.DEFAULT_ASSIGNEE_LIST + 1, Arrays.asList(String.valueOf(sysUser.getId())));
             ProcessInstance processInstance = runtimeService.startProcessInstanceById(tfCustomFlow.getFlowDefinitionId(), map);
             processFlowId = processInstance.getId();
 
@@ -340,6 +341,27 @@ public class ActivitiServiceImpl implements ActivitiService {
                         taskService.setVariable(task.getId(), SystemConstant.FLOW_APPROVE_LOG, tfFlowLog);
                         taskService.setVariable(task.getId(), SystemConstant.FLOW_SYS_USER, sysUser);
                         taskService.complete(task.getId(), map);
+                        if (flowApproveParam.getApprove() == FlowApprovePassEnum.START || flowApproveParam.getApprove() == FlowApprovePassEnum.PASS) {
+                            List<Task> tasks = taskService.createTaskQuery().processInstanceId(processFlowId).list();
+                            if (!CollectionUtils.isEmpty(tasks)) {
+                                Set<String> approveIdSet = new LinkedHashSet<>();
+                                for (Task t : tasks) {
+                                    if (Objects.isNull(t.getAssignee())) {
+                                        List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(t.getId());
+                                        if (!CollectionUtils.isEmpty(identityLinkList)) {
+                                            for (IdentityLink i : identityLinkList) {
+                                                approveIdSet.add(i.getUserId());
+                                            }
+                                        }
+                                    } else {
+                                        approveIdSet.add(t.getAssignee());
+                                    }
+                                }
+                                tfFlowLog.setPendApproveId(approveIdSet.toString().replaceAll("\\[", "").replaceAll("\\]", ""));
+                            } else {
+                                tfFlowLog.setPendApproveId(null);
+                            }
+                        }
                     }
                     map.put(SystemConstant.FLOW_APPROVE_LOG, tfFlowLog);
                     tfFlowLogList.add(tfFlowLog);

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

@@ -73,6 +73,11 @@ public class TBDingApply implements Serializable {
     @NotNull(message = "流程部署id不能为空")
     private String flowDeploymentId;
 
+    @ApiModelProperty(value = "流程审批人")
+    @TableField(exist = false)
+    @JsonSerialize(using = ToStringSerializer.class)
+    private List<String> approveUserIds;
+
     public void setCode(String dingExceptionNo, List<Long> attachmentIdList, Long userId) {
         this.dingExceptionNo = dingExceptionNo;
         setId(SystemConstant.getDbUuid());
@@ -81,6 +86,14 @@ public class TBDingApply implements Serializable {
         this.attachmentIds = StringUtils.join(attachmentIdList, SystemConstant.LIST_JOIN_SPLIT);
     }
 
+    public List<String> getApproveUserIds() {
+        return approveUserIds;
+    }
+
+    public void setApproveUserIds(List<String> approveUserIds) {
+        this.approveUserIds = approveUserIds;
+    }
+
     public List<Long> getAttachmentIdList() {
         return attachmentIdList;
     }

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

@@ -17,6 +17,7 @@ import com.qmth.sop.common.enums.FlowApprovePassEnum;
 import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import javax.annotation.Resource;
 import java.util.Arrays;
@@ -57,7 +58,7 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         TBDing tbDing = tbDingService.getById(tbDingApply.getDingId());
         Optional.ofNullable(tbDing).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("考勤记录为空"));
 
-        Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(tbDingApply.getFlowDeploymentId(), FlowApprovePassEnum.START, Arrays.asList(String.valueOf(sysUser.getId())), tbDing.getCrmNo()));
+        Map<String, Object> map = activitiService.taskApprove(new FlowApproveParam(tbDingApply.getFlowDeploymentId(), FlowApprovePassEnum.START, !CollectionUtils.isEmpty(tbDingApply.getApproveUserIds()) ? tbDingApply.getApproveUserIds() : Arrays.asList(String.valueOf(sysUser.getId())), tbDing.getCrmNo()));
         TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
         tbDingApply.setCode(tfCustomFlowEntity.getCode(), tbDingApply.getAttachmentIdList(), sysUser.getId());
         tfCustomFlowEntity.setObjId(tbDingApply.getId());

+ 7 - 32
sop-server/src/main/resources/dingExceptionFlow.bpmn

@@ -14,23 +14,16 @@
       </multiInstanceLoopCharacteristics>
     </userTask>
     <sequenceFlow id="flow6" sourceRef="startevent1" targetRef="f_usertask_ding_exception_apply_1"></sequenceFlow>
-    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
     <sequenceFlow id="flow14" sourceRef="f_usertask_ding_exception_apply_1" targetRef="f_usertask_ding_exception_approve_2"></sequenceFlow>
-    <sequenceFlow id="flow15" name="驳回" sourceRef="exclusivegateway2" targetRef="f_usertask_ding_exception_apply_1">
-      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approve == 'f_usertask_ding_exception_apply_1'}]]></conditionExpression>
-    </sequenceFlow>
-    <sequenceFlow id="flow16" sourceRef="f_usertask_ding_exception_approve_2" targetRef="exclusivegateway2"></sequenceFlow>
-    <sequenceFlow id="flow17" name="通过" sourceRef="exclusivegateway2" targetRef="f_usertask_ding_exception_end_0">
-      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approve == 'f_usertask_ding_exception_end_0'}]]></conditionExpression>
-    </sequenceFlow>
+    <sequenceFlow id="flow18" sourceRef="f_usertask_ding_exception_approve_2" targetRef="f_usertask_ding_exception_end_0"></sequenceFlow>
   </process>
   <bpmndi:BPMNDiagram id="BPMNDiagram_DING_EXCEPTION_FLOW">
     <bpmndi:BPMNPlane bpmnElement="DING_EXCEPTION_FLOW" id="BPMNPlane_DING_EXCEPTION_FLOW">
       <bpmndi:BPMNShape bpmnElement="f_usertask_ding_exception_end_0" id="BPMNShape_f_usertask_ding_exception_end_0">
-        <omgdc:Bounds height="35.0" width="35.0" x="475.0" y="360.0"></omgdc:Bounds>
+        <omgdc:Bounds height="35.0" width="35.0" x="240.0" y="370.0"></omgdc:Bounds>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape bpmnElement="f_usertask_ding_exception_approve_2" id="BPMNShape_f_usertask_ding_exception_approve_2">
-        <omgdc:Bounds height="55.0" width="85.0" x="450.0" y="130.0"></omgdc:Bounds>
+        <omgdc:Bounds height="55.0" width="85.0" x="215.0" y="240.0"></omgdc:Bounds>
       </bpmndi:BPMNShape>
       <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
         <omgdc:Bounds height="35.0" width="35.0" x="240.0" y="40.0"></omgdc:Bounds>
@@ -38,35 +31,17 @@
       <bpmndi:BPMNShape bpmnElement="f_usertask_ding_exception_apply_1" id="BPMNShape_f_usertask_ding_exception_apply_1">
         <omgdc:Bounds height="55.0" width="85.0" x="215.0" y="130.0"></omgdc:Bounds>
       </bpmndi:BPMNShape>
-      <bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
-        <omgdc:Bounds height="40.0" width="40.0" x="472.0" y="240.0"></omgdc:Bounds>
-      </bpmndi:BPMNShape>
       <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
         <omgdi:waypoint x="257.0" y="75.0"></omgdi:waypoint>
         <omgdi:waypoint x="257.0" y="130.0"></omgdi:waypoint>
       </bpmndi:BPMNEdge>
       <bpmndi:BPMNEdge bpmnElement="flow14" id="BPMNEdge_flow14">
-        <omgdi:waypoint x="300.0" y="157.0"></omgdi:waypoint>
-        <omgdi:waypoint x="450.0" y="157.0"></omgdi:waypoint>
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge bpmnElement="flow15" id="BPMNEdge_flow15">
-        <omgdi:waypoint x="472.0" y="260.0"></omgdi:waypoint>
-        <omgdi:waypoint x="257.0" y="260.0"></omgdi:waypoint>
         <omgdi:waypoint x="257.0" y="185.0"></omgdi:waypoint>
-        <bpmndi:BPMNLabel>
-          <omgdc:Bounds height="16.0" width="22.0" x="472.0" y="260.0"></omgdc:Bounds>
-        </bpmndi:BPMNLabel>
-      </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge bpmnElement="flow16" id="BPMNEdge_flow16">
-        <omgdi:waypoint x="492.0" y="185.0"></omgdi:waypoint>
-        <omgdi:waypoint x="492.0" y="240.0"></omgdi:waypoint>
+        <omgdi:waypoint x="257.0" y="240.0"></omgdi:waypoint>
       </bpmndi:BPMNEdge>
-      <bpmndi:BPMNEdge bpmnElement="flow17" id="BPMNEdge_flow17">
-        <omgdi:waypoint x="492.0" y="280.0"></omgdi:waypoint>
-        <omgdi:waypoint x="492.0" y="360.0"></omgdi:waypoint>
-        <bpmndi:BPMNLabel>
-          <omgdc:Bounds height="16.0" width="22.0" x="492.0" y="280.0"></omgdc:Bounds>
-        </bpmndi:BPMNLabel>
+      <bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
+        <omgdi:waypoint x="257.0" y="295.0"></omgdi:waypoint>
+        <omgdi:waypoint x="257.0" y="370.0"></omgdi:waypoint>
       </bpmndi:BPMNEdge>
     </bpmndi:BPMNPlane>
   </bpmndi:BPMNDiagram>

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