Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product

# Conflicts:
#	sql/mysql/mall.sql
This commit is contained in:
owen 2023-10-17 23:29:11 +08:00
commit 0c4713b7e0
24 changed files with 811 additions and 84 deletions

View File

@ -1,5 +1,2 @@
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
VALUES ('商城首页', '', 2, 1, 2362, 'home', 'ep:home-filled', 'mall/home/index', 'MallHome');
INSERT INTO system_menu (name, permission, type, sort, parent_id, path, icon, component, component_name)
VALUES ('核销订单', '', 2, 2, 2166, 'pick-up-order', 'ep:list', 'mall/trade/delivery/pickUpOrder/index', 'PickUpOrder');

View File

@ -11,7 +11,7 @@
Target Server Version : 80034
File Encoding : 65001
Date: 14/10/2023 20:04:17
Date: 17/10/2023 23:22:59
*/
SET NAMES utf8mb4;
@ -384,7 +384,7 @@ CREATE TABLE `infra_api_error_log` (
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1734 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志';
) ENGINE = InnoDB AUTO_INCREMENT = 1735 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统异常日志';
-- ----------------------------
-- Records of infra_api_error_log
@ -422,7 +422,7 @@ CREATE TABLE `infra_codegen_column` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1805 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表字段定义';
) ENGINE = InnoDB AUTO_INCREMENT = 1804 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表字段定义';
-- ----------------------------
-- Records of infra_codegen_column
@ -455,7 +455,7 @@ CREATE TABLE `infra_codegen_table` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 137 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表定义';
) ENGINE = InnoDB AUTO_INCREMENT = 136 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '代码生成表定义';
-- ----------------------------
-- Records of infra_codegen_table
@ -538,7 +538,7 @@ CREATE TABLE `infra_file` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1095 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表';
) ENGINE = InnoDB AUTO_INCREMENT = 1098 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表';
-- ----------------------------
-- Records of infra_file
@ -587,7 +587,7 @@ CREATE TABLE `infra_file_content` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 188 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表';
) ENGINE = InnoDB AUTO_INCREMENT = 191 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '文件表';
-- ----------------------------
-- Records of infra_file_content
@ -615,7 +615,7 @@ CREATE TABLE `infra_job` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 28 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '定时任务表';
) ENGINE = InnoDB AUTO_INCREMENT = 27 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '定时任务表';
-- ----------------------------
-- Records of infra_job
@ -656,7 +656,7 @@ CREATE TABLE `infra_job_log` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 233 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '定时任务日志表';
) ENGINE = InnoDB AUTO_INCREMENT = 232 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '定时任务日志表';
-- ----------------------------
-- Records of infra_job_log
@ -709,7 +709,7 @@ CREATE TABLE `member_address` (
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_userId`(`user_id` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户收件地址';
) ENGINE = InnoDB AUTO_INCREMENT = 24 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_bin COMMENT = '用户收件地址';
-- ----------------------------
-- Records of member_address
@ -768,7 +768,7 @@ CREATE TABLE `member_experience_record` (
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_user_id`(`user_id` ASC) USING BTREE COMMENT '会员经验记录-用户编号',
INDEX `idx_user_biz_type`(`user_id` ASC, `biz_type` ASC) USING BTREE COMMENT '会员经验记录-用户业务类型'
) ENGINE = InnoDB AUTO_INCREMENT = 41 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员经验记录';
) ENGINE = InnoDB AUTO_INCREMENT = 40 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员经验记录';
-- ----------------------------
-- Records of member_experience_record
@ -883,7 +883,7 @@ CREATE TABLE `member_level_record` (
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_user_id`(`user_id` ASC) USING BTREE COMMENT '会员等级记录-用户编号'
) ENGINE = InnoDB AUTO_INCREMENT = 20 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员等级记录';
) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员等级记录';
-- ----------------------------
-- Records of member_level_record
@ -913,7 +913,7 @@ CREATE TABLE `member_point_record` (
PRIMARY KEY (`id`) USING BTREE,
INDEX `index_userId`(`user_id` ASC) USING BTREE,
INDEX `index_title`(`title` ASC) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 60 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户积分记录';
) ENGINE = InnoDB AUTO_INCREMENT = 59 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '用户积分记录';
-- ----------------------------
-- Records of member_point_record
@ -1072,6 +1072,7 @@ CREATE TABLE `member_user` (
`password` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '密码',
`status` tinyint NOT NULL COMMENT '状态',
`register_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '注册 IP',
`register_terminal` tinyint NULL DEFAULT NULL COMMENT '注册终端',
`login_ip` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '最后登录IP',
`login_date` datetime NULL DEFAULT NULL COMMENT '最后登录时间',
`nickname` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '用户昵称',
@ -1539,7 +1540,7 @@ CREATE TABLE `system_error_code` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 5933 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '错误码表';
) ENGINE = InnoDB AUTO_INCREMENT = 5932 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '错误码表';
-- ----------------------------
-- Records of system_error_code
@ -1568,7 +1569,7 @@ CREATE TABLE `system_login_log` (
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2561 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录';
) ENGINE = InnoDB AUTO_INCREMENT = 2582 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '系统访问记录';
-- ----------------------------
-- Records of system_login_log
@ -1633,7 +1634,7 @@ CREATE TABLE `system_mail_log` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 355 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '邮件日志表';
) ENGINE = InnoDB AUTO_INCREMENT = 354 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '邮件日志表';
-- ----------------------------
-- Records of system_mail_log
@ -1698,7 +1699,7 @@ CREATE TABLE `system_menu` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2377 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '菜单权限表';
) ENGINE = InnoDB AUTO_INCREMENT = 2389 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '菜单权限表';
-- ----------------------------
-- Records of system_menu
@ -1950,7 +1951,7 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2021, '规格创建', 'product:property:create', 3, 2, 2019, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-12-12 20:26:30', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2022, '规格更新', 'product:property:update', 3, 3, 2019, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-12-12 20:26:33', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2023, '规格删除', 'product:property:delete', 3, 4, 2019, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2022-08-01 14:55:35', '', '2022-12-12 20:26:37', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2025, 'Banner管理', '', 2, 100, 2030, 'banner', '', 'mall/market/banner/index', NULL, 0, b'1', b'1', b'1', '', '2022-08-01 14:56:14', '1', '2023-08-21 10:27:51', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2025, 'Banner管理', '', 2, 100, 2387, 'banner', 'fa:bandcamp', 'mall/market/banner/index', NULL, 0, b'1', b'1', b'1', '', '2022-08-01 14:56:14', '1', '2023-10-16 09:41:54', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2026, 'Banner查询', 'market:banner:query', 3, 1, 2025, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2027, 'Banner创建', 'market:banner:create', 3, 2, 2025, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2028, 'Banner更新', 'market:banner:update', 3, 3, 2025, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2022-08-01 14:56:14', '', '2022-08-01 14:56:14', b'0');
@ -2180,6 +2181,18 @@ INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_i
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2374, '会员统计', '', 2, 2, 2358, 'member', 'ep:avatar', 'statistics/member/index', 'MemberStatistics', 0, b'1', b'1', b'1', '', '2023-10-11 04:39:24', '1', '2023-10-11 12:50:22', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2375, '会员统计查询', 'statistics:member:query', 3, 1, 2374, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-11 04:39:24', '', '2023-10-11 04:39:24', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2376, '订单核销', 'trade:order:pick-up', 3, 10, 2076, '', '', '', '', 0, b'1', b'1', b'1', '1', '2023-10-14 17:11:58', '1', '2023-10-14 17:11:58', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2377, '文章分类', '', 2, 0, 2387, 'article/category', 'fa:certificate', 'mall/promotion/article/category/index', 'ArticleCategory', 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '1', '2023-10-16 09:38:26', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2378, '分类查询', 'promotion:article-category:query', 3, 1, 2377, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '', '2023-10-16 01:26:18', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2379, '分类创建', 'promotion:article-category:create', 3, 2, 2377, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '', '2023-10-16 01:26:18', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2380, '分类更新', 'promotion:article-category:update', 3, 3, 2377, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '', '2023-10-16 01:26:18', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2381, '分类删除', 'promotion:article-category:delete', 3, 4, 2377, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '', '2023-10-16 01:26:18', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2382, '文章列表', '', 2, 2, 2387, 'article', 'ep:connection', 'mall/promotion/article/index', 'Article', 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '1', '2023-10-16 09:41:19', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2383, '文章管理查询', 'promotion:article:query', 3, 1, 2382, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '', '2023-10-16 01:26:18', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2384, '文章管理创建', 'promotion:article:create', 3, 2, 2382, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '', '2023-10-16 01:26:18', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2385, '文章管理更新', 'promotion:article:update', 3, 3, 2382, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '', '2023-10-16 01:26:18', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2386, '文章管理删除', 'promotion:article:delete', 3, 4, 2382, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-10-16 01:26:18', '', '2023-10-16 01:26:18', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2387, '内容管理', '', 1, 1, 2030, 'content', 'ep:collection', '', '', 0, b'1', b'1', b'1', '1', '2023-10-16 09:37:31', '1', '2023-10-16 09:37:31', b'0');
INSERT INTO `system_menu` (`id`, `name`, `permission`, `type`, `sort`, `parent_id`, `path`, `icon`, `component`, `component_name`, `status`, `visible`, `keep_alive`, `always_show`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2388, '商城首页', '', 2, 1, 2362, 'home', 'ep:home-filled', 'mall/home/index', 'MallHome', 0, b'1', b'1', b'1', '', '2023-10-16 12:10:33', '', '2023-10-16 12:10:33', b'0');
COMMIT;
-- ----------------------------
@ -2270,7 +2283,7 @@ CREATE TABLE `system_notify_template` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '站内信模板表';
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '站内信模板表';
-- ----------------------------
-- Records of system_notify_template
@ -2298,7 +2311,7 @@ CREATE TABLE `system_oauth2_access_token` (
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3022 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌';
) ENGINE = InnoDB AUTO_INCREMENT = 3056 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 访问令牌';
-- ----------------------------
-- Records of system_oauth2_access_token
@ -2420,7 +2433,7 @@ CREATE TABLE `system_oauth2_refresh_token` (
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1049 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 刷新令牌';
) ENGINE = InnoDB AUTO_INCREMENT = 1063 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = 'OAuth2 刷新令牌';
-- ----------------------------
-- Records of system_oauth2_refresh_token
@ -2460,7 +2473,7 @@ CREATE TABLE `system_operate_log` (
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 8718 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录';
) ENGINE = InnoDB AUTO_INCREMENT = 8738 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '操作日志记录';
-- ----------------------------
-- Records of system_operate_log
@ -3468,7 +3481,7 @@ CREATE TABLE `system_sms_code` (
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_mobile`(`mobile` ASC) USING BTREE COMMENT '手机号'
) ENGINE = InnoDB AUTO_INCREMENT = 531 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '手机验证码';
) ENGINE = InnoDB AUTO_INCREMENT = 530 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '手机验证码';
-- ----------------------------
-- Records of system_sms_code
@ -3511,7 +3524,7 @@ CREATE TABLE `system_sms_log` (
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 442 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '短信日志';
) ENGINE = InnoDB AUTO_INCREMENT = 445 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '短信日志';
-- ----------------------------
-- Records of system_sms_log
@ -3583,7 +3596,7 @@ CREATE TABLE `system_social_user` (
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社交用户表';
) ENGINE = InnoDB AUTO_INCREMENT = 21 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社交用户表';
-- ----------------------------
-- Records of system_social_user
@ -3608,7 +3621,7 @@ CREATE TABLE `system_social_user_bind` (
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 77 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社交绑定表';
) ENGINE = InnoDB AUTO_INCREMENT = 76 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '社交绑定表';
-- ----------------------------
-- Records of system_social_user_bind
@ -3784,7 +3797,7 @@ CREATE TABLE `system_users` (
-- Records of system_users
-- ----------------------------
BEGIN;
INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$mRMIYLDtRHlf6.9ipiqH1.Z.bh/R9dO9d5iHiGYPigi6r5KOoR2Wm', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://test.yudao.iocoder.cn/e1fdd7271685ec143a0900681606406621717a666ad0b2798b096df41422b32f.png', 0, '0:0:0:0:0:0:0:1', '2023-10-14 17:12:19', 'admin', '2021-01-05 17:03:47', NULL, '2023-10-14 17:12:19', b'0', 1);
INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (1, 'admin', '$2a$10$mRMIYLDtRHlf6.9ipiqH1.Z.bh/R9dO9d5iHiGYPigi6r5KOoR2Wm', '芋道源码', '管理员', 103, '[1]', 'aoteman@126.com', '15612345678', 1, 'http://test.yudao.iocoder.cn/e1fdd7271685ec143a0900681606406621717a666ad0b2798b096df41422b32f.png', 0, '0:0:0:0:0:0:0:1', '2023-10-17 21:03:03', 'admin', '2021-01-05 17:03:47', NULL, '2023-10-17 21:03:03', b'0', 1);
INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (100, 'yudao', '$2a$10$11U48RhyJ5pSBYWSn12AD./ld671.ycSzJHbyrtpeoMeYiw31eo8a', '芋道', '不要吓我', 104, '[1]', 'yudao@iocoder.cn', '15601691300', 1, '', 1, '127.0.0.1', '2022-07-09 23:03:33', '', '2021-01-07 09:07:17', NULL, '2022-07-09 23:03:33', b'0', 1);
INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (103, 'yuanma', '$2a$10$YMpimV4T6BtDhIaA8jSW.u8UTGBeGhc/qwXP4oxoMr4mOw9.qttt6', '源码', NULL, 106, NULL, 'yuanma@iocoder.cn', '15601701300', 0, '', 0, '127.0.0.1', '2022-07-08 01:26:27', '', '2021-01-13 23:50:35', NULL, '2022-07-08 01:26:27', b'0', 1);
INSERT INTO `system_users` (`id`, `username`, `password`, `nickname`, `remark`, `dept_id`, `post_ids`, `email`, `mobile`, `sex`, `avatar`, `status`, `login_ip`, `login_date`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `tenant_id`) VALUES (104, 'test', '$2a$10$GP8zvqHB//TekuzYZSBYAuBQJiNq1.fxQVDYJ.uBCOnWCtDVKE4H6', '测试号', NULL, 107, '[1,2]', '111@qq.com', '15601691200', 1, '', 0, '0:0:0:0:0:0:0:1', '2023-09-24 18:21:19', '', '2021-01-21 02:13:53', NULL, '2023-09-24 18:21:19', b'0', 1);

View File

@ -19,7 +19,7 @@
<!-- 统一依赖管理 -->
<spring.boot.version>2.7.16</spring.boot.version>
<!-- Web 相关 -->
<springdoc.version>1.7.0</springdoc.version>
<springdoc.version>1.6.15</springdoc.version>
<knife4j.version>4.3.0</knife4j.version>
<servlet.versoin>2.5</servlet.versoin>
<!-- DB 相关 -->

View File

@ -88,6 +88,8 @@ public class ServletUtils {
return ServletUtil.getClientIP(request);
}
// TODO @疯狂terminal 还是从 ServletUtils 里拿更容易全局治理
public static boolean isJsonRequest(ServletRequest request) {
return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE);
}

View File

@ -50,6 +50,10 @@ public interface ErrorCodeConstants {
ErrorCode TASK_RETURN_FAIL_SOURCE_TARGET_ERROR = new ErrorCode(1_009_005_006, "回退任务失败,目标节点是在并行网关上或非同一路线上,不可跳转");
ErrorCode TASK_DELEGATE_FAIL_USER_REPEAT = new ErrorCode(1_009_005_007, "任务委派失败,委派人和当前审批人为同一人");
ErrorCode TASK_DELEGATE_FAIL_USER_NOT_EXISTS = new ErrorCode(1_009_005_008, "任务委派失败,被委派人不存在");
ErrorCode TASK_ADD_SIGN_USER_NOT_EXIST = new ErrorCode(1_009_005_009, "任务加签:选择的用户不存在");
ErrorCode TASK_ADD_SIGN_TYPE_ERROR = new ErrorCode(1_009_005_010, "任务加签:当前任务已经{},不能{}");
ErrorCode TASK_ADD_SIGN_USER_REPEAT = new ErrorCode(1_009_005_011, "任务加签失败,加签人与现有审批人[{}]重复");
ErrorCode TASK_SUB_SIGN_NO_PARENT = new ErrorCode(1_009_005_011, "任务减签失败,被减签的任务必须是通过加签生成的任务");
// ========== 流程任务分配规则 1-009-006-000 ==========
ErrorCode TASK_ASSIGN_RULE_EXISTS = new ErrorCode(1_009_006_000, "流程({}) 的任务({}) 已经存在分配规则");

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.bpm.enums.task;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 流程任务 -- comment类型枚举
*/
@Getter
@AllArgsConstructor
public enum BpmCommentTypeEnum {
APPROVE(1, "通过", ""),
REJECT(2, "不通过", ""),
CANCEL(3, "已取消", ""),
BACK(4, "退回", ""),
DELEGATE(5, "委派", ""),
ADD_SIGN(6, "加签", "[{}]{}给了[{}],理由为:{}"),
SUB_SIGN(7, "减签", "[{}]操作了【减签】,审批人[{}]的任务被取消"),
;
/**
* 结果
*/
private final Integer type;
/**
* 描述
*/
private final String desc;
/**
* 模板信息
*/
private final String templateComment;
}

View File

@ -4,6 +4,9 @@ import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
/**
* 流程实例的结果
*
@ -21,11 +24,34 @@ public enum BpmProcessInstanceResultEnum {
// ========== 流程任务独有的状态 ==========
BACK(5, "驳回"), // 退回
DELEGATE(6, "委派");
DELEGATE(6, "委派"),
/**
* 加签源任务已经审批完成但是它使用了后加签后加签的任务未完成源任务就会是这个状态
* 相当于是 通过 APPROVE 的特殊状态
* 例如A审批 A 后加签了 B并且审批通过了任务但是 B 还未审批则当前任务状态为待后加签任务完成
*/
ADD_SIGN_AFTER(7, "待后加签任务完成"),
/**
* 加签源任务未审批但是向前加签了所以源任务状态变为待前加签任务完成
* 相当于是 处理中 PROCESS 的特殊状态
* 例如A 审批 A 前加签了 BB 还未审核
*/
ADD_SIGN_BEFORE(8, "待前加签任务完成"),
/**
* 加签后加签任务被创建时的初始状态
* 相当于是 处理中 PROCESS 的特殊状态
* 因为需要源任务先完成才能到后加签的人来审批所以加了一个状态区分
*/
WAIT_BEFORE_TASK(9, "待前置任务完成");
/**
* 能被减签的状态
*/
public static final List<Integer> CAN_SUB_SIGN_STATUS_LIST = Arrays.asList(PROCESS.result, WAIT_BEFORE_TASK.result);
/**
* 结果
*
* <p>
* 如果新增时注意 {@link #isEndResult(Integer)} 是否需要变更
*/
private final Integer result;
@ -36,14 +62,16 @@ public enum BpmProcessInstanceResultEnum {
/**
* 判断该结果是否已经处于 End 最终结果
*
* <p>
* 主要用于一些结果更新的逻辑如果已经是最终结果就不再进行更新
*
* @param result 结果
* @return 是否
*/
public static boolean isEndResult(Integer result) {
return ObjectUtils.equalsAny(result, APPROVE.getResult(), REJECT.getResult(), CANCEL.getResult(), BACK.getResult());
return ObjectUtils.equalsAny(result, APPROVE.getResult(), REJECT.getResult(),
CANCEL.getResult(), BACK.getResult(),
ADD_SIGN_AFTER.getResult());
}
}

View File

@ -0,0 +1,41 @@
package cn.iocoder.yudao.module.bpm.enums.task;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 流程任务 -- 加签类型枚举类型
*/
@Getter
@AllArgsConstructor
public enum BpmTaskAddSignTypeEnum {
/**
* 向前加签需要前置任务审批完成才回到原审批人
*/
BEFORE("before", "向前加签"),
/**
* 向后加签需要后置任务全部审批完才会通过原审批人节点
*/
AFTER("after", "向后加签"),
/**
* 创建后置加签时的过度状态用于控制向后加签生成的任务状态
*/
AFTER_CHILDREN_TASK("afterChildrenTask", "向后加签生成的子任务");
private final String type;
private final String desc;
public static String formatDesc(String type) {
for (BpmTaskAddSignTypeEnum value : values()) {
if (value.type.equals(type)) {
return value.desc;
}
}
return null;
}
}

View File

@ -4,16 +4,15 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -95,9 +94,31 @@ public class BpmTaskController {
@Operation(summary = "委派任务", description = "用于【流程详情】的【委派】按钮。和向前【加签】有点像,唯一区别是【委托】没有单独创立任务")
@PreAuthorize("@ss.hasPermission('bpm:task:update')")
public CommonResult<Boolean> delegateTask(@Valid @RequestBody BpmTaskDelegateReqVO reqVO) {
// TODO @海, 后面要有空格
taskService.delegateTask(reqVO,getLoginUserId());
taskService.delegateTask(getLoginUserId(), reqVO);
return success(true);
}
@PutMapping("/add-sign")
@Operation(summary = "加签", description = "before 前加签after 后加签")
@PreAuthorize("@ss.hasPermission('bpm:task:update')")
public CommonResult<Boolean> addSignTask(@Valid @RequestBody BpmTaskAddSignReqVO reqVO) {
taskService.addSignTask(getLoginUserId(), reqVO);
return success(true);
}
@PutMapping("/sub-sign")
@Operation(summary = "减签")
@PreAuthorize("@ss.hasPermission('bpm:task:update')")
public CommonResult<Boolean> subSignTask(@Valid @RequestBody BpmTaskSubSignReqVO reqVO) {
taskService.subSignTask(getLoginUserId(), reqVO);
return success(true);
}
@GetMapping("/get-children-task-list")
@Operation(summary = "获取能被减签的任务")
@PreAuthorize("@ss.hasPermission('bpm:task:update')")
public CommonResult<List<BpmTaskSubSignRespVO>> getChildrenTaskList(@RequestParam("taskId") String taskId) {
return success(taskService.getChildrenTaskList(taskId));
}
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import java.util.Set;
@Schema(description = "管理后台 - 加签流程任务的 Request VO")
@Data
public class BpmTaskAddSignReqVO {
@Schema(description = "需要加签的任务 ID")
@NotEmpty(message = "任务编号不能为空")
private String id;
@Schema(description = "加签的用户 ID")
@NotEmpty(message = "加签用户 ID 不能为空")
private Set<Long> userIdList;
@Schema(description = "加签类型before 向前加签after 向后加签")
@NotEmpty(message = "加签类型不能为空")
private String type;
@Schema(description = "加签原因")
@NotEmpty(message = "加签原因不能为空")
private String reason;
}

View File

@ -5,6 +5,8 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List;
@Schema(description = "管理后台 - 流程任务的 Response VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ -19,6 +21,14 @@ public class BpmTaskRespVO extends BpmTaskDonePageItemRespVO {
*/
private User assigneeUser;
/**
* 父任务ID
*/
private String parentTaskId;
@Schema(description = "子任务(由加签生成)", requiredMode = Schema.RequiredMode.REQUIRED, example = "childrenTask")
private List<BpmTaskRespVO> children;
@Schema(description = "用户信息")
@Data
public static class User {

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
@Schema(description = "管理后台 - 减签流程任务的 Request VO")
@Data
public class BpmTaskSubSignReqVO {
@Schema(description = "被减签的任务 ID")
@NotEmpty(message = "任务编号不能为空")
private String id;
@Schema(description = "加签原因")
@NotEmpty(message = "加签原因不能为空")
private String reason;
}

View File

@ -0,0 +1,15 @@
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 减签流程任务的 Response VO")
@Data
public class BpmTaskSubSignRespVO {
@Schema(description = "审核的用户信息", requiredMode = Schema.RequiredMode.REQUIRED, example = "小李")
private BpmTaskRespVO.User assigneeUser;
@Schema(description = "任务 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "12312")
private String id;
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "经理审批")
private String name;
}

View File

@ -1,13 +1,12 @@
package cn.iocoder.yudao.module.bpm.convert.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskDonePageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskSimpleRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskTodoPageItemRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
import cn.iocoder.yudao.module.bpm.service.message.dto.BpmMessageSendWhenTaskCreatedReqDTO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
@ -18,9 +17,11 @@ import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.Task;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
import org.mapstruct.*;
import org.mapstruct.factory.Mappers;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -145,4 +146,53 @@ public interface BpmTaskConvert {
.setName(element.getName())
.setDefinitionKey(element.getId()));
}
//此处不用 mapstruct 映射因为 TaskEntityImpl 还有很多其他属性这里我们只设置我们需要的
//使用 mapstruct 会将里面嵌套的各个属性值都设置进去会出现意想不到的问题
default TaskEntityImpl convert(TaskEntityImpl task,TaskEntityImpl parentTask){
task.setCategory(parentTask.getCategory());
task.setDescription(parentTask.getDescription());
task.setTenantId(parentTask.getTenantId());
task.setName(parentTask.getName());
task.setParentTaskId(parentTask.getId());
task.setProcessDefinitionId(parentTask.getProcessDefinitionId());
task.setProcessInstanceId(parentTask.getProcessInstanceId());
task.setTaskDefinitionKey(parentTask.getTaskDefinitionKey());
task.setTaskDefinitionId(parentTask.getTaskDefinitionId());
task.setPriority(parentTask.getPriority());
task.setCreateTime(new Date());
return task;
}
default List<BpmTaskSubSignRespVO> convertList(List<BpmTaskExtDO> bpmTaskExtDOList,
Map<Long, AdminUserRespDTO> userMap,
Map<String, Task> idTaskMap){
return CollectionUtils.convertList(bpmTaskExtDOList, task->{
BpmTaskSubSignRespVO bpmTaskSubSignRespVO = new BpmTaskSubSignRespVO();
bpmTaskSubSignRespVO.setName(task.getName());
bpmTaskSubSignRespVO.setId(task.getTaskId());
Task sourceTask = idTaskMap.get(task.getTaskId());
// 后加签任务不会直接设置 assignee ,所以不存在 assignee 的情况则去取 owner
String assignee = StrUtil.isNotEmpty(sourceTask.getAssignee()) ? sourceTask.getAssignee() : sourceTask.getOwner();
AdminUserRespDTO assignUser = userMap.get(NumberUtils.parseLong(assignee));
if (assignUser != null) {
bpmTaskSubSignRespVO.setAssigneeUser(convert3(assignUser));
}
return bpmTaskSubSignRespVO;
});
}
/**
* 转换任务为父子级
* @param sourceList 原始数据
* @return 转换后的父子级数组
*/
default List<BpmTaskRespVO> convertChildrenList(List<BpmTaskRespVO> sourceList){
List<BpmTaskRespVO> childrenTaskList = CollectionUtils.filterList(sourceList, r -> StrUtil.isNotEmpty(r.getParentTaskId()));
Map<String, List<BpmTaskRespVO>> parentChildrenTaskListMap = CollectionUtils.convertMultiMap(childrenTaskList, BpmTaskRespVO::getParentTaskId);
for (BpmTaskRespVO bpmTaskRespVO : sourceList) {
bpmTaskRespVO.setChildren(parentChildrenTaskListMap.get(bpmTaskRespVO.getId()));
}
return CollectionUtils.filterList(sourceList, r -> StrUtil.isEmpty(r.getParentTaskId()));
}
}

View File

@ -1,7 +1,9 @@
package cn.iocoder.yudao.module.bpm.dal.mysql.task;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.ibatis.annotations.Mapper;
@ -19,8 +21,19 @@ public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {
return selectList(BpmTaskExtDO::getTaskId, taskIds);
}
default List<BpmTaskExtDO> selectProcessListByTaskIds(Collection<String> taskIds) {
return selectList(new LambdaQueryWrapperX<BpmTaskExtDO>()
.in(BpmTaskExtDO::getTaskId, taskIds)
.in(BpmTaskExtDO::getResult, BpmProcessInstanceResultEnum.CAN_SUB_SIGN_STATUS_LIST));
}
default BpmTaskExtDO selectByTaskId(String taskId) {
return selectOne(BpmTaskExtDO::getTaskId, taskId);
}
default void updateBatchByTaskIdList(List<String> taskIdList, BpmTaskExtDO updateObj) {
update(updateObj, new LambdaQueryWrapper<BpmTaskExtDO>().in(BpmTaskExtDO::getTaskId, taskIdList));
}
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bpm.service.task;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
import org.flowable.task.api.Task;
import javax.validation.Valid;
@ -62,6 +63,15 @@ public interface BpmTaskService {
*/
List<BpmTaskRespVO> getTaskListByProcessInstanceId(String processInstanceId);
/**
* 通过任务 ID 集合获取任务扩展表信息集合
*
* @param taskIdList 任务 ID 集合
* @return 任务列表
*/
List<BpmTaskExtDO> getTaskListByTaskIdList(List<String> taskIdList);
/**
* 通过任务
*
@ -134,17 +144,41 @@ public interface BpmTaskService {
* 将任务回退到指定的 targetDefinitionKey 位置
*
* @param userId 用户编号
* @param reqVO 回退的任务key和当前所在的任务ID
* @param reqVO 回退的任务key和当前所在的任务ID
*/
void returnTask(Long userId, BpmTaskReturnReqVO reqVO);
// TODO @海userId 放前面
/**
* 将指定任务委派给其他人处理等接收人处理后再回到原审批人手中审批
*
* @param reqVO 被委派人和被委派的任务编号理由参数
* @param userId 用户编号
* @param reqVO 被委派人和被委派的任务编号理由参数
*/
void delegateTask(BpmTaskDelegateReqVO reqVO, Long userId);
void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO);
/**
* 任务加签
*
* @param userId 被加签的用户和任务 ID加签类型
* @param reqVO 当前用户 ID
*/
void addSignTask(Long userId, BpmTaskAddSignReqVO reqVO);
/**
* 任务减签名
*
* @param userId 当前用户ID
* @param reqVO 被减签的任务 ID理由
*/
void subSignTask(Long userId, BpmTaskSubSignReqVO reqVO);
/**
* 获取指定任务的子任务和审批人信息
*
* @param taskId 指定任务ID
* @return 子任务列表
*/
List<BpmTaskSubSignRespVO> getChildrenTaskList(String taskId);
}

View File

@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.bpm.service.task;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
@ -13,8 +15,10 @@ import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.*;
import cn.iocoder.yudao.module.bpm.convert.task.BpmTaskConvert;
import cn.iocoder.yudao.module.bpm.dal.dataobject.task.BpmTaskExtDO;
import cn.iocoder.yudao.module.bpm.dal.mysql.task.BpmTaskExtMapper;
import cn.iocoder.yudao.module.bpm.enums.task.BpmCommentTypeEnum;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceDeleteReasonEnum;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.enums.task.BpmTaskAddSignTypeEnum;
import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService;
import cn.iocoder.yudao.module.bpm.service.message.BpmMessageService;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
@ -26,15 +30,19 @@ import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.bpmn.model.UserTask;
import org.flowable.engine.HistoryService;
import org.flowable.engine.ManagementService;
import org.flowable.engine.RuntimeService;
import org.flowable.engine.TaskService;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.api.DelegationState;
import org.flowable.task.api.Task;
import org.flowable.task.api.TaskInfo;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.task.service.impl.persistence.entity.TaskEntityImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronization;
@ -45,6 +53,8 @@ import javax.annotation.Resource;
import javax.validation.Valid;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
@ -82,6 +92,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
@Resource
private BpmTaskExtMapper taskExtMapper;
@Resource
private ManagementService managementService;
@Override
public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) {
// 查询待办任务
@ -183,7 +196,13 @@ public class BpmTaskServiceImpl implements BpmTaskService {
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
// 拼接数据
return BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap);
List<BpmTaskRespVO> result = BpmTaskConvert.INSTANCE.convertList3(tasks, bpmTaskExtDOMap, processInstance, userMap, deptMap);
return BpmTaskConvert.INSTANCE.convertChildrenList(result);
}
@Override
public List<BpmTaskExtDO> getTaskListByTaskIdList(List<String> taskIdList) {
return taskExtMapper.selectListByTaskIds(taskIdList);
}
@Override
@ -203,13 +222,182 @@ public class BpmTaskServiceImpl implements BpmTaskService {
return;
}
// 情况二自己审批的任务调用 complete 去完成任务
// 情况二后加签的任务
if (BpmTaskAddSignTypeEnum.AFTER.getType().equals(task.getScopeType())) {
// 后加签处理
approveAfterSignTask(task, reqVO);
return;
}
// 情况三自己审批的任务调用 complete 去完成任务
// 完成任务审批通过
taskService.complete(task.getId(), instance.getProcessVariables());
// 更新任务拓展表为通过
taskExtMapper.updateByTaskId(
new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.APPROVE.getResult())
.setReason(reqVO.getReason()));
// 处理加签任务
handleParentTask(task);
}
/**
* 审批通过存在后加签的任务
* <p>
* 注意该任务不能马上完成需要一个中间状态ADD_SIGN_AFTER并激活剩余所有子任务PROCESS为可审批处理
*
* @param task 当前任务
* @param reqVO 前端请求参数
*/
private void approveAfterSignTask(Task task, BpmTaskApproveReqVO reqVO) {
// 1. 有向后加签则该任务状态临时设置为 ADD_SIGN_AFTER 状态
taskExtMapper.updateByTaskId(
new BpmTaskExtDO().setTaskId(task.getId()).setResult(BpmProcessInstanceResultEnum.ADD_SIGN_AFTER.getResult())
.setReason(reqVO.getReason()).setEndTime(LocalDateTime.now()));
// 2. 激活子任务
List<String> childrenTaskIdList = getChildrenTaskIdList(task.getId());
for (String childrenTaskId : childrenTaskIdList) {
taskService.resolveTask(childrenTaskId);
}
// 2.1 更新任务扩展表中子任务为进行中
taskExtMapper.updateBatchByTaskIdList(childrenTaskIdList,
new BpmTaskExtDO().setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()));
}
/**
* 处理当前任务的父任务
*
* @param task 当前任务
*/
private void handleParentTask(Task task) {
String parentTaskId = task.getParentTaskId();
if (StrUtil.isBlank(parentTaskId)) {
return;
}
if (StrUtil.isNotBlank(parentTaskId)) {
// 1. 判断当前任务的父任务是否还有子任务
Long childrenTaskCount = getChildrenTaskCount(parentTaskId);
if (childrenTaskCount > 0) {
return;
}
// 2. 获取父任务
Task parentTask = validateTaskExist(parentTaskId);
// 3. 情况一处理向前加签
String scopeType = parentTask.getScopeType();
if (BpmTaskAddSignTypeEnum.BEFORE.getType().equals(scopeType)) {
// 3.1 如果是向前加签的任务则调用 resolveTask 指派父任务 owner 重新赋值给父任务的 assignee
taskService.resolveTask(parentTaskId);
// 3.2 更新任务拓展表为处理中
taskExtMapper.updateByTaskId(
new BpmTaskExtDO().setTaskId(parentTask.getId()).setResult(BpmProcessInstanceResultEnum.PROCESS.getResult()));
} else if (BpmTaskAddSignTypeEnum.AFTER.getType().equals(scopeType)) {
// 3. 情况二处理向后加签
handleAfterSign(parentTask);
}
// 4. 子任务已处理完成清空 scopeType 字段修改 parentTask 信息方便后续可以继续向前后向后加签
// 再查询一次的原因是避免报错Task was updated by another transaction concurrently
// 因为前面处理后可能会导致 parentTask rev 字段被修改需要重新获取最新的
parentTask = getTask(parentTaskId);
if (parentTask == null) {
// 为空的情况是已经通过 handleAfterSign 方法将任务完成了所以 ru_task 表会查不到数据
return;
}
clearTaskScopeTypeAndSave(parentTask);
}
}
/**
* 处理后加签任务
*
* @param parentTask 当前审批任务的父任务
*/
private void handleAfterSign(Task parentTask) {
String parentTaskId = parentTask.getId();
//1. 更新 parentTask 的任务拓展表为通过并调用 complete 完成自己
BpmTaskExtDO currentTaskExt = taskExtMapper.selectByTaskId(parentTask.getId());
BpmTaskExtDO currentTaskUpdateEntity = new BpmTaskExtDO().setTaskId(parentTask.getId())
.setResult(BpmProcessInstanceResultEnum.APPROVE.getResult());
if (currentTaskExt.getEndTime() == null) {
// 1.1 有这个判断是因为,以前没设置过结束时间才去设置
currentTaskUpdateEntity.setEndTime(LocalDateTime.now());
}
// 1.2 完成自己
taskExtMapper.updateByTaskId(currentTaskUpdateEntity);
taskService.complete(parentTaskId);
// 2. 如果有父级递归查询上级任务是否都已经完成
if (StrUtil.isEmpty(parentTask.getParentTaskId())) {
return;
}
// TODO @海这块待讨论脑子略乱感觉 handleAfterSign 的后半段 handleParentTask 有点重叠
// 2.1 判断整条链路的任务是否完成
// 例如从 A 任务加签了一个 B 任务B 任务又加签了一个 C 任务C 任务加签了 D 任务
// 此时D 任务完成要一直往上找到祖先任务 A调用 complete 方法完成 A 任务
boolean allChildrenTaskFinish = true;
while (StrUtil.isNotBlank(parentTask.getParentTaskId())) {
parentTask = validateTaskExist(parentTask.getParentTaskId());
BpmTaskExtDO bpmTaskExtDO = taskExtMapper.selectByTaskId(parentTask.getId());
if (bpmTaskExtDO == null) {
break;
}
boolean currentTaskFinish = BpmProcessInstanceResultEnum.isEndResult(bpmTaskExtDO.getResult());
// 2.2 如果 allChildrenTaskFinish 已经被赋值为 false ,则不会再赋值为 true因为整个链路没有完成
if (allChildrenTaskFinish) {
allChildrenTaskFinish = currentTaskFinish;
}
// 2.3 任务已完成则不处理
if (currentTaskFinish) {
continue;
}
// 3 处理非完成状态的任务
// 3.1 判断当前任务的父任务是否还有子任务
Long childrenTaskCount = getChildrenTaskCount(bpmTaskExtDO.getTaskId());
if (childrenTaskCount > 0) {
continue;
}
// 3.2 没有子任务判断当前任务状态是否为 ADD_SIGN_BEFORE 待前加签任务完成
if (BpmProcessInstanceResultEnum.ADD_SIGN_BEFORE.getResult().equals(bpmTaskExtDO.getResult())) {
// 3.3 需要修改该任务状态为处理中
taskService.resolveTask(bpmTaskExtDO.getTaskId());
bpmTaskExtDO.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
taskExtMapper.updateByTaskId(bpmTaskExtDO);
}
// 3.4 清空 scopeType 字段用于任务没有子任务时使用该方法方便任务可以再次被不同的方式加签
parentTask = validateTaskExist(bpmTaskExtDO.getTaskId());
clearTaskScopeTypeAndSave(parentTask);
}
// 4. 完成最后的顶级祖先任务
if (allChildrenTaskFinish) {
taskService.complete(parentTask.getId());
}
}
/**
* 清空 scopeType 字段用于任务没有子任务时使用该方法方便任务可以再次被不同的方式加签
*
* @param task 需要被清空的任务
*/
private void clearTaskScopeTypeAndSave(Task task) {
TaskEntityImpl taskImpl = (TaskEntityImpl) task;
taskImpl.setScopeType(null);
taskService.saveTask(task);
}
/**
* 获取子任务个数
*
* @param parentTaskId 父任务 ID
* @return 剩余子任务个数
*/
private Long getChildrenTaskCount(String parentTaskId) {
String tableName = managementService.getTableName(TaskEntity.class);
String sql = "SELECT COUNT(1) from " + tableName + " WHERE PARENT_TASK_ID_=#{parentTaskId}";
return taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).count();
}
/**
@ -226,7 +414,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
String comment = StrUtil.format("[{}]完成委派任务,任务重新回到[{}]手中,审批意见为:{}", currentUser.getNickname(),
sourceApproveUser.getNickname(), reqVO.getReason());
taskService.addComment(reqVO.getId(), task.getProcessInstanceId(),
BpmProcessInstanceResultEnum.DELEGATE.getResult().toString(), comment);
BpmCommentTypeEnum.DELEGATE.getType().toString(), comment);
// 2.1 调用 resolveTask 完成任务
// 底层调用 TaskHelper.changeTaskAssignee(task, task.getOwner()) owner 设置为 assignee
@ -276,10 +464,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
* @param taskId task id
*/
private Task validateTask(Long userId, String taskId) {
Task task = getTask(taskId);
if (task == null) {
throw exception(TASK_NOT_EXISTS);
}
Task task = validateTaskExist(taskId);
if (!Objects.equals(userId, NumberUtils.parseLong(task.getAssignee()))) {
throw exception(TASK_OPERATE_FAIL_ASSIGN_NOT_SELF);
}
@ -288,8 +473,12 @@ public class BpmTaskServiceImpl implements BpmTaskService {
@Override
public void createTaskExt(Task task) {
BpmTaskExtDO taskExtDO =
BpmTaskConvert.INSTANCE.convert2TaskExt(task).setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
BpmTaskExtDO taskExtDO = BpmTaskConvert.INSTANCE.convert2TaskExt(task)
.setResult(BpmProcessInstanceResultEnum.PROCESS.getResult());
// 向后加签生成的任务状态不能为进行中需要等前面父任务完成
if (BpmTaskAddSignTypeEnum.AFTER_CHILDREN_TASK.getType().equals(task.getScopeType())) {
taskExtDO.setResult(BpmProcessInstanceResultEnum.WAIT_BEFORE_TASK.getResult());
}
taskExtMapper.insert(taskExtDO);
}
@ -343,23 +532,29 @@ public class BpmTaskServiceImpl implements BpmTaskService {
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
ProcessInstance processInstance =
processInstanceService.getProcessInstance(task.getProcessInstanceId());
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId()));
messageService.sendMessageWhenTaskAssigned(
BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task));
if (StrUtil.isNotEmpty(task.getAssignee())) {
ProcessInstance processInstance =
processInstanceService.getProcessInstance(task.getProcessInstanceId());
AdminUserRespDTO startUser = adminUserApi.getUser(Long.valueOf(processInstance.getStartUserId()));
messageService.sendMessageWhenTaskAssigned(
BpmTaskConvert.INSTANCE.convert(processInstance, startUser, task));
}
}
});
}
private Task getTask(String id) {
Task task = taskService.createTaskQuery().taskId(id).singleResult();
if (null == task) {
private Task validateTaskExist(String id) {
Task task = getTask(id);
if (task == null) {
throw exception(TASK_NOT_EXISTS);
}
return task;
}
private Task getTask(String id) {
return taskService.createTaskQuery().taskId(id).singleResult();
}
private HistoricTaskInstance getHistoricTask(String id) {
return historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult();
}
@ -367,10 +562,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
@Override
public List<BpmTaskSimpleRespVO> getReturnTaskList(String taskId) {
// 1. 校验当前任务 task 存在
Task task = getTask(taskId);
if (task == null) {
throw exception(TASK_NOT_EXISTS);
}
Task task = validateTaskExist(taskId);
// 根据流程定义获取流程模型信息
BpmnModel bpmnModel = bpmModelService.getBpmnModelByDefinitionId(task.getProcessDefinitionId());
FlowElement source = BpmnModelUtils.getFlowElementById(bpmnModel, task.getTaskDefinitionKey());
@ -437,7 +629,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
/**
* 执行回退逻辑
*
* @param currentTask 当前回退的任务
* @param currentTask 当前回退的任务
* @param targetElement 需要回退到的目标任务
* @param reqVO 前端参数封装
*/
@ -458,7 +650,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
return;
}
taskService.addComment(task.getId(), currentTask.getProcessInstanceId(),
BpmProcessInstanceResultEnum.BACK.getResult().toString(), reqVO.getReason());
BpmCommentTypeEnum.BACK.getType().toString(), reqVO.getReason());
});
// 3. 执行驳回
@ -471,7 +663,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
@Override
@Transactional(rollbackFor = Exception.class)
public void delegateTask(BpmTaskDelegateReqVO reqVO, Long userId) {
public void delegateTask(Long userId, BpmTaskDelegateReqVO reqVO) {
// 1.1 校验任务
Task task = validateTaskCanDelegate(userId, reqVO);
// 1.2 校验目标用户存在
@ -485,9 +677,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
String comment = StrUtil.format("[{}]将任务委派给[{}],委派理由为:{}", currentUser.getNickname(),
delegateUser.getNickname(), reqVO.getReason());
String taskId = reqVO.getId();
// TODO 后面改感觉 comment 应该 type 做个枚举不和 result 耦合在一起
taskService.addComment(taskId, task.getProcessInstanceId(),
BpmProcessInstanceResultEnum.DELEGATE.getResult().toString(), comment);
BpmCommentTypeEnum.DELEGATE.getType().toString(), comment);
// 3.1 设置任务所有人 (owner) 为原任务的处理人 (assignee)
taskService.setOwner(taskId, task.getAssignee());
@ -503,7 +694,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
* 校验任务委派参数
*
* @param userId 用户编号
* @param reqVO 任务编号接收人ID
* @param reqVO 任务编号接收人ID
* @return 当前任务信息
*/
private Task validateTaskCanDelegate(Long userId, BpmTaskDelegateReqVO reqVO) {
@ -516,4 +707,228 @@ public class BpmTaskServiceImpl implements BpmTaskService {
return task;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void addSignTask(Long userId, BpmTaskAddSignReqVO reqVO) {
// 1. 获取和校验任务
TaskEntityImpl taskEntity = validateAddSign(userId, reqVO);
List<AdminUserRespDTO> userList = adminUserApi.getUserList(reqVO.getUserIdList());
if (CollUtil.isEmpty(userList)) {
throw exception(TASK_ADD_SIGN_USER_NOT_EXIST);
}
// 2. 处理当前任务
// 2.1 开启计数功能主要用于为了让表 ACT_RU_TASK 中的 SUB_TASK_COUNT_ 字段记录下总共有多少子任务后续可能有用
taskEntity.setCountEnabled(true);
if (reqVO.getType().equals(BpmTaskAddSignTypeEnum.BEFORE.getType())) {
// 2.2 向前加签设置 owner置空 assign等子任务都完成后再调用 resolveTask 重新将 owner 设置为 assign
// 原因是不能和向前加签的子任务一起审批需要等前面的子任务都完成才能审批
taskEntity.setOwner(taskEntity.getAssignee());
taskEntity.setAssignee(null);
// 2.3 更新扩展表状态
taskExtMapper.updateByTaskId(
new BpmTaskExtDO().setTaskId(taskEntity.getId())
.setResult(BpmProcessInstanceResultEnum.ADD_SIGN_BEFORE.getResult())
.setReason(reqVO.getReason()));
}
// 2.4 记录加签方式完成任务时需要用到判断
taskEntity.setScopeType(reqVO.getType());
// 2.5 保存当前任务修改后的值
taskService.saveTask(taskEntity);
// 3. 创建加签任务
createAddSignChildrenTasks(convertList(reqVO.getUserIdList(), String::valueOf), taskEntity);
// 4. 记录加签 comment拼接结果为 [当前用户]向前加签/向后加签给了[多个用户]理由为reason
AdminUserRespDTO currentUser = adminUserApi.getUser(userId);
String comment = StrUtil.format(BpmCommentTypeEnum.ADD_SIGN.getTemplateComment(), currentUser.getNickname(), BpmTaskAddSignTypeEnum.formatDesc(reqVO.getType()),
String.join(",", convertList(userList, AdminUserRespDTO::getNickname)), reqVO.getReason());
taskService.addComment(reqVO.getId(), taskEntity.getProcessInstanceId(),
BpmCommentTypeEnum.ADD_SIGN.getType().toString(), comment);
}
/**
* 校验任务的加签是否一致
* <p>
* 1. 如果存在向前加签的任务则不能向后加签
* 2. 如果存在向后加签的任务则不能向前加签
*
* @param userId 当前用户 ID
* @param reqVO 请求参数包含任务 ID 和加签类型
* @return 当前任务
*/
private TaskEntityImpl validateAddSign(Long userId, BpmTaskAddSignReqVO reqVO) {
TaskEntityImpl taskEntity = (TaskEntityImpl) validateTask(userId, reqVO.getId());
// 向前加签和向后加签不能同时存在
if (StrUtil.isNotBlank(taskEntity.getScopeType())
&& ObjectUtil.notEqual(BpmTaskAddSignTypeEnum.AFTER_CHILDREN_TASK.getType(), taskEntity.getScopeType())
&& ObjectUtil.notEqual(taskEntity.getScopeType(), reqVO.getType())) {
throw exception(TASK_ADD_SIGN_TYPE_ERROR,
BpmTaskAddSignTypeEnum.formatDesc(taskEntity.getScopeType()), BpmTaskAddSignTypeEnum.formatDesc(reqVO.getType()));
}
// 同一个 key 的任务审批人不重复
List<Task> taskList = taskService.createTaskQuery().processInstanceId(taskEntity.getProcessInstanceId())
.taskDefinitionKey(taskEntity.getTaskDefinitionKey()).list();
List<Long> currentAssigneeList = convertList(taskList, task -> NumberUtils.parseLong(task.getAssignee()));
// 保留交集在 currentAssigneeList
currentAssigneeList.retainAll(reqVO.getUserIdList());
if (CollUtil.isNotEmpty(currentAssigneeList)) {
List<AdminUserRespDTO> userList = adminUserApi.getUserList(currentAssigneeList);
throw exception(TASK_ADD_SIGN_USER_REPEAT, String.join(",", convertList(userList, AdminUserRespDTO::getNickname)));
}
return taskEntity;
}
/**
* 创建加签子任务
*
* @param addSingUserIdList 被加签的用户 ID
* @param taskEntity 被加签的任务
*/
private void createAddSignChildrenTasks(List<String> addSingUserIdList, TaskEntityImpl taskEntity) {
if (CollUtil.isEmpty(addSingUserIdList)) {
return;
}
// 创建加签人的新任务全部基于 taskEntity 为父任务来创建
for (String addSignId : addSingUserIdList) {
if (StrUtil.isBlank(addSignId)) {
continue;
}
createChildrenTask(taskEntity, addSignId);
}
}
/**
* 创建子任务
*
* @param parentTask 父任务
* @param assignee 子任务的执行人
* @return
*/
private void createChildrenTask(TaskEntityImpl parentTask, String assignee) {
// 1. 生成子任务
TaskEntityImpl task = (TaskEntityImpl) taskService.newTask(IdUtil.fastSimpleUUID());
task = BpmTaskConvert.INSTANCE.convert(task, parentTask);
if (BpmTaskAddSignTypeEnum.BEFORE.getType().equals(parentTask.getScopeType())) {
// 2.1 前加签才设置审批人否则设置 owner
task.setAssignee(assignee);
} else {
// 2.2.1 设置 owner 不设置 assignee 是因为不能同时审批需要等父任务完成
task.setOwner(assignee);
// 2.2.2 设置向后加签任务的 scopeType afterChildrenTask用于设置任务扩展表的状态
task.setScopeType(BpmTaskAddSignTypeEnum.AFTER_CHILDREN_TASK.getType());
}
// 2. 保存子任务
taskService.saveTask(task);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void subSignTask(Long userId, BpmTaskSubSignReqVO reqVO) {
Task task = validateSubSign(reqVO.getId());
AdminUserRespDTO user = adminUserApi.getUser(userId);
AdminUserRespDTO cancelUser = null;
if (StrUtil.isNotBlank(task.getAssignee())) {
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getAssignee()));
}
if (cancelUser == null && StrUtil.isNotBlank(task.getOwner())) {
cancelUser = adminUserApi.getUser(NumberUtils.parseLong(task.getOwner()));
}
Assert.notNull(cancelUser, "任务中没有所有者和审批人,数据错误");
//1. 获取所有需要删除的任务 ID 包含当前任务和所有子任务
List<String> allTaskIdList = getAllChildTaskIds(task.getId());
//2. 删除任务和所有子任务
taskService.deleteTasks(allTaskIdList);
//3. 修改扩展表状态为取消
taskExtMapper.updateBatchByTaskIdList(allTaskIdList, new BpmTaskExtDO().setResult(BpmProcessInstanceResultEnum.CANCEL.getResult())
.setReason(StrUtil.format("由于{}操作[减签],任务被取消", user.getNickname())));
//4.记录日志到父任务中 先记录日志是因为通过 handleParentTask 方法之后任务可能被完成了并且不存在了会报异常所以先记录
String comment = StrUtil.format(BpmCommentTypeEnum.SUB_SIGN.getTemplateComment(), user.getNickname(), cancelUser.getNickname());
taskService.addComment(task.getParentTaskId(), task.getProcessInstanceId(),
BpmCommentTypeEnum.SUB_SIGN.getType().toString(), comment);
//5. 处理当前任务的父任务
this.handleParentTask(task);
}
/**
* 校验任务是否能被减签
*
* @param id 任务ID
* @return 任务信息
*/
private Task validateSubSign(String id) {
Task task = validateTaskExist(id);
//必须有parentId
if (StrUtil.isEmpty(task.getParentTaskId())) {
throw exception(TASK_SUB_SIGN_NO_PARENT);
}
return task;
}
/**
* 获取所有要被取消的删除的任务 ID 集合
*
* @param parentTaskId 父级任务ID
* @return 所有任务ID
*/
public List<String> getAllChildTaskIds(String parentTaskId) {
List<String> allChildTaskIds = new ArrayList<>();
//1. 先将自己放入
allChildTaskIds.add(parentTaskId);
//2. 递归获取子级
recursiveGetChildTaskIds(parentTaskId, allChildTaskIds);
return allChildTaskIds;
}
/**
* 递归处理子级任务
*
* @param taskId 当前任务ID
* @param taskIds 结果
*/
private void recursiveGetChildTaskIds(String taskId, List<String> taskIds) {
List<String> childrenTaskIdList = getChildrenTaskIdList(taskId);
for (String childTaskId : childrenTaskIdList) {
taskIds.add(childTaskId); // 将子任务的ID添加到集合中
recursiveGetChildTaskIds(childTaskId, taskIds); // 递归获取子任务的子任务
}
}
/**
* 获取指定父级任务的所有子任务 ID 集合
*
* @param parentTaskId 父任务 ID
* @return 所有子任务的 ID 集合
*/
private List<String> getChildrenTaskIdList(String parentTaskId) {
String tableName = managementService.getTableName(TaskEntity.class);
String sql = "select ID_ from " + tableName + " where PARENT_TASK_ID_=#{parentTaskId}";
List<Task> childrenTaskList = taskService.createNativeTaskQuery().sql(sql).parameter("parentTaskId", parentTaskId).list();
return convertList(childrenTaskList, Task::getId);
}
@Override
public List<BpmTaskSubSignRespVO> getChildrenTaskList(String taskId) {
List<String> childrenTaskIdList = getChildrenTaskIdList(taskId);
if (CollUtil.isEmpty(childrenTaskIdList)) {
return Collections.emptyList();
}
//1. 只查询进行中的任务
List<BpmTaskExtDO> bpmTaskExtDOList = taskExtMapper.selectProcessListByTaskIds(childrenTaskIdList);
//2. 后加签的任务可能不存在 assignee,所以还需要查询 owner
List<Task> taskList = taskService.createTaskQuery().taskIds(childrenTaskIdList).list();
Map<String, Task> idTaskMap = convertMap(taskList, TaskInfo::getId);
//3. owner assignee 统一到一个集合中
List<Long> userIds = taskList.stream()
.flatMap(control ->
Stream.of(control.getAssignee(), control.getOwner())
.filter(Objects::nonNull))
.distinct()
.map(NumberUtils::parseLong)
.collect(Collectors.toList());
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds);
return BpmTaskConvert.INSTANCE.convertList(bpmTaskExtDOList, userMap, idTaskMap);
}
}

View File

@ -108,6 +108,7 @@ public class TradeStatisticsController {
// 订单统计
Long undeliveredCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType(
TradeOrderStatusEnum.UNDELIVERED.getStatus(), DeliveryTypeEnum.EXPRESS.getType());
// TODO @疯狂订单支付后如果是门店自提的需要 update DELIVERED目前还没搞~~突然反应过来
Long pickUpCount = tradeOrderStatisticsService.getCountByStatusAndDeliveryType(
TradeOrderStatusEnum.DELIVERED.getStatus(), DeliveryTypeEnum.PICK_UP.getType());
// 售后统计

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.statistics.job.trade;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjUtil;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
import cn.iocoder.yudao.framework.tenant.core.job.TenantJob;
@ -10,6 +11,7 @@ import org.springframework.stereotype.Component;
import javax.annotation.Resource;
// TODO 芋艿缺个 Job 的配置等和 Product 一起配置
/**
* 交易统计 Job
*
@ -30,10 +32,10 @@ public class TradeStatisticsJob implements JobHandler {
@Override
@TenantJob
public String execute(String param) {
// 默认 昨日
if (StrUtil.isBlank(param)) {
param = "1";
} else if (!NumberUtil.isInteger(param)) {
// 默认昨日
param = ObjUtil.defaultIfBlank(param, "1");
// 校验参数的合理性
if (!NumberUtil.isInteger(param)) {
throw new RuntimeException("交易统计任务的参数只能为是正整数");
}
Integer days = Convert.toInt(param, 0);

View File

@ -129,7 +129,6 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService {
entity = TradeStatisticsConvert.INSTANCE.convert(date, orderSummary, afterSaleSummary, brokerageSettlementPrice,
walletSummary);
tradeStatisticsMapper.insert(entity);
// TODO @疯狂这里是不是也要把日期带上类似 108 那边; 110 已经带上了
return stopWatch.prettyPrint();
}

View File

@ -21,7 +21,6 @@ public enum TradeOrderOperateTypeEnum {
MEMBER_RECEIVE(30, "用户已收货"),
SYSTEM_RECEIVE(31, "到期未收货,系统自动确认收货"),
ADMIN_PICK_UP_RECEIVE(32, "管理员自提收货"),
MEMBER_PICK_UP_RECEIVE(32, "用户自提收货"),
MEMBER_COMMENT(33, "用户评价"),
SYSTEM_COMMENT(34, "到期未评价,系统自动评价"),
MEMBER_CANCEL(40, "取消订单"),

View File

@ -143,7 +143,7 @@ public class TradeOrderController {
@Parameter(name = "id", description = "交易订单编号")
@PreAuthorize("@ss.hasPermission('trade:order:pick-up')")
public CommonResult<Boolean> pickUpOrderById(@RequestParam("id") Long id) {
tradeOrderUpdateService.pickUpOrderByMember(id);
tradeOrderUpdateService.pickUpOrderByAdmin(id);
return success(true);
}

View File

@ -122,7 +122,7 @@ public interface TradeOrderUpdateService {
*
* @param id 订单编号
*/
void pickUpOrderByMember(Long id);
void pickUpOrderByAdmin(Long id);
/**
* 管理员核销订单

View File

@ -669,8 +669,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
}
@Override
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.MEMBER_PICK_UP_RECEIVE)
public void pickUpOrderByMember(Long id) {
@TradeOrderLog(operateType = TradeOrderOperateTypeEnum.ADMIN_PICK_UP_RECEIVE)
public void pickUpOrderByAdmin(Long id) {
getSelf().pickUpOrder(tradeOrderMapper.selectById(id));
}