|
|
@@ -18,6 +18,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.common.workflow.service.dto.ActiHistoricTaskDTO;
|
|
|
import com.common.workflow.service.dto.ActiMyTaskDTO;
|
|
|
+import com.common.workflow.service.dto.ActiPageResultDTO;
|
|
|
import com.common.workflow.web.rest.vm.ActiCompleteVM;
|
|
|
import com.common.workflow.web.rest.vm.MultiActiCompleteVM;
|
|
|
import com.common.workflow.web.rest.vm.MultiOrgAuditVM;
|
|
|
@@ -71,6 +72,24 @@ public class ActivitiService {
|
|
|
return processInstance.getProcessInstanceId();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 启动流程
|
|
|
+ * @param businessKey 业务id
|
|
|
+ */
|
|
|
+ public String startProcesses(String processKey, String businessKey, String userNames, String result, String type, String supplierName) {
|
|
|
+
|
|
|
+ Map<String, Object> variables = new HashMap<String, Object>();
|
|
|
+ variables.put("businessKey", businessKey);
|
|
|
+ variables.put("recorder", userNames);
|
|
|
+ variables.put("result", result);
|
|
|
+ variables.put("type", type);
|
|
|
+ variables.put("supplierName", supplierName);
|
|
|
+
|
|
|
+ ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processKey, variables);
|
|
|
+ System.out.println("流程启动成功,流程id:"+processInstance.getId());
|
|
|
+ return processInstance.getProcessInstanceId();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* <p>描述: 根据工作流Key, 用户id, 业务表Key 查询待办任务列表</p>
|
|
|
@@ -234,6 +253,41 @@ public class ActivitiService {
|
|
|
return myTaskDTOS;
|
|
|
}
|
|
|
|
|
|
+ public ActiPageResultDTO findAllTypePagingTasksWithCreateTimeByUserId(String userId, int pageIndex, int pageSize, String wfName, String type, String supplierName) {
|
|
|
+ TaskQuery taskQuery = taskService.createTaskQuery().taskCandidateOrAssigned(userId);
|
|
|
+ //按工作流名称查询
|
|
|
+ if (!wfName.isEmpty()) {
|
|
|
+ taskQuery = taskQuery.processDefinitionKeyIn(Arrays.asList(wfName.split(",")));
|
|
|
+ }
|
|
|
+ //按分类查询
|
|
|
+ if (!type.isEmpty()) {
|
|
|
+ taskQuery = taskQuery.processVariableValueEquals("type", type);
|
|
|
+ }
|
|
|
+ //按供应商名称查询
|
|
|
+ if (!supplierName.isEmpty()) {
|
|
|
+ taskQuery = taskQuery.processVariableValueLikeIgnoreCase("supplierName", "%"+supplierName +"%");
|
|
|
+ }
|
|
|
+ long taskTotal = taskQuery.count();
|
|
|
+
|
|
|
+ List<ActiMyTaskDTO> myTaskDTOS = new ArrayList<>();
|
|
|
+ List<Task> resultTasks = taskQuery.orderByTaskCreateTime().desc().listPage((pageIndex-1)*pageSize, pageSize);
|
|
|
+
|
|
|
+ for (Task myTask : resultTasks) {
|
|
|
+ ActiMyTaskDTO myTaskDTO = new ActiMyTaskDTO();
|
|
|
+ myTaskDTO.setProcessDefinitionId(myTask.getProcessDefinitionId());
|
|
|
+ myTaskDTO.setBusinessKey(taskService.getVariable(myTask.getId(), "businessKey").toString());
|
|
|
+ myTaskDTO.setWorkflowId(myTask.getProcessInstanceId());
|
|
|
+ myTaskDTO.setCreateTime(myTask.getCreateTime().getTime());
|
|
|
+ myTaskDTO.setTaskName(myTask.getName());
|
|
|
+ myTaskDTOS.add(myTaskDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ ActiPageResultDTO pageResultDTO = new ActiPageResultDTO();
|
|
|
+ pageResultDTO.setTotal(taskTotal);
|
|
|
+ pageResultDTO.setTaskDTOList(myTaskDTOS);
|
|
|
+ return pageResultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* <p>描述: 根据工作流Key 和 用户id查询已办任务列表</p>
|
|
|
@@ -301,6 +355,55 @@ public class ActivitiService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public ActiPageResultDTO findAllTypePagingTaskHistWithCreateTimeByUserId(String userId, int pageIndex, int pageSize, String wfName, String type, String supplierName) {
|
|
|
+ HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(userId);
|
|
|
+ //按工作流名称查询
|
|
|
+ if (!wfName.isEmpty()) {
|
|
|
+ taskInstanceQuery = taskInstanceQuery.processDefinitionKeyIn(Arrays.asList(wfName.split(",")));
|
|
|
+ }
|
|
|
+ //按分类查询
|
|
|
+ if (!type.isEmpty()) {
|
|
|
+ taskInstanceQuery = taskInstanceQuery.processVariableValueEquals("type", type);
|
|
|
+ }
|
|
|
+ //按供应商名称查询
|
|
|
+ if (!supplierName.isEmpty()) {
|
|
|
+ taskInstanceQuery = taskInstanceQuery.processVariableValueLike("supplierName", supplierName);
|
|
|
+ }
|
|
|
+ //查询总条数
|
|
|
+ long taskTotal = taskInstanceQuery.count();
|
|
|
+ //查询分页
|
|
|
+ List<HistoricTaskInstance> hisTaskList = taskInstanceQuery.orderByTaskCreateTime().desc()
|
|
|
+ .listPage((pageIndex-1)*pageSize, pageSize);
|
|
|
+ List<ActiMyTaskDTO> myTaskDTOS = new ArrayList<>();
|
|
|
+
|
|
|
+ for (HistoricTaskInstance myTask : hisTaskList) {
|
|
|
+ ActiMyTaskDTO myTaskDTO = new ActiMyTaskDTO();
|
|
|
+
|
|
|
+ myTaskDTO.setProcessDefinitionId(myTask.getProcessDefinitionId());
|
|
|
+ myTaskDTO.setTaskName(myTask.getName());
|
|
|
+ myTaskDTO.setWorkflowId(myTask.getProcessInstanceId());
|
|
|
+ myTaskDTO.setCreateTime(myTask.getCreateTime().getTime());
|
|
|
+
|
|
|
+ List<HistoricVariableInstance> varList = historyService.createHistoricVariableInstanceQuery()
|
|
|
+ .processInstanceId(myTask.getProcessInstanceId())
|
|
|
+ .list();
|
|
|
+
|
|
|
+ for(HistoricVariableInstance hisvar : varList) {
|
|
|
+ if (hisvar.getVariableName().equals("businessKey")) {
|
|
|
+ myTaskDTO.setBusinessKey(hisvar.getValue().toString());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ myTaskDTOS.add(myTaskDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ ActiPageResultDTO pageResultDTO = new ActiPageResultDTO();
|
|
|
+ pageResultDTO.setTotal(taskTotal);
|
|
|
+ pageResultDTO.setTaskDTOList(myTaskDTOS);
|
|
|
+ return pageResultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 查询当前用户的待办任务
|