流程和表单结合

This commit is contained in:
jinqiming 2021-12-03 17:49:43 +08:00
parent ce37281a22
commit 86d5de4a51
12 changed files with 166 additions and 9 deletions

View File

@ -0,0 +1,32 @@
package com.snow.flowable.domain.response;
import lombok.Data;
import java.io.Serializable;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/12/3 14:09
*/
@Data
public class ProcessDefinitionResponse implements Serializable {
private static final long serialVersionUID = 3341234579178886021L;
private String id;
/**
* 分类
*/
private String category;
/**
* 流程名称
*/
private String name;
/**
* 流程key
*/
private String key;
}

View File

@ -3,6 +3,7 @@ package com.snow.flowable.service;
import com.snow.common.core.page.PageModel;
import com.snow.flowable.common.enums.FlowDefEnum;
import com.snow.flowable.domain.*;
import com.snow.flowable.domain.response.ProcessDefinitionResponse;
import com.snow.system.domain.ActDeModel;
import com.snow.system.domain.SysUser;
import org.flowable.common.engine.api.delegate.event.FlowableEngineEvent;
@ -205,4 +206,11 @@ public interface FlowableService {
* @return
*/
Set<FlowDefEnum> getAllFlowDefEnumsSet();
/**
* 根据流程定义key获取流程
* @param processDefinitionKey 流程定义
* @return 流程集合
*/
List<ProcessDefinitionResponse> getProcessDefByKey(String processDefinitionKey);
}

View File

@ -2,9 +2,11 @@ package com.snow.flowable.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.date.BetweenFormater;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@ -21,6 +23,7 @@ import com.snow.flowable.common.enums.FlowInstanceEnum;
import com.snow.flowable.common.skipTask.TaskSkipService;
import com.snow.flowable.config.ICustomProcessDiagramGenerator;
import com.snow.flowable.domain.*;
import com.snow.flowable.domain.response.ProcessDefinitionResponse;
import com.snow.flowable.service.FlowableService;
import com.snow.flowable.service.FlowableTaskService;
import com.snow.flowable.service.FlowableUserService;
@ -45,6 +48,7 @@ import org.flowable.engine.impl.util.CommandContextUtil;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.DeploymentQuery;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.repository.ProcessDefinitionQuery;
import org.flowable.engine.runtime.Execution;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.image.ProcessDiagramGenerator;
@ -1027,6 +1031,19 @@ public class FlowableServiceImpl implements FlowableService {
return Sets.newHashSet(values);
}
@Override
public List<ProcessDefinitionResponse> getProcessDefByKey(String processDefinitionKey) {
ProcessDefinitionQuery processDefinitionQuery=repositoryService.createProcessDefinitionQuery();
if(StrUtil.isNotBlank(processDefinitionKey)){
processDefinitionQuery.processDefinitionKey(StrUtil.format("%{}%", processDefinitionKey));
}
List<ProcessDefinition> list = processDefinitionQuery
.latestVersion()
.active()
.list();
return cn.hutool.core.convert.Convert.toList(ProcessDefinitionResponse.class,list);
}
/**
* 构建ProcessInstanceVO对象

View File

@ -22,7 +22,7 @@
<!-- 通用工具-->
<dependency>
<groupId>com.snow</groupId>
<artifactId>snow-framework</artifactId>
<artifactId>snow-flowable</artifactId>
</dependency>

View File

@ -137,6 +137,16 @@ public class FormController{
return "fromPreview";
}
/**
* 跳转绑定流程页
* @return 跳转绑定流程页
*/
@GetMapping("bindProcess")
public String bindProcess(@RequestParam Long id, ModelMap mmap) {
SysFormInstance sysFormInstance = sysFormInstanceService.selectSysFormInstanceById(id);
mmap.put("sysFormInstance",sysFormInstance);
return "system/instance/bindProcess";
}
/**
* 保存表单填写记录
* @return

View File

@ -125,6 +125,16 @@ public class SysFormInstanceController extends BaseController
return toAjax(sysFormInstanceService.updateSysFormInstance(sysFormInstance));
}
/**
* 绑定流程key
*/
@RequiresPermissions("system:instance:bindProcess")
@PostMapping("/bindProcess")
@ResponseBody
public AjaxResult bindProcess(SysFormInstance sysFormInstance) {
return toAjax(sysFormInstanceService.updateSysFormInstance(sysFormInstance));
}
/**
* 跳转表单记录
* @param id 记录id

View File

@ -29,6 +29,11 @@ public class SysFormInstance extends BaseEntity
@Excel(name = "表单名称")
private String formName;
/**
* 流程定义key
*/
private String processKey;
/**
* 表单内容
*/

View File

@ -0,0 +1,26 @@
package com.snow.from.service;
import com.snow.flowable.domain.response.ProcessDefinitionResponse;
import com.snow.flowable.service.FlowableService;
import com.snow.system.domain.SysDictData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/12/3 14:39
*/
@Service("form")
public class FormService {
@Autowired
private FlowableService flowableService;
public List<ProcessDefinitionResponse> getFlow(String key) {
return flowableService.getProcessDefByKey(key);
}
}

View File

