flowable集成

This commit is contained in:
459816669@qq.com 2020-12-02 22:01:34 +08:00
parent 441e5e078b
commit b0f5f60d51
10 changed files with 133 additions and 207 deletions

View File

@ -3,10 +3,14 @@ package com.snow.web.controller.flowable;
import java.util.List;
import com.snow.flowable.service.impl.FlowablePublishServiceImpl;
import com.snow.flowable.service.impl.FlowableServiceImpl;
import com.snow.framework.util.ShiroUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.flowable.engine.repository.Deployment;
import org.flowable.ui.modeler.domain.Model;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.ModelMap;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
@ -40,6 +44,9 @@ public class ActDeModelController extends BaseController
@Autowired
private FlowablePublishServiceImpl flowablePublishServiceImpl;
@Autowired
private FlowableServiceImpl flowableService;
@RequiresPermissions("system:model:view")
@GetMapping()
public String model()
@ -92,7 +99,22 @@ public class ActDeModelController extends BaseController
@ResponseBody
public AjaxResult addSave(ActDeModel actDeModel)
{
return toAjax(actDeModelService.insertActDeModel(actDeModel));
Long userId = ShiroUtils.getUserId();
ActDeModel actDeModelName=new ActDeModel();
actDeModelName.setName(actDeModel.getName());
List<ActDeModel> actDeModels = actDeModelService.selectActDeModelList(actDeModelName);
if(!CollectionUtils.isEmpty(actDeModels)){
return AjaxResult.error("该模型名称已存在");
}
ActDeModel actDeModelKey=new ActDeModel();
actDeModelKey.setModelKey(actDeModel.getModelKey());
List<ActDeModel> actDeModelKeyList = actDeModelService.selectActDeModelList(actDeModelKey);
if(!CollectionUtils.isEmpty(actDeModelKeyList)){
return AjaxResult.error("该模型key已存在");
}
actDeModel.setCreatedBy(String.valueOf(userId));
flowableService.saveModel(actDeModel);
return toAjax(1);
}
/**
@ -126,8 +148,10 @@ public class ActDeModelController extends BaseController
@PostMapping( "/remove")
@ResponseBody
public AjaxResult remove(String ids)
{
return toAjax(actDeModelService.deleteActDeModelByIds(ids));
flowableService.deleteModel(ids);
return toAjax(1);
}

View File

@ -63,17 +63,7 @@ public class FlowModelerController extends BaseController
return prefix + "/model";
}
/**
* 查询发布实例列表
*/
@RequiresPermissions("modeler:model:list")
@PostMapping("/model/list")
@ResponseBody
public TableDataInfo list(ModelDTO modelDTO)
{
PageModel<Model> modelList = flowableService.getModelList(modelDTO);
return getFlowDataTable(modelList);
}
@RequiresPermissions("modeler:deployment:view")
@GetMapping()
@ -129,28 +119,6 @@ public class FlowModelerController extends BaseController
flowableService.getDeploymentSource(id,resourceName,"png",response);
}
/**
* 新增保存财务支付宝流水
*/
@RequiresPermissions("system:flow:add")
@Log(title = "财务支付宝流水", businessType = BusinessType.INSERT)
@PostMapping("/add")
@ResponseBody
public AjaxResult addSave(FinanceAlipayFlow financeAlipayFlow)
{
return toAjax(financeAlipayFlowService.insertFinanceAlipayFlow(financeAlipayFlow));
}
/**
* 修改财务支付宝流水
*/
@GetMapping("/edit/{id}")
public String edit(@PathVariable("id") Long id, ModelMap mmap)
{
FinanceAlipayFlow financeAlipayFlow = financeAlipayFlowService.selectFinanceAlipayFlowById(id);
mmap.put("financeAlipayFlow", financeAlipayFlow);
return prefix + "/edit";
}
/**
* 获取流程图

View File

@ -14,15 +14,8 @@
<ul>
<li>
<label>name</label>
<input type="text" name="name"/>
<input type="text" name="deploymentNameLike"/>
</li>
<li>
<label>key</label>
<input type="text" name="key"/>
</li>
</ul>
</div>
<div class="row">
<li>
<label>流程分类:</label>
@ -91,29 +84,6 @@
return $.table.selectDictLabel(flowCategoryDatas, value);
}
},
/* {
field: 'processDefinitionVO',
title: '流程定义key',
formatter: function(value, row, index) {
return value.key;
}
},*/
/* {
field: 'processDefinitionVO',
title: '版本号',
formatter: function(value, row, index) {
return value.version;
}
},*/
/* {
field: 'processDefinitionVO',
title: '文件名',
formatter: function(value, row, index) {
return value.resourceName;
}
},*/
{
field: 'deploymentTime',
title: '流程发布时间'

View File

@ -1,99 +1,46 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('新增设计器model')" />
<th:block th:include="include :: header('新增模型')" />
<th:block th:include="include :: datetimepicker-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-model-add">
<div class="form-group">
<label class="col-sm-3 control-label is-required">null</label>
<label class="col-sm-3 control-label is-required">模型名称</label>
<div class="col-sm-8">
<input name="name" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label is-required">null</label>
<label class="col-sm-3 control-label is-required">模型key</label>
<div class="col-sm-8">
<input name="modelKey" class="form-control" type="text" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<label class="col-sm-3 control-label">模型描述</label>
<div class="col-sm-8">
<textarea name="description" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<label class="col-sm-3 control-label">模型评论</label>
<div class="col-sm-8">
<textarea name="modelComment" class="form-control"></textarea>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="created" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
<div class="form-group">
<label class="col-sm-2 control-label">模型类型:</label>
<div class="col-sm-10">
<div class="radio-box" th:each="dict : ${@dict.getType('flow_model_type')}">
<input type="radio" th:id="${dict.dictCode}" name="modelType" th:value="${dict.dictValue}" th:checked="${dict.default}">
<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<div class="col-sm-8">
<input name="createdBy" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<div class="col-sm-8">
<div class="input-group date">
<input name="lastUpdated" class="form-control" placeholder="yyyy-MM-dd" type="text">
<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<div class="col-sm-8">
<input name="lastUpdatedBy" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<div class="col-sm-8">
<input name="version" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<div class="col-sm-8">
<input name="modelEditorJson" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<div class="col-sm-8">
<input name="thumbnail" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<div class="col-sm-8">
<select name="modelType" class="form-control m-b">
<option value="">所有</option>
</select>
<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 代码生成请选择字典属性</span>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">null</label>
<div class="col-sm-8">
<input name="tenantId" class="form-control" type="text">
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
@ -109,18 +56,6 @@
$.operate.save(prefix + "/add", $('#form-model-add').serialize());
}
}
$("input[name='created']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
$("input[name='lastUpdated']").datetimepicker({
format: "yyyy-mm-dd",
minView: "month",
autoclose: true
});
</script>
</body>
</html>

View File

@ -34,17 +34,19 @@
</div>
<div class="btn-group-sm" id="toolbar" role="group">
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:model:add">
<i class="fa fa-plus"></i> 添加
<a class="btn btn-primary" href="/modeler/index" target="_blank" shiro:hasPermission="modeler:flow:view">
<i class="fa fa-desktop"></i> 设计流程
</a>
<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="system:model:edit">
<i class="fa fa-edit"></i> 修改
<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:model:add">
<i class="fa fa-plus"></i> 添加模型
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:model:remove">
<i class="fa fa-remove"></i> 删除
<i class="fa fa-remove"></i> 删除模型
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:model:export">
<i class="fa fa-download"></i> 导出
<i class="fa fa-download"></i> 导出数据
</a>
</div>
<div class="col-sm-12 select-table table-striped">
@ -53,9 +55,12 @@
</div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('system:model:edit')}]];
var removeFlag = [[${@permission.hasPermi('system:model:remove')}]];
var flowModelTypes = [[${@dict.getType('flow_model_type')}]];
var prefix = ctx + "system/model";
$(function() {
@ -88,26 +93,27 @@
field: 'modelKey',
title: '模型key'
},
{
field: 'description',
title: '描述'
},
{
field: 'modelType',
title: '模型类型',
formatter: function(value, row, index) {
return $.table.selectDictLabel(flowModelTypes, value);
}
},
{
field: 'created',
title: '创建时间'
},
{
field: 'lastUpdated',
title: '更新时间'
},
/* {
field: 'modelType',
title: 'null'
},*/
{
title: '操作',
align: 'center',

View File

@ -21,5 +21,8 @@ public class DeploymentQueryDTO extends FlowBaseDTO implements Serializable {
private String processDefinitionKeyLike;
private String startUserId;
/**
* 发布分类
*/
private String deploymentCategory;
}

View File

@ -29,6 +29,11 @@ public class DeploymentVO implements Serializable {
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date deploymentTime;
/**
* 发布key
*/
private String key;
/**
* 分类
*/
@ -37,11 +42,14 @@ public class DeploymentVO implements Serializable {
/**
* 租户Id
*/
protected String tenantId;
private String tenantId;
/**
* 父节点
*/
protected String parentDeploymentId;
private String parentDeploymentId;
/**
* 版本
*/
private String engineVersion;
}

View File

@ -2,6 +2,7 @@ package com.snow.flowable.service;
import com.snow.common.core.page.PageModel;
import com.snow.flowable.domain.*;
import com.snow.system.domain.ActDeModel;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.repository.Model;
import org.flowable.engine.runtime.ProcessInstance;
@ -18,13 +19,18 @@ import java.util.List;
* @date 2020/11/19 17:27
*/
public interface FlowableService {
/**
* 获取model列表
* @param modelDTO
* @return
*/
PageModel<Model> getModelList(ModelDTO modelDTO);
/**
* 保存model
* @param actDeModel
*/
void saveModel(ActDeModel actDeModel);
/**
* 删除model
* @param modelId
*/
void deleteModel(String modelId);
/**
* 查询发布列表(分页)
* @param deploymentQueryDTO

View File

@ -4,9 +4,6 @@ import com.snow.common.utils.StringUtils;
import com.snow.flowable.domain.ClassDeploymentDTO;
import com.snow.flowable.domain.DeploymentDTO;
import com.snow.flowable.service.FlowablePublishService;
import com.snow.system.domain.ActDeModel;
import com.snow.system.mapper.ActDeModelMapper;
import com.snow.system.service.IActDeModelService;
import lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.common.engine.impl.util.IoUtil;
@ -17,10 +14,9 @@ import org.flowable.ui.modeler.domain.Model;
import org.flowable.ui.modeler.service.ModelServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.Optional;
import java.util.zip.ZipInputStream;
/**
@ -46,8 +42,6 @@ public class FlowablePublishServiceImpl implements FlowablePublishService {
@Autowired
private RepositoryService repositoryService;
@Autowired
private IActDeModelService iActDeModelService;
@Autowired
private ModelServiceImpl modelService;
@ -126,7 +120,7 @@ public class FlowablePublishServiceImpl implements FlowablePublishService {
@Override
public Deployment createBytesDeploymentByModelId(String id) {
Model model = modelService.getModel(id);
BpmnModel bpmnModel = modelService.getBpmnModel(model);
// BpmnModel bpmnModel = modelService.getBpmnModel(model);
if(StringUtils.isNull(model)){
return null;
}

View File

@ -10,6 +10,7 @@ import com.snow.common.core.text.Convert;
import com.snow.common.exception.BusinessException;
import com.snow.flowable.domain.*;
import com.snow.flowable.service.FlowableService;
import com.snow.system.domain.ActDeModel;
import com.snow.system.domain.SysRole;
import com.snow.system.domain.SysUser;
import com.snow.system.mapper.SysUserMapper;
@ -27,11 +28,15 @@ import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.repository.*;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.idm.api.User;
import org.flowable.image.ProcessDiagramGenerator;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.flowable.ui.modeler.repository.ModelRepository;
import org.flowable.ui.modeler.service.ModelServiceImpl;
import org.flowable.ui.modeler.serviceapi.ModelService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -88,40 +93,44 @@ public class FlowableServiceImpl implements FlowableService {
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private ModelServiceImpl modelService;
public static final String MODEL_EDITOR_JSON="{\n" +
" \"resourceId\":\"canvas\",\n" +
" \"stencil\":{\n" +
" \"id\":\"BPMNDiagram\"\n" +
" },\n" +
" \"stencilset\":{\n" +
" \"namespace\":\"http://b3mn.org/stencilset/bpmn2.0#\",\n" +
" \"url\":\"../editor/stencilsets/bpmn2.0/bpmn2.0.json\"\n" +
" }" +
"}";
@Override
public void saveModel(ActDeModel actDeModel) {
org.flowable.ui.modeler.domain.Model model=new org.flowable.ui.modeler.domain.Model();
model.setName(actDeModel.getName());
model.setComment(actDeModel.getModelComment());
model.setDescription(actDeModel.getDescription());
model.setCreated(new Date());
model.setCreatedBy(actDeModel.getCreatedBy());
model.setKey(actDeModel.getModelKey());
model.setModelType(actDeModel.getModelType().intValue());
model.setVersion(1);
model.setModelEditorJson(MODEL_EDITOR_JSON);
modelService.saveModel(model);
}
@Override
public PageModel<Model> getModelList(ModelDTO modelDTO) {
ModelQuery modelQuery = repositoryService.createModelQuery();
if(!StringUtils.isEmpty(modelDTO.getNameLike())){
modelQuery.modelNameLike(modelDTO.getNameLike());
}
if(!StringUtils.isEmpty(modelDTO.getDeploymentId())){
modelQuery.modelNameLike(modelDTO.getDeploymentId());
}
if(!StringUtils.isEmpty(modelDTO.getCategoryLike())){
modelQuery.modelCategoryLike(modelDTO.getCategoryLike());
}
if(!StringUtils.isEmpty(modelDTO.getVersion())){
modelQuery.modelVersion(modelDTO.getVersion());
}
long count = modelQuery.orderByCreateTime().desc()
.count();
List<Model> modelList = modelQuery.orderByCreateTime().desc()
.listPage(modelDTO.getPageNum(), modelDTO.getPageSize());
List<ModelVO> modelVOVOList = modelList.stream().map(t -> {
ModelVO modelVO = new ModelVO();
public void deleteModel(String modelId) {
List<String> idList = Arrays.asList(Convert.toStrArray(modelId));
idList.forEach(t->{
//删除会保留一份历史记录
modelService.deleteModel(t);
});
BeanUtils.copyProperties(t,modelVO);
return modelVO;
}).collect(Collectors.toList());
PageModel<Model> pageModel = new PageModel<> ();
pageModel.setTotalCount((int)count);
pageModel.setPagedRecords(modelList);
return null;
}
@Override
@ -129,7 +138,10 @@ public class FlowableServiceImpl implements FlowableService {
DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery();
if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentNameLike())){
deploymentQuery.deploymentKeyLike(deploymentQueryDTO.getDeploymentNameLike());
deploymentQuery.deploymentNameLike(deploymentQueryDTO.getDeploymentNameLike());
}
if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentCategory())){
deploymentQuery.deploymentCategory(deploymentQueryDTO.getDeploymentCategory());
}
if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentId())){
deploymentQuery.deploymentId(deploymentQueryDTO.getDeploymentId());