1.调整流程设计页面样式。2.新增查看流程图功能
This commit is contained in:
parent
5813b5a263
commit
603f40e0d8
@ -5,9 +5,10 @@ import ink.wgink.common.base.DefaultBaseController;
|
||||
import ink.wgink.exceptions.ParamsException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.module.activiti.service.activiti.IActivitiModelService;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import ink.wgink.pojo.result.SuccessResult;
|
||||
import ink.wgink.util.RegexUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@ -35,6 +36,11 @@ public class ActivitiModelController extends DefaultBaseController {
|
||||
@Autowired
|
||||
private IActivitiModelService activitiModelService;
|
||||
|
||||
@ApiOperation(value = "保存模型", notes = "保存模型接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "modelId", value = "模型ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("save/{modelId}")
|
||||
public SuccessResult saveModel(@PathVariable String modelId, String name, String description, String json_xml, String svg_xml) throws Exception {
|
||||
name = name.trim().replace("\\s", "");
|
||||
@ -48,11 +54,18 @@ public class ActivitiModelController extends DefaultBaseController {
|
||||
return new SuccessResult();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "模型json数据", notes = "模型json数据接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "modelId", value = "模型ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("json/{modelId}")
|
||||
public JSONObject getEditorJson(@PathVariable String modelId) throws UnsupportedEncodingException {
|
||||
return activitiModelService.getEditorJson(modelId);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "汉化配置json数据", notes = "汉化配置json数据接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("editor/stencilset")
|
||||
public JSONObject getStencilset() throws IOException {
|
||||
return activitiModelService.getStencilset();
|
||||
|
@ -14,8 +14,10 @@ package ink.wgink.module.activiti.controller.api;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import ink.wgink.exceptions.base.SystemException;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import io.swagger.annotations.*;
|
||||
import org.activiti.editor.constants.ModelDataJsonConstants;
|
||||
import org.activiti.engine.ActivitiException;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.repository.Model;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -36,7 +38,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@RequestMapping("service")
|
||||
public class ActivitiModelEditorController implements ModelDataJsonConstants {
|
||||
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(ActivitiModelEditorController.class);
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(ActivitiModelEditorController.class);
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
@ -44,6 +46,11 @@ public class ActivitiModelEditorController implements ModelDataJsonConstants {
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@ApiOperation(value = "模型编辑时的json数据", notes = "模型编辑时的json数据接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "modelId", value = "模型ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("model/{modelId}/json")
|
||||
public JSONObject getEditorJson(@PathVariable String modelId) {
|
||||
JSONObject result = null;
|
||||
@ -62,8 +69,8 @@ public class ActivitiModelEditorController implements ModelDataJsonConstants {
|
||||
JSONObject editorJson = JSONObject.parseObject(readTree);
|
||||
result.put("model", editorJson);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error creating model JSON", e);
|
||||
throw new ActivitiException("Error creating model JSON", e);
|
||||
LOG.error(e.getMessage(), e);
|
||||
throw new SystemException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
@ -14,6 +14,8 @@ package ink.wgink.module.activiti.controller.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import io.swagger.annotations.*;
|
||||
import org.activiti.editor.constants.ModelDataJsonConstants;
|
||||
import org.activiti.engine.ActivitiException;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
@ -42,7 +44,7 @@ import java.io.InputStream;
|
||||
@RequestMapping("service")
|
||||
public class ActivitiModelSaveController implements ModelDataJsonConstants {
|
||||
|
||||
protected static final Logger LOGGER = LoggerFactory.getLogger(ActivitiModelSaveController.class);
|
||||
protected static final Logger LOG = LoggerFactory.getLogger(ActivitiModelSaveController.class);
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
@ -50,6 +52,11 @@ public class ActivitiModelSaveController implements ModelDataJsonConstants {
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@ApiOperation(value = "保存流程模型", notes = "保存流程模型接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "modelId", value = "模型ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@PutMapping("model/{modelId}/save")
|
||||
public void saveModel(@PathVariable String modelId, String name, String description, String json_xml, String svg_xml) {
|
||||
try {
|
||||
@ -81,8 +88,7 @@ public class ActivitiModelSaveController implements ModelDataJsonConstants {
|
||||
outStream.close();
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("Error saving model", e);
|
||||
throw new ActivitiException("Error saving model", e);
|
||||
throw new ActivitiException("保存模型异常", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,18 @@
|
||||
package ink.wgink.module.activiti.controller.route;
|
||||
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import io.swagger.annotations.Api;
|
||||
import ink.wgink.module.activiti.service.activiti.IActivitiModelService;
|
||||
import ink.wgink.pojo.result.ErrorResult;
|
||||
import io.swagger.annotations.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* @ClassName: ActivitiRouteController
|
||||
* @Description: activiti路由
|
||||
@ -19,6 +25,10 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/activiti")
|
||||
public class ActivitiRouteController {
|
||||
|
||||
@Autowired
|
||||
private IActivitiModelService activitiModelService;
|
||||
|
||||
|
||||
@GetMapping("list")
|
||||
public ModelAndView list() {
|
||||
ModelAndView mv = new ModelAndView("activiti/list");
|
||||
@ -37,4 +47,15 @@ public class ActivitiRouteController {
|
||||
return mv;
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "查看流程图", notes = "查看流程图接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "deploymentId", value = "流程部署ID", paramType = "path")
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("get-process-image/{deploymentId}")
|
||||
public void getProcessImage(HttpServletResponse response, @PathVariable("deploymentId") String deploymentId) {
|
||||
activitiModelService.getProcessImage(response, deploymentId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package ink.wgink.module.activiti.service.activiti;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
@ -22,4 +23,12 @@ public interface IActivitiModelService {
|
||||
JSONObject getEditorJson(String modelId) throws UnsupportedEncodingException;
|
||||
|
||||
JSONObject getStencilset() throws IOException;
|
||||
|
||||
/**
|
||||
* 查看部署流程图
|
||||
*
|
||||
* @param response 响应
|
||||
* @param deploymentId 部署ID
|
||||
*/
|
||||
void getProcessImage(HttpServletResponse response, String deploymentId);
|
||||
}
|
||||
|
@ -3,12 +3,17 @@ package ink.wgink.module.activiti.service.activiti.impl;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import ink.wgink.common.base.DefaultBaseService;
|
||||
import ink.wgink.exceptions.SearchException;
|
||||
import ink.wgink.exceptions.UpdateException;
|
||||
import ink.wgink.exceptions.base.SystemException;
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.module.activiti.service.activiti.IActivitiModelService;
|
||||
import ink.wgink.util.ResourceUtil;
|
||||
import org.activiti.bpmn.model.BpmnModel;
|
||||
import org.activiti.editor.constants.ModelDataJsonConstants;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.repository.Model;
|
||||
import org.activiti.engine.repository.ProcessDefinition;
|
||||
import org.activiti.image.impl.DefaultProcessDiagramGenerator;
|
||||
import org.apache.batik.transcoder.TranscoderInput;
|
||||
import org.apache.batik.transcoder.TranscoderOutput;
|
||||
import org.apache.batik.transcoder.image.PNGTranscoder;
|
||||
@ -17,7 +22,9 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* When you feel like quitting. Think about why you started
|
||||
@ -41,6 +48,9 @@ public class ActivitiModelServiceImpl extends DefaultBaseService implements IAct
|
||||
if (model == null) {
|
||||
throw new SearchException("模型不存在");
|
||||
}
|
||||
if (!StringUtils.isBlank(model.getDeploymentId())) {
|
||||
throw new UpdateException("已经部署的流程无法编辑");
|
||||
}
|
||||
JSONObject modelObject = JSONObject.parseObject(model.getMetaInfo());
|
||||
|
||||
modelObject.put(MODEL_NAME, name);
|
||||
@ -92,4 +102,26 @@ public class ActivitiModelServiceImpl extends DefaultBaseService implements IAct
|
||||
String result = IOUtils.toString(fileInputStream, ISystemConstant.CHARSET_UTF8);
|
||||
return JSONObject.parseObject(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getProcessImage(HttpServletResponse response, String deploymentId) {
|
||||
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId).singleResult();
|
||||
if (processDefinition == null) {
|
||||
throw new SearchException("流程定义不存在,请检查流程部署情况");
|
||||
}
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(processDefinition.getId());
|
||||
DefaultProcessDiagramGenerator defaultProcessDiagramGenerator = new DefaultProcessDiagramGenerator();
|
||||
response.setContentType("text/xml");
|
||||
try (InputStream inputStream = defaultProcessDiagramGenerator.generateDiagram(bpmnModel, new ArrayList<>(), new ArrayList<>(), "Heiti SC", "Heiti SC", "宋体");
|
||||
OutputStream outputStream = response.getOutputStream();
|
||||
) {
|
||||
byte[] buf = new byte[1024];
|
||||
for (int size; (size = inputStream.read(buf)) != -1; ) {
|
||||
outputStream.write(buf, 0, size);
|
||||
}
|
||||
outputStream.flush();
|
||||
} catch (IOException e) {
|
||||
throw new SystemException("流程图生成错误", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -239,8 +239,8 @@ activitiModeler
|
||||
}
|
||||
|
||||
var totalAvailable = jQuery(window).height() - offset.top - mainHeader.height() - 21;
|
||||
canvas.height(totalAvailable - propSectionHeight);
|
||||
jQuery('#paletteSection').height(totalAvailable);
|
||||
canvas.height(totalAvailable - propSectionHeight - 38);
|
||||
jQuery('#paletteSection').height(totalAvailable - 38);
|
||||
|
||||
// Update positions of the resize-markers, according to the canvas
|
||||
|
||||
|
@ -117,13 +117,20 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{field: 'option', width: 80, title: '流程图', align:'center', fixed: 'right',
|
||||
templet: function(row) {
|
||||
if(!row.deploymentId) {
|
||||
return '-';
|
||||
}
|
||||
return '<button class="layui-btn layui-btn-sm" lay-event="flowChatEvent">查看</button>';
|
||||
}
|
||||
},
|
||||
{field: 'option', width: 80, title: '操作', align:'center', fixed: 'right',
|
||||
templet: function(row) {
|
||||
if(!row.deploymentId) {
|
||||
return '<button class="layui-btn layui-btn-normal layui-btn-sm" lay-event="publishEvent">部署</button>';
|
||||
} else {
|
||||
return '<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="revokePublishEvent">撤销</button>';
|
||||
}
|
||||
return '<button class="layui-btn layui-btn-danger layui-btn-sm" lay-event="revokePublishEvent">撤销</button>';
|
||||
}
|
||||
},
|
||||
]
|
||||
@ -205,9 +212,13 @@
|
||||
} else if(checkDatas.length > 1) {
|
||||
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
||||
} else {
|
||||
if(checkDatas[0].deploymentId) {
|
||||
top.dialog.msg('已经部署的流程不能编辑');
|
||||
return;
|
||||
}
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/activiti/update?modelId={modelId}', [checkDatas[0].id]),
|
||||
title: '编辑流程图',
|
||||
title: false,
|
||||
width: '90%',
|
||||
height: '90%',
|
||||
onClose: function() {
|
||||
@ -259,6 +270,18 @@
|
||||
top.dialog.close(loadLayerIndex);
|
||||
});
|
||||
});
|
||||
} else if(layEvent === 'flowChatEvent') {
|
||||
if(!data.deploymentId) {
|
||||
top.dialog.msg('流程未部署,无法查看流程图');
|
||||
return;
|
||||
}
|
||||
top.dialog.open({
|
||||
url: top.restAjax.path('route/activiti/get-process-image/{deploymentId}', [data.deploymentId]),
|
||||
title: '流程图',
|
||||
width: '800px',
|
||||
height: '400px',
|
||||
onClose: function() {}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user