ActivitiController.java 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /*
  2. * Copyright 2017-2020 吴学文 and java110 team.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.java110.front.controller.activiti;
  17. import com.alibaba.fastjson.JSONObject;
  18. import com.java110.dto.oaWorkflow.StencilsetJson;
  19. import com.java110.dto.workflow.WorkflowModelDto;
  20. import com.java110.front.smo.activiti.IModelSMO;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.http.HttpStatus;
  23. import org.springframework.http.ResponseEntity;
  24. import org.springframework.web.bind.annotation.*;
  25. import javax.xml.ws.Response;
  26. /**
  27. * @desc add by 吴学文 8:38
  28. */
  29. @RestController
  30. @RequestMapping(value = "/app/activiti")
  31. public class ActivitiController {
  32. @Autowired
  33. private IModelSMO modelSMOImpl;
  34. /**
  35. * 查询工作流json
  36. *
  37. * @param modelId
  38. * @return
  39. */
  40. @RequestMapping(value = "/model/{modelId}/json", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
  41. public String queryJson(@PathVariable String modelId) {
  42. JSONObject paramOut = JSONObject.parseObject(modelSMOImpl.getJson(modelId).getBody());
  43. return paramOut.getJSONObject("data").toJSONString();
  44. }
  45. /**
  46. * 查询工作流json
  47. *
  48. * @param version
  49. * @return
  50. */
  51. @RequestMapping(value = "/editor/stencilset", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
  52. public String stencilset(@RequestParam(value = "version", required = false) String version) {
  53. return StencilsetJson.JSON;
  54. }
  55. /**
  56. * 更新流程
  57. *
  58. * @param modelId 模型ID
  59. * @param xmlJson 流程模型名称
  60. */
  61. @RequestMapping(value = "/model/{modelId}/save", method = RequestMethod.POST)
  62. public ResponseEntity<String> saveModel(@PathVariable String modelId
  63. , @RequestBody String xmlJson) {
  64. JSONObject paramJson = JSONObject.parseObject(xmlJson);
  65. WorkflowModelDto workflowModelDto = new WorkflowModelDto();
  66. workflowModelDto.setJson_xml(paramJson.getString("xml"));
  67. workflowModelDto.setSvg_xml(paramJson.getString("svg"));
  68. workflowModelDto.setModelId(modelId);
  69. return modelSMOImpl.saveModel(workflowModelDto);
  70. }
  71. }