新增流程类别
This commit is contained in:
parent
64363ccfed
commit
55768e1d03
@ -14,7 +14,6 @@ import ink.wgink.pojo.result.SuccessResultData;
|
||||
import ink.wgink.pojo.result.SuccessResultList;
|
||||
import ink.wgink.util.RegexUtil;
|
||||
import io.swagger.annotations.*;
|
||||
import org.activiti.engine.repository.Model;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -77,19 +76,20 @@ public class ActivitiController extends DefaultBaseController {
|
||||
@ApiOperation(value = "模型列表", notes = "模型列表接口")
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("list")
|
||||
public List<ModelDTO> list() {
|
||||
return activitiService.list();
|
||||
public List<ModelDTO> list(@RequestParam(required = false, name = "modelCategory") String modelCategory) {
|
||||
return activitiService.listByCategory(modelCategory);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "模型分页列表", notes = "模型分页列表接口")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "modelCategory", value = "模型类别", paramType = "query", dataType = "string"),
|
||||
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "Integer", defaultValue = "1"),
|
||||
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "Integer", defaultValue = "20"),
|
||||
})
|
||||
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
||||
@GetMapping("listpage")
|
||||
public SuccessResultList<List<ModelDTO>> listPage(ListPage page) {
|
||||
return activitiService.listPage(page.getPage(), page.getRows());
|
||||
public SuccessResultList<List<ModelDTO>> listPage(@RequestParam(required = false, name = "modelCategory") String modelCategory, ListPage page) {
|
||||
return activitiService.listPageByCategory(modelCategory, page.getPage(), page.getRows());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +1,22 @@
|
||||
package ink.wgink.module.activiti.controller.route;
|
||||
|
||||
import ink.wgink.interfaces.consts.ISystemConstant;
|
||||
import ink.wgink.module.activiti.service.activiti.IActivitiModelService;
|
||||
import io.swagger.annotations.Api;
|
||||
import org.activiti.engine.RepositoryService;
|
||||
import org.activiti.engine.repository.Model;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName: ActivitiRouteController
|
||||
* @Description: activiti路由
|
||||
@ -21,15 +29,20 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
@RequestMapping(ISystemConstant.ROUTE_PREFIX + "/activiti")
|
||||
public class ActivitiRouteController {
|
||||
|
||||
@Autowired
|
||||
private RepositoryService repositoryService;
|
||||
|
||||
@GetMapping("list")
|
||||
public ModelAndView list() {
|
||||
ModelAndView mv = new ModelAndView("activiti/list");
|
||||
mv.addObject("modelCategories", listCategory());
|
||||
return mv;
|
||||
}
|
||||
|
||||
@GetMapping("save")
|
||||
public ModelAndView save() {
|
||||
ModelAndView mv = new ModelAndView("activiti/save");
|
||||
mv.addObject("modelCategories", listCategory());
|
||||
return mv;
|
||||
}
|
||||
|
||||
@ -39,4 +52,17 @@ public class ActivitiRouteController {
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<String> listCategory() {
|
||||
Set<String> modelCategorySet = repositoryService.createModelQuery().list().stream().map(Model::getCategory).collect(Collectors.toSet());
|
||||
modelCategorySet.removeIf(modelCategory -> StringUtils.isBlank(modelCategory));
|
||||
ArrayList<String> modelCategories = new ArrayList<>(modelCategorySet);
|
||||
Collections.sort(modelCategories);
|
||||
return modelCategories;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ public class ModelDTO {
|
||||
private String createTime;
|
||||
@ApiModelProperty(name = "lastUpdateTime", value = "最后更新时间")
|
||||
private String lastUpdateTime;
|
||||
@ApiModelProperty(name = "modelCategory", value = "模型类别")
|
||||
private String modelCategory;
|
||||
|
||||
public String getId() {
|
||||
return id == null ? "" : id.trim();
|
||||
@ -85,6 +87,14 @@ public class ModelDTO {
|
||||
this.lastUpdateTime = lastUpdateTime;
|
||||
}
|
||||
|
||||
public String getModelCategory() {
|
||||
return modelCategory == null ? "" : modelCategory.trim();
|
||||
}
|
||||
|
||||
public void setModelCategory(String modelCategory) {
|
||||
this.modelCategory = modelCategory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder sb = new StringBuilder("{");
|
||||
@ -102,6 +112,8 @@ public class ModelDTO {
|
||||
.append(createTime).append('\"');
|
||||
sb.append(",\"lastUpdateTime\":\"")
|
||||
.append(lastUpdateTime).append('\"');
|
||||
sb.append(",\"modelCategory\":\"")
|
||||
.append(modelCategory).append('\"');
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ public class ActivitiVO {
|
||||
private String modelKey;
|
||||
@ApiModelProperty(name = "modelDescription", value = "模型描述")
|
||||
private String modelDescription;
|
||||
@ApiModelProperty(name = "modelCategory", value = "模型分类")
|
||||
private String modelCategory;
|
||||
|
||||
public String getModelName() {
|
||||
return modelName == null ? "" : modelName.trim().replaceAll("\\s", "");
|
||||
@ -49,4 +51,12 @@ public class ActivitiVO {
|
||||
public void setModelDescription(String modelDescription) {
|
||||
this.modelDescription = modelDescription;
|
||||
}
|
||||
|
||||
public String getModelCategory() {
|
||||
return modelCategory == null ? "" : modelCategory.trim();
|
||||
}
|
||||
|
||||
public void setModelCategory(String modelCategory) {
|
||||
this.modelCategory = modelCategory;
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,14 @@ public interface IActivitiService {
|
||||
*/
|
||||
List<ModelDTO> list();
|
||||
|
||||
/**
|
||||
* 模型列表
|
||||
*
|
||||
* @param modelCategory
|
||||
* @return
|
||||
*/
|
||||
List<ModelDTO> listByCategory(String modelCategory);
|
||||
|
||||
/**
|
||||
* 模型分页列表
|
||||
*
|
||||
@ -60,4 +68,13 @@ public interface IActivitiService {
|
||||
*/
|
||||
SuccessResultList<List<ModelDTO>> listPage(int page, int rows);
|
||||
|
||||
/**
|
||||
* 模型分页列表
|
||||
*
|
||||
* @param modelCategory 类别
|
||||
* @param page
|
||||
* @param rows
|
||||
* @return
|
||||
*/
|
||||
SuccessResultList<List<ModelDTO>> listPageByCategory(String modelCategory, int page, int rows);
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ public class ActivitiServiceImpl extends DefaultBaseService implements IActiviti
|
||||
Model model = repositoryService.newModel();
|
||||
model.setName(activitiVO.getModelName());
|
||||
model.setKey(activitiVO.getModelKey());
|
||||
model.setCategory(activitiVO.getModelCategory());
|
||||
model.setMetaInfo(createModelMetaInfo(activitiVO));
|
||||
model.setVersion(1);
|
||||
LOG.debug("保存模型");
|
||||
@ -152,13 +153,31 @@ public class ActivitiServiceImpl extends DefaultBaseService implements IActiviti
|
||||
|
||||
@Override
|
||||
public List<ModelDTO> list() {
|
||||
return listModelDTO(repositoryService.createModelQuery().list());
|
||||
return listModelDTO(repositoryService.createModelQuery().orderByCreateTime().asc().list());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModelDTO> listByCategory(String modelCategory) {
|
||||
if(StringUtils.isBlank(modelCategory)) {
|
||||
return list();
|
||||
}
|
||||
return listModelDTO(repositoryService.createModelQuery().modelCategory(modelCategory).orderByCreateTime().asc().list());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<ModelDTO>> listPage(int page, int rows) {
|
||||
ModelQuery modelQuery = repositoryService.createModelQuery();
|
||||
List<Model> models = modelQuery.orderByCreateTime().asc().listPage(page - 1, rows);
|
||||
List<Model> models = modelQuery.orderByCreateTime().desc().listPage(page - 1, rows);
|
||||
return new SuccessResultList<>(listModelDTO(models), page, modelQuery.count());
|
||||
}
|
||||
|
||||
@Override
|
||||
public SuccessResultList<List<ModelDTO>> listPageByCategory(String modelCategory, int page, int rows) {
|
||||
if(StringUtils.isBlank(modelCategory)) {
|
||||
return listPage(page, rows);
|
||||
}
|
||||
ModelQuery modelQuery = repositoryService.createModelQuery();
|
||||
List<Model> models = modelQuery.modelCategory(modelCategory).orderByCreateTime().desc().listPage(page - 1, rows);
|
||||
return new SuccessResultList<>(listModelDTO(models), page, modelQuery.count());
|
||||
}
|
||||
|
||||
@ -170,6 +189,7 @@ public class ActivitiServiceImpl extends DefaultBaseService implements IActiviti
|
||||
ModelDTO modelDTO = new ModelDTO();
|
||||
modelDTO.setId(model.getId());
|
||||
modelDTO.setName(model.getName());
|
||||
modelDTO.setModelCategory(model.getCategory());
|
||||
modelDTO.setKey(model.getKey());
|
||||
modelDTO.setVersion(model.getVersion());
|
||||
modelDTO.setDeploymentId(model.getDeploymentId());
|
||||
|
@ -10,6 +10,9 @@
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
|
||||
<style>
|
||||
.layui-input, .layui-select, .layui-textarea {height: 30px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-fluid layui-anim layui-anim-fadein">
|
||||
@ -17,6 +20,17 @@
|
||||
<div class="layui-col-md12">
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
||||
<div class="layui-inline layui-form">
|
||||
<select id="modelCategory" name="modelCategory" lay-filter="modelCategoryFilter">
|
||||
<option value="">选择模型类别</option>
|
||||
<option th:each="modelCategory:${modelCategories}" th:value="${modelCategory}" th:text="${modelCategory}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
||||
<i class="fa fa-lg fa-search"></i> 搜索
|
||||
</button>
|
||||
</div>
|
||||
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
||||
<!-- 表头按钮组 -->
|
||||
<script type="text/html" id="headerToolBar">
|
||||
@ -41,6 +55,7 @@
|
||||
}).use(['index', 'table', 'laydate', 'common'], function() {
|
||||
var $ = layui.$;
|
||||
var $win = $(window);
|
||||
var form = layui.form;
|
||||
var table = layui.table;
|
||||
var admin = layui.admin;
|
||||
var laydate = layui.laydate;
|
||||
@ -55,7 +70,7 @@
|
||||
id: 'dataTable',
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
width: admin.screen() > 1 ? '100%' : '',
|
||||
height: $win.height() - 50,
|
||||
height: $win.height() - 90,
|
||||
limit: 20,
|
||||
limits: [20, 40, 60, 80, 100, 200],
|
||||
toolbar: '#headerToolBar',
|
||||
@ -75,6 +90,15 @@
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field:'modelCategory', width:150, title: '模型类别', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
||||
return '-';
|
||||
}
|
||||
return rowData;
|
||||
}
|
||||
},
|
||||
{field:'key', width:150, title: '模型key', align:'center',
|
||||
templet: function(row) {
|
||||
var rowData = row[this.field];
|
||||
@ -167,11 +191,12 @@
|
||||
function reloadTable(currentPage) {
|
||||
table.reload('dataTable', {
|
||||
url: top.restAjax.path(tableUrl, []),
|
||||
where: {},
|
||||
where: {
|
||||
modelCategory: $('#modelCategory').val()
|
||||
},
|
||||
page: {
|
||||
curr: currentPage
|
||||
},
|
||||
height: $win.height() - 50,
|
||||
});
|
||||
}
|
||||
initTable();
|
||||
@ -186,6 +211,7 @@
|
||||
$(document).on('click', '#search', function() {
|
||||
reloadTable(1);
|
||||
});
|
||||
|
||||
// 事件 - 增删改
|
||||
table.on('toolbar(dataTable)', function(obj) {
|
||||
var layEvent = obj.event;
|
||||
@ -198,7 +224,7 @@
|
||||
width: '400px',
|
||||
height: '350px',
|
||||
onClose: function() {
|
||||
reloadTable();
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -9,6 +9,13 @@
|
||||
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
||||
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
||||
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
||||
<style>
|
||||
.input-select-change-box {position: relative;}
|
||||
.input-select-change-btn {position: absolute; top: 0; right: 0;}
|
||||
.layui-form-select dl {max-height: 155px;}
|
||||
#selectChangeBtn {display: none;}
|
||||
#modelCategoryInputBox {display: none;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="layui-anim layui-anim-fadein">
|
||||
@ -33,6 +40,21 @@
|
||||
<input type="text" id="modelDescription" name="modelDescription" class="layui-input" value="" placeholder="请输入模型描述" lay-verify="required">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">模型分类 *</label>
|
||||
<div class="layui-input-block input-select-change-box">
|
||||
<div id="modelCategoryInputBox">
|
||||
<input type="text" id="modelCategoryInput" name="modelCategory" class="layui-input" value="" placeholder="请输入模型分类" lay-verify="required">
|
||||
</div>
|
||||
<div id="modelCategorySelectBox">
|
||||
<select id="modelCategorySelect" name="modelCategory" lay-verify="required">
|
||||
<option th:each="modelCategory:${modelCategories}" th:value="${modelCategory}" th:text="${modelCategory}"></option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="button" id="inputChangeBtn" class="layui-btn layui-btn-xs input-select-change-btn">输入</button>
|
||||
<button type="button" id="selectChangeBtn" class="layui-btn layui-btn-xs input-select-change-btn">选择</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item layui-layout-admin">
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-footer" style="left: 0;">
|
||||
@ -85,6 +107,24 @@
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#inputChangeBtn').click(function() {
|
||||
$(this).hide();
|
||||
$('#selectChangeBtn').show();
|
||||
$('#modelCategorySelectBox').hide();
|
||||
$('#modelCategorySelect').removeAttr('name');
|
||||
$('#modelCategoryInputBox').show();
|
||||
$('#modelCategoryInput').attr('name', 'modelCategory');
|
||||
});
|
||||
|
||||
$('#selectChangeBtn').click(function() {
|
||||
$(this).hide();
|
||||
$('#inputChangeBtn').show();
|
||||
$('#modelCategoryInputBox').hide();
|
||||
$('#modelCategoryInput').removeAttr('name');
|
||||
$('#modelCategorySelectBox').show();
|
||||
$('#modelCategorySelect').attr('name', 'modelCategory');
|
||||
});
|
||||
|
||||
// 校验
|
||||
form.verify({
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user