|
@@ -8,11 +8,14 @@ import org.activiti.bpmn.model.BpmnModel;
|
|
|
import org.activiti.engine.*;
|
|
|
import org.activiti.engine.history.HistoricProcessInstance;
|
|
|
import org.activiti.engine.history.HistoricProcessInstanceQuery;
|
|
|
+import org.activiti.engine.history.HistoricVariableInstance;
|
|
|
import org.activiti.engine.identity.Group;
|
|
|
import org.activiti.engine.identity.User;
|
|
|
import org.activiti.engine.impl.identity.Authentication;
|
|
|
+import org.activiti.engine.impl.persistence.entity.VariableInstance;
|
|
|
import org.activiti.engine.repository.Model;
|
|
|
import org.activiti.engine.repository.ProcessDefinition;
|
|
|
+import org.activiti.engine.runtime.Execution;
|
|
|
import org.activiti.engine.runtime.ProcessInstance;
|
|
|
import org.activiti.engine.task.Task;
|
|
|
import org.activiti.engine.task.TaskQuery;
|
|
@@ -30,6 +33,8 @@ import org.jeecg.common.utils.AjaxResult;
|
|
|
import org.jeecg.modules.activiti.model.entity.EntityUtil;
|
|
|
import org.jeecg.modules.activiti.model.entity.FlowInfo;
|
|
|
import org.jeecg.modules.activiti.model.entity.TaskInfo;
|
|
|
+import org.jeecg.modules.customform.entity.CustomForm;
|
|
|
+import org.jeecg.modules.customform.service.ICustomFormService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@@ -73,6 +78,8 @@ public class ServiceController {
|
|
|
RuntimeService runtimeService;
|
|
|
@Autowired
|
|
|
TaskService taskService;
|
|
|
+ @Autowired
|
|
|
+ private ICustomFormService customFormService;
|
|
|
@Resource
|
|
|
private ActivitiTracingChart activitiTracingChart;
|
|
|
/**
|
|
@@ -208,28 +215,34 @@ public class ServiceController {
|
|
|
String formKey = formService.getStartFormKey(pdid);
|
|
|
// 根据任务id获取任务id的formKey,也就是获取任务节点的自定义表单值
|
|
|
//formService.getTaskFormData(taskId).getFormKey();
|
|
|
- return Result.OK("",formKey);
|
|
|
+ CustomForm customForm = customFormService.getById(formKey);
|
|
|
+ return Result.OK("",customForm.getFormcontent());
|
|
|
}
|
|
|
@ApiOperation("发起流程")
|
|
|
@RequestMapping(value = "/act/startProc", method = RequestMethod.GET, produces = "application/json;charset=utf-8")
|
|
|
public Result startProc(@RequestParam("procKey") String procKey,
|
|
|
- @RequestParam("businessKey") String businessKey ,HttpServletResponse response) throws Exception {
|
|
|
+ @RequestParam("businessKey") String businessKey ,
|
|
|
+ @RequestParam("formData") String formData ,HttpServletResponse response) throws Exception {
|
|
|
// 设置申请人,将之保存在流程变量中
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
Map<String ,Object > variables = new HashMap<>();
|
|
|
//variables.put("applyuserid", user.getId());
|
|
|
variables.put("userid", user.getId());
|
|
|
variables.put("applyUser", user.getId());
|
|
|
+ variables.put("formData",formData);
|
|
|
// String[] person ={user.getId()};
|
|
|
// variables.put("people",Arrays.asList(person));
|
|
|
Authentication.setAuthenticatedUserId(String.valueOf(user.getId()));
|
|
|
-
|
|
|
- runtimeService.startProcessInstanceByKeyAndTenantId(procKey,businessKey,variables,"0");
|
|
|
+ ProcessInstance processInstance = null;
|
|
|
+ try {
|
|
|
+ processInstance = runtimeService.startProcessInstanceByKeyAndTenantId(procKey,businessKey,variables,"0");
|
|
|
+ }catch (Exception e){
|
|
|
+ processInstance = runtimeService.startProcessInstanceByKey(procKey,businessKey,variables);
|
|
|
+ }
|
|
|
|
|
|
//
|
|
|
Task autoTask = taskService.createTaskQuery()
|
|
|
- .processDefinitionKey(procKey)
|
|
|
- .processInstanceBusinessKey(businessKey).singleResult();
|
|
|
+ .processDefinitionKey(procKey).processInstanceId(processInstance.getId()).singleResult();
|
|
|
autoTask.setOwner(user.getId());
|
|
|
taskService.saveTask(autoTask);
|
|
|
|
|
@@ -277,21 +290,43 @@ public class ServiceController {
|
|
|
activitiTracingChart.generateFlowChart(processInstanceId, response.getOutputStream());
|
|
|
}
|
|
|
@ApiOperation("办理一个用户任务")
|
|
|
+ @RequestMapping(value = "/getTaskInfo/{executionId}/{taskId}", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public Result completeTask(@PathVariable("executionId") String executionId,@PathVariable("taskId") String taskId) {
|
|
|
+ VariableInstance variableInstance = runtimeService.getVariableInstance(executionId,"formData");
|
|
|
+
|
|
|
+ List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
|
|
|
+ .processInstanceId(executionId)
|
|
|
+ .variableName("formData").list();
|
|
|
+
|
|
|
+ Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
|
|
+ // 根据任务id获取任务id的formKey,也就是获取任务节点的自定义表单值
|
|
|
+ //formService.getTaskFormData(taskId).getFormKey();
|
|
|
+ CustomForm customForm = customFormService.getById(task.getFormKey());
|
|
|
+ Map<String ,Object> map = new HashMap<>();
|
|
|
+ map.put("fromData1",variableInstances);
|
|
|
+ map.put("fromData2",customForm.getFormcontent());
|
|
|
+ return Result.OK("查询成功",map);
|
|
|
+ }
|
|
|
+ @ApiOperation("提交一个用户任务")
|
|
|
@RequestMapping(value = "/completeTask/{taskId}", method = RequestMethod.POST)
|
|
|
@ResponseBody
|
|
|
- public AjaxResult completeTask(@PathVariable("taskId") String taskId, @RequestBody(required=false) Map<String, Object> variables) {
|
|
|
+ public AjaxResult completeTask(@PathVariable("taskId") String taskId,
|
|
|
+ @RequestBody(required=false) String comment,
|
|
|
+ @RequestBody(required=false) String formData) {
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
String username = user.getId();
|
|
|
taskService.setAssignee(taskId, username);
|
|
|
+ Map<String ,Object > variables = new HashMap<>();
|
|
|
+ variables.put("formData",formData);
|
|
|
// 查出流程实例id
|
|
|
String processInstanceId = taskService.createTaskQuery().taskId(taskId).singleResult().getProcessInstanceId();
|
|
|
- if (variables == null) {
|
|
|
- taskService.complete(taskId);
|
|
|
+ if (comment == null||comment.equals("")) {
|
|
|
+ taskService.complete(taskId,variables);
|
|
|
} else {
|
|
|
// 添加审批意见
|
|
|
- if (variables.get("comment") != null) {
|
|
|
- taskService.addComment(taskId, processInstanceId, (String) variables.get("comment"));
|
|
|
- variables.remove("comment");
|
|
|
+ if (comment != null && !comment.equals("")) {
|
|
|
+ taskService.addComment(taskId, processInstanceId,comment);
|
|
|
}
|
|
|
taskService.complete(taskId, variables);
|
|
|
}
|