| | |
| | | |
| | | |
| | | import com.java110.core.base.smo.BaseServiceSMO; |
| | | import com.java110.core.smo.audit.IAuditUserInnerServiceSMO; |
| | | import com.java110.core.smo.complaint.IComplaintInnerServiceSMO; |
| | | import com.java110.core.smo.purchaseApplyUser.IPurchaseApplyUserInnerServiceSMO; |
| | | import com.java110.core.smo.user.IUserInnerServiceSMO; |
| | | import com.java110.dto.PageDto; |
| | | import com.java110.dto.auditMessage.AuditMessageDto; |
| | | import com.java110.dto.auditUser.AuditUserDto; |
| | | import com.java110.dto.complaint.ComplaintDto; |
| | | import com.java110.dto.purchaseApply.PurchaseApplyDto; |
| | | import com.java110.dto.user.UserDto; |
| | | import com.java110.entity.audit.AuditUser; |
| | | import com.java110.utils.util.Assert; |
| | | import com.java110.utils.util.Base64Convert; |
| | | import com.java110.utils.util.DateUtil; |
| | | import com.java110.utils.util.StringUtil; |
| | | import org.activiti.bpmn.model.BpmnModel; |
| | | import org.activiti.engine.HistoryService; |
| | | import org.activiti.engine.ProcessEngine; |
| | | import org.activiti.engine.RepositoryService; |
| | | import org.activiti.engine.RuntimeService; |
| | | import org.activiti.engine.TaskService; |
| | | import org.activiti.engine.history.HistoricProcessInstance; |
| | |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | private TaskService taskService; |
| | | |
| | | @Autowired |
| | | private HistoryService historyService; |
| | | |
| | | @Autowired |
| | | private RepositoryService repositoryService; |
| | | |
| | | |
| | | @Autowired |
| | | private IUserInnerServiceSMO userInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IComplaintInnerServiceSMO complaintInnerServiceSMOImpl; |
| | | |
| | | @Autowired |
| | | private IAuditUserInnerServiceSMO auditUserInnerServiceSMOImpl; |
| | | |
| | | /** |
| | | * 启动流程 |
| | |
| | | //将信息加入map,以便传入流程中 |
| | | Map<String, Object> variables = new HashMap<String, Object>(); |
| | | variables.put("purchaseApplyDto", purchaseApplyDto); |
| | | variables.put("nextAuditStaffId",purchaseApplyDto.getStaffId()); |
| | | variables.put("userId", purchaseApplyDto.getCurrentUserId()); |
| | | //开启流程 |
| | | ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("resourceEntry", purchaseApplyDto.getApplyOrderId(), variables); |
| | | //将得到的实例流程id值赋给之前设置的变量 |
| | | // //将得到的实例流程id值赋给之前设置的变量 |
| | | String processInstanceId = processInstance.getId(); |
| | | // System.out.println("流程开启成功.......实例流程id:" + processInstanceId); |
| | | |
| | | // // System.out.println("流程开启成功.......实例流程id:" + processInstanceId); |
| | | // |
| | | purchaseApplyDto.setProcessInstanceId(processInstanceId); |
| | | //第一个节点自动提交 |
| | | autoFinishFirstTask(purchaseApplyDto); |
| | | return purchaseApplyDto; |
| | | } |
| | |
| | | Task task = null; |
| | | TaskQuery query = taskService.createTaskQuery().taskCandidateOrAssigned(purchaseApplyDto.getCurrentUserId()).active(); |
| | | List<Task> todoList = query.list();//获取申请人的待办任务列表 |
| | | List<Task> list = taskService.createTaskQuery().list(); |
| | | |
| | | for (Task tmp : todoList) { |
| | | if (tmp.getProcessInstanceId().equals(purchaseApplyDto.getProcessInstanceId())) { |
| | | task = tmp;//获取当前流程实例,当前申请人的待办任务 |
| | |
| | | HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery() |
| | | .processDefinitionKey("resourceEnter") |
| | | .taskAssignee(user.getUserId()); |
| | | if(!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())){ |
| | | if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) { |
| | | historicTaskInstanceQuery.taskName("resourceEnter"); |
| | | }else if(!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())){ |
| | | } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) { |
| | | historicTaskInstanceQuery.taskName("resourceEnterDealUser"); |
| | | } |
| | | |
| | |
| | | |
| | | HistoricTaskInstanceQuery historicTaskInstanceQuery = historyService.createHistoricTaskInstanceQuery() |
| | | .processDefinitionKey("resourceEnter") |
| | | .taskAssignee(user.getUserId()) ; |
| | | if(!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())){ |
| | | .taskAssignee(user.getUserId()); |
| | | if (!StringUtil.isEmpty(user.getAuditLink()) && "START".equals(user.getAuditLink())) { |
| | | historicTaskInstanceQuery.taskName("resourceEnter"); |
| | | }else if(!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())){ |
| | | } else if (!StringUtil.isEmpty(user.getAuditLink()) && "AUDIT".equals(user.getAuditLink())) { |
| | | historicTaskInstanceQuery.taskName("resourceEnterDealUser"); |
| | | } |
| | | |
| | |
| | | Map<String, Object> variables = new HashMap<String, Object>(); |
| | | variables.put("auditCode", purchaseApplyDto.getAuditCode()); |
| | | variables.put("currentUserId", purchaseApplyDto.getCurrentUserId()); |
| | | variables.put("nextAuditStaffId",purchaseApplyDto.getStaffId()); |
| | | //taskService.setAssignee(complaintDto.getTaskId(),complaintDto.getCurrentUserId()); |
| | | //taskService.addCandidateUser(complaintDto.getTaskId(), complaintDto.getCurrentUserId()); |
| | | //taskService.claim(complaintDto.getTaskId(), complaintDto.getCurrentUserId()); |
| | | taskService.complete(purchaseApplyDto.getTaskId(), variables); |
| | | //taskService.setVariable(purchaseApplyDto.getTaskId(), "purchaseApplyDto", purchaseApplyDto); |
| | | |
| | | ProcessInstance pi = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult(); |
| | | if (pi == null) { |
| | |
| | | return auditMessageDtos; |
| | | } |
| | | |
| | | /** |
| | | * 获取任务当前处理人 |
| | | * |
| | | * @param purchaseApplyDto |
| | | * @return |
| | | */ |
| | | public PurchaseApplyDto getTaskCurrentUser(@RequestBody PurchaseApplyDto purchaseApplyDto) { |
| | | |
| | | TaskService taskService = processEngine.getTaskService(); |
| | | Task task = taskService.createTaskQuery().processInstanceBusinessKey(purchaseApplyDto.getApplyOrderId()).singleResult(); |
| | | |
| | | if (task == null) { |
| | | purchaseApplyDto.setStaffId(""); |
| | | purchaseApplyDto.setStaffName(""); |
| | | purchaseApplyDto.setStaffTel(""); |
| | | return purchaseApplyDto; |
| | | } |
| | | |
| | | String userId = task.getAssignee(); |
| | | List<UserDto> users = userInnerServiceSMOImpl.getUserInfo(new String[]{userId}); |
| | | |
| | | if (users == null || users.size() == 0) { |
| | | purchaseApplyDto.setStaffId(""); |
| | | purchaseApplyDto.setStaffName(""); |
| | | purchaseApplyDto.setStaffTel(""); |
| | | return purchaseApplyDto; |
| | | } |
| | | |
| | | purchaseApplyDto.setCurrentUserId(userId); |
| | | purchaseApplyDto.setStaffName(users.get(0).getName()); |
| | | purchaseApplyDto.setStaffTel(users.get(0).getTel()); |
| | | return purchaseApplyDto; |
| | | |
| | | } |
| | | |
| | | |
| | | |