新增JeecgBoot BPM流程自动生成器,包含流程创建、修改及审批人配置功能,支持自然语言描述转化为BPMN XML,并通过API与JeecgBoot系统交互。

This commit is contained in:
geht
2026-04-08 16:24:41 +08:00
parent 7c60acd679
commit 67104af7de
168 changed files with 207167 additions and 8 deletions

View File

@@ -103,7 +103,7 @@
<groupId>com.yomahub</groupId>
<artifactId>liteflow-script-graaljs</artifactId>
<version>${liteflow.version}</version>
<scope>provided</scope>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.yomahub</groupId>

View File

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jeecg-boot-module</artifactId>
<groupId>org.jeecgframework.boot3</groupId>
<version>3.9.1</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jeecg-module-print</artifactId>
<name>jeecg-module-print</name>
<description>可视化打印模板vue-plugin-hiprint</description>
<dependencies>
<dependency>
<groupId>org.jeecgframework.boot3</groupId>
<artifactId>jeecg-boot-base-core</artifactId>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,164 @@
package org.jeecg.modules.print.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.print.entity.PrintTemplate;
import org.jeecg.modules.print.service.IPrintTemplateService;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/**
* 打印模板维护Hiprint
*/
@Slf4j
@Tag(name = "打印模板")
@RestController
@RequestMapping("/print/template")
public class PrintTemplateController extends JeecgController<PrintTemplate, IPrintTemplateService> {
/**
* 分页列表
*/
@Operation(summary = "打印模板-分页列表")
@GetMapping(value = "/list")
@RequiresPermissions("print:template:list")
public Result<IPage<PrintTemplate>> list(PrintTemplate query,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<PrintTemplate> qw = QueryGenerator.initQueryWrapper(query, req.getParameterMap());
qw.orderByDesc("create_time");
Page<PrintTemplate> page = new Page<>(pageNo, pageSize);
return Result.OK(service.page(page, qw));
}
/**
* 添加
*/
@AutoLog(value = "打印模板-添加")
@Operation(summary = "打印模板-添加")
@PostMapping(value = "/add")
@RequiresPermissions("print:template:add")
public Result<String> add(@RequestBody PrintTemplate entity) {
if (StringUtils.isBlank(entity.getTemplateCode())) {
return Result.error("模板编码不能为空");
}
if (service.getByCode(entity.getTemplateCode()) != null) {
return Result.error("模板编码已存在");
}
if (StringUtils.isBlank(entity.getTemplateJson())) {
entity.setTemplateJson("{}");
}
service.save(entity);
return Result.OK("添加成功");
}
/**
* 编辑(基础字段,不含大 JSON 时可单独调 saveJson
*/
@AutoLog(value = "打印模板-编辑")
@Operation(summary = "打印模板-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
@RequiresPermissions("print:template:edit")
public Result<String> edit(@RequestBody PrintTemplate entity) {
PrintTemplate db = service.getById(entity.getId());
if (db == null) {
return Result.error("记录不存在");
}
if (StringUtils.isNotBlank(entity.getTemplateCode()) && !entity.getTemplateCode().equals(db.getTemplateCode())) {
if (service.getByCode(entity.getTemplateCode()) != null) {
return Result.error("模板编码已存在");
}
}
service.updateById(entity);
return Result.OK("修改成功");
}
/**
* 仅保存 Hiprint 模板 JSON设计器保存
*/
@AutoLog(value = "打印模板-保存JSON")
@Operation(summary = "打印模板-保存模板JSON")
@PostMapping(value = "/saveJson")
@RequiresPermissions("print:template:edit")
public Result<String> saveJson(@RequestBody Map<String, String> body) {
String id = body.get("id");
String templateJson = body.get("templateJson");
if (StringUtils.isBlank(id)) {
return Result.error("id 不能为空");
}
if (templateJson == null) {
return Result.error("templateJson 不能为空");
}
PrintTemplate db = service.getById(id);
if (db == null) {
return Result.error("记录不存在");
}
db.setTemplateJson(templateJson);
service.updateById(db);
return Result.OK("保存成功");
}
/**
* 通过 id 删除
*/
@AutoLog(value = "打印模板-删除")
@Operation(summary = "打印模板-删除")
@DeleteMapping(value = "/delete")
@RequiresPermissions("print:template:delete")
public Result<String> delete(@RequestParam(name = "id") String id) {
service.removeById(id);
return Result.OK("删除成功");
}
/**
* 批量删除
*/
@AutoLog(value = "打印模板-批量删除")
@Operation(summary = "打印模板-批量删除")
@DeleteMapping(value = "/deleteBatch")
@RequiresPermissions("print:template:delete")
public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) {
if (StringUtils.isBlank(ids)) {
return Result.error("参数 ids 不能为空");
}
service.removeByIds(java.util.Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功");
}
/**
* 通过 id 查询
*/
@Operation(summary = "打印模板-通过id查询")
@GetMapping(value = "/queryById")
@RequiresPermissions("print:template:list")
public Result<PrintTemplate> queryById(@RequestParam(name = "id") String id) {
return Result.OK(service.getById(id));
}
/**
* 通过编码查询(业务单据打印时调用)
*/
@Operation(summary = "打印模板-通过编码查询")
@GetMapping(value = "/queryByCode")
@RequiresPermissions("print:template:list")
public Result<PrintTemplate> queryByCode(@RequestParam(name = "code") String code) {
PrintTemplate t = service.getByCode(code);
if (t == null) {
return Result.error("未找到模板: " + code);
}
return Result.OK(t);
}
}

View File

@@ -0,0 +1,63 @@
package org.jeecg.modules.print.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.system.base.entity.JeecgEntity;
import org.jeecgframework.poi.excel.annotation.Excel;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 打印模板Hiprint JSON 存储)
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@JsonIgnoreProperties(ignoreUnknown = true)
@Schema(description = "打印模板")
@TableName("print_template")
public class PrintTemplate extends JeecgEntity implements Serializable {
@Excel(name = "模板编码", width = 20)
@Schema(description = "模板编码,业务调用唯一标识")
@TableField("template_code")
private String templateCode;
@Excel(name = "模板名称", width = 25)
@Schema(description = "模板名称")
@TableField("template_name")
private String templateName;
@Excel(name = "分类", width = 12)
@Schema(description = "barcode=条码标签 form=表单套打 report=报表")
@TableField("category")
private String category;
@Schema(description = "纸张宽度(mm)")
@TableField("paper_width_mm")
private BigDecimal paperWidthMm;
@Schema(description = "纸张高度(mm)")
@TableField("paper_height_mm")
private BigDecimal paperHeightMm;
@Excel(name = "方向", width = 10)
@Schema(description = "portrait 纵向 landscape 横向")
@TableField("paper_orientation")
private String paperOrientation;
@Schema(description = "Hiprint 模板 JSON")
@TableField("template_json")
private String templateJson;
@Excel(name = "备注", width = 30)
@Schema(description = "备注")
@TableField("remark")
private String remark;
}