@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="formCode" column="form_code_" />
<result property="formName" column="form_name_" />
<result property="fromUrl" column="from_url_" />
<result property="processKey" column="process_key" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
@ -21,7 +22,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectSysFormInstanceVo">
select id_, form_code_, form_name_, from_url_, create_by, from_content_html_,create_time, update_time, update_by, rev_, is_delete, tenant_id_ from sys_form_instance
select id_, form_code_, form_name_, from_url_,process_key, create_by, from_content_html_,create_time, update_time, update_by, rev_, is_delete, tenant_id_ from sys_form_instance
</sql>
<select id="selectSysFormInstanceList" parameterType="SysFormInstance" resultMap="SysFormInstanceResult">
@ -29,6 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<where>
<if test="formCode != null and formCode != ''"> and form_code_ like concat('%', #{formCode}, '%')</if>
<if test="formName != null and formName != ''"> and form_name_ like concat('%', #{formName}, '%')</if>
<if test="processKey != null and processKey != ''"> and process_key like concat('%', #{processKey}, '%')</if>
<if test="rev != null "> and rev_ = #{rev}</if>
<if test="isDelete != null "> and is_delete = #{isDelete}</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id_ = #{tenantId}</if>
@ -59,6 +61,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="formCode != null and formCode != ''">form_code_,</if>
<if test="formName != null and formName != ''">form_name_,</if>
<if test="fromUrl != null and fromUrl != ''">from_url_,</if>
<if test="processKey != null and processKey != ''">process_key,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
@ -72,6 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="formCode != null and formCode != ''">#{formCode},</if>
<if test="formName != null and formName != ''">#{formName},</if>
<if test="fromUrl != null and fromUrl != ''">#{fromUrl},</if>
<if test="processKey != null and processKey != ''">#{processKey},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
@ -89,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="formCode != null and formCode != ''">form_code_ = #{formCode},</if>
<if test="formName != null and formName != ''">form_name_ = #{formName},</if>
<if test="fromUrl != null and fromUrl != ''">from_url_ = #{fromUrl},</if>
<if test="processKey != null and processKey != ''">process_key=#{processKey},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>

View File

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
<th:block th:include="include :: header('绑定流程')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-instance-edit" th:object="${sysFormInstance}">
<input name="id" th:field="*{id}" type="hidden">
<div class="form-group">
<label class="col-sm-3 control-label">流程:</label>
<div class="col-sm-8">
<select name="processKey" th:with="type=${@form.getFlow('')}" class="form-control m-b" required>
<option th:each="dict : ${type}" th:text="${dict.name}" th:value="${dict.key}" th:field="*{processKey}" ></option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label "></label>
<div class="col-sm-8">
<span class="help-block m-b-none text-warning"><i class="fa fa-info-circle"></i> 请注意:选定流程后,后续表单审批走向都将按照所选流程</span>
</div>
</div>
</form>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
var prefix = "/from/instance";
$("#form-instance-edit").validate({
focusCleanup: true
});
function submitHandler() {
if ($.validate.form()) {
$.operate.save(prefix + "/bindProcess", $('#form-instance-edit').serialize());
}
}
</script>
</body>
</html>

View File

@ -103,6 +103,7 @@
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="fromDetail(\'' + row.id+ '\')"><i class="fa fa-add"></i>填写表单</a> ');
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="formRecordDetail(\'' + row.id+ '\')"><i class="fa fa-eyes"></i>查看表单</a> ');
actions.push('<a class="btn btn-success btn-xs" data-toggle="modal" data-target="#formQRCode" onclick="createQRCode(\'' + row.id+ '\')" ><i class="fa fa-add"></i>二维码</a> ');
actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="bindProcess(\'' + row.id+ '\')"><i class="fa fa-add"></i>绑定流程</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
@ -119,7 +120,9 @@
var detailUrl="/formIndex";
$.modal.openTab("设计表单", detailUrl);
}
function bindProcess(id) {
$.modal.open("绑定流程", "/bindProcess?id="+id);
}
function formRecordDetail(id) {
var detailUrl="/from/instance/formRecord?id="+id;
$.modal.openTab("表单数据列表", detailUrl);

View File

@ -1,22 +1,22 @@
-- 菜单 SQL
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}', '${parentMenuId}', '1', '/${moduleName}/${businessName}', 'C', '0', '${permissionPrefix}:view', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '${functionName}菜单');
values('${functionName}', '${parentMenuId}', '1', '/${moduleName}/${businessName}', 'C', '0', '${permissionPrefix}:view', '#', 'admin', NOW(), 'ry', NOW(), '${functionName}菜单');
-- 按钮父菜单ID
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}查询', @parentId, '1', '#', 'F', '0', '${permissionPrefix}:list', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
values('${functionName}查询', @parentId, '1', '#', 'F', '0', '${permissionPrefix}:list', '#', 'admin', NOW(), 'ry', NOW(), '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}新增', @parentId, '2', '#', 'F', '0', '${permissionPrefix}:add', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
values('${functionName}新增', @parentId, '2', '#', 'F', '0', '${permissionPrefix}:add', '#', 'admin', NOW(), 'ry', NOW(), '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}修改', @parentId, '3', '#', 'F', '0', '${permissionPrefix}:edit', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
values('${functionName}修改', @parentId, '3', '#', 'F', '0', '${permissionPrefix}:edit', '#', 'admin', NOW(), 'ry', NOW(), '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}删除', @parentId, '4', '#', 'F', '0', '${permissionPrefix}:remove', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
values('${functionName}删除', @parentId, '4', '#', 'F', '0', '${permissionPrefix}:remove', '#', 'admin', NOW(), 'ry', NOW(), '');
insert into sys_menu (menu_name, parent_id, order_num, url, menu_type, visible, perms, icon, create_by, create_time, update_by, update_time, remark)
values('${functionName}导出', @parentId, '5', '#', 'F', '0', '${permissionPrefix}:export', '#', 'admin', '2018-03-01', 'ry', '2018-03-01', '');
values('${functionName}导出', @parentId, '5', '#', 'F', '0', '${permissionPrefix}:export', '#', 'admin', NOW(), 'ry', NOW(), '');