| | |
| | | import com.java110.intf.common.IContractApplyUserInnerServiceSMO; |
| | | import com.java110.intf.common.IWorkflowInnerServiceSMO; |
| | | import com.java110.intf.store.IContractInnerServiceSMO; |
| | | import com.java110.po.contract.ContractPo; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.activiti.engine.HistoryService; |
| | |
| | | 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; |
| | |
| | | //将信息加入map,以便传入流程中 |
| | | 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); |
| | |
| | | contractDto.setProcessInstanceId(processInstanceId); |
| | | |
| | | return contractDto; |
| | | |
| | | } |
| | | |
| | | /** |
| | |
| | | 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())) { |
| | |
| | | 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; |
| | | } |
| | | |
| | | //删除任务 |
| | | public boolean deleteTask(@RequestBody ContractPo contractDto) { |
| | | TaskService taskService = processEngine.getTaskService(); |
| | | |
| | | TaskQuery query = taskService.createTaskQuery().processInstanceBusinessKey(contractDto.getContractId()); |
| | | query.orderByTaskCreateTime().desc(); |
| | | List<Task> list = query.list(); |
| | | |
| | | if (list == null || list.size() < 1) { |
| | | return true; |
| | | } |
| | | |
| | | for (Task task : list) { |
| | | String processInstanceId = task.getProcessInstanceId(); |
| | | //3.使用流程实例,查询 |
| | | runtimeService.deleteProcessInstance(processInstanceId, "取消合同"); |
| | | |
| | | } |
| | | |
| | | return true; |
| | | } |
| | | |
| | | |
| | | } |