View File

@@ -0,0 +1,10 @@
package org.jeecg.modules.print.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.print.entity.PrintTemplate;
/**
* 打印模板 Mapper
*/
public interface PrintTemplateMapper extends BaseMapper<PrintTemplate> {
}

View File

@@ -0,0 +1,15 @@
package org.jeecg.modules.print.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.print.entity.PrintTemplate;
/**
* 打印模板 Service
*/
public interface IPrintTemplateService extends IService<PrintTemplate> {
/**
* 按编码查询(未删除)
*/
PrintTemplate getByCode(String templateCode);
}

View File

@@ -0,0 +1,23 @@
package org.jeecg.modules.print.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.jeecg.modules.print.entity.PrintTemplate;
import org.jeecg.modules.print.mapper.PrintTemplateMapper;
import org.jeecg.modules.print.service.IPrintTemplateService;
import org.springframework.stereotype.Service;
/**
* 打印模板 Service 实现
*/
@Service
public class PrintTemplateServiceImpl extends ServiceImpl<PrintTemplateMapper, PrintTemplate> implements IPrintTemplateService {
@Override
public PrintTemplate getByCode(String templateCode) {
LambdaQueryWrapper<PrintTemplate> q = new LambdaQueryWrapper<>();
q.eq(PrintTemplate::getTemplateCode, templateCode);
q.last("LIMIT 1");
return getOne(q);
}
}

