|
|
@@ -3,35 +3,48 @@ package com.izouma.awesomeadmin.web;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.izouma.awesomeadmin.dto.Result;
|
|
|
+import org.activiti.bpmn.converter.BpmnXMLConverter;
|
|
|
+import org.activiti.bpmn.model.BpmnModel;
|
|
|
import org.activiti.editor.constants.ModelDataJsonConstants;
|
|
|
+import org.activiti.editor.language.json.converter.BpmnJsonConverter;
|
|
|
import org.activiti.engine.*;
|
|
|
+import org.activiti.engine.form.FormProperty;
|
|
|
import org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
|
|
+import org.activiti.engine.impl.form.EnumFormType;
|
|
|
+import org.activiti.engine.impl.form.FormData;
|
|
|
+import org.activiti.engine.impl.form.StartFormDataImpl;
|
|
|
+import org.activiti.engine.repository.Deployment;
|
|
|
+import org.activiti.engine.repository.DeploymentBuilder;
|
|
|
import org.activiti.engine.repository.Model;
|
|
|
import org.activiti.engine.repository.ModelQuery;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
-import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Set;
|
|
|
|
|
|
@Controller
|
|
|
@RequestMapping("/activiti")
|
|
|
public class ActivitiController {
|
|
|
@Autowired
|
|
|
- protected IdentityService identityService;
|
|
|
+ private IdentityService identityService;
|
|
|
@Autowired
|
|
|
- protected RepositoryService repositoryService;
|
|
|
+ private RepositoryService repositoryService;
|
|
|
@Autowired
|
|
|
- protected RuntimeService runtimeService;
|
|
|
+ private RuntimeService runtimeService;
|
|
|
@Autowired
|
|
|
- protected TaskService taskService;
|
|
|
+ private TaskService taskService;
|
|
|
@Autowired
|
|
|
- protected ManagementService managementService;
|
|
|
+ private ManagementService managementService;
|
|
|
@Autowired
|
|
|
- protected ProcessEngineConfigurationImpl processEngineConfiguration;
|
|
|
+ private FormService formService;
|
|
|
+ @Autowired
|
|
|
+ private ProcessEngineConfigurationImpl processEngineConfiguration;
|
|
|
|
|
|
@RequestMapping(value = "/processList", method = RequestMethod.GET)
|
|
|
@ResponseBody
|
|
|
@@ -72,4 +85,31 @@ public class ActivitiController {
|
|
|
}
|
|
|
return new Result(false, "创建失败");
|
|
|
}
|
|
|
+
|
|
|
+ @RequestMapping(value = "/publishModel", method = RequestMethod.GET)
|
|
|
+ @ResponseBody
|
|
|
+ public Result publishModel(@RequestParam("id") String id) {
|
|
|
+ try {
|
|
|
+ Model modelData = repositoryService.getModel(id);
|
|
|
+ ObjectNode modelNode = (ObjectNode) new ObjectMapper().readTree(repositoryService.getModelEditorSource(modelData.getId()));
|
|
|
+ byte[] bpmnBytes = null;
|
|
|
+
|
|
|
+ BpmnModel model = new BpmnJsonConverter().convertToBpmnModel(modelNode);
|
|
|
+ bpmnBytes = new BpmnXMLConverter().convertToXML(model);
|
|
|
+
|
|
|
+ String processName = modelData.getName() + ".bpmn20.xml";
|
|
|
+ Deployment deployment = repositoryService.createDeployment().name(modelData.getName()).addString(processName, new String(bpmnBytes)).deploy();
|
|
|
+ return new Result(true, deployment);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return new Result(false, "失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "/startProcess", method = RequestMethod.POST)
|
|
|
+ @ResponseBody
|
|
|
+ public Result startProcess(@RequestBody Map<String, String> formProperties) {
|
|
|
+ return new Result(true, "");
|
|
|
+ }
|
|
|
+
|
|
|
}
|