From 093b73aadb022895a02dbbcd64b87613e19b547b Mon Sep 17 00:00:00 2001
From: 1098226878@qq.com <1098226878@qq.com>
Date: 星期一, 10 一月 2022 18:05:21 +0800
Subject: [PATCH] Merge branch 'master' of http://git.homecommunity.cn/supervip/MicroCommunity

---
 service-common/src/main/java/com/java110/common/smo/impl/ContractApplyUserInnerServiceSMOImpl.java |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/service-common/src/main/java/com/java110/common/smo/impl/ContractApplyUserInnerServiceSMOImpl.java b/service-common/src/main/java/com/java110/common/smo/impl/ContractApplyUserInnerServiceSMOImpl.java
index 4080f70..5c6edc0 100644
--- a/service-common/src/main/java/com/java110/common/smo/impl/ContractApplyUserInnerServiceSMOImpl.java
+++ b/service-common/src/main/java/com/java110/common/smo/impl/ContractApplyUserInnerServiceSMOImpl.java
@@ -4,6 +4,7 @@
 import com.java110.core.base.smo.BaseServiceSMO;
 import com.java110.dto.PageDto;
 import com.java110.dto.contract.ContractDto;
+import com.java110.dto.purchaseApply.PurchaseApplyDto;
 import com.java110.dto.workflow.WorkflowDto;
 import com.java110.entity.audit.AuditUser;
 import com.java110.intf.common.IContractApplyUserInnerServiceSMO;
@@ -18,6 +19,7 @@
 import org.activiti.engine.history.HistoricProcessInstance;
 import org.activiti.engine.history.HistoricTaskInstance;
 import org.activiti.engine.history.HistoricTaskInstanceQuery;
+import org.activiti.engine.impl.identity.Authentication;
 import org.activiti.engine.query.Query;
 import org.activiti.engine.runtime.ProcessInstance;
 import org.activiti.engine.task.Task;
@@ -60,9 +62,10 @@
         //灏嗕俊鎭姞鍏ap,浠ヤ究浼犲叆娴佺▼涓�
         Map<String, Object> variables = new HashMap<String, Object>();
         variables.put("contractDto", contractDto);
-
+        variables.put("userId", contractDto.getCurrentUserId());
+        variables.put("startUserId", contractDto.getCurrentUserId());
         //寮�鍚祦绋�
-        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(getWorkflowDto(contractDto.getStoreId()), variables);
+        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(getWorkflowDto(contractDto.getStoreId()),contractDto.getContractId(), variables);
         //灏嗗緱鍒扮殑瀹炰緥娴佺▼id鍊艰祴缁欎箣鍓嶈缃殑鍙橀噺
         String processInstanceId = processInstance.getId();
         // System.out.println("娴佺▼寮�鍚垚鍔�.......瀹炰緥娴佺▼id:" + processInstanceId);
@@ -70,6 +73,7 @@
         contractDto.setProcessInstanceId(processInstanceId);
 
         return contractDto;
+
     }
 
     /**
@@ -172,7 +176,7 @@
         workflowDto.setFlowType(WorkflowDto.FLOW_TYPE_CONTRACT_APPLY);
         workflowDto.setStoreId(storeId);
         List<WorkflowDto> workflowDtos = workflowInnerServiceSMOImpl.queryWorkflows(workflowDto);
-        Assert.listOnlyOne(workflowDtos, "鏈壘鍒� 鎶曡瘔寤鸿娴佺▼鎴栨壘鍒板鏉★紝璇峰湪鐗╀笟璐﹀彿绯荤粺绠$悊涓嬫祦绋嬬鐞嗕腑閰嶇疆娴佺▼");
+        Assert.listOnlyOne(workflowDtos, "鏈壘鍒� 鍚堝悓璧疯崏缁娴佺▼鎴栨壘鍒板鏉★紝璇峰湪鐗╀笟璐﹀彿绯荤粺绠$悊涓嬫祦绋嬬鐞嗕腑閰嶇疆娴佺▼");
 
         WorkflowDto tmpWorkflowDto = workflowDtos.get(0);
         if (StringUtil.isEmpty(tmpWorkflowDto.getProcessDefinitionKey())) {
@@ -259,4 +263,25 @@
         return tmpContractDtos;
     }
 
+
+    public boolean completeTask(@RequestBody ContractDto contractDto) {
+        TaskService taskService = processEngine.getTaskService();
+        Task task = taskService.createTaskQuery().taskId(contractDto.getTaskId()).singleResult();
+        String processInstanceId = task.getProcessInstanceId();
+        Authentication.setAuthenticatedUserId(contractDto.getCurrentUserId());
+        taskService.addComment(contractDto.getTaskId(), processInstanceId, contractDto.getAuditMessage());
+        Map<String, Object> variables = new HashMap<String, Object>();
+        variables.put("auditCode", contractDto.getAuditCode());
+        variables.put("currentUserId", contractDto.getCurrentUserId());
+        variables.put("flag", "1200".equals(contractDto.getAuditCode()) ? "false" : "true");
+        variables.put("startUserId", contractDto.getStartUserId());
+        taskService.complete(contractDto.getTaskId(), variables);
+
+        ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
+        if (pi == null) {
+            return true;
+        }
+        return false;
+    }
+
 }

--
Gitblit v1.8.0