View File

@@ -15,6 +15,7 @@
<modules>
<module>jeecg-module-demo</module>
<module>jeecg-boot-module-airag</module>
<module>jeecg-module-print</module>
</modules>

View File

@@ -24,6 +24,12 @@
<artifactId>jeecg-module-demo</artifactId>
<version>${jeecgboot.version}</version>
</dependency>
<!-- 打印模板Hiprint -->
<dependency>
<groupId>org.jeecgframework.boot3</groupId>
<artifactId>jeecg-module-print</artifactId>
<version>${jeecgboot.version}</version>
</dependency>
<!-- flyway 数据库自动升级 -->
<dependency>

View File

@@ -0,0 +1,41 @@
-- 打印模板表Hiprint JSON
CREATE TABLE IF NOT EXISTS `print_template` (
`id` varchar(36) NOT NULL COMMENT '主键',
`template_code` varchar(64) NOT NULL COMMENT '模板编码',
`template_name` varchar(200) NOT NULL COMMENT '模板名称',
`category` varchar(32) DEFAULT 'form' COMMENT 'barcode/form/report',
`paper_width_mm` decimal(10,2) DEFAULT 210.00 COMMENT '纸宽mm',
`paper_height_mm` decimal(10,2) DEFAULT 297.00 COMMENT '纸高mm',
`paper_orientation` varchar(16) DEFAULT 'portrait' COMMENT 'portrait/landscape',
`template_json` longtext COMMENT 'Hiprint模板JSON',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
`update_by` varchar(50) DEFAULT NULL COMMENT '更新人',
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_print_template_code` (`template_code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='打印模板';
-- 菜单打印管理
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000100', '', '打印管理', '/print', 'layouts/default/index', 1, NULL, '/print/template', 0, NULL, '0', 50.00, 0, 'ant-design:printer-outlined', 0, 0, 0, 0, 'Hiprint 可视化打印模板', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000101', '1900000000000000100', '打印模板', '/print/template', 'print/template/index', 1, 'PrintTemplateList', NULL, 1, NULL, '0', 1.00, 0, 'ant-design:file-text-outlined', 1, 1, 0, 0, '模板列表与设计入口', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000102', '1900000000000000100', '打印设计器', '/print/designer', 'print/template/PrintDesigner', 1, 'PrintDesigner', NULL, 1, NULL, '0', 2.00, 0, '', 1, 0, 1, 0, 'Hiprint 设计器隐藏菜单', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);
-- 按钮权限
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000111', '1900000000000000101', '打印模板-查询', NULL, NULL, 0, NULL, NULL, 2, 'print:template:list', '1', 1.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000112', '1900000000000000101', '打印模板-添加', NULL, NULL, 0, NULL, NULL, 2, 'print:template:add', '1', 2.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000113', '1900000000000000101', '打印模板-编辑', NULL, NULL, 0, NULL, NULL, 2, 'print:template:edit', '1', 3.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
VALUES ('1900000000000000114', '1900000000000000101', '打印模板-删除', NULL, NULL, 0, NULL, NULL, 2, 'print:template:delete', '1', 4.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0);

View File

@@ -0,0 +1,9 @@
-- 打印管理相关菜单与按钮授权给默认管理员角色 V3.8.1 openapi 脚本中 role_id 一致
-- 若贵司管理员角色 id 不同请在角色管理中手动勾选权限
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('1900000000000000201', 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000100', NULL, NOW(), '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('1900000000000000202', 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000101', NULL, NOW(), '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('1900000000000000203', 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000102', NULL, NOW(), '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('1900000000000000204', 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000111', NULL, NOW(), '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('1900000000000000205', 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000112', NULL, NOW(), '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('1900000000000000206', 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000113', NULL, NOW(), '127.0.0.1');
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`) VALUES ('1900000000000000207', 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000114', NULL, NOW(), '127.0.0.1');