mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 03:30:06 +08:00
Merge branch 'develop' of https://gitee.com/zhijiantianya/ruoyi-vue-pro into master-jdk21
This commit is contained in:
commit
ba3fe15ec5
@ -92,6 +92,8 @@
|
||||
|
||||
如果你想把【完整版】的功能,迁移到【精简版】,可以参考 [《迁移功能到精简版》](https://doc.iocoder.cn/migrate-module/) 文档。
|
||||
|
||||
如果你想把【完整版】的功能,迁移到【精简版】,可以参考 [《迁移功能到精简版》](https://doc.iocoder.cn/migrate-module/) 文档。
|
||||
|
||||
## 😎 开源协议
|
||||
|
||||
**为什么推荐使用本项目?**
|
||||
|
8
pom.xml
8
pom.xml
@ -15,13 +15,13 @@
|
||||
<!-- 各种 module 拓展 -->
|
||||
<module>yudao-module-system</module>
|
||||
<module>yudao-module-infra</module>
|
||||
<!-- <module>yudao-module-member</module>-->
|
||||
<module>yudao-module-member</module>
|
||||
<!-- <module>yudao-module-bpm</module>-->
|
||||
<!-- <module>yudao-module-report</module>-->
|
||||
<!-- <module>yudao-module-mp</module>-->
|
||||
<!-- <module>yudao-module-pay</module>-->
|
||||
<!-- <module>yudao-module-mall</module>-->
|
||||
<!-- <module>yudao-module-crm</module>-->
|
||||
<module>yudao-module-pay</module>
|
||||
<module>yudao-module-mall</module>
|
||||
<module>yudao-module-crm</module>
|
||||
<!-- 示例项目 -->
|
||||
<!-- <module>yudao-example</module>-->
|
||||
</modules>
|
||||
|
@ -1,15 +0,0 @@
|
||||
-- `ruoyi-vue-pro`.crm_contact_business_link definition
|
||||
|
||||
CREATE TABLE `crm_contact_business_link` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`contact_id` int(11) DEFAULT NULL COMMENT '联系人id',
|
||||
`business_id` int(11) DEFAULT NULL COMMENT '商机id',
|
||||
`creator` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `crm_contact_business_link_un` (`contact_id`,`business_id`,`deleted`,`tenant_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=29 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='联系人商机关联表';
|
@ -1,256 +0,0 @@
|
||||
-- ----------------------------
|
||||
-- 转账单表
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pay_transfer`;
|
||||
CREATE TABLE `pay_transfer`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`no` varchar(64) NOT NULL COMMENT '转账单号',
|
||||
`app_id` bigint NOT NULL COMMENT '应用编号',
|
||||
`channel_id` bigint NOT NULL COMMENT '转账渠道编号',
|
||||
`channel_code` varchar(32) NOT NULL COMMENT '转账渠道编码',
|
||||
`merchant_transfer_id` varchar(64) NOT NULL COMMENT '商户转账单编号',
|
||||
`type` int NOT NULL COMMENT '类型',
|
||||
`status` tinyint NOT NULL COMMENT '转账状态',
|
||||
`success_time` datetime NULL COMMENT '转账成功时间',
|
||||
`price` int NOT NULL COMMENT '转账金额,单位:分',
|
||||
`subject` varchar(512) NOT NULL COMMENT '转账标题',
|
||||
`user_name` varchar(64) NULL COMMENT '收款人姓名',
|
||||
`alipay_logon_id` varchar(64) NULL COMMENT '支付宝登录号',
|
||||
`openid` varchar(64) NULL COMMENT '微信 openId',
|
||||
`notify_url` varchar(1024) NOT NULL COMMENT '异步通知商户地址',
|
||||
`user_ip` varchar(50) NOT NULL COMMENT '用户 IP',
|
||||
`channel_extras` varchar(512) NULL DEFAULT NULL COMMENT '渠道的额外参数',
|
||||
`channel_transfer_no` varchar(64) NULL DEFAULT NULL COMMENT '渠道转账单号',
|
||||
`channel_error_code` varchar(128) NULL DEFAULT NULL COMMENT '调用渠道的错误码',
|
||||
`channel_error_msg` varchar(256) NULL DEFAULT NULL COMMENT '调用渠道的错误提示',
|
||||
`channel_notify_data` varchar(4096) NULL DEFAULT NULL COMMENT '渠道的同步/异步通知的内容',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB COMMENT='转账单表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pay_demo_transfer
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pay_demo_transfer`;
|
||||
CREATE TABLE `pay_demo_transfer` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '订单编号',
|
||||
`app_id` bigint NOT NULL COMMENT '应用编号',
|
||||
`type` int NOT NULL COMMENT '转账类型',
|
||||
`price` int NOT NULL COMMENT '转账金额,单位:分',
|
||||
`user_name` varchar(64) NULL COMMENT '收款人姓名',
|
||||
`alipay_logon_id` varchar(64) NULL COMMENT '支付宝登录号',
|
||||
`openid` varchar(64) NULL COMMENT '微信 openId',
|
||||
`transfer_status` tinyint NOT NULL DEFAULT 0 COMMENT '转账状态',
|
||||
`pay_transfer_id` bigint NULL DEFAULT NULL COMMENT '转账订单编号',
|
||||
`pay_channel_code` varchar(16) NULL DEFAULT NULL COMMENT '转账支付成功渠道',
|
||||
`transfer_time` datetime NULL DEFAULT NULL COMMENT '转账支付时间',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB COMMENT = '示例业务转账订单';
|
||||
|
||||
|
||||
-- ALTER TABLE `pay_channel`
|
||||
-- MODIFY COLUMN `config` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '支付渠道配置' AFTER `app_id`;
|
||||
|
||||
-- ----------------------------
|
||||
-- 充值套餐表
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pay_wallet_recharge_package`;
|
||||
CREATE TABLE `pay_wallet_recharge_package`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`name` varchar(64) NOT NULL COMMENT '套餐名',
|
||||
`pay_price` int NOT NULL COMMENT '支付金额',
|
||||
`bonus_price` int NOT NULL COMMENT '赠送金额',
|
||||
`status` tinyint NOT NULL COMMENT '状态',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB COMMENT='充值套餐表';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for pay_wallet_recharge
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `pay_wallet_recharge`;
|
||||
CREATE TABLE `pay_wallet_recharge` (
|
||||
`id` bigint(0) NOT NULL AUTO_INCREMENT COMMENT '编号',
|
||||
`wallet_id` bigint(0) NOT NULL COMMENT '会员钱包 id',
|
||||
`total_price` int(0) NOT NULL COMMENT '用户实际到账余额,例如充 100 送 20,则该值是 120',
|
||||
`pay_price` int(0) NOT NULL COMMENT '实际支付金额',
|
||||
`bonus_price` int(0) NOT NULL COMMENT '钱包赠送金额',
|
||||
`package_id` bigint(0) DEFAULT NULL COMMENT '充值套餐编号',
|
||||
`pay_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已支付:[0:未支付 1:已经支付过]',
|
||||
`pay_order_id` bigint(0) DEFAULT NULL COMMENT '支付订单编号',
|
||||
`pay_channel_code` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '支付成功的支付渠道',
|
||||
`pay_time` datetime(0) DEFAULT NULL COMMENT '订单支付时间',
|
||||
`pay_refund_id` bigint(0) DEFAULT NULL COMMENT '支付退款单编号',
|
||||
`refund_total_price` int(0) NOT NULL DEFAULT 0 COMMENT '退款金额,包含赠送金额',
|
||||
`refund_pay_price` int(0) NOT NULL DEFAULT 0 COMMENT '退款支付金额',
|
||||
`refund_bonus_price` int(0) NOT NULL DEFAULT 0 COMMENT '退款钱包赠送金额',
|
||||
`refund_time` datetime(0) DEFAULT NULL COMMENT '退款时间',
|
||||
`refund_status` int(0) NOT NULL DEFAULT 0 COMMENT '退款状态',
|
||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '创建者',
|
||||
`create_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT '' COMMENT '更新者',
|
||||
`update_time` datetime(0) NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP(0) COMMENT '更新时间',
|
||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
||||
`tenant_id` bigint(0) NOT NULL DEFAULT 0 COMMENT '租户编号',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员钱包充值' ROW_FORMAT = Dynamic;
|
||||
|
||||
-- 钱包充值套餐,钱包余额菜单脚本
|
||||
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status, component_name
|
||||
)
|
||||
VALUES (
|
||||
'钱包管理', '', 1, 5, 1117,
|
||||
'wallet', 'ep:caret-right', '', 0, ''
|
||||
);
|
||||
SELECT @parentId1 := LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status, component_name
|
||||
)
|
||||
VALUES (
|
||||
'充值套餐', '', 2, 2, @parentId1,
|
||||
'wallet-recharge-package', 'fa:leaf', 'pay/wallet/rechargePackage/index', 0, 'WalletRechargePackage'
|
||||
);
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
|
||||
-- 按钮 SQL
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status
|
||||
)
|
||||
VALUES (
|
||||
'钱包充值套餐查询', 'pay:wallet-recharge-package:query', 3, 1, @parentId,
|
||||
'', '', '', 0
|
||||
);
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status
|
||||
)
|
||||
VALUES (
|
||||
'钱包充值套餐创建', 'pay:wallet-recharge-package:create', 3, 2, @parentId,
|
||||
'', '', '', 0
|
||||
);
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status
|
||||
)
|
||||
VALUES (
|
||||
'钱包充值套餐更新', 'pay:wallet-recharge-package:update', 3, 3, @parentId,
|
||||
'', '', '', 0
|
||||
);
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status
|
||||
)
|
||||
VALUES (
|
||||
'钱包充值套餐删除', 'pay:wallet-recharge-package:delete', 3, 4, @parentId,
|
||||
'', '', '', 0
|
||||
);
|
||||
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status, component_name
|
||||
)
|
||||
VALUES (
|
||||
'钱包余额', '', 2, 1, @parentId1,
|
||||
'wallet-balance', 'fa:leaf', 'pay/wallet/balance/index', 0, 'WalletBalance'
|
||||
);
|
||||
|
||||
SELECT @parentId := LAST_INSERT_ID();
|
||||
|
||||
-- 按钮 SQL
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status
|
||||
)
|
||||
VALUES (
|
||||
'钱包余额查询', 'pay:wallet:query', 3, 1, @parentId,
|
||||
'', '', '', 0
|
||||
);
|
||||
|
||||
-- 支付实战和转账实战数据库脚本
|
||||
|
||||
update system_menu set deleted = 1 where id = 2161;
|
||||
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status, component_name
|
||||
)
|
||||
VALUES (
|
||||
'接入示例', '', 1, 99, 1117,
|
||||
'demo', 'ep:caret-right', '', 0, ''
|
||||
);
|
||||
|
||||
SELECT @parentId1 := LAST_INSERT_ID();
|
||||
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status, component_name
|
||||
)
|
||||
VALUES (
|
||||
'支付实战', '', 2, 1, @parentId1,
|
||||
'demo-order', 'fa:leaf', 'pay/demo/order/index', 0, NULL
|
||||
);
|
||||
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status, component_name
|
||||
)
|
||||
VALUES (
|
||||
'转账实战', '', 2, 1, @parentId1,
|
||||
'demo-transfer', 'fa:leaf', 'pay/demo/transfer/index', 0, NULL
|
||||
);
|
||||
|
||||
-- 转账状态和转账类型数据字典
|
||||
INSERT INTO `system_dict_type`(`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ('支付转账类型', 'pay_transfer_type', 0, '', '1', '2023-10-28 16:27:18', '1', '2023-10-28 16:27:18', b'0', '1970-01-01 00:00:00');
|
||||
INSERT INTO `system_dict_type`(`name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES ('转账订单状态', 'pay_transfer_status', 0, '', '1', '2023-10-28 16:18:32', '1', '2023-10-28 16:18:32', b'0', '1970-01-01 00:00:00');
|
||||
|
||||
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (4, '钱包余额', '4', 'pay_transfer_type', 0, 'info', '', '', '1', '2023-10-28 16:28:37', '1', '2023-10-28 16:28:37', b'0');
|
||||
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3, '银行卡', '3', 'pay_transfer_type', 0, 'default', '', '', '1', '2023-10-28 16:28:21', '1', '2023-10-28 16:28:21', b'0');
|
||||
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2, '微信余额', '2', 'pay_transfer_type', 0, 'info', '', '', '1', '2023-10-28 16:28:07', '1', '2023-10-28 16:28:07', b'0');
|
||||
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '支付宝余额', '1', 'pay_transfer_type', 0, 'default', '', '', '1', '2023-10-28 16:27:44', '1', '2023-10-28 16:27:44', b'0');
|
||||
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (4, '转账失败', '30', 'pay_transfer_status', 0, 'warning', '', '', '1', '2023-10-28 16:24:16', '1', '2023-10-28 16:24:16', b'0');
|
||||
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (3, '转账成功', '20', 'pay_transfer_status', 0, 'success', '', '', '1', '2023-10-28 16:23:50', '1', '2023-10-28 16:23:50', b'0');
|
||||
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (2, '转账进行中', '10', 'pay_transfer_status', 0, 'info', '', '', '1', '2023-10-28 16:23:12', '1', '2023-10-28 16:23:12', b'0');
|
||||
INSERT INTO `system_dict_data`(`sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (1, '等待转账', '0', 'pay_transfer_status', 0, 'default', '', '', '1', '2023-10-28 16:21:43', '1', '2023-10-28 16:23:22', b'0');
|
||||
|
||||
-- 转账订单菜单脚本
|
||||
|
||||
INSERT INTO system_menu(
|
||||
name, permission, type, sort, parent_id,
|
||||
path, icon, component, status, component_name
|
||||
)
|
||||
VALUES (
|
||||
'转账订单', '', 2, 3, 1117,
|
||||
'transfer', 'ep:credit-card', 'pay/transfer/index', 0, 'PayTransfer'
|
||||
);
|
||||
|
||||
-- 转账通知脚本
|
||||
|
||||
ALTER TABLE `pay_app`
|
||||
ADD COLUMN `transfer_notify_url` varchar(1024) NOT NULL COMMENT '转账结果的回调地址' AFTER `refund_notify_url`;
|
||||
ALTER TABLE `pay_notify_task`
|
||||
MODIFY COLUMN `merchant_order_id` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '商户订单编号' AFTER `status`,
|
||||
ADD COLUMN `merchant_transfer_id` varchar(64) COMMENT '商户转账单编号' AFTER `merchant_order_id`;
|
@ -2370,6 +2370,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 (2369, '拼团记录', 'promotion:combination-record:query', 2, 2, 2303, 'record', 'ep:avatar', 'mall/promotion/combination/record/index.vue', 'PromotionCombinationRecord', 0, b'1', b'1', b'1', '1', '2023-10-08 07:10:22', '1', '2023-10-08 07:34:11', 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 (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');
|
||||
--此处缺少trade:order:query 和 trade:order:update权限,会导致订单的发货和更多按钮无法显示。
|
||||
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');
|
||||
@ -2478,6 +2479,15 @@ 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 (2523, '客户限制配置导出', 'crm:customer-limit-config:export', 3, 5, 2518, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-11-18 13:33:53', '', '2023-11-18 13:33:53', 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 (2524, '系统配置', '', 1, 99, 2397, 'config', 'ep:connection', '', '', 0, b'1', b'1', b'1', '1', '2023-11-18 21:58:00', '1', '2023-11-18 21:58:00', 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 (2525, 'WebSocket 测试', '', 2, 7, 2, 'websocket', 'ep:connection', 'infra/webSocket/index', 'InfraWebSocket', 0, b'1', b'1', b'1', '1', '2023-11-23 19:41:55', '1', '2023-11-24 19:22: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 (2526, '抄送流程', '', 2, 21, 1200, 'processInstanceCC', 'eye', '/bpm/task/cc/index',
|
||||
'BpmCCProcessInstance', 0, true, true, true, 1, '2023-01-13 16:14:00', '1', '2023-01-13 16:14:00', false),
|
||||
(2527, '抄送流程查询', 'bpm:process-instance-cc:query', 3, 1, 2526, '', '', '', NULL, 0, b'1', b'1', b'1', '1',
|
||||
'2023-01-13 16:14:00', '1', '2023-01-13 16:14:00', b'0'),
|
||||
(2528, '抄送流程创建', 'bpm:process-instance-cc:create', 3, 2, 2526, '', '', '', NULL, 0, b'1', b'1', b'1', '1',
|
||||
'2023-01-13 16:14:00', '1', '2023-01-13 16:14:00', b'0');
|
||||
COMMIT;
|
||||
|
||||
-- ----------------------------
|
||||
|
@ -26,7 +26,7 @@
|
||||
<mybatis-plus.version>3.5.4.1</mybatis-plus.version>
|
||||
<mybatis-plus-generator.version>3.5.4.1</mybatis-plus-generator.version>
|
||||
<dynamic-datasource.version>4.2.0</dynamic-datasource.version>
|
||||
<mybatis-plus-join.version>1.4.7.2</mybatis-plus-join.version>
|
||||
<mybatis-plus-join.version>1.4.8.1</mybatis-plus-join.version>
|
||||
<redisson.version>3.25.0</redisson.version>
|
||||
<dm8.jdbc.version>8.1.3.62</dm8.jdbc.version>
|
||||
<!-- 消息队列 -->
|
||||
@ -62,6 +62,7 @@
|
||||
<jsch.version>0.1.55</jsch.version>
|
||||
<tika-core.version>2.9.1</tika-core.version>
|
||||
<ip2region.version>2.7.0</ip2region.version>
|
||||
<bizlog-sdk.version>3.0.6</bizlog-sdk.version>
|
||||
<!-- 三方云服务相关 -->
|
||||
<okio.version>3.5.0</okio.version>
|
||||
<okhttp3.version>4.11.0</okhttp3.version>
|
||||
@ -99,6 +100,17 @@
|
||||
<artifactId>yudao-spring-boot-starter-biz-operatelog</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.github.mouzt</groupId>
|
||||
<artifactId>bizlog-sdk</artifactId>
|
||||
<version>${bizlog-sdk.version}</version>
|
||||
<exclusions>
|
||||
<exclusion> <!-- 排除掉springboot依赖使用项目的 -->
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
|
||||
|
@ -15,6 +15,7 @@ import java.util.Arrays;
|
||||
@Getter
|
||||
public enum TerminalEnum implements IntArrayValuable {
|
||||
|
||||
UNKNOWN(0, "未知"), // 目的:在无法解析到 terminal 时,使用它
|
||||
WECHAT_MINI_PROGRAM(10, "微信小程序"),
|
||||
WECHAT_WAP(11, "微信公众号"),
|
||||
H5(20, "H5 网页"),
|
||||
|
@ -0,0 +1,19 @@
|
||||
package cn.iocoder.yudao.framework.common.pojo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "可排序的分页参数")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class SortablePageParam extends PageParam {
|
||||
|
||||
@Schema(description = "排序字段")
|
||||
private List<SortingField> sortingFields;
|
||||
|
||||
}
|
@ -177,4 +177,14 @@ public class DateUtils {
|
||||
return LocalDateTimeUtil.isSameDay(date, LocalDateTime.now());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否昨天
|
||||
*
|
||||
* @param date 日期
|
||||
* @return 是否
|
||||
*/
|
||||
public static boolean isYesterday(LocalDateTime date) {
|
||||
return LocalDateTimeUtil.isSameDay(date, LocalDateTime.now().minusDays(1));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
|
||||
/**
|
||||
@ -121,4 +122,14 @@ public class LocalDateTimeUtils {
|
||||
return date.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定日期到现在过了几天,如果指定日期在当前日期之后,获取结果为负
|
||||
*
|
||||
* @param dateTime 日期
|
||||
* @return 相差天数
|
||||
*/
|
||||
public static Long between(LocalDateTime dateTime) {
|
||||
return LocalDateTimeUtil.between(dateTime, LocalDateTime.now(), ChronoUnit.DAYS);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Bean 工具类
|
||||
@ -20,6 +21,14 @@ public class BeanUtils {
|
||||
return BeanUtil.toBean(source, targetClass);
|
||||
}
|
||||
|
||||
public static <T> T toBean(Object source, Class<T> targetClass, Consumer<T> peek) {
|
||||
T target = toBean(source, targetClass);
|
||||
if (target != null) {
|
||||
peek.accept(target);
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
public static <S, T> List<T> toBean(List<S> source, Class<T> targetType) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
@ -27,11 +36,27 @@ public class BeanUtils {
|
||||
return CollectionUtils.convertList(source, s -> toBean(s, targetType));
|
||||
}
|
||||
|
||||
public static <S, T> PageResult<T> toBean(PageResult<S> source, Class<T> targetType) {
|
||||
public static <S, T> List<T> toBean(List<S> source, Class<T> targetType, Consumer<T> peek) {
|
||||
List<T> list = toBean(source, targetType);
|
||||
if (list != null) {
|
||||
list.forEach(peek);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static <S, T> PageResult<T> toBean(PageResult<S> source, Class<T> targetType) {
|
||||
return toBean(source, targetType, null);
|
||||
}
|
||||
|
||||
public static <S, T> PageResult<T> toBean(PageResult<S> source, Class<T> targetType, Consumer<T> peek) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
return new PageResult<>(toBean(source.getList(), targetType), source.getTotal());
|
||||
List<T> list = toBean(source.getList(), targetType);
|
||||
if (peek != null) {
|
||||
list.forEach(peek);
|
||||
}
|
||||
return new PageResult<>(list, source.getTotal());
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,15 @@
|
||||
package cn.iocoder.yudao.framework.common.util.object;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.func.Func1;
|
||||
import cn.hutool.core.lang.func.LambdaUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortablePageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortingField;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link cn.iocoder.yudao.framework.common.pojo.PageParam} 工具类
|
||||
@ -9,8 +18,50 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
*/
|
||||
public class PageUtils {
|
||||
|
||||
private static final Object[] ORDER_TYPES = new String[]{SortingField.ORDER_ASC, SortingField.ORDER_DESC};
|
||||
|
||||
public static int getStart(PageParam pageParam) {
|
||||
return (pageParam.getPageNo() - 1) * pageParam.getPageSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建排序字段(默认倒序)
|
||||
*
|
||||
* @param func 排序字段的 Lambda 表达式
|
||||
* @param <T> 排序字段所属的类型
|
||||
* @return 排序字段
|
||||
*/
|
||||
public static <T> SortingField buildSortingField(Func1<T, ?> func) {
|
||||
return buildSortingField(func, SortingField.ORDER_DESC);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建排序字段
|
||||
*
|
||||
* @param func 排序字段的 Lambda 表达式
|
||||
* @param order 排序类型 {@link SortingField#ORDER_ASC} {@link SortingField#ORDER_DESC}
|
||||
* @param <T> 排序字段所属的类型
|
||||
* @return 排序字段
|
||||
*/
|
||||
public static <T> SortingField buildSortingField(Func1<T, ?> func, String order) {
|
||||
Assert.isTrue(ArrayUtil.contains(ORDER_TYPES, order), String.format("字段的排序类型只能是 %s/%s", ORDER_TYPES));
|
||||
|
||||
String fieldName = LambdaUtil.getFieldName(func);
|
||||
return new SortingField(fieldName, order);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建默认的排序字段
|
||||
* 如果排序字段为空,则设置排序字段;否则忽略
|
||||
*
|
||||
* @param sortablePageParam 排序分页查询参数
|
||||
* @param func 排序字段的 Lambda 表达式
|
||||
* @param <T> 排序字段所属的类型
|
||||
*/
|
||||
public static <T> void buildDefaultSortingField(SortablePageParam sortablePageParam, Func1<T, ?> func) {
|
||||
if (sortablePageParam != null && CollUtil.isEmpty(sortablePageParam.getSortingFields())) {
|
||||
sortablePageParam.setSortingFields(List.of(buildSortingField(func)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -88,8 +88,6 @@ public class ServletUtils {
|
||||
return JakartaServletUtil.getClientIP(request);
|
||||
}
|
||||
|
||||
// TODO @疯狂:terminal 还是从 ServletUtils 里拿,更容易全局治理;
|
||||
|
||||
public static boolean isJsonRequest(ServletRequest request) {
|
||||
return StrUtil.startWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE);
|
||||
}
|
||||
|
@ -496,7 +496,8 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
|
||||
Expression allExpression = null;
|
||||
for (DataPermissionRule rule : ContextHolder.getRules()) {
|
||||
// 判断表名是否匹配
|
||||
if (!rule.getTableNames().contains(table.getName())) {
|
||||
String tableName = MyBatisUtils.getTableName(table);
|
||||
if (!rule.getTableNames().contains(tableName)) {
|
||||
continue;
|
||||
}
|
||||
// 如果有匹配的规则,说明可重写。
|
||||
@ -505,7 +506,6 @@ public class DataPermissionDatabaseInterceptor extends JsqlParserSupport impleme
|
||||
ContextHolder.setRewrite(true);
|
||||
|
||||
// 单条规则的条件
|
||||
String tableName = MyBatisUtils.getTableName(table);
|
||||
Expression oneExpress = rule.getExpression(tableName, table.getAlias());
|
||||
if (oneExpress == null){
|
||||
continue;
|
||||
|
@ -46,6 +46,7 @@
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
@ -71,6 +71,7 @@ public abstract class AbstractWxPayClient extends AbstractPayClient<WxPayClientC
|
||||
if (StrUtil.isNotEmpty(config.getPrivateCertContent())) {
|
||||
payConfig.setPrivateCertPath(FileUtils.createTempFile(config.getPrivateCertContent()).getPath());
|
||||
}
|
||||
// payConfig.setCertSerialNo();
|
||||
|
||||
// 创建 client 客户端
|
||||
client = new WxPayServiceImpl();
|
||||
|
@ -17,8 +17,8 @@ public class YudaoFlowableConfiguration {
|
||||
*
|
||||
* 如果不创建,会导致项目启动时,Flowable 报错的问题
|
||||
*/
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@Bean(name = "applicationTaskExecutor")
|
||||
@ConditionalOnMissingBean(name = "applicationTaskExecutor")
|
||||
public AsyncListenableTaskExecutor taskExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(8);
|
||||
|
@ -3,6 +3,8 @@ package cn.iocoder.yudao.framework.mybatis.core.mapper;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortablePageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.SortingField;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -13,6 +15,7 @@ import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||
import com.baomidou.mybatisplus.extension.toolkit.Db;
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.github.yulichang.interfaces.MPJBaseJoin;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.Collection;
|
||||
@ -26,7 +29,15 @@ import java.util.List;
|
||||
*/
|
||||
public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
||||
|
||||
default PageResult<T> selectPage(SortablePageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) {
|
||||
return selectPage(pageParam, pageParam.getSortingFields(), queryWrapper);
|
||||
}
|
||||
|
||||
default PageResult<T> selectPage(PageParam pageParam, @Param("ew") Wrapper<T> queryWrapper) {
|
||||
return selectPage(pageParam, null, queryWrapper);
|
||||
}
|
||||
|
||||
default PageResult<T> selectPage(PageParam pageParam, Collection<SortingField> sortingFields, @Param("ew") Wrapper<T> queryWrapper) {
|
||||
// 特殊:不分页,直接查询全部
|
||||
if (PageParam.PAGE_SIZE_NONE.equals(pageParam.getPageSize())) {
|
||||
List<T> list = selectList(queryWrapper);
|
||||
@ -34,12 +45,26 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
||||
}
|
||||
|
||||
// MyBatis Plus 查询
|
||||
IPage<T> mpPage = MyBatisUtils.buildPage(pageParam);
|
||||
IPage<T> mpPage = MyBatisUtils.buildPage(pageParam, sortingFields);
|
||||
selectPage(mpPage, queryWrapper);
|
||||
// 转换返回
|
||||
return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
|
||||
}
|
||||
|
||||
default <D> PageResult<D> selectJoinPage(PageParam pageParam, Class<D> clazz, MPJLambdaWrapper<T> lambdaWrapper) {
|
||||
// 特殊:不分页,直接查询全部
|
||||
if (PageParam.PAGE_SIZE_NONE.equals(pageParam.getPageNo())) {
|
||||
List<D> list = selectJoinList(clazz, lambdaWrapper);
|
||||
return new PageResult<>(list, (long) list.size());
|
||||
}
|
||||
|
||||
// MyBatis Plus Join 查询
|
||||
IPage<D> mpPage = MyBatisUtils.buildPage(pageParam);
|
||||
mpPage = selectJoinPage(mpPage, clazz, lambdaWrapper);
|
||||
// 转换返回
|
||||
return new PageResult<>(mpPage.getRecords(), mpPage.getTotal());
|
||||
}
|
||||
|
||||
default <DTO> PageResult<DTO> selectJoinPage(PageParam pageParam, Class<DTO> resultTypeClass, MPJBaseJoin<T> joinQueryWrapper) {
|
||||
IPage<DTO> mpPage = MyBatisUtils.buildPage(pageParam);
|
||||
selectJoinPage(mpPage, resultTypeClass, joinQueryWrapper);
|
||||
|
@ -45,8 +45,8 @@ public class MyBatisUtils {
|
||||
* 由于 MybatisPlusInterceptor 不支持添加拦截器,所以只能全量设置
|
||||
*
|
||||
* @param interceptor 链
|
||||
* @param inner 拦截器
|
||||
* @param index 位置
|
||||
* @param inner 拦截器
|
||||
* @param index 位置
|
||||
*/
|
||||
public static void addInterceptor(MybatisPlusInterceptor interceptor, InnerInterceptor inner, int index) {
|
||||
List<InnerInterceptor> inners = new ArrayList<>(interceptor.getInterceptors());
|
||||
@ -73,9 +73,9 @@ public class MyBatisUtils {
|
||||
/**
|
||||
* 构建 Column 对象
|
||||
*
|
||||
* @param tableName 表名
|
||||
* @param tableName 表名
|
||||
* @param tableAlias 别名
|
||||
* @param column 字段名
|
||||
* @param column 字段名
|
||||
* @return Column 对象
|
||||
*/
|
||||
public static Column buildColumn(String tableName, Alias tableAlias, String column) {
|
||||
|
@ -12,7 +12,10 @@
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>${project.artifactId}</name>
|
||||
<description>用户的认证、权限的校验</description>
|
||||
<description>
|
||||
1. security:用户的认证、权限的校验,实现「谁」可以做「什么事」
|
||||
2. operatelog:操作日志,实现「谁」在「什么时间」对「什么」做了「什么事」
|
||||
</description>
|
||||
<url>https://github.com/YunaiV/ruoyi-vue-pro</url>
|
||||
|
||||
<dependencies>
|
||||
@ -50,6 +53,13 @@
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- Spring Boot 通用操作日志组件,基于注解实现 -->
|
||||
<!-- 此组件解决的问题是:「谁」在「什么时间」对「什么」做了「什么事」 -->
|
||||
<groupId>io.github.mouzt</groupId>
|
||||
<artifactId>bizlog-sdk</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 业务组件 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.framework.operatelog.config;
|
||||
|
||||
import cn.iocoder.yudao.framework.operatelog.core.service.LogRecordServiceImpl;
|
||||
import com.mzt.logapi.service.ILogRecordService;
|
||||
import com.mzt.logapi.starter.annotation.EnableLogRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
|
||||
/**
|
||||
* 操作日志配置类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@EnableLogRecord(tenant = "") // 貌似用不上 tenant 这玩意给个空好啦
|
||||
@AutoConfiguration
|
||||
@Slf4j
|
||||
public class YudaoOperateLogV2Configuration {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
public ILogRecordService iLogRecordServiceImpl() {
|
||||
return new LogRecordServiceImpl();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* 占位,无特殊作用
|
||||
*/
|
||||
package cn.iocoder.yudao.framework.operatelog.core;
|
@ -0,0 +1,89 @@
|
||||
package cn.iocoder.yudao.framework.operatelog.core.service;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import cn.iocoder.yudao.framework.security.core.LoginUser;
|
||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2CreateReqDTO;
|
||||
import com.mzt.logapi.beans.LogRecord;
|
||||
import com.mzt.logapi.service.ILogRecordService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 操作日志 ILogRecordService 实现类
|
||||
*
|
||||
* 基于 {@link OperateLogApi} 实现,记录操作日志
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Slf4j
|
||||
public class LogRecordServiceImpl implements ILogRecordService {
|
||||
|
||||
@Resource
|
||||
private OperateLogApi operateLogApi;
|
||||
|
||||
@Override
|
||||
public void record(LogRecord logRecord) {
|
||||
// 1. 补全通用字段
|
||||
OperateLogV2CreateReqDTO reqDTO = new OperateLogV2CreateReqDTO();
|
||||
reqDTO.setTraceId(TracerUtils.getTraceId());
|
||||
// 补充用户信息
|
||||
fillUserFields(reqDTO);
|
||||
// 补全模块信息
|
||||
fillModuleFields(reqDTO, logRecord);
|
||||
// 补全请求信息
|
||||
fillRequestFields(reqDTO);
|
||||
|
||||
// 2. 异步记录日志
|
||||
operateLogApi.createOperateLogV2(reqDTO);
|
||||
// TODO 测试结束删除或搞个开关
|
||||
log.info("操作日志 ===> {}", reqDTO);
|
||||
}
|
||||
|
||||
private static void fillUserFields(OperateLogV2CreateReqDTO reqDTO) {
|
||||
// 使用 SecurityFrameworkUtils。因为要考虑,rpc、mq、job,它其实不是 web;
|
||||
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return;
|
||||
}
|
||||
reqDTO.setUserId(loginUser.getId());
|
||||
reqDTO.setUserType(loginUser.getUserType());
|
||||
}
|
||||
|
||||
public static void fillModuleFields(OperateLogV2CreateReqDTO reqDTO, LogRecord logRecord) {
|
||||
reqDTO.setType(logRecord.getType()); // 大模块类型,例如:CRM 客户
|
||||
reqDTO.setSubType(logRecord.getSubType());// 操作名称,例如:转移客户
|
||||
reqDTO.setBizId(Long.parseLong(logRecord.getBizNo())); // 业务编号,例如:客户编号
|
||||
reqDTO.setAction(logRecord.getAction());// 操作内容,例如:修改编号为 1 的用户信息,将性别从男改成女,将姓名从芋道改成源码。
|
||||
reqDTO.setExtra(logRecord.getExtra()); // 拓展字段,有些复杂的业务,需要记录一些字段 ( JSON 格式 ),例如说,记录订单编号,{ orderId: "1"}
|
||||
}
|
||||
|
||||
private static void fillRequestFields(OperateLogV2CreateReqDTO reqDTO) {
|
||||
// 获得 Request 对象
|
||||
HttpServletRequest request = ServletUtils.getRequest();
|
||||
if (request == null) {
|
||||
return;
|
||||
}
|
||||
// 补全请求信息
|
||||
reqDTO.setRequestMethod(request.getMethod());
|
||||
reqDTO.setRequestUrl(request.getRequestURI());
|
||||
reqDTO.setUserIp(ServletUtils.getClientIP(request));
|
||||
reqDTO.setUserAgent(ServletUtils.getUserAgent(request));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogRecord> queryLog(String bizNo, String type) {
|
||||
throw new UnsupportedOperationException("使用 OperateLogApi 进行操作日志的查询");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LogRecord> queryLogByBizNo(String bizNo, String type, String subType) {
|
||||
throw new UnsupportedOperationException("使用 OperateLogApi 进行操作日志的查询");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* 基于 mzt-log 框架
|
||||
* 实现操作日志功能
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
package cn.iocoder.yudao.framework.operatelog;
|
@ -1,2 +1,3 @@
|
||||
cn.iocoder.yudao.framework.security.config.YudaoSecurityAutoConfiguration
|
||||
cn.iocoder.yudao.framework.security.config.YudaoWebSecurityConfigurerAdapter
|
||||
cn.iocoder.yudao.framework.security.config.YudaoWebSecurityConfigurerAdapter
|
||||
cn.iocoder.yudao.framework.operatelog.config.YudaoOperateLogV2Configuration
|
@ -1,8 +1,11 @@
|
||||
package cn.iocoder.yudao.framework.web.core.util;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
|
||||
import cn.iocoder.yudao.framework.web.config.WebProperties;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
@ -25,6 +28,13 @@ public class WebFrameworkUtils {
|
||||
|
||||
public static final String HEADER_TENANT_ID = "tenant-id";
|
||||
|
||||
/**
|
||||
* 终端的 Header
|
||||
*
|
||||
* @see cn.iocoder.yudao.framework.common.enums.TerminalEnum
|
||||
*/
|
||||
public static final String HEADER_TERMINAL = "terminal";
|
||||
|
||||
private static WebProperties properties;
|
||||
|
||||
public WebFrameworkUtils(WebProperties webProperties) {
|
||||
@ -107,6 +117,15 @@ public class WebFrameworkUtils {
|
||||
return getLoginUserId(request);
|
||||
}
|
||||
|
||||
public static Integer getTerminal() {
|
||||
HttpServletRequest request = getRequest();
|
||||
if (request == null) {
|
||||
return TerminalEnum.UNKNOWN.getTerminal();
|
||||
}
|
||||
String terminalValue = request.getHeader(HEADER_TERMINAL);
|
||||
return NumberUtil.parseInt(terminalValue, TerminalEnum.UNKNOWN.getTerminal());
|
||||
}
|
||||
|
||||
public static void setCommonResult(ServletRequest request, CommonResult<?> result) {
|
||||
request.setAttribute(REQUEST_ATTRIBUTE_COMMON_RESULT, result);
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.rule.BpmTaskAssignRuleBaseVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 流程任务分配规则 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*
|
||||
* @see BpmTaskAssignRuleBaseVO
|
||||
*/
|
||||
@Data
|
||||
public class BpmTaskCandidateRuleVO {
|
||||
|
||||
@Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "bpm_task_assign_rule_type")
|
||||
@NotNull(message = "规则类型不能为空")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "规则值数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "1,2,3")
|
||||
@NotNull(message = "规则值数组不能为空")
|
||||
private Set<Long> options;
|
||||
|
||||
}
|
@ -3,17 +3,17 @@ package cn.iocoder.yudao.module.bpm.controller.admin.task;
|
||||
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.instance.*;
|
||||
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
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 jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@ -26,6 +26,9 @@ public class BpmProcessInstanceController {
|
||||
@Resource
|
||||
private BpmProcessInstanceService processInstanceService;
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceCopyService processInstanceCopyService;
|
||||
|
||||
@GetMapping("/my-page")
|
||||
@Operation(summary = "获得我的实例分页列表", description = "在【我的流程】菜单中,进行调用")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-instance:query')")
|
||||
@ -56,4 +59,22 @@ public class BpmProcessInstanceController {
|
||||
processInstanceService.cancelProcessInstance(getLoginUserId(), cancelReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO @kyle:抄送要不单独 controller?
|
||||
|
||||
@PostMapping("/cc/create")
|
||||
@Operation(summary = "抄送流程")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:create')")
|
||||
public CommonResult<Boolean> createProcessInstanceCC(@Valid @RequestBody BpmProcessInstanceCCReqVO createReqVO) {
|
||||
return success(processInstanceCopyService.ccProcessInstance(getLoginUserId(), createReqVO));
|
||||
}
|
||||
|
||||
@GetMapping("/cc/my-page")
|
||||
@Operation(summary = "获得抄送流程分页列表")
|
||||
@PreAuthorize("@ss.hasPermission('bpm:process-instance-cc:query')")
|
||||
public CommonResult<PageResult<BpmProcessInstanceCCPageItemRespVO>> getProcessInstanceCCPage(
|
||||
@Valid BpmProcessInstanceCCMyPageReqVO pageReqVO) {
|
||||
return success(processInstanceCopyService.getMyProcessInstanceCCPage(getLoginUserId(), pageReqVO));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
// TODO @kyle:建议改成 BpmProcessInstanceCopyMyPageReqVO;cc 缩写不容易理解,所以改成 copy,虽然会长一点,但是可读性更重要;
|
||||
@Schema(description = "管理后台 - 流程实例抄送的分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmProcessInstanceCCMyPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "流程名称", example = "芋道")
|
||||
private String processInstanceName;
|
||||
|
||||
@Schema(description = "流程编号", example = "123456768")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 流程实例抄送的分页 Item Response VO")
|
||||
@Data
|
||||
public class BpmProcessInstanceCCPageItemRespVO {
|
||||
|
||||
// TODO @kyle:如果已经写了 swagger 注解,可以不用写 java 注释哈;
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@Schema(description = "抄送主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 发起人Id
|
||||
*/
|
||||
@Schema(description = "发起人Id")
|
||||
private Long startUserId;
|
||||
|
||||
@Schema(description = "发起人别名")
|
||||
private String startUserNickname;
|
||||
|
||||
/**
|
||||
* 流程主键
|
||||
*/
|
||||
@Schema(description = "流程实例的主键")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "流程实例的名称")
|
||||
private String processInstanceName;
|
||||
/**
|
||||
* 任务主键
|
||||
*/
|
||||
@Schema(description = "发起抄送的任务编号")
|
||||
private String taskId;
|
||||
|
||||
@Schema(description = "发起抄送的任务名称")
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "抄送原因")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "抄送人")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "抄送人别名")
|
||||
private String creatorNickname;
|
||||
|
||||
@Schema(description = "抄送时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
// TODO @kyle:这个 VO 可以改成 BpmProcessInstanceCopyCreateReqVO
|
||||
@Schema(description = "管理后台 - 流程实例的抄送 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class BpmProcessInstanceCCReqVO extends BpmTaskCandidateRuleVO {
|
||||
|
||||
@Schema(description = "任务编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotEmpty(message = "任务编号不能为空")
|
||||
private String taskKey;
|
||||
|
||||
@Schema(description = "任务名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotEmpty(message = "任务名称不能为空")
|
||||
private String taskName;
|
||||
|
||||
@Schema(description = "流程实例的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotEmpty(message = "流程实例的编号不能为空")
|
||||
private String processInstanceKey;
|
||||
|
||||
@Schema(description = "发起流程的用户的编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotNull(message = "发起流程的用户的编号不能为空")
|
||||
private Long startUserId;
|
||||
|
||||
@Schema(description = "任务实例名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||
@NotEmpty(message = "任务实例名称不能为空")
|
||||
private String processInstanceName;
|
||||
|
||||
@Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!")
|
||||
@NotBlank(message = "抄送原因不能为空")
|
||||
private String reason;
|
||||
|
||||
// TODO @kyle:看了下字段有点多,尽量不传递可推导的字段;
|
||||
// 需要传递:taskId(任务编号)、reason、userIds(被抄送的人)
|
||||
// 不需要传递:taskKey、taskName、processInstanceKey、startUserId、processInstanceName 因为这些可以后端查询到
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
package cn.iocoder.yudao.module.bpm.convert.cc;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
|
||||
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyVO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
// TODO kyle:类注释不太对
|
||||
/**
|
||||
* 动态表单 Convert
|
||||
*
|
||||
* @author 芋艿
|
||||
*/
|
||||
@Mapper
|
||||
public interface BpmProcessInstanceCopyConvert {
|
||||
|
||||
BpmProcessInstanceCopyConvert INSTANCE = Mappers.getMapper(BpmProcessInstanceCopyConvert.class);
|
||||
|
||||
// TODO @kyle:可以使用 BeanUtils copy 替代这些简单的哈;
|
||||
BpmProcessInstanceCopyDO copy(BpmProcessInstanceCopyDO bean);
|
||||
|
||||
BpmProcessInstanceCopyVO convert(BpmProcessInstanceCopyDO bean);
|
||||
|
||||
List<BpmProcessInstanceCCPageItemRespVO> convertList(List<BpmProcessInstanceCopyDO> list);
|
||||
|
||||
// TODO @kyle:/* taskId */ 这种注释一般不用写,可以一眼看明白的;避免变量看着略微不清晰哈
|
||||
default PageResult<BpmProcessInstanceCCPageItemRespVO> convertPage(PageResult<BpmProcessInstanceCopyDO> page
|
||||
, Map<String/* taskId */, String/* taskName */> taskMap
|
||||
, Map<String/* processInstaneId */, String/* processInstaneName */> processInstaneMap
|
||||
, Map<Long/* userId */, String/* userName */> userMap
|
||||
) {
|
||||
List<BpmProcessInstanceCCPageItemRespVO> list = convertList(page.getList());
|
||||
for (BpmProcessInstanceCCPageItemRespVO vo : list) {
|
||||
MapUtils.findAndThen(userMap, Long.valueOf(vo.getCreator()),
|
||||
vo::setCreatorNickname);
|
||||
MapUtils.findAndThen(userMap, vo.getStartUserId(),
|
||||
vo::setStartUserNickname);
|
||||
MapUtils.findAndThen(taskMap, vo.getTaskId(),
|
||||
vo::setTaskName);
|
||||
MapUtils.findAndThen(processInstaneMap, vo.getProcessInstanceId(),
|
||||
vo::setProcessInstanceName);
|
||||
}
|
||||
// TODO @kyle:可以精简成下面的哈;
|
||||
// List<BpmProcessInstanceCCPageItemRespVO> list2 = BeanUtils.toBean(page.getList(),
|
||||
// BpmProcessInstanceCCPageItemRespVO.class,
|
||||
// copy -> {
|
||||
// MapUtils.findAndThen(userMap, Long.valueOf(copy.getCreator()), copy::setCreatorNickname);
|
||||
// MapUtils.findAndThen(userMap, copy.getStartUserId(), copy::setStartUserNickname);
|
||||
// MapUtils.findAndThen(taskMap, copy.getTaskId(), copy::setTaskName);
|
||||
// MapUtils.findAndThen(processInstaneMap, copy.getProcessInstanceId(), copy::setProcessInstanceName);
|
||||
// });
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.dataobject.cc;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 流程抄送 DO
|
||||
*
|
||||
* @author kyle
|
||||
* @date 2022-05-19 TODO @kyle:@date 不是标准 java doc,可以使用 @since 替代,然后日期是不是不对
|
||||
*/
|
||||
@TableName(value = "bpm_process_instance_copy", autoResultMap = true)
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BpmProcessInstanceCopyDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
// TODO @kyle:字段如果是关联或者冗余,要写下注释。以 processInstanceId 举例子。
|
||||
/**
|
||||
* 发起人 Id
|
||||
*/
|
||||
private Long startUserId;
|
||||
/**
|
||||
* 流程名
|
||||
*/
|
||||
private String processInstanceName;
|
||||
/**
|
||||
* 流程实例的编号
|
||||
*
|
||||
* 关联 ProcessInstance 的 id 属性
|
||||
*/
|
||||
private String processInstanceId;
|
||||
|
||||
/**
|
||||
* 任务主键
|
||||
*/
|
||||
private String taskId;
|
||||
|
||||
/**
|
||||
* 任务名称
|
||||
*/
|
||||
private String taskName;
|
||||
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 抄送原因
|
||||
*/
|
||||
private String reason;
|
||||
|
||||
// TODO @kyle:这个字段,可以用 category 简化点
|
||||
/**
|
||||
* 流程分类
|
||||
*/
|
||||
private String processDefinitionCategory;
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.iocoder.yudao.module.bpm.dal.mysql.cc;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCMyPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BpmProcessInstanceCopyMapper extends BaseMapperX<BpmProcessInstanceCopyDO> { // TODO @kyle:方法和类之间要空行下;
|
||||
default PageResult<BpmProcessInstanceCopyDO> selectPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO reqVO){
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BpmProcessInstanceCopyDO>()
|
||||
.eqIfPresent(BpmProcessInstanceCopyDO::getUserId, loginUserId)
|
||||
.eqIfPresent(BpmProcessInstanceCopyDO::getProcessInstanceId, reqVO.getProcessInstanceId())
|
||||
.likeIfPresent(BpmProcessInstanceCopyDO::getProcessInstanceName, reqVO.getProcessInstanceName())
|
||||
.betweenIfPresent(BpmProcessInstanceCopyDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(BpmProcessInstanceCopyDO::getId));
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package cn.iocoder.yudao.module.bpm.framework.bpm.config;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor.*;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
// TODO @芋艿:Candidate 相关还在完善中,用户可以暂时忽略,仅 yudao 开发的同学需要关注~计划是把 Candidate 和 Assign 融合成一套
|
||||
/**
|
||||
* BPM 通用的 Configuration 配置类,提供给 Activiti 和 Flowable
|
||||
* @author kyle
|
||||
*/
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
public class BpmCandidateProcessorConfiguration {
|
||||
@Bean
|
||||
public BpmCandidateAdminUserApiSourceInfoProcessor bpmCandidateAdminUserApiSourceInfoProcessor() {
|
||||
return new BpmCandidateAdminUserApiSourceInfoProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BpmCandidateDeptApiSourceInfoProcessor bpmCandidateDeptApiSourceInfoProcessor() {
|
||||
return new BpmCandidateDeptApiSourceInfoProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BpmCandidatePostApiSourceInfoProcessor bpmCandidatePostApiSourceInfoProcessor() {
|
||||
return new BpmCandidatePostApiSourceInfoProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BpmCandidateRoleApiSourceInfoProcessor bpmCandidateRoleApiSourceInfoProcessor() {
|
||||
return new BpmCandidateRoleApiSourceInfoProcessor();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BpmCandidateUserGroupApiSourceInfoProcessor bpmCandidateUserGroupApiSourceInfoProcessor() {
|
||||
return new BpmCandidateUserGroupApiSourceInfoProcessor();
|
||||
}
|
||||
|
||||
/**
|
||||
* 可以自己定制脚本,然后通过这里设置到处理器里面去
|
||||
* @param scriptsOp 脚本包装对象
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public BpmCandidateScriptApiSourceInfoProcessor bpmCandidateScriptApiSourceInfoProcessor(ObjectProvider<BpmTaskAssignScript> scriptsOp) {
|
||||
BpmCandidateScriptApiSourceInfoProcessor bpmCandidateScriptApiSourceInfoProcessor = new BpmCandidateScriptApiSourceInfoProcessor();
|
||||
bpmCandidateScriptApiSourceInfoProcessor.setScripts(scriptsOp);
|
||||
return bpmCandidateScriptApiSourceInfoProcessor;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate;
|
||||
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 获取候选人信息
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class BpmCandidateSourceInfo {
|
||||
|
||||
@Schema(description = "流程id")
|
||||
@NotNull
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "当前任务ID")
|
||||
@NotNull
|
||||
private String taskId;
|
||||
/**
|
||||
* 通过这些规则,生成最终需要生成的用户
|
||||
*/
|
||||
@Schema(description = "当前任务预选规则")
|
||||
@NotEmpty(message = "不允许空规则")
|
||||
private Set<BpmTaskCandidateRuleVO> rules;
|
||||
|
||||
@Schema(description = "发起抄送的用户")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "抄送原因", requiredMode = Schema.RequiredMode.REQUIRED, example = "请帮忙审查下!")
|
||||
@NotEmpty(message = "抄送原因不能为空")
|
||||
private String reason;
|
||||
|
||||
public void addRule(BpmTaskCandidateRuleVO vo) {
|
||||
assert vo != null;
|
||||
if (rules == null) {
|
||||
rules = new HashSet<>();
|
||||
}
|
||||
rules.add(vo);
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public interface BpmCandidateSourceInfoProcessor {
|
||||
/**
|
||||
* 获取该处理器支持的类型
|
||||
* 来自 {@link BpmTaskAssignRuleTypeEnum}
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Set<Integer> getSupportedTypes();
|
||||
|
||||
/**
|
||||
* 对规则和人员做校验
|
||||
*
|
||||
* @param type 规则
|
||||
* @param options 人员id
|
||||
*/
|
||||
void validRuleOptions(Integer type, Set<Long> options);
|
||||
|
||||
/**
|
||||
* 默认的处理
|
||||
* 如果想去操作所有的规则,则可以覆盖此方法
|
||||
*
|
||||
* @param request 原始请求
|
||||
* @param delegateExecution 审批过程中的对象
|
||||
* @return 必须包含的是用户ID,而不是其他的ID
|
||||
* @throws Exception
|
||||
*/
|
||||
default Set<Long> process(BpmCandidateSourceInfo request, DelegateExecution delegateExecution) throws Exception {
|
||||
Set<BpmTaskCandidateRuleVO> rules = request.getRules();
|
||||
Set<Long> results = new HashSet<>();
|
||||
for (BpmTaskCandidateRuleVO rule : rules) {
|
||||
// 每个处理器都有机会处理自己支持的事件
|
||||
if (CollUtil.contains(getSupportedTypes(), rule.getType())) {
|
||||
results.addAll(doProcess(request, rule, delegateExecution));
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
default Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class BpmCandidateSourceInfoProcessorChain {
|
||||
|
||||
// 保存处理节点
|
||||
|
||||
private List<BpmCandidateSourceInfoProcessor> processorList;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
/**
|
||||
* 可添加其他处理器
|
||||
*
|
||||
* @param processorOp
|
||||
* @return
|
||||
*/
|
||||
@Resource
|
||||
// 动态扩展处理节点
|
||||
public BpmCandidateSourceInfoProcessorChain addProcessor(ObjectProvider<BpmCandidateSourceInfoProcessor> processorOp) {
|
||||
List<BpmCandidateSourceInfoProcessor> processor = ListUtil.toList(processorOp.iterator());
|
||||
if (null == processorList) {
|
||||
processorList = new ArrayList<>(processor.size());
|
||||
}
|
||||
processorList.addAll(processor);
|
||||
return this;
|
||||
}
|
||||
|
||||
// 获取处理器处理
|
||||
public Set<Long> process(BpmCandidateSourceInfo sourceInfo, DelegateExecution execution) throws Exception {
|
||||
// Verify our parameters
|
||||
if (sourceInfo == null) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
for (BpmCandidateSourceInfoProcessor processor : processorList) {
|
||||
try {
|
||||
for (BpmTaskCandidateRuleVO vo : sourceInfo.getRules()) {
|
||||
if (CollUtil.contains(processor.getSupportedTypes(), vo.getType())) {
|
||||
processor.validRuleOptions(vo.getType(), vo.getOptions());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
Set<Long> saveResult = Collections.emptySet();
|
||||
Exception saveException = null;
|
||||
for (BpmCandidateSourceInfoProcessor processor : processorList) {
|
||||
try {
|
||||
saveResult = processor.process(sourceInfo, execution);
|
||||
if (CollUtil.isNotEmpty(saveResult)) {
|
||||
removeDisableUsers(saveResult);
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
saveException = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Return the exception or result state from the last execute()
|
||||
if ((saveException != null)) {
|
||||
throw saveException;
|
||||
} else {
|
||||
return (saveResult);
|
||||
}
|
||||
}
|
||||
|
||||
public Set<Long> calculateTaskCandidateUsers(DelegateExecution execution, BpmCandidateSourceInfo sourceInfo) {
|
||||
Set<Long> results = Collections.emptySet();
|
||||
try {
|
||||
results = process(sourceInfo, execution);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除禁用用户
|
||||
*
|
||||
* @param assigneeUserIds
|
||||
*/
|
||||
public void removeDisableUsers(Set<Long> assigneeUserIds) {
|
||||
if (CollUtil.isEmpty(assigneeUserIds)) {
|
||||
return;
|
||||
}
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(assigneeUserIds);
|
||||
assigneeUserIds.removeIf(id -> {
|
||||
AdminUserRespDTO user = userMap.get(id);
|
||||
return user == null || !CommonStatusEnum.ENABLE.getStatus().equals(user.getStatus());
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Set;
|
||||
|
||||
public class BpmCandidateAdminUserApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
|
||||
@Resource
|
||||
private AdminUserApi api;
|
||||
|
||||
@Override
|
||||
public Set<Integer> getSupportedTypes() {
|
||||
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.USER.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validRuleOptions(Integer type, Set<Long> options) {
|
||||
api.validateUserList(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
|
||||
return rule.getOptions();
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
public class BpmCandidateDeptApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
|
||||
@Resource
|
||||
private DeptApi api;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public Set<Integer> getSupportedTypes() {
|
||||
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(),
|
||||
BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validRuleOptions(Integer type, Set<Long> options) {
|
||||
api.validateDeptList(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
|
||||
if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType(), rule.getType())) {
|
||||
List<AdminUserRespDTO> users = adminUserApi.getUserListByDeptIds(rule.getOptions());
|
||||
return convertSet(users, AdminUserRespDTO::getId);
|
||||
} else if (Objects.equals(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType(), rule.getType())) {
|
||||
List<DeptRespDTO> depts = api.getDeptList(rule.getOptions());
|
||||
return convertSet(depts, DeptRespDTO::getLeaderUserId);
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
|
||||
import cn.iocoder.yudao.module.system.api.dept.PostApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
|
||||
public class BpmCandidatePostApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
|
||||
@Resource
|
||||
private PostApi api;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public Set<Integer> getSupportedTypes() {
|
||||
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.POST.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validRuleOptions(Integer type, Set<Long> options) {
|
||||
api.validPostList(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
|
||||
List<AdminUserRespDTO> users = adminUserApi.getUserListByPostIds(rule.getOptions());
|
||||
return convertSet(users, AdminUserRespDTO::getId);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
|
||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.Set;
|
||||
|
||||
public class BpmCandidateRoleApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
|
||||
@Resource
|
||||
private RoleApi api;
|
||||
|
||||
@Resource
|
||||
private PermissionApi permissionApi;
|
||||
|
||||
@Override
|
||||
public Set<Integer> getSupportedTypes() {
|
||||
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.ROLE.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validRuleOptions(Integer type, Set<Long> options) {
|
||||
api.validRoleList(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
|
||||
return permissionApi.getUserRoleIdListByRoleIds(rule.getOptions());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.DictTypeConstants;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
|
||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.springframework.beans.factory.ObjectProvider;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
|
||||
import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.TASK_ASSIGN_SCRIPT_NOT_EXISTS;
|
||||
|
||||
public class BpmCandidateScriptApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
|
||||
@Resource
|
||||
private DictDataApi dictDataApi;
|
||||
|
||||
/**
|
||||
* 任务分配脚本
|
||||
*/
|
||||
private Map<Long, BpmTaskAssignScript> scriptMap = Collections.emptyMap();
|
||||
|
||||
public void setScripts(ObjectProvider<BpmTaskAssignScript> scriptsOp) {
|
||||
List<BpmTaskAssignScript> scripts = scriptsOp.orderedStream().collect(Collectors.toList());
|
||||
setScripts(scripts);
|
||||
}
|
||||
|
||||
public void setScripts(List<BpmTaskAssignScript> scripts) {
|
||||
this.scriptMap = convertMap(scripts, script -> script.getEnum().getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Integer> getSupportedTypes() {
|
||||
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.SCRIPT.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validRuleOptions(Integer type, Set<Long> options) {
|
||||
dictDataApi.validateDictDataList(DictTypeConstants.TASK_ASSIGN_SCRIPT,
|
||||
CollectionUtils.convertSet(options, String::valueOf));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
|
||||
return calculateTaskCandidateUsersByScript(delegateExecution, rule.getOptions());
|
||||
}
|
||||
|
||||
private Set<Long> calculateTaskCandidateUsersByScript(DelegateExecution execution, Set<Long> options) {
|
||||
// 获得对应的脚本
|
||||
List<BpmTaskAssignScript> scripts = new ArrayList<>(options.size());
|
||||
options.forEach(id -> {
|
||||
BpmTaskAssignScript script = scriptMap.get(id);
|
||||
if (script == null) {
|
||||
throw exception(TASK_ASSIGN_SCRIPT_NOT_EXISTS, id);
|
||||
}
|
||||
scripts.add(script);
|
||||
});
|
||||
// 逐个计算任务
|
||||
Set<Long> userIds = new HashSet<>();
|
||||
scripts.forEach(script -> CollUtil.addAll(userIds, script.calculateTaskCandidateUsers(execution)));
|
||||
return userIds;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.util.collection.SetUtils;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessor;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class BpmCandidateUserGroupApiSourceInfoProcessor implements BpmCandidateSourceInfoProcessor {
|
||||
@Resource
|
||||
private BpmUserGroupService api;
|
||||
@Resource
|
||||
private BpmUserGroupService userGroupService;
|
||||
|
||||
@Override
|
||||
public Set<Integer> getSupportedTypes() {
|
||||
return SetUtils.asSet(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validRuleOptions(Integer type, Set<Long> options) {
|
||||
api.validUserGroups(options);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> doProcess(BpmCandidateSourceInfo request, BpmTaskCandidateRuleVO rule, DelegateExecution delegateExecution) {
|
||||
List<BpmUserGroupDO> userGroups = userGroupService.getUserGroupList(rule.getOptions());
|
||||
Set<Long> userIds = new HashSet<>();
|
||||
userGroups.forEach(group -> userIds.addAll(group.getMemberUserIds()));
|
||||
return userIds;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.cc;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCMyPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||
|
||||
// TODO @kyle:这个 Service 要不挪到 task 包下;保持统一,task 下有流程、任务、抄送等;
|
||||
// TODO @kyle:中文和英文之间,有个空格,会更清晰点;例如说;流程抄送 Service 接口;中文写作习惯~
|
||||
/**
|
||||
* 流程抄送Service接口
|
||||
*
|
||||
* 现在是在审批的时候进行流程抄送
|
||||
*/
|
||||
public interface BpmProcessInstanceCopyService {
|
||||
|
||||
// TODO @kyle:无用的方法,可以去掉哈;另外,考虑到避免过多的 VO,这里就可以返回 BpmProcessInstanceCopyDO
|
||||
/**
|
||||
* 查询流程抄送
|
||||
*
|
||||
* @param copyId 流程抄送主键
|
||||
* @return 流程抄送
|
||||
*/
|
||||
BpmProcessInstanceCopyVO queryById(Long copyId);
|
||||
|
||||
// TODO 芋艿:这块要 review 下;思考下~~
|
||||
/**
|
||||
* 抄送
|
||||
* @param sourceInfo 抄送源信息,方便抄送处理
|
||||
* @return
|
||||
*/
|
||||
boolean makeCopy(BpmCandidateSourceInfo sourceInfo);
|
||||
|
||||
// TODO @kyle:可以方法名改成 createProcessInstanceCopy;现在项目一般新增都用 create 为主;
|
||||
/**
|
||||
* 流程实例的抄送
|
||||
*
|
||||
* @param userId 当前登录用户
|
||||
* @param createReqVO 创建的抄送请求
|
||||
* @return 是否抄送成功,抄送成功则返回true TODO @kyle:这里可以不用返回哈;目前一般是失败,就抛出业务异常;
|
||||
*/
|
||||
boolean ccProcessInstance(Long userId, BpmProcessInstanceCCReqVO createReqVO);
|
||||
|
||||
/**
|
||||
* 抄送的流程
|
||||
* @param loginUserId 登录用户id
|
||||
* @param pageReqVO 分页请求
|
||||
* @return 抄送的分页结果
|
||||
*/
|
||||
PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId,
|
||||
BpmProcessInstanceCCMyPageReqVO pageReqVO);
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.cc;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCMyPageReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCPageItemRespVO;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmProcessInstanceCCReqVO;
|
||||
import cn.iocoder.yudao.module.bpm.convert.cc.BpmProcessInstanceCopyConvert;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.cc.BpmProcessInstanceCopyDO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.mysql.cc.BpmProcessInstanceCopyMapper;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfo;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.BpmCandidateSourceInfoProcessorChain;
|
||||
import cn.iocoder.yudao.module.bpm.service.cc.dto.BpmDelegateExecutionDTO;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
|
||||
import cn.iocoder.yudao.module.bpm.service.task.BpmTaskService;
|
||||
import cn.iocoder.yudao.module.bpm.util.FlowableUtils;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// TODO @kyle:类注释要写下
|
||||
@Slf4j // TODO @kyle:按照 @Service、@Validated、@Slf4j,从重要到不重要的顺序;
|
||||
@Service
|
||||
@Validated
|
||||
public class BpmProcessInstanceCopyServiceImpl implements BpmProcessInstanceCopyService {
|
||||
@Resource // TODO @kyle:第一个变量,和类之间要有空行;
|
||||
private BpmProcessInstanceCopyMapper processInstanceCopyMapper;
|
||||
|
||||
/**
|
||||
* 和flowable有关的,查询流程名用的 TODO @kyle:可以不写哈注释;
|
||||
*/
|
||||
@Resource
|
||||
private RuntimeService runtimeService;
|
||||
|
||||
/**
|
||||
* 找抄送人用的 TODO @kyle:可以不写哈注释;
|
||||
*/
|
||||
@Resource
|
||||
private BpmCandidateSourceInfoProcessorChain processorChain;
|
||||
|
||||
// TODO @kyle:多余的变量,可以去掉哈
|
||||
@Resource
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmTaskService bpmTaskService;
|
||||
@Resource
|
||||
@Lazy // 解决循环依赖
|
||||
private BpmProcessInstanceService bpmProcessInstanceService;
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
|
||||
@Override
|
||||
public BpmProcessInstanceCopyVO queryById(Long copyId) {
|
||||
BpmProcessInstanceCopyDO bpmProcessInstanceCopyDO = processInstanceCopyMapper.selectById(copyId);
|
||||
return BpmProcessInstanceCopyConvert.INSTANCE.convert(bpmProcessInstanceCopyDO);
|
||||
}
|
||||
|
||||
// TODO @kyle:makeCopy 和 ccProcessInstance 的调用关系,感受上反了;
|
||||
// makeCopy 有点像基于规则,查找抄送人,然后创建;
|
||||
// ccProcessInstance 是已经有了抄送人,然后创建;
|
||||
// 建议的改造:独立基于 processInstanceCopyMapper 做 insert
|
||||
@Override
|
||||
public boolean makeCopy(BpmCandidateSourceInfo sourceInfo) {
|
||||
if (null == sourceInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
DelegateExecution executionEntity = new BpmDelegateExecutionDTO(sourceInfo.getProcessInstanceId());
|
||||
Set<Long> ccCandidates = processorChain.calculateTaskCandidateUsers(executionEntity, sourceInfo);
|
||||
if (CollUtil.isEmpty(ccCandidates)) {
|
||||
log.warn("相关抄送人不存在 {}", sourceInfo.getTaskId());
|
||||
return false;
|
||||
} else {
|
||||
BpmProcessInstanceCopyDO copyDO = new BpmProcessInstanceCopyDO();
|
||||
// 调用
|
||||
// 设置任务id
|
||||
copyDO.setTaskId(sourceInfo.getTaskId());
|
||||
copyDO.setTaskName(FlowableUtils.getTaskNameByTaskId(sourceInfo.getTaskId()));
|
||||
copyDO.setProcessInstanceId(sourceInfo.getProcessInstanceId());
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(sourceInfo.getProcessInstanceId())
|
||||
.singleResult();
|
||||
if (null == processInstance) {
|
||||
log.warn("相关流程实例不存在 {}", sourceInfo.getTaskId());
|
||||
return false;
|
||||
}
|
||||
copyDO.setStartUserId(FlowableUtils.getStartUserIdFromProcessInstance(processInstance));
|
||||
copyDO.setProcessInstanceName(processInstance.getName());
|
||||
ProcessDefinition processDefinition = FlowableUtils.getProcessDefinition(processInstance.getProcessDefinitionId());
|
||||
copyDO.setProcessDefinitionCategory(processDefinition.getCategory());
|
||||
copyDO.setReason(sourceInfo.getReason());
|
||||
copyDO.setCreator(sourceInfo.getCreator());
|
||||
copyDO.setCreateTime(LocalDateTime.now());
|
||||
List<BpmProcessInstanceCopyDO> copyList = new ArrayList<>(ccCandidates.size());
|
||||
for (Long userId : ccCandidates) {
|
||||
BpmProcessInstanceCopyDO copy = BpmProcessInstanceCopyConvert.INSTANCE.copy(copyDO);
|
||||
copy.setUserId(userId);
|
||||
copyList.add(copy);
|
||||
}
|
||||
return processInstanceCopyMapper.insertBatch(copyList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean ccProcessInstance(Long userId, BpmProcessInstanceCCReqVO reqVO) {
|
||||
// 在能正常审批的情况下抄送流程
|
||||
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
||||
sourceInfo.setTaskId(reqVO.getTaskKey());
|
||||
sourceInfo.setProcessInstanceId(reqVO.getProcessInstanceKey());
|
||||
sourceInfo.addRule(reqVO);
|
||||
sourceInfo.setCreator(String.valueOf(userId));
|
||||
sourceInfo.setReason(reqVO.getReason());
|
||||
if (!makeCopy(sourceInfo)) {
|
||||
throw new RuntimeException("抄送任务失败");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//获取流程抄送分页 TODO @kyle:接口已经注释,这里不用注释了哈;
|
||||
@Override
|
||||
public PageResult<BpmProcessInstanceCCPageItemRespVO> getMyProcessInstanceCCPage(Long loginUserId, BpmProcessInstanceCCMyPageReqVO pageReqVO) {
|
||||
// 通过 BpmProcessInstanceExtDO 表,先查询到对应的分页
|
||||
// TODO @kyle:一般读逻辑,Service 返回 PageResult<BpmProcessInstanceCopyDO> 即可。关联数据的查询和拼接,交给 Controller;目的是:保证 Service 聚焦写逻辑,清晰简洁;
|
||||
PageResult<BpmProcessInstanceCopyDO> pageResult = processInstanceCopyMapper.selectPage(loginUserId, pageReqVO);
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return new PageResult<>(pageResult.getTotal());
|
||||
}
|
||||
|
||||
// TODO @kyle:这种可以简洁点;参考如下
|
||||
// Map<String, ProcessInstance> processInstanceMap = bpmProcessInstanceService.getProcessInstanceMap(
|
||||
// convertSet(pageResult.getList(), BpmProcessInstanceCopyDO::getProcessInstanceId));
|
||||
|
||||
Set<String/* taskId */> taskIds = new HashSet<>();
|
||||
Set<String/* processInstaneId */> processInstaneIds = new HashSet<>();
|
||||
Set<Long/* userId */> userIds = new HashSet<>();
|
||||
for (BpmProcessInstanceCopyDO doItem : pageResult.getList()) {
|
||||
taskIds.add(doItem.getTaskId());
|
||||
processInstaneIds.add(doItem.getProcessInstanceId());
|
||||
userIds.add(doItem.getStartUserId());
|
||||
Long userId = Long.valueOf(doItem.getCreator());
|
||||
userIds.add(userId);
|
||||
}
|
||||
|
||||
Map<String, String> taskNameByTaskIds = FlowableUtils.getTaskNameByTaskIds(taskIds);
|
||||
Map<String, String> processInstanceNameByTaskIds = FlowableUtils.getProcessInstanceNameByTaskIds(processInstaneIds);
|
||||
|
||||
Map<Long, String> userMap = adminUserApi.getUserList(userIds).stream().collect(Collectors.toMap(
|
||||
AdminUserRespDTO::getId, AdminUserRespDTO::getNickname));
|
||||
|
||||
// 转换返回
|
||||
return BpmProcessInstanceCopyConvert.INSTANCE.convertPage(pageResult, taskNameByTaskIds, processInstanceNameByTaskIds, userMap);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.cc;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
// TODO @kyle:看看是不是要删除
|
||||
/**
|
||||
* 流程抄送视图对象 wf_copy
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2022-05-19
|
||||
*/
|
||||
@Data
|
||||
public class BpmProcessInstanceCopyVO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@Schema(description = "抄送主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 发起人Id
|
||||
*/
|
||||
@Schema(description = "发起人Id")
|
||||
private Long startUserId;
|
||||
|
||||
@Schema(description = "发起人别名")
|
||||
private String startUserNickname;
|
||||
|
||||
/**
|
||||
* 流程主键
|
||||
*/
|
||||
@Schema(description = "流程实例的主键")
|
||||
private String processInstanceId;
|
||||
|
||||
@Schema(description = "流程实例的名字")
|
||||
private String processInstanceName;
|
||||
|
||||
/**
|
||||
* 任务主键
|
||||
*/
|
||||
@Schema(description = "发起抄送的任务编号")
|
||||
private String taskId;
|
||||
|
||||
@Schema(description = "发起抄送的任务名称")
|
||||
private String taskName;
|
||||
/**
|
||||
* 用户主键
|
||||
*/
|
||||
@Schema(description = "用户编号")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "用户别名")
|
||||
private Long userNickname;
|
||||
|
||||
@Schema(description = "抄送原因")
|
||||
private String reason;
|
||||
|
||||
@Schema(description = "抄送人")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "抄送时间")
|
||||
private LocalDateTime createTime;
|
||||
}
|
@ -0,0 +1,439 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.cc.dto;
|
||||
|
||||
import org.flowable.bpmn.model.FlowElement;
|
||||
import org.flowable.bpmn.model.FlowableListener;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.flowable.engine.delegate.ReadOnlyDelegateExecution;
|
||||
import org.flowable.variable.api.persistence.entity.VariableInstance;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 仅为了传输processInstanceId
|
||||
*/
|
||||
public class BpmDelegateExecutionDTO implements DelegateExecution {
|
||||
|
||||
public BpmDelegateExecutionDTO(String getProcessInstanceId) {
|
||||
this.getProcessInstanceId = getProcessInstanceId;
|
||||
}
|
||||
|
||||
private final String getProcessInstanceId;
|
||||
|
||||
@Override
|
||||
public String getId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProcessInstanceId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRootProcessInstanceId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEventName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEventName(String eventName) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProcessInstanceBusinessKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProcessInstanceBusinessStatus() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProcessDefinitionId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropagatedStageInstanceId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParentId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuperExecutionId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentActivityId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenantId() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowElement getCurrentFlowElement() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentFlowElement(FlowElement flowElement) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlowableListener getCurrentFlowableListener() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentFlowableListener(FlowableListener currentListener) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReadOnlyDelegateExecution snapshotReadOnly() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DelegateExecution getParent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends DelegateExecution> getExecutions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean isActive) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConcurrent(boolean isConcurrent) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConcurrent() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProcessInstanceType() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactivate() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScope() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScope(boolean isScope) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMultiInstanceRoot() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMultiInstanceRoot(boolean isMultiInstanceRoot) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getVariables() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, VariableInstance> getVariableInstances() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getVariables(Collection<String> collection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, VariableInstance> getVariableInstances(Collection<String> collection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getVariables(Collection<String> collection, boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, VariableInstance> getVariableInstances(Collection<String> collection, boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getVariablesLocal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, VariableInstance> getVariableInstancesLocal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getVariablesLocal(Collection<String> collection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, VariableInstance> getVariableInstancesLocal(Collection<String> collection) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getVariablesLocal(Collection<String> collection, boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, VariableInstance> getVariableInstancesLocal(Collection<String> collection, boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getVariable(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableInstance getVariableInstance(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getVariable(String s, boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableInstance getVariableInstance(String s, boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getVariableLocal(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableInstance getVariableInstanceLocal(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getVariableLocal(String s, boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public VariableInstance getVariableInstanceLocal(String s, boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getVariable(String s, Class<T> aClass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getVariableLocal(String s, Class<T> aClass) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getVariableNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getVariableNamesLocal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariable(String s, Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariable(String s, Object o, boolean b) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setVariableLocal(String s, Object o) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object setVariableLocal(String s, Object o, boolean b) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariables(Map<String, ?> map) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVariablesLocal(Map<String, ?> map) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariables() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariablesLocal() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariable(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasVariableLocal(String s) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVariable(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVariableLocal(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVariables(Collection<String> collection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVariablesLocal(Collection<String> collection) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVariables() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeVariablesLocal() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransientVariable(String s, Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransientVariableLocal(String s, Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransientVariables(Map<String, Object> map) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTransientVariable(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getTransientVariables() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTransientVariablesLocal(Map<String, Object> map) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getTransientVariableLocal(String s) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getTransientVariablesLocal() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTransientVariableLocal(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTransientVariable(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTransientVariables() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTransientVariablesLocal() {
|
||||
|
||||
}
|
||||
}
|
@ -19,6 +19,8 @@ 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.candidate.BpmCandidateSourceInfo;
|
||||
import cn.iocoder.yudao.module.bpm.service.cc.BpmProcessInstanceCopyService;
|
||||
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;
|
||||
@ -94,6 +96,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
||||
@Resource
|
||||
private ManagementService managementService;
|
||||
|
||||
@Resource
|
||||
private BpmProcessInstanceCopyService processInstanceCopyService;
|
||||
|
||||
@Override
|
||||
public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) {
|
||||
// 查询待办任务
|
||||
|
@ -0,0 +1,127 @@
|
||||
package cn.iocoder.yudao.module.bpm.util;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.bpmn.model.ExtensionElement;
|
||||
import org.flowable.bpmn.model.FlowElement;
|
||||
import org.flowable.bpmn.model.FlowNode;
|
||||
import org.flowable.engine.RepositoryService;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.repository.ProcessDefinition;
|
||||
import org.flowable.engine.runtime.ProcessInstance;
|
||||
import org.flowable.task.api.Task;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 流程引擎工具类封装
|
||||
*
|
||||
* @author: linjinp
|
||||
* @create: 2019-12-24 13:51
|
||||
**/
|
||||
public class FlowableUtils {
|
||||
|
||||
/**
|
||||
* 获取流程名称
|
||||
*
|
||||
* @param processDefinitionId
|
||||
* @return
|
||||
*/
|
||||
public static String getProcessDefinitionName(String processDefinitionId) {
|
||||
RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class);
|
||||
ProcessDefinition processDefinition = repositoryService.getProcessDefinition(processDefinitionId);
|
||||
return processDefinition.getName();
|
||||
}
|
||||
|
||||
public static ProcessDefinition getProcessDefinition(String processDefinitionId) {
|
||||
RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class);
|
||||
return repositoryService.getProcessDefinition(processDefinitionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取节点数据
|
||||
*
|
||||
* @param processInstanceId
|
||||
* @param nodeId
|
||||
* @return
|
||||
*/
|
||||
public static FlowNode getFlowNode(String processInstanceId, String nodeId) {
|
||||
|
||||
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
|
||||
RepositoryService repositoryService = SpringUtil.getBean(RepositoryService.class);
|
||||
|
||||
String definitionld = runtimeService.createProcessInstanceQuery().processInstanceId(processInstanceId).singleResult().getProcessDefinitionId(); // 获取bpm(模型)对象
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(definitionld);
|
||||
// 传节点定义key获取当前节点
|
||||
FlowNode flowNode = (FlowNode) bpmnModel.getFlowElement(nodeId);
|
||||
return flowNode;
|
||||
}
|
||||
|
||||
public static ExtensionElement generateFlowNodeIdExtension(String nodeId) {
|
||||
ExtensionElement extensionElement = new ExtensionElement();
|
||||
extensionElement.setElementText(nodeId);
|
||||
extensionElement.setName("nodeId");
|
||||
extensionElement.setNamespacePrefix("flowable");
|
||||
extensionElement.setNamespace("nodeId");
|
||||
return extensionElement;
|
||||
}
|
||||
|
||||
public static String getNodeIdFromExtension(FlowElement flowElement) {
|
||||
Map<String, List<ExtensionElement>> extensionElements = flowElement.getExtensionElements();
|
||||
return extensionElements.get("nodeId").get(0).getElementText();
|
||||
}
|
||||
|
||||
public static Long getStartUserIdFromProcessInstance(ProcessInstance instance) {
|
||||
if (null == instance) {
|
||||
return null;
|
||||
}
|
||||
return NumberUtils.parseLong(instance.getStartUserId());
|
||||
}
|
||||
|
||||
public static String getTaskNameByTaskId(String taskId) {
|
||||
TaskService taskService = SpringUtil.getBean(TaskService.class);
|
||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
return task.getName();
|
||||
}
|
||||
|
||||
// TODO @kyle:Utils 里不做查询;可以封装到 bpmTaskService 里
|
||||
public static Map<String/* taskId */, String/* taskName */> getTaskNameByTaskIds(Collection<String> taskIds) {
|
||||
TaskService taskService = SpringUtil.getBean(TaskService.class);
|
||||
List<Task> tasks = taskService.createTaskQuery().taskIds(taskIds).list();
|
||||
if (CollUtil.isNotEmpty(tasks)) {
|
||||
Map<String/* taskId */, String/* taskName */> taskMap = new HashMap<>(tasks.size());
|
||||
for (Task task : tasks) {
|
||||
taskMap.putIfAbsent(task.getId(), task.getName());
|
||||
}
|
||||
return taskMap;
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
public static String getProcessInstanceNameByTaskId(String processInstanceId) {
|
||||
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
|
||||
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery()
|
||||
.processInstanceId(processInstanceId)
|
||||
.singleResult();
|
||||
return processInstance.getName();
|
||||
}
|
||||
|
||||
// TODO @kyle:Utils 里不做查询;可以封装到 bpmTaskService 里
|
||||
public static Map<String/* processInstaneId */, String/* processInstaneName */> getProcessInstanceNameByTaskIds(Set<String> taskIds) {
|
||||
RuntimeService runtimeService = SpringUtil.getBean(RuntimeService.class);
|
||||
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processInstanceIds(taskIds).list();
|
||||
if (CollUtil.isNotEmpty(processInstances)) {
|
||||
Map<String/* processInstaneId */, String/* processInstaneName */> processInstaneMap = new HashMap<>(processInstances.size());
|
||||
for (ProcessInstance processInstance : processInstances) {
|
||||
processInstaneMap.putIfAbsent(processInstance.getId(), processInstance.getName());
|
||||
}
|
||||
return processInstaneMap;
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,242 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.candidate;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import cn.iocoder.yudao.module.bpm.controller.admin.candidate.vo.BpmTaskCandidateRuleVO;
|
||||
import cn.iocoder.yudao.module.bpm.dal.dataobject.definition.BpmUserGroupDO;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskAssignRuleTypeEnum;
|
||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmTaskRuleScriptEnum;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.BpmTaskAssignScript;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl.BpmTaskAssignLeaderX1Script;
|
||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.behavior.script.impl.BpmTaskAssignLeaderX2Script;
|
||||
import cn.iocoder.yudao.module.bpm.service.candidate.sourceInfoProcessor.BpmCandidateScriptApiSourceInfoProcessor;
|
||||
import cn.iocoder.yudao.module.bpm.service.definition.BpmUserGroupService;
|
||||
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.PostApi;
|
||||
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.PermissionApi;
|
||||
import cn.iocoder.yudao.module.system.api.permission.RoleApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.flowable.engine.delegate.DelegateExecution;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.SetUtils.asSet;
|
||||
import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo;
|
||||
import static java.util.Collections.singleton;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@Import({BpmCandidateSourceInfoProcessorChain.class,
|
||||
BpmCandidateScriptApiSourceInfoProcessor.class, BpmTaskAssignLeaderX1Script.class,
|
||||
BpmTaskAssignLeaderX2Script.class})
|
||||
public class BpmCandidateSourceInfoProcessorChainTest extends BaseDbUnitTest {
|
||||
@Resource
|
||||
private BpmCandidateSourceInfoProcessorChain processorChain;
|
||||
|
||||
@MockBean
|
||||
private BpmUserGroupService userGroupService;
|
||||
@MockBean
|
||||
private DeptApi deptApi;
|
||||
@MockBean
|
||||
private AdminUserApi adminUserApi;
|
||||
@MockBean
|
||||
private PermissionApi permissionApi;
|
||||
@MockBean
|
||||
private RoleApi roleApi;
|
||||
@MockBean
|
||||
private PostApi postApi;
|
||||
@MockBean
|
||||
private DictDataApi dictDataApi;
|
||||
@Resource
|
||||
private BpmCandidateScriptApiSourceInfoProcessor bpmCandidateScriptApiSourceInfoProcessor;
|
||||
|
||||
@Test
|
||||
public void testCalculateTaskCandidateUsers_Role() {
|
||||
// 准备参数
|
||||
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
|
||||
.setType(BpmTaskAssignRuleTypeEnum.ROLE.getType());
|
||||
// mock 方法
|
||||
when(permissionApi.getUserRoleIdListByRoleIds(eq(rule.getOptions())))
|
||||
.thenReturn(asSet(11L, 22L));
|
||||
mockGetUserMap(asSet(11L, 22L));
|
||||
|
||||
// 调用
|
||||
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
||||
sourceInfo.addRule(rule);
|
||||
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
|
||||
// 断言
|
||||
assertEquals(asSet(11L, 22L), results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateTaskCandidateUsers_DeptMember() {
|
||||
// 准备参数
|
||||
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
|
||||
.setType(BpmTaskAssignRuleTypeEnum.DEPT_MEMBER.getType());
|
||||
// mock 方法
|
||||
List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L),
|
||||
id -> new AdminUserRespDTO().setId(id));
|
||||
when(adminUserApi.getUserListByDeptIds(eq(rule.getOptions()))).thenReturn(users);
|
||||
mockGetUserMap(asSet(11L, 22L));
|
||||
|
||||
// 调用
|
||||
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
||||
sourceInfo.addRule(rule);
|
||||
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
|
||||
// 断言
|
||||
assertEquals(asSet(11L, 22L), results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateTaskCandidateUsers_DeptLeader() {
|
||||
// 准备参数
|
||||
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
|
||||
.setType(BpmTaskAssignRuleTypeEnum.DEPT_LEADER.getType());
|
||||
// mock 方法
|
||||
DeptRespDTO dept1 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(11L));
|
||||
DeptRespDTO dept2 = randomPojo(DeptRespDTO.class, o -> o.setLeaderUserId(22L));
|
||||
when(deptApi.getDeptList(eq(rule.getOptions()))).thenReturn(Arrays.asList(dept1, dept2));
|
||||
mockGetUserMap(asSet(11L, 22L));
|
||||
|
||||
// 调用
|
||||
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
||||
sourceInfo.addRule(rule);
|
||||
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
|
||||
// 断言
|
||||
assertEquals(asSet(11L, 22L), results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateTaskCandidateUsers_Post() {
|
||||
// 准备参数
|
||||
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
|
||||
.setType(BpmTaskAssignRuleTypeEnum.POST.getType());
|
||||
// mock 方法
|
||||
List<AdminUserRespDTO> users = CollectionUtils.convertList(asSet(11L, 22L),
|
||||
id -> new AdminUserRespDTO().setId(id));
|
||||
when(adminUserApi.getUserListByPostIds(eq(rule.getOptions()))).thenReturn(users);
|
||||
mockGetUserMap(asSet(11L, 22L));
|
||||
|
||||
// 调用
|
||||
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
||||
sourceInfo.addRule(rule);
|
||||
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
|
||||
// 断言
|
||||
assertEquals(asSet(11L, 22L), results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateTaskCandidateUsers_User() {
|
||||
// 准备参数
|
||||
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
|
||||
.setType(BpmTaskAssignRuleTypeEnum.USER.getType());
|
||||
// mock 方法
|
||||
mockGetUserMap(asSet(1L, 2L));
|
||||
|
||||
// 调用
|
||||
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
||||
sourceInfo.addRule(rule);
|
||||
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
|
||||
// 断言
|
||||
assertEquals(asSet(1L, 2L), results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateTaskCandidateUsers_UserGroup() {
|
||||
// 准备参数
|
||||
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(1L, 2L))
|
||||
.setType(BpmTaskAssignRuleTypeEnum.USER_GROUP.getType());
|
||||
// mock 方法
|
||||
BpmUserGroupDO userGroup1 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(11L, 12L)));
|
||||
BpmUserGroupDO userGroup2 = randomPojo(BpmUserGroupDO.class, o -> o.setMemberUserIds(asSet(21L, 22L)));
|
||||
when(userGroupService.getUserGroupList(eq(rule.getOptions()))).thenReturn(Arrays.asList(userGroup1, userGroup2));
|
||||
mockGetUserMap(asSet(11L, 12L, 21L, 22L));
|
||||
|
||||
// 调用
|
||||
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
||||
sourceInfo.addRule(rule);
|
||||
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
|
||||
// 断言
|
||||
assertEquals(asSet(11L, 12L, 21L, 22L), results);
|
||||
}
|
||||
|
||||
private void mockGetUserMap(Set<Long> assigneeUserIds) {
|
||||
Map<Long, AdminUserRespDTO> userMap = CollectionUtils.convertMap(assigneeUserIds, id -> id,
|
||||
id -> new AdminUserRespDTO().setId(id).setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCalculateTaskCandidateUsers_Script() {
|
||||
// 准备参数
|
||||
BpmTaskCandidateRuleVO rule = new BpmTaskCandidateRuleVO().setOptions(asSet(20L, 21L))
|
||||
.setType(BpmTaskAssignRuleTypeEnum.SCRIPT.getType());
|
||||
// mock 方法
|
||||
BpmTaskAssignScript script1 = new BpmTaskAssignScript() {
|
||||
|
||||
@Override
|
||||
public Set<Long> calculateTaskCandidateUsers(DelegateExecution task) {
|
||||
return singleton(11L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskRuleScriptEnum getEnum() {
|
||||
return BpmTaskRuleScriptEnum.LEADER_X1;
|
||||
}
|
||||
};
|
||||
BpmTaskAssignScript script2 = new BpmTaskAssignScript() {
|
||||
|
||||
@Override
|
||||
public Set<Long> calculateTaskCandidateUsers(DelegateExecution task) {
|
||||
return singleton(22L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BpmTaskRuleScriptEnum getEnum() {
|
||||
return BpmTaskRuleScriptEnum.LEADER_X2;
|
||||
}
|
||||
};
|
||||
bpmCandidateScriptApiSourceInfoProcessor.setScripts(Arrays.asList(script1, script2));
|
||||
mockGetUserMap(asSet(11L, 22L));
|
||||
|
||||
// 调用
|
||||
BpmCandidateSourceInfo sourceInfo = new BpmCandidateSourceInfo();
|
||||
sourceInfo.addRule(rule);
|
||||
Set<Long> results = processorChain.calculateTaskCandidateUsers(null, sourceInfo);
|
||||
// 断言
|
||||
assertEquals(asSet(11L, 22L), results);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRemoveDisableUsers() {
|
||||
// 准备参数. 1L 可以找到;2L 是禁用的;3L 找不到
|
||||
Set<Long> assigneeUserIds = asSet(1L, 2L, 3L);
|
||||
// mock 方法
|
||||
AdminUserRespDTO user1 = randomPojo(AdminUserRespDTO.class, o -> o.setId(1L)
|
||||
.setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||
AdminUserRespDTO user2 = randomPojo(AdminUserRespDTO.class, o -> o.setId(2L)
|
||||
.setStatus(CommonStatusEnum.DISABLE.getStatus()));
|
||||
Map<Long, AdminUserRespDTO> userMap = MapUtil.builder(user1.getId(), user1)
|
||||
.put(user2.getId(), user2).build();
|
||||
when(adminUserApi.getUserMap(eq(assigneeUserIds))).thenReturn(userMap);
|
||||
|
||||
// 调用
|
||||
processorChain.removeDisableUsers(assigneeUserIds);
|
||||
// 断言
|
||||
assertEquals(asSet(1L), assigneeUserIds);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package cn.iocoder.yudao.module.bpm.service.cc;
|
||||
|
||||
import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
@Import({BpmProcessInstanceCopyServiceImpl.class})
|
||||
class BpmProcessInstanceCopyServiceTest extends BaseDbUnitTest {
|
||||
@Resource
|
||||
private BpmProcessInstanceCopyServiceImpl service;
|
||||
|
||||
@Test
|
||||
void queryById() {
|
||||
}
|
||||
}
|
@ -13,5 +13,6 @@ public interface DictTypeConstants {
|
||||
String CRM_AUDIT_STATUS = "crm_audit_status"; // CRM 审批状态
|
||||
String CRM_PRODUCT_UNIT = "crm_product_unit"; // CRM 产品单位
|
||||
String CRM_PRODUCT_STATUS = "crm_product_status"; // CRM 产品状态
|
||||
String CRM_FOLLOW_UP_TYPE = "crm_follow_up_type"; // CRM 跟进方式
|
||||
|
||||
}
|
||||
|
@ -14,9 +14,12 @@ public interface ErrorCodeConstants {
|
||||
|
||||
// ========== 线索管理 1-020-001-000 ==========
|
||||
ErrorCode CLUE_NOT_EXISTS = new ErrorCode(1_020_001_000, "线索不存在");
|
||||
ErrorCode CLUE_ANY_CLUE_NOT_EXISTS = new ErrorCode(1_020_001_001, "线索【{}】不存在");
|
||||
ErrorCode CLUE_ANY_CLUE_ALREADY_TRANSLATED = new ErrorCode(1_020_001_002, "线索【{}】已经转化过了,请勿重复转化");
|
||||
|
||||
// ========== 商机管理 1-020-002-000 ==========
|
||||
ErrorCode BUSINESS_NOT_EXISTS = new ErrorCode(1_020_002_000, "商机不存在");
|
||||
ErrorCode BUSINESS_CONTRACT_EXISTS = new ErrorCode(1_020_002_001, "商机已关联合同,不能删除");
|
||||
|
||||
// TODO @lilleo:商机状态、商机类型,都单独错误码段
|
||||
|
||||
@ -24,6 +27,7 @@ public interface ErrorCodeConstants {
|
||||
// ========== 联系人管理 1-020-003-000 ==========
|
||||
ErrorCode CONTACT_NOT_EXISTS = new ErrorCode(1_020_003_000, "联系人不存在");
|
||||
ErrorCode CONTACT_BUSINESS_LINK_NOT_EXISTS = new ErrorCode( 1_020_003_001, "联系人商机关联不存在");
|
||||
ErrorCode CONTACT_DELETE_FAIL_CONTRACT_LINK_EXISTS = new ErrorCode( 1_020_003_002, "联系人已关联合同,不能删除");
|
||||
|
||||
// ========== 回款 1-020-004-000 ==========
|
||||
ErrorCode RECEIVABLE_NOT_EXISTS = new ErrorCode(1_020_004_000, "回款不存在");
|
||||
@ -39,6 +43,11 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CUSTOMER_IN_POOL = new ErrorCode(1_020_006_004, "客户【{}】放入公海失败,原因:已经是公海客户");
|
||||
ErrorCode CUSTOMER_LOCKED_PUT_POOL_FAIL = new ErrorCode(1_020_006_005, "客户【{}】放入公海失败,原因:客户已锁定");
|
||||
ErrorCode CUSTOMER_UPDATE_OWNER_USER_FAIL = new ErrorCode(1_020_006_006, "更新客户【{}】负责人失败, 原因:系统异常");
|
||||
ErrorCode CUSTOMER_LOCK_FAIL_IS_LOCK = new ErrorCode(1_020_006_007, "锁定客户失败,它已经处于锁定状态");
|
||||
ErrorCode CUSTOMER_UNLOCK_FAIL_IS_UNLOCK = new ErrorCode(1_020_006_008, "解锁客户失败,它已经处于未锁定状态");
|
||||
ErrorCode CUSTOMER_LOCK_EXCEED_LIMIT = new ErrorCode(1_020_006_009, "锁定客户失败,超出锁定规则上限");
|
||||
ErrorCode CUSTOMER_OWNER_EXCEED_LIMIT = new ErrorCode(1_020_006_010, "操作失败,超出客户数拥有上限");
|
||||
ErrorCode CUSTOMER_DELETE_FAIL_HAVE_REFERENCE = new ErrorCode(1_020_006_011, "删除客户失败,有关联{}");
|
||||
|
||||
// ========== 权限管理 1_020_007_000 ==========
|
||||
ErrorCode CRM_PERMISSION_NOT_EXISTS = new ErrorCode(1_020_007_000, "数据权限不存在");
|
||||
@ -49,6 +58,7 @@ public interface ErrorCodeConstants {
|
||||
ErrorCode CRM_PERMISSION_DELETE_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_005, "删除数据权限失败,原因:存在负责人");
|
||||
ErrorCode CRM_PERMISSION_DELETE_DENIED = new ErrorCode(1_020_007_006, "删除数据权限失败,原因:没有权限");
|
||||
ErrorCode CRM_PERMISSION_DELETE_SELF_PERMISSION_FAIL_EXIST_OWNER = new ErrorCode(1_020_007_007, "删除数据权限失败,原因:不能删除负责人");
|
||||
ErrorCode CRM_PERMISSION_CREATE_FAIL = new ErrorCode(1_020_007_008, "创建数据权限失败,原因:所加用户已有权限");
|
||||
|
||||
// ========== 产品 1_020_008_000 ==========
|
||||
ErrorCode PRODUCT_NOT_EXISTS = new ErrorCode(1_020_008_000, "产品不存在");
|
||||
@ -72,4 +82,8 @@ public interface ErrorCodeConstants {
|
||||
// ========== 客户公海规则设置 1_020_012_000 ==========
|
||||
ErrorCode CUSTOMER_LIMIT_CONFIG_NOT_EXISTS = new ErrorCode(1_020_012_000, "客户限制配置不存在");
|
||||
|
||||
// ========== 跟进记录 1_020_013_000 ==========
|
||||
ErrorCode FOLLOW_UP_RECORD_NOT_EXISTS = new ErrorCode(1_020_013_000, "跟进记录不存在");
|
||||
ErrorCode FOLLOW_UP_RECORD_DELETE_DENIED = new ErrorCode(1_020_013_001, "删除跟进记录失败,原因:没有权限");
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,125 @@
|
||||
package cn.iocoder.yudao.module.crm.enums;
|
||||
|
||||
/**
|
||||
* CRM 操作日志枚举
|
||||
* 目的:统一管理,也减少 Service 里各种“复杂”字符串
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface LogRecordConstants {
|
||||
|
||||
// ======================= CRM_LEADS 线索 =======================
|
||||
|
||||
String CRM_LEADS_TYPE = "CRM 线索";
|
||||
|
||||
// ======================= CRM_CUSTOMER 客户 =======================
|
||||
|
||||
String CRM_CUSTOMER_TYPE = "CRM 客户";
|
||||
String CRM_CUSTOMER_CREATE_SUB_TYPE = "创建客户";
|
||||
String CRM_CUSTOMER_CREATE_SUCCESS = "创建了客户{{#customer.name}}";
|
||||
String CRM_CUSTOMER_UPDATE_SUB_TYPE = "更新客户";
|
||||
String CRM_CUSTOMER_UPDATE_SUCCESS = "更新了客户【{{#customerName}}】: {_DIFF{#updateReqVO}}";
|
||||
String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户";
|
||||
String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】";
|
||||
String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户";
|
||||
String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#customer.name}}】的负责人从【{getAdminUserById{#customer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
|
||||
String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#customer.lockStatus ? '解锁客户' : '锁定客户'}}";
|
||||
String CRM_CUSTOMER_LOCK_SUCCESS = "{{#customer.lockStatus ? '将客户【' + #customer.name + '】解锁' : '将客户【' + #customer.name + '】锁定'}}";
|
||||
String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海";
|
||||
String CRM_CUSTOMER_POOL_SUCCESS = "将客户【{{#customerName}}】放入了公海";
|
||||
String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}";
|
||||
String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【' + #customer.name + '】分配给【' + #ownerUserName + '】' : '领取客户【' + #customer.name + '】'}}";
|
||||
|
||||
// ======================= CRM_CUSTOMER_LIMIT_CONFIG 客户限制配置 =======================
|
||||
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_TYPE = "CRM 客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE = "创建客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS = "创建了【{{#limitType}}】类型的客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE = "更新客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS = "更新了客户限制配置: {_DIFF{#updateReqVO}}";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE = "删除客户限制配置";
|
||||
String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS = "删除了【{{#limitType}}】类型的客户限制配置";
|
||||
|
||||
// ======================= CRM_CUSTOMER_POOL_CONFIG 客户公海规则 =======================
|
||||
|
||||
String CRM_CUSTOMER_POOL_CONFIG_TYPE = "CRM 客户公海规则";
|
||||
String CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE = "{{#isPoolConfigUpdate ? '更新客户公海规则' : '创建客户公海规则'}}";
|
||||
String CRM_CUSTOMER_POOL_CONFIG_SUCCESS = "{{#isPoolConfigUpdate ? '更新了客户公海规则' : '创建了客户公海规则'}}";
|
||||
|
||||
// ======================= CRM_CONTACT 联系人 =======================
|
||||
|
||||
String CRM_CONTACT_TYPE = "CRM 联系人";
|
||||
String CRM_CONTACT_CREATE_SUB_TYPE = "创建联系人";
|
||||
String CRM_CONTACT_CREATE_SUCCESS = "创建了联系人{{#contact.name}}";
|
||||
String CRM_CONTACT_UPDATE_SUB_TYPE = "更新联系人";
|
||||
String CRM_CONTACT_UPDATE_SUCCESS = "更新了联系人【{{#contactName}}】: {_DIFF{#updateReqVO}}";
|
||||
String CRM_CONTACT_DELETE_SUB_TYPE = "删除联系人";
|
||||
String CRM_CONTACT_DELETE_SUCCESS = "删除了联系人【{{#contactName}}】";
|
||||
String CRM_CONTACT_TRANSFER_SUB_TYPE = "转移联系人";
|
||||
String CRM_CONTACT_TRANSFER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
|
||||
|
||||
// ======================= CRM_BUSINESS 商机 =======================
|
||||
|
||||
String CRM_BUSINESS_TYPE = "CRM 商机";
|
||||
String CRM_BUSINESS_CREATE_SUB_TYPE = "创建商机";
|
||||
String CRM_BUSINESS_CREATE_SUCCESS = "创建了商机{{#business.name}}";
|
||||
String CRM_BUSINESS_UPDATE_SUB_TYPE = "更新商机";
|
||||
String CRM_BUSINESS_UPDATE_SUCCESS = "更新了商机【{{#businessName}}】: {_DIFF{#updateReqVO}}";
|
||||
String CRM_BUSINESS_DELETE_SUB_TYPE = "删除商机";
|
||||
String CRM_BUSINESS_DELETE_SUCCESS = "删除了商机【{{#businessName}}】";
|
||||
String CRM_BUSINESS_TRANSFER_SUB_TYPE = "转移商机";
|
||||
String CRM_BUSINESS_TRANSFER_SUCCESS = "将商机【{{#business.name}}】的负责人从【{getAdminUserById{#business.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
|
||||
|
||||
// ======================= CRM_CONTRACT 合同 =======================
|
||||
|
||||
String CRM_CONTRACT_TYPE = "CRM 合同";
|
||||
String CRM_CONTRACT_CREATE_SUB_TYPE = "创建合同";
|
||||
String CRM_CONTRACT_CREATE_SUCCESS = "创建了合同{{#contract.name}}";
|
||||
String CRM_CONTRACT_UPDATE_SUB_TYPE = "更新合同";
|
||||
String CRM_CONTRACT_UPDATE_SUCCESS = "更新了合同【{{#contractName}}】: {_DIFF{#updateReqVO}}";
|
||||
String CRM_CONTRACT_DELETE_SUB_TYPE = "删除合同";
|
||||
String CRM_CONTRACT_DELETE_SUCCESS = "删除了合同【{{#contractName}}】";
|
||||
String CRM_CONTRACT_TRANSFER_SUB_TYPE = "转移合同";
|
||||
String CRM_CONTRACT_TRANSFER_SUCCESS = "将合同【{{#contract.name}}】的负责人从【{getAdminUserById{#contract.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
|
||||
|
||||
// ======================= CRM_PRODUCT 产品 =======================
|
||||
|
||||
String CRM_PRODUCT_TYPE = "CRM 产品";
|
||||
String CRM_PRODUCT_CREATE_SUB_TYPE = "创建产品";
|
||||
String CRM_PRODUCT_CREATE_SUCCESS = "创建了产品【{{#createReqVO.name}}】";
|
||||
String CRM_PRODUCT_UPDATE_SUB_TYPE = "更新产品";
|
||||
String CRM_PRODUCT_UPDATE_SUCCESS = "更新了产品【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}";
|
||||
String CRM_PRODUCT_DELETE_SUB_TYPE = "删除产品";
|
||||
String CRM_PRODUCT_DELETE_SUCCESS = "删除了产品【{{#product.name}}】";
|
||||
|
||||
// ======================= CRM_PRODUCT_CATEGORY 产品分类 =======================
|
||||
|
||||
String CRM_PRODUCT_CATEGORY_TYPE = "CRM 产品分类";
|
||||
String CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE = "创建产品分类";
|
||||
String CRM_PRODUCT_CATEGORY_CREATE_SUCCESS = "创建了产品分类【{{#createReqVO.name}}】";
|
||||
String CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE = "更新产品分类";
|
||||
String CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS = "更新了产品分类【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}";
|
||||
String CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE = "删除产品分类";
|
||||
String CRM_PRODUCT_CATEGORY_DELETE_SUCCESS = "删除了产品分类【{{#productCategory.name}}】";
|
||||
|
||||
// ======================= CRM_RECEIVABLE 回款 =======================
|
||||
|
||||
String CRM_RECEIVABLE_TYPE = "CRM 回款";
|
||||
String CRM_RECEIVABLE_CREATE_SUB_TYPE = "创建回款";
|
||||
String CRM_RECEIVABLE_CREATE_SUCCESS = "创建了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款";
|
||||
String CRM_RECEIVABLE_UPDATE_SUB_TYPE = "更新回款";
|
||||
String CRM_RECEIVABLE_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款: {_DIFF{#updateReqVO}}";
|
||||
String CRM_RECEIVABLE_DELETE_SUB_TYPE = "删除回款";
|
||||
String CRM_RECEIVABLE_DELETE_SUCCESS = "删除了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款";
|
||||
|
||||
// ======================= CRM_RECEIVABLE_PLAN 回款计划 =======================
|
||||
|
||||
String CRM_RECEIVABLE_PLAN_TYPE = "CRM 回款计划";
|
||||
String CRM_RECEIVABLE_PLAN_CREATE_SUB_TYPE = "创建回款计划";
|
||||
String CRM_RECEIVABLE_PLAN_CREATE_SUCCESS = "创建了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划";
|
||||
String CRM_RECEIVABLE_PLAN_UPDATE_SUB_TYPE = "更新回款计划";
|
||||
String CRM_RECEIVABLE_PLAN_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划: {_DIFF{#updateReqVO}}";
|
||||
String CRM_RECEIVABLE_PLAN_DELETE_SUB_TYPE = "删除回款计划";
|
||||
String CRM_RECEIVABLE_PLAN_DELETE_SUCCESS = "删除了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划";
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package cn.iocoder.yudao.module.crm.enums.business;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
// TODO @lzxhqs:1)title、description、create 可以删除,非标准的 javadoc 注释哈,然后可以在类上加下这个类的注释;2)CrmBizEndStatus 改成 CrmBusinessEndStatus,非必要不缩写哈,可阅读比较重要
|
||||
/**
|
||||
* @author lzxhqs
|
||||
* @version 1.0
|
||||
* @title CrmBizEndStatus
|
||||
* @description
|
||||
* @create 2024/1/12
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum CrmBizEndStatus implements IntArrayValuable {
|
||||
|
||||
WIN(1, "赢单"),
|
||||
LOSE(2, "输单"),
|
||||
INVALID(3, "无效");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizEndStatus::getStatus).toArray();
|
||||
|
||||
// TODO @lzxhqs:这里的方法,建议放到 49 行之后;一般类里是,静态变量,普通变量;静态方法;普通方法
|
||||
public static boolean isWin(Integer status) {
|
||||
return ObjectUtil.equal(WIN.getStatus(), status);
|
||||
}
|
||||
|
||||
public static boolean isLose(Integer status) {
|
||||
return ObjectUtil.equal(LOSE.getStatus(), status);
|
||||
}
|
||||
|
||||
public static boolean isInvalid(Integer status) {
|
||||
return ObjectUtil.equal(INVALID.getStatus(), status);
|
||||
}
|
||||
|
||||
/**
|
||||
* 场景类型
|
||||
*/
|
||||
private final Integer status;
|
||||
/**
|
||||
* 场景名称
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,9 @@ public enum CrmBizTypeEnum implements IntArrayValuable {
|
||||
CRM_CONTACT(3, "联系人"),
|
||||
CRM_BUSINESS(4, "商机"),
|
||||
CRM_CONTRACT(5, "合同"),
|
||||
CRM_PRODUCT(6, "产品")
|
||||
CRM_PRODUCT(6, "产品"),
|
||||
CRM_RECEIVABLE(7, "回款"),
|
||||
CRM_RECEIVABLE_PLAN(8, "回款计划")
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmBizTypeEnum::getType).toArray();
|
||||
|
@ -7,7 +7,6 @@ import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
// TODO @puhui999:这个枚举,要不改成 CrmSceneTypeEnum
|
||||
/**
|
||||
* CRM 列表检索场景
|
||||
*
|
||||
@ -15,14 +14,13 @@ import java.util.Arrays;
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CrmSceneEnum implements IntArrayValuable {
|
||||
public enum CrmSceneTypeEnum implements IntArrayValuable {
|
||||
|
||||
OWNER(1, "我负责的"),
|
||||
FOLLOW(2, "我关注的"),
|
||||
// TODO @puhui999:还有一个我参与的
|
||||
INVOLVED(2, "我参与的"),
|
||||
SUBORDINATE(3, "下属负责的");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneEnum::getType).toArray();
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmSceneTypeEnum::getType).toArray();
|
||||
|
||||
/**
|
||||
* 场景类型
|
||||
@ -37,8 +35,8 @@ public enum CrmSceneEnum implements IntArrayValuable {
|
||||
return ObjUtil.equal(OWNER.getType(), type);
|
||||
}
|
||||
|
||||
public static boolean isFollow(Integer type) {
|
||||
return ObjUtil.equal(FOLLOW.getType(), type);
|
||||
public static boolean isInvolved(Integer type) {
|
||||
return ObjUtil.equal(INVOLVED.getType(), type);
|
||||
}
|
||||
|
||||
public static boolean isSubordinate(Integer type) {
|
@ -1,5 +1,7 @@
|
||||
package cn.iocoder.yudao.module.crm.enums.customer;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
@ -18,24 +20,30 @@ public enum CrmCustomerLimitConfigTypeEnum implements IntArrayValuable {
|
||||
/**
|
||||
* 拥有客户数限制
|
||||
*/
|
||||
CUSTOMER_QUANTITY_LIMIT(1, "拥有客户数限制"),
|
||||
CUSTOMER_OWNER_LIMIT(1, "拥有客户数限制"),
|
||||
/**
|
||||
* 锁定客户数限制
|
||||
*/
|
||||
CUSTOMER_LOCK_LIMIT(2, "锁定客户数限制"),
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLimitConfigTypeEnum::getCode).toArray();
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmCustomerLimitConfigTypeEnum::getType).toArray();
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer code;
|
||||
private final Integer type;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
public static String getNameByType(Integer type) {
|
||||
CrmCustomerLimitConfigTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmCustomerLimitConfigTypeEnum.values()),
|
||||
item -> ObjUtil.equal(item.type, type));
|
||||
return typeEnum == null ? null : typeEnum.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
|
@ -0,0 +1,39 @@
|
||||
package cn.iocoder.yudao.module.crm.enums.message;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* CRM 联系状态
|
||||
*
|
||||
* @author dhb52
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Getter
|
||||
public enum CrmContactStatusEnum implements IntArrayValuable {
|
||||
|
||||
NEEDED_TODAY(1, "今日需联系"),
|
||||
EXPIRED(2, "已逾期"),
|
||||
ALREADY_CONTACT(3, "已联系"),
|
||||
;
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(CrmContactStatusEnum::getType).toArray();
|
||||
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private final Integer type;
|
||||
/**
|
||||
* 状态名
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.iocoder.yudao.module.crm.enums.permission;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* Crm 数据权限角色枚举
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum CrmPermissionRoleCodeEnum {
|
||||
|
||||
CRM_ADMIN("crm_admin", "CRM 管理员");
|
||||
|
||||
/**
|
||||
* 角色标识
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
}
|
||||
|
@ -60,6 +60,10 @@
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-excel</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.boot</groupId>
|
||||
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Test 测试相关 -->
|
||||
<dependency>
|
||||
|
@ -1,15 +1,15 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.status.CrmBusinessStatusQueryVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.type.CrmBusinessStatusTypeQueryVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.CrmContractPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessTransferReqVO;
|
||||
import cn.iocoder.yudao.module.crm.convert.business.CrmBusinessConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessStatusDO;
|
||||
@ -22,22 +22,24 @@ import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_NOT_EXISTS;
|
||||
|
||||
@Tag(name = "管理后台 - 商机")
|
||||
@RestController
|
||||
@ -47,27 +49,24 @@ public class CrmBusinessController {
|
||||
|
||||
@Resource
|
||||
private CrmBusinessService businessService;
|
||||
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
|
||||
@Resource
|
||||
private CrmBusinessStatusTypeService businessStatusTypeService;
|
||||
|
||||
@Resource
|
||||
private CrmBusinessStatusService businessStatusService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建商机")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:create')")
|
||||
public CommonResult<Long> createBusiness(@Valid @RequestBody CrmBusinessCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createBusiness(@Valid @RequestBody CrmBusinessSaveReqVO createReqVO) {
|
||||
return success(businessService.createBusiness(createReqVO, getLoginUserId()));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新商机")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:update')")
|
||||
public CommonResult<Boolean> updateBusiness(@Valid @RequestBody CrmBusinessUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateBusiness(@Valid @RequestBody CrmBusinessSaveReqVO updateReqVO) {
|
||||
businessService.updateBusiness(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -87,7 +86,26 @@ public class CrmBusinessController {
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:query')")
|
||||
public CommonResult<CrmBusinessRespVO> getBusiness(@RequestParam("id") Long id) {
|
||||
CrmBusinessDO business = businessService.getBusiness(id);
|
||||
return success(CrmBusinessConvert.INSTANCE.convert(business));
|
||||
return success(BeanUtils.toBean(business, CrmBusinessRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得商机列表")
|
||||
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:query')")
|
||||
public CommonResult<List<CrmBusinessRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) {
|
||||
return success(BeanUtils.toBean(businessService.getBusinessList(ids, getLoginUserId()), CrmBusinessRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/simple-all-list")
|
||||
@Operation(summary = "获得联系人的精简列表")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
|
||||
public CommonResult<List<CrmBusinessRespVO>> getSimpleContactList() {
|
||||
CrmBusinessPageReqVO reqVO = new CrmBusinessPageReqVO();
|
||||
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(reqVO, getLoginUserId());
|
||||
return success(convertList(pageResult.getList(), business -> // 只返回 id、name 字段
|
||||
new CrmBusinessRespVO().setId(business.getId()).setName(business.getName())));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ -95,60 +113,25 @@ public class CrmBusinessController {
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:query')")
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPage(@Valid CrmBusinessPageReqVO pageVO) {
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(pageVO, getLoginUserId());
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return success(PageResult.empty(pageResult.getTotal()));
|
||||
}
|
||||
// 处理客户名称回显
|
||||
// TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
|
||||
Set<Long> customerIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
|
||||
// 处理商机状态类型名称回显
|
||||
Set<Long> statusTypeIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO();
|
||||
queryStatusTypeVO.setIdList(statusTypeIds);
|
||||
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
|
||||
// 处理商机状态名称回显
|
||||
Set<Long> statusIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
|
||||
queryVO.setIdList(statusIds);
|
||||
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
|
||||
return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList));
|
||||
return success(buildBusinessDetailPageResult(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/page-by-customer")
|
||||
@Operation(summary = "获得商机分页,基于指定客户")
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmContractPageReqVO pageReqVO) {
|
||||
Assert.notNull(pageReqVO.getCustomerId(), "客户编号不能为空");
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomer(pageReqVO);
|
||||
// 处理客户名称回显
|
||||
// TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
|
||||
Set<Long> customerIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getCustomerId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(customerIds);
|
||||
// 处理商机状态类型名称回显
|
||||
Set<Long> statusTypeIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getStatusTypeId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
CrmBusinessStatusTypeQueryVO queryStatusTypeVO = new CrmBusinessStatusTypeQueryVO();
|
||||
queryStatusTypeVO.setIdList(statusTypeIds);
|
||||
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.selectList(queryStatusTypeVO);
|
||||
// 处理商机状态名称回显
|
||||
Set<Long> statusIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessDO::getStatusId).filter(Objects::nonNull).collect(Collectors.toSet());
|
||||
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
|
||||
queryVO.setIdList(statusIds);
|
||||
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
|
||||
return success(CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList));
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPageByCustomer(@Valid CrmBusinessPageReqVO pageReqVO) {
|
||||
if (pageReqVO.getCustomerId() == null) {
|
||||
throw exception(CUSTOMER_NOT_EXISTS);
|
||||
}
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByCustomerId(pageReqVO);
|
||||
return success(buildBusinessDetailPageResult(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/pool-page")
|
||||
@Operation(summary = "获得商机公海分页")
|
||||
@GetMapping("/page-by-contact")
|
||||
@Operation(summary = "获得联系人的商机分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business:query')")
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessPoolPage(@Valid CrmBusinessPageReqVO pageVO) {
|
||||
// TODO puhui999: 等数据权限完善后再实现
|
||||
return null;
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getBusinessContactPage(@Valid CrmBusinessPageReqVO pageReqVO) {
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPageByContact(pageReqVO);
|
||||
return success(buildBusinessDetailPageResult(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ -157,10 +140,30 @@ public class CrmBusinessController {
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportBusinessExcel(@Valid CrmBusinessPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageSize(PAGE_SIZE_NONE);
|
||||
PageResult<CrmBusinessDO> pageResult = businessService.getBusinessPage(exportReqVO, getLoginUserId());
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessExcelVO.class,
|
||||
CrmBusinessConvert.INSTANCE.convertList02(pageResult.getList()));
|
||||
ExcelUtils.write(response, "商机.xls", "数据", CrmBusinessRespVO.class,
|
||||
buildBusinessDetailPageResult(pageResult).getList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建详细的商机分页结果
|
||||
*
|
||||
* @param pageResult 简单的商机分页结果
|
||||
* @return 详细的商机分页结果
|
||||
*/
|
||||
private PageResult<CrmBusinessRespVO> buildBusinessDetailPageResult(PageResult<CrmBusinessDO> pageResult) {
|
||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||
return PageResult.empty(pageResult.getTotal());
|
||||
}
|
||||
List<CrmBusinessStatusTypeDO> statusTypeList = businessStatusTypeService.getBusinessStatusTypeList(
|
||||
convertSet(pageResult.getList(), CrmBusinessDO::getStatusTypeId));
|
||||
List<CrmBusinessStatusDO> statusList = businessStatusService.getBusinessStatusList(
|
||||
convertSet(pageResult.getList(), CrmBusinessDO::getStatusId));
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(
|
||||
convertSet(pageResult.getList(), CrmBusinessDO::getCustomerId));
|
||||
return CrmBusinessConvert.INSTANCE.convertPage(pageResult, customerList, statusTypeList, statusList);
|
||||
}
|
||||
|
||||
@PutMapping("/transfer")
|
||||
|
@ -4,6 +4,7 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
@ -24,19 +25,17 @@ import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
@ -85,13 +84,13 @@ public class CrmBusinessStatusTypeController {
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('crm:business-status-type:query')")
|
||||
public CommonResult<CrmBusinessStatusTypeRespVO> getBusinessStatusType(@RequestParam("id") Long id) {
|
||||
CrmBusinessStatusTypeDO businessStatusType = businessStatusTypeService.getBusinessStatusType(id);
|
||||
CrmBusinessStatusTypeDO statusType = businessStatusTypeService.getBusinessStatusType(id);
|
||||
// 处理状态回显
|
||||
// TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
|
||||
// TODO @lzxhqs:可以在 businessStatusService 加个 getBusinessStatusListByTypeId 方法,直接返回 List<CrmBusinessStatusDO> 哈,常用的,尽量封装个简单易懂的方法,不用追求绝对通用哈;
|
||||
CrmBusinessStatusQueryVO queryVO = new CrmBusinessStatusQueryVO();
|
||||
queryVO.setTypeId(id);
|
||||
List<CrmBusinessStatusDO> statusList = businessStatusService.selectList(queryVO);
|
||||
return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(businessStatusType, statusList));
|
||||
return success(CrmBusinessStatusTypeConvert.INSTANCE.convert(statusType, statusList));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@ -100,12 +99,7 @@ public class CrmBusinessStatusTypeController {
|
||||
public CommonResult<PageResult<CrmBusinessStatusTypeRespVO>> getBusinessStatusTypePage(@Valid CrmBusinessStatusTypePageReqVO pageReqVO) {
|
||||
PageResult<CrmBusinessStatusTypeDO> pageResult = businessStatusTypeService.getBusinessStatusTypePage(pageReqVO);
|
||||
// 处理部门回显
|
||||
// TODO @ljlleo:可以使用 CollectionUtils.convertSet 替代常用的 stream 操作,更简洁一点;下面几个也是哈;
|
||||
Set<Long> deptIds = pageResult.getList().stream()
|
||||
.map(CrmBusinessStatusTypeDO::getDeptIds)
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toSet());
|
||||
Set<Long> deptIds = CollectionUtils.convertSetByFlatMap(pageResult.getList(), CrmBusinessStatusTypeDO::getDeptIds,Collection::stream);
|
||||
List<DeptRespDTO> deptList = deptApi.getDeptList(deptIds);
|
||||
return success(CrmBusinessStatusTypeConvert.INSTANCE.convertPage(pageResult, deptList));
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - 商机创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessCreateReqVO extends CrmBusinessBaseVO {
|
||||
|
||||
// TODO @ljileo:新建的时候,应该可以传递添加的产品;
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -18,4 +20,11 @@ public class CrmBusinessPageReqVO extends PageParam {
|
||||
@Schema(description = "客户编号", example = "10795")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "联系人编号", example = "10795")
|
||||
private Long contactId;
|
||||
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType; // 场景类型,为 null 时则表示全部
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,59 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 商机 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessRespVO extends CrmBusinessBaseVO {
|
||||
public class CrmBusinessRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@NotNull(message = "商机名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "商机状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714")
|
||||
@NotNull(message = "商机状态类型不能为空")
|
||||
private Long statusTypeId;
|
||||
|
||||
@Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "商机状态不能为空")
|
||||
private Long statusId;
|
||||
|
||||
@Schema(description = "下次联系时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299")
|
||||
@NotNull(message = "客户不能为空")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "预计成交日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime dealTime;
|
||||
|
||||
@Schema(description = "商机金额", example = "12371")
|
||||
private Integer price;
|
||||
|
||||
// TODO @ljileo:折扣使用 Integer 类型,存储时,默认 * 100;展示的时候,前端需要 / 100;避免精度丢失问题
|
||||
@Schema(description = "整单折扣")
|
||||
private Integer discountPercent;
|
||||
|
||||
@Schema(description = "产品总金额", example = "12025")
|
||||
private BigDecimal productPrice;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
@ -1,57 +1,85 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.product.CrmBusinessProductSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.enums.business.CrmBizEndStatus;
|
||||
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerParseFunction;
|
||||
import com.mzt.logapi.starter.annotation.DiffLogField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 商机 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - CRM 商机创建/更新 Request VO")
|
||||
@Data
|
||||
public class CrmBusinessBaseVO {
|
||||
public class CrmBusinessSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "商机名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "李四")
|
||||
@DiffLogField(name = "商机名称")
|
||||
@NotNull(message = "商机名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "商机状态类型编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "25714")
|
||||
@DiffLogField(name = "商机状态")
|
||||
@NotNull(message = "商机状态类型不能为空")
|
||||
private Long statusTypeId;
|
||||
|
||||
@Schema(description = "商机状态编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@DiffLogField(name = "商机状态")
|
||||
@NotNull(message = "商机状态不能为空")
|
||||
private Long statusId;
|
||||
|
||||
@Schema(description = "下次联系时间")
|
||||
@DiffLogField(name = "下次联系时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10299")
|
||||
@DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME)
|
||||
@NotNull(message = "客户不能为空")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "预计成交日期")
|
||||
@DiffLogField(name = "预计成交日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime dealTime;
|
||||
|
||||
@Schema(description = "商机金额", example = "12371")
|
||||
@DiffLogField(name = "商机金额")
|
||||
private Integer price;
|
||||
|
||||
// TODO @ljileo:折扣使用 Integer 类型,存储时,默认 * 100;展示的时候,前端需要 / 100;避免精度丢失问题
|
||||
// TODO @lzxhqs:折扣使用 Integer 类型,存储时,默认 * 100;展示的时候,前端需要 / 100;避免精度丢失问题
|
||||
@Schema(description = "整单折扣")
|
||||
@DiffLogField(name = "整单折扣")
|
||||
private Integer discountPercent;
|
||||
|
||||
@Schema(description = "产品总金额", example = "12025")
|
||||
@DiffLogField(name = "产品总金额")
|
||||
private BigDecimal productPrice;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
@DiffLogField(name = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "结束状态", example = "1")
|
||||
@InEnum(CrmBizEndStatus.class)
|
||||
private Integer endStatus;
|
||||
|
||||
// TODO @lzxhqs:不设置默认 new ArrayList<>();一般 pojo 不设置默认值哈
|
||||
@Schema(description = "商机产品列表")
|
||||
private List<CrmBusinessProductSaveReqVO> products = new ArrayList<>();
|
||||
|
||||
@Schema(description = "联系人编号", example = "110")
|
||||
private Long contactId; // 使用场景,在【联系人详情】添加商机时,如果需要关联两者,需要传递 contactId 字段
|
||||
|
||||
}
|
@ -2,16 +2,15 @@ package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 商机转移 Request VO")
|
||||
@Data
|
||||
public class CrmBusinessTransferReqVO {
|
||||
|
||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "联系人编号不能为空")
|
||||
@NotNull(message = "商机编号不能为空")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
|
@ -1,23 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.business;
|
||||
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessBaseVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 商机更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessUpdateReqVO extends CrmBusinessBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
// TODO @ljileo:修改的时候,应该可以传递添加的产品;
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
// TODO @lzxhqs:这个类,如果没用到,可以考虑删除哈
|
||||
@Schema(description = "管理后台 - 商机产品分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmBusinessProductPageReqVO extends PageParam {
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 商机产品关联 Response VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmBusinessProductRespVO {
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.business.vo.product;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 商机产品关联表 创建/更新 Request VO")
|
||||
@Data
|
||||
public class CrmBusinessProductSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "32129")
|
||||
private Long id;
|
||||
|
||||
// TODO @lzxhqs:这个字段,应该是 Long 类型
|
||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "商机编号不能为空")
|
||||
private Integer businessId;
|
||||
|
||||
// TODO @lzxhqs:这个字段,应该是 Long 类型
|
||||
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "产品编号不能为空")
|
||||
private Integer productId;
|
||||
|
||||
@Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "产品单价不能为空")
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "销售价格", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "销售价格不能为空")
|
||||
private BigDecimal salesPrice;
|
||||
|
||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "数量不能为空")
|
||||
private BigDecimal num;
|
||||
|
||||
@Schema(description = "折扣", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "折扣不能为空")
|
||||
private BigDecimal discount;
|
||||
|
||||
@Schema(description = "小计(折扣后价格)", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "小计(折扣后价格)不能为空")
|
||||
private BigDecimal subtotal;
|
||||
|
||||
// TODO @lzxhqs:字符串,用 @NotEmpty,因为要考虑 "" 前端搞了这个玩意
|
||||
@Schema(description = "单位", requiredMode = Schema.RequiredMode.REQUIRED, example = "30320")
|
||||
@NotNull(message = "单位不能为空")
|
||||
private String unit;
|
||||
|
||||
}
|
@ -21,11 +21,11 @@ public class CrmBusinessStatusSaveReqVO {
|
||||
@NotEmpty(message = "状态名不能为空")
|
||||
private String name;
|
||||
|
||||
// TODO @lilleo:percent 应该是 Integer;
|
||||
// TODO @lzxhqs::percent 应该是 Integer;
|
||||
@Schema(description = "赢单率")
|
||||
private String percent;
|
||||
|
||||
// TODO @lilleo:这个是不是不用前端新增和修改的时候传递,交给顺序计算出来,存储起来就好了;
|
||||
// TODO @lzxhqs:这个是不是不用前端新增和修改的时候传递,交给顺序计算出来,存储起来就好了;
|
||||
@Schema(description = "排序")
|
||||
private Integer sort;
|
||||
|
||||
|
@ -19,11 +19,11 @@ public class CrmBusinessStatusTypeSaveReqVO {
|
||||
@NotEmpty(message = "状态类型名不能为空")
|
||||
private String name;
|
||||
|
||||
// TODO @lzxhqs: VO 里面,我们不使用默认值哈。这里 Lists.newArrayList() 看看怎么去掉。上面 deptIds 也是类似噢
|
||||
@Schema(description = "使用的部门编号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<Long> deptIds = Lists.newArrayList();
|
||||
|
||||
// TODO @ljlleo VO 里面,我们不使用默认值哈。这里 Lists.newArrayList() 看看怎么去掉。上面 deptIds 也是类似噢
|
||||
@Schema(description = "商机状态集合", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<CrmBusinessStatusSaveReqVO> statusList = Lists.newArrayList();
|
||||
private List<CrmBusinessStatusSaveReqVO> statusList;
|
||||
|
||||
}
|
||||
|
@ -2,27 +2,29 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.clue.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.convert.clue.CrmClueConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.clue.CrmClueDO;
|
||||
import cn.iocoder.yudao.module.crm.service.clue.CrmClueService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
@Tag(name = "管理后台 - 线索")
|
||||
@RestController
|
||||
@ -36,14 +38,14 @@ public class CrmClueController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建线索")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:create')")
|
||||
public CommonResult<Long> createClue(@Valid @RequestBody CrmClueCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createClue(@Valid @RequestBody CrmClueSaveReqVO createReqVO) {
|
||||
return success(clueService.createClue(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新线索")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
|
||||
public CommonResult<Boolean> updateClue(@Valid @RequestBody CrmClueUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateClue(@Valid @RequestBody CrmClueSaveReqVO updateReqVO) {
|
||||
clueService.updateClue(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -63,27 +65,43 @@ public class CrmClueController {
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:query')")
|
||||
public CommonResult<CrmClueRespVO> getClue(@RequestParam("id") Long id) {
|
||||
CrmClueDO clue = clueService.getClue(id);
|
||||
return success(CrmClueConvert.INSTANCE.convert(clue));
|
||||
return success(BeanUtils.toBean(clue, CrmClueRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得线索分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:query')")
|
||||
public CommonResult<PageResult<CrmClueRespVO>> getCluePage(@Valid CrmCluePageReqVO pageVO) {
|
||||
PageResult<CrmClueDO> pageResult = clueService.getCluePage(pageVO);
|
||||
return success(CrmClueConvert.INSTANCE.convertPage(pageResult));
|
||||
PageResult<CrmClueDO> pageResult = clueService.getCluePage(pageVO, getLoginUserId());
|
||||
return success(BeanUtils.toBean(pageResult, CrmClueRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@Operation(summary = "导出线索 Excel")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:export')")
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportClueExcel(@Valid CrmClueExportReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
List<CrmClueDO> list = clueService.getClueList(exportReqVO);
|
||||
public void exportClueExcel(@Valid CrmCluePageReqVO pageReqVO, HttpServletResponse response) throws IOException {
|
||||
pageReqVO.setPageSize(PAGE_SIZE_NONE);
|
||||
List<CrmClueDO> list = clueService.getCluePage(pageReqVO, getLoginUserId()).getList();
|
||||
// 导出 Excel
|
||||
List<CrmClueExcelVO> datas = CrmClueConvert.INSTANCE.convertList02(list);
|
||||
ExcelUtils.write(response, "线索.xls", "数据", CrmClueExcelVO.class, datas);
|
||||
List<CrmClueRespVO> datas = BeanUtils.toBean(list, CrmClueRespVO.class);
|
||||
ExcelUtils.write(response, "线索.xls", "数据", CrmClueRespVO.class, datas);
|
||||
}
|
||||
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "线索转移")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmClueTransferReqVO reqVO) {
|
||||
clueService.transferClue(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/transform")
|
||||
@Operation(summary = "线索转化为客户")
|
||||
@PreAuthorize("@ss.hasPermission('crm:clue:update')")
|
||||
public CommonResult<Boolean> translateCustomer(@Valid @RequestBody CrmClueTransformReqVO reqVO) {
|
||||
clueService.translateCustomer(reqVO, getLoginUserId());
|
||||
return success(Boolean.TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.*;
|
||||
|
||||
@Schema(description = "管理后台 - 线索创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmClueCreateReqVO extends CrmClueBaseVO {
|
||||
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
|
||||
/**
|
||||
* 线索 Excel VO
|
||||
*
|
||||
* @author Wanwan
|
||||
*/
|
||||
@Data
|
||||
public class CrmClueExcelVO {
|
||||
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty(value = "转化状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean transformStatus;
|
||||
|
||||
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean followUpStatus;
|
||||
|
||||
@ExcelProperty("线索名称")
|
||||
private String name;
|
||||
|
||||
// TODO 这里需要导出成客户名称
|
||||
@ExcelProperty("客户id")
|
||||
private Long customerId;
|
||||
|
||||
@ExcelProperty("下次联系时间")
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@ExcelProperty("电话")
|
||||
private String telephone;
|
||||
|
||||
@ExcelProperty("手机号")
|
||||
private String mobile;
|
||||
|
||||
@ExcelProperty("地址")
|
||||
private String address;
|
||||
|
||||
@ExcelProperty("负责人的用户编号")
|
||||
private Long ownerUserId;
|
||||
|
||||
@ExcelProperty("最后跟进时间")
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import lombok.*;
|
||||
import java.util.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import java.time.LocalDateTime;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 线索 Excel 导出 Request VO,参数和 CrmCluePageReqVO 是一致的")
|
||||
@Data
|
||||
public class CrmClueExportReqVO {
|
||||
|
||||
@Schema(description = "转化状态", example = "true")
|
||||
private Boolean transformStatus;
|
||||
|
||||
@Schema(description = "跟进状态", example = "true")
|
||||
private Boolean followUpStatus;
|
||||
|
||||
@Schema(description = "线索名称", example = "线索xxx")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "客户id", example = "520")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] contactNextTime;
|
||||
|
||||
@Schema(description = "电话", example = "18000000000")
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "手机号", example = "18000000000")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "地址", example = "北京市海淀区")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "负责人的用户编号", example = "27199")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] contactLastTime;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -21,4 +23,11 @@ public class CrmCluePageReqVO extends PageParam {
|
||||
@Schema(description = "手机号", example = "18000000000")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType; // 场景类型,为 null 时则表示全部
|
||||
|
||||
@Schema(description = "是否为公海数据", requiredMode = Schema.RequiredMode.REQUIRED, example = "false")
|
||||
private Boolean pool; // null 则表示为不是公海数据
|
||||
|
||||
}
|
||||
|
@ -1,27 +1,80 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - 线索 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmClueRespVO extends CrmClueBaseVO {
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmClueRespVO {
|
||||
|
||||
@Schema(description = "编号,主键自增", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969")
|
||||
@ExcelProperty("编号")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "转化状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@ExcelProperty(value = "转化状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean transformStatus;
|
||||
|
||||
@Schema(description = "跟进状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "true")
|
||||
@ExcelProperty(value = "跟进状态", converter = DictConvert.class)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean followUpStatus;
|
||||
|
||||
@Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx")
|
||||
@ExcelProperty("线索名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520")
|
||||
// TODO 这里需要导出成客户名称
|
||||
@ExcelProperty("客户id")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ExcelProperty("下次联系时间")
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "电话", example = "18000000000")
|
||||
@ExcelProperty("电话")
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "手机号", example = "18000000000")
|
||||
@ExcelProperty("手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "地址", example = "北京市海淀区")
|
||||
@ExcelProperty("地址")
|
||||
private String address;
|
||||
|
||||
@Schema(description = "负责人编号")
|
||||
@ExcelProperty("负责人的用户编号")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ExcelProperty("最后跟进时间")
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
@ExcelProperty("备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
@ExcelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
@ -3,30 +3,25 @@ package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||
import cn.iocoder.yudao.framework.common.validation.Telephone;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
/**
|
||||
* 线索 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - CRM 线索 创建/更新 Request VO")
|
||||
@Data
|
||||
public class CrmClueBaseVO {
|
||||
public class CrmClueSaveReqVO {
|
||||
|
||||
@Schema(description = "编号", example = "10969")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "线索名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "线索xxx")
|
||||
@NotEmpty(message = "线索名称不能为空")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "客户 id", requiredMode = Schema.RequiredMode.REQUIRED, example = "520")
|
||||
@NotNull(message = "客户不能为空")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "下次联系时间", example = "2023-10-18 01:00:00")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactNextTime;
|
||||
@ -46,6 +41,9 @@ public class CrmClueBaseVO {
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@Schema(description = "负责人编号", example = "2048")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "备注", example = "随便")
|
||||
private String remark;
|
||||
|
@ -0,0 +1,25 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Schema(description = "管理后台 - 线索转移 Request VO")
|
||||
@Data
|
||||
public class CrmClueTransferReqVO {
|
||||
|
||||
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "线索编号不能为空")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "新负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10430")
|
||||
@NotNull(message = "新负责人的用户编号不能为空")
|
||||
private Long newOwnerUserId;
|
||||
|
||||
@Schema(description = "老负责人加入团队后的权限级别", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||
@InEnum(value = CrmPermissionLevelEnum.class)
|
||||
private Integer oldOwnerPermissionLevel; // 老负责人加入团队后的权限级别。如果 null 说明移除
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Schema(description = "管理后台 - 线索转化为客户 Request VO")
|
||||
@Data
|
||||
public class CrmClueTransformReqVO {
|
||||
|
||||
@Schema(description = "线索编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024, 1025]")
|
||||
@NotEmpty(message = "线索编号不能为空")
|
||||
private Set<Long> ids;
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.clue.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - 线索更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmClueUpdateReqVO extends CrmClueBaseVO {
|
||||
|
||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10969")
|
||||
@NotNull(message = "编号不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -4,32 +4,36 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contact.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.convert.contact.ContactConvert;
|
||||
import cn.iocoder.yudao.module.crm.convert.contact.CrmContactConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contact.CrmContactDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants;
|
||||
import cn.iocoder.yudao.module.crm.service.contact.CrmContactBusinessService;
|
||||
import cn.iocoder.yudao.module.crm.service.contact.CrmContactService;
|
||||
import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerService;
|
||||
import cn.iocoder.yudao.module.system.api.logger.OperateLogApi;
|
||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO;
|
||||
import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO;
|
||||
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
|
||||
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@ -38,10 +42,11 @@ import java.util.stream.Stream;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertListByFlatMap;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT_TYPE;
|
||||
|
||||
@Tag(name = "管理后台 - CRM 联系人")
|
||||
@RestController
|
||||
@ -54,21 +59,26 @@ public class CrmContactController {
|
||||
private CrmContactService contactService;
|
||||
@Resource
|
||||
private CrmCustomerService customerService;
|
||||
@Resource
|
||||
private CrmContactBusinessService contactBusinessLinkService;
|
||||
|
||||
@Resource
|
||||
private AdminUserApi adminUserApi;
|
||||
@Resource
|
||||
private OperateLogApi operateLogApi;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建联系人")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:create')")
|
||||
public CommonResult<Long> createContact(@Valid @RequestBody CrmContactCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createContact(@Valid @RequestBody CrmContactSaveReqVO createReqVO) {
|
||||
return success(contactService.createContact(createReqVO, getLoginUserId()));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新联系人")
|
||||
@OperateLog(enable = false)
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:update')")
|
||||
public CommonResult<Boolean> updateContact(@Valid @RequestBody CrmContactUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateContact(@Valid @RequestBody CrmContactSaveReqVO updateReqVO) {
|
||||
contactService.updateContact(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -95,34 +105,45 @@ public class CrmContactController {
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(CollUtil.removeNull(Lists.newArrayList(
|
||||
NumberUtil.parseLong(contact.getCreator()), contact.getOwnerUserId())));
|
||||
// 2. 获取客户信息
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(Collections.singletonList(contact.getCustomerId()));
|
||||
List<CrmCustomerDO> customerList = customerService.getCustomerList(
|
||||
Collections.singletonList(contact.getCustomerId()));
|
||||
// 3. 直属上级
|
||||
List<CrmContactDO> parentContactList = contactService.getContactList(Collections.singletonList(contact.getParentId()));
|
||||
return success(ContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList));
|
||||
List<CrmContactDO> parentContactList = contactService.getContactList(
|
||||
Collections.singletonList(contact.getParentId()), getLoginUserId());
|
||||
return success(CrmContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList));
|
||||
}
|
||||
|
||||
@GetMapping("/list-by-ids")
|
||||
@Operation(summary = "获得联系人列表")
|
||||
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
|
||||
public CommonResult<List<CrmContactRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) {
|
||||
return success(BeanUtils.toBean(contactService.getContactList(ids, getLoginUserId()), CrmContactRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/simple-all-list")
|
||||
@Operation(summary = "获得联系人列表")
|
||||
@Operation(summary = "获得联系人的精简列表")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
|
||||
public CommonResult<List<CrmContactSimpleRespVO>> getSimpleContactList() {
|
||||
List<CrmContactDO> list = contactService.getContactList();
|
||||
return success(ContactConvert.INSTANCE.convertAllList(list));
|
||||
public CommonResult<List<CrmContactRespVO>> getSimpleContactList() {
|
||||
List<CrmContactDO> list = contactService.getSimpleContactList(getLoginUserId());
|
||||
return success(convertList(list, contact -> // 只返回 id、name 字段
|
||||
new CrmContactRespVO().setId(contact.getId()).setName(contact.getName())));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得联系人分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
|
||||
public CommonResult<PageResult<CrmContactRespVO>> getContactPage(@Valid CrmContactPageReqVO pageVO) {
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO);
|
||||
return success(convertDetailContactPage(pageResult));
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(pageVO, getLoginUserId());
|
||||
return success(buildContactDetailPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/page-by-customer")
|
||||
@Operation(summary = "获得联系人分页,基于指定客户")
|
||||
public CommonResult<PageResult<CrmContactRespVO>> getContactPageByCustomer(@Valid CrmContactPageReqVO pageVO) {
|
||||
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomer(pageVO);
|
||||
return success(convertDetailContactPage(pageResult));
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPageByCustomerId(pageVO);
|
||||
return success(buildContactDetailPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ -131,19 +152,30 @@ public class CrmContactController {
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportContactExcel(@Valid CrmContactPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
exportReqVO.setPageNo(PageParam.PAGE_SIZE_NONE);
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(exportReqVO);
|
||||
exportReqVO.setPageNo(PAGE_SIZE_NONE);
|
||||
PageResult<CrmContactDO> pageResult = contactService.getContactPage(exportReqVO, getLoginUserId());
|
||||
ExcelUtils.write(response, "联系人.xls", "数据", CrmContactRespVO.class,
|
||||
convertDetailContactPage(pageResult).getList());
|
||||
buildContactDetailPage(pageResult).getList());
|
||||
}
|
||||
|
||||
@GetMapping("/operate-log-page")
|
||||
@Operation(summary = "获得客户操作日志")
|
||||
@PreAuthorize("@ss.hasPermission('crm:customer:query')")
|
||||
public CommonResult<PageResult<OperateLogV2RespDTO>> getCustomerOperateLog(@RequestParam("bizId") Long bizId) {
|
||||
OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO();
|
||||
reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页
|
||||
reqVO.setBizType(CRM_CONTACT_TYPE);
|
||||
reqVO.setBizId(bizId);
|
||||
return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换成详细的联系人分页,即读取关联信息
|
||||
* 构建详细的联系人分页结果
|
||||
*
|
||||
* @param pageResult 联系人分页
|
||||
* @return 详细的联系人分页
|
||||
* @param pageResult 简单的联系人分页结果
|
||||
* @return 详细的联系人分页结果
|
||||
*/
|
||||
private PageResult<CrmContactRespVO> convertDetailContactPage(PageResult<CrmContactDO> pageResult) {
|
||||
private PageResult<CrmContactRespVO> buildContactDetailPage(PageResult<CrmContactDO> pageResult) {
|
||||
List<CrmContactDO> contactList = pageResult.getList();
|
||||
if (CollUtil.isEmpty(contactList)) {
|
||||
return PageResult.empty(pageResult.getTotal());
|
||||
@ -156,8 +188,34 @@ public class CrmContactController {
|
||||
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
|
||||
// 3. 直属上级
|
||||
List<CrmContactDO> parentContactList = contactService.getContactList(
|
||||
convertSet(contactList, CrmContactDO::getParentId));
|
||||
return ContactConvert.INSTANCE.convertPage(pageResult, userMap, crmCustomerDOList, parentContactList);
|
||||
convertSet(contactList, CrmContactDO::getParentId), getLoginUserId());
|
||||
return CrmContactConvert.INSTANCE.convertPage(pageResult, userMap, crmCustomerDOList, parentContactList);
|
||||
}
|
||||
|
||||
@PutMapping("/transfer")
|
||||
@Operation(summary = "联系人转移")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:update')")
|
||||
public CommonResult<Boolean> transfer(@Valid @RequestBody CrmContactTransferReqVO reqVO) {
|
||||
contactService.transferContact(reqVO, getLoginUserId());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// ================== 关联/取关联系人 ===================
|
||||
|
||||
@PostMapping("/create-business-list")
|
||||
@Operation(summary = "创建联系人与商机的关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:create-business')")
|
||||
public CommonResult<Boolean> createContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO createReqVO) {
|
||||
contactBusinessLinkService.createContactBusinessList(createReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete-business-list")
|
||||
@Operation(summary = "删除联系人与联系人的关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact:delete-business')")
|
||||
public CommonResult<Boolean> deleteContactBusinessList(@Valid @RequestBody CrmContactBusinessReqVO deleteReqVO) {
|
||||
contactBusinessLinkService.deleteContactBusinessList(deleteReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,22 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人商机 Request VO") // 用于关联,取消关联的操作
|
||||
@Data
|
||||
public class CrmContactBusinessReqVO {
|
||||
|
||||
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878")
|
||||
@NotNull(message="联系人不能为空")
|
||||
private Long contactId;
|
||||
|
||||
@Schema(description = "商机编号数组", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638")
|
||||
@NotEmpty(message="商机不能为空")
|
||||
private List<Long> businessIds;
|
||||
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人创建 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmContactCreateReqVO extends CrmContactBaseVO {
|
||||
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.crm.enums.common.CrmSceneTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -33,4 +35,8 @@ public class CrmContactPageReqVO extends PageParam {
|
||||
@Schema(description = "微信", example = "zzZ98373")
|
||||
private String wechat;
|
||||
|
||||
@Schema(description = "场景类型", example = "1")
|
||||
@InEnum(CrmSceneTypeEnum.class)
|
||||
private Integer sceneType; // 场景类型,为 null 时则表示全部
|
||||
|
||||
}
|
||||
|
@ -1,28 +1,90 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人 Response VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmContactRespVO extends CrmContactBaseVO {
|
||||
public class CrmContactRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@ExcelProperty(value = "创建时间", order = 8)
|
||||
private LocalDateTime createTime;
|
||||
@Schema(description = "姓名", example = "芋艿")
|
||||
@ExcelProperty(value = "姓名", order = 1)
|
||||
private String name;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
@ExcelProperty(value = "更新时间", order = 8)
|
||||
private LocalDateTime updateTime;
|
||||
@Schema(description = "客户编号", example = "10795")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(description = "性别")
|
||||
@ExcelProperty(value = "性别", converter = DictConvert.class, order = 3)
|
||||
@DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX)
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "职位")
|
||||
@ExcelProperty(value = "职位", order = 3)
|
||||
private String post;
|
||||
|
||||
@Schema(description = "是否关键决策人")
|
||||
@ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
private Boolean master;
|
||||
|
||||
@Schema(description = "直属上级", example = "23457")
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "手机号", example = "1387171766")
|
||||
@ExcelProperty(value = "手机号", order = 4)
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "电话", example = "021-0029922")
|
||||
@ExcelProperty(value = "电话", order = 4)
|
||||
private String telephone;
|
||||
|
||||
@Schema(description = "QQ", example = "197272662")
|
||||
@ExcelProperty(value = "QQ", order = 4)
|
||||
private Long qq;
|
||||
|
||||
@Schema(description = "微信", example = "zzz3883")
|
||||
@ExcelProperty(value = "微信", order = 4)
|
||||
private String wechat;
|
||||
|
||||
@Schema(description = "电子邮箱", example = "1111@22.com")
|
||||
@ExcelProperty(value = "邮箱", order = 4)
|
||||
private String email;
|
||||
|
||||
@Schema(description = "地区编号", example = "20158")
|
||||
private Integer areaId;
|
||||
|
||||
@Schema(description = "地址")
|
||||
@ExcelProperty(value = "地址", order = 5)
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty(value = "备注", order = 6)
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "负责人用户编号", example = "14334")
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@ExcelProperty(value = "最后跟进时间", order = 6)
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@Schema(description = "下次联系时间")
|
||||
@ExcelProperty(value = "下次联系时间", order = 6)
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "创建人", example = "25682")
|
||||
private String creator;
|
||||
@ -31,7 +93,7 @@ public class CrmContactRespVO extends CrmContactBaseVO {
|
||||
@ExcelProperty(value = "创建人", order = 8)
|
||||
private String creatorName;
|
||||
|
||||
@ExcelProperty(value = "客户名称",order = 2)
|
||||
@ExcelProperty(value = "客户名称", order = 2)
|
||||
@Schema(description = "客户名字", example = "test")
|
||||
private String customerName;
|
||||
|
||||
|
@ -2,102 +2,102 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.validation.Mobile;
|
||||
import cn.iocoder.yudao.framework.common.validation.Telephone;
|
||||
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import cn.iocoder.yudao.module.crm.framework.operatelog.core.*;
|
||||
import com.mzt.logapi.starter.annotation.DiffLogField;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
// TODO zyna:要不按照新的,干掉这个 basevo,都放子类里
|
||||
/**
|
||||
* CRM 联系人 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Schema(description = "管理后台 - CRM 联系人创建/更新 Request VO")
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class CrmContactBaseVO {
|
||||
public class CrmContactSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", example = "3167")
|
||||
private Long id;
|
||||
|
||||
@ExcelProperty(value = "姓名",order = 1)
|
||||
@Schema(description = "姓名", example = "芋艿")
|
||||
@NotNull(message = "姓名不能为空")
|
||||
@DiffLogField(name = "姓名")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "客户编号", example = "10795")
|
||||
@DiffLogField(name = "客户", function = CrmCustomerParseFunction.NAME)
|
||||
private Long customerId;
|
||||
|
||||
@ExcelProperty(value = "性别", converter = DictConvert.class, order = 3)
|
||||
@DictFormat(cn.iocoder.yudao.module.system.enums.DictTypeConstants.USER_SEX)
|
||||
@Schema(description = "性别")
|
||||
@DiffLogField(name = "性别", function = SysSexParseFunction.NAME)
|
||||
private Integer sex;
|
||||
|
||||
@Schema(description = "职位")
|
||||
@ExcelProperty(value = "职位", order = 3)
|
||||
@DiffLogField(name = "职位")
|
||||
private String post;
|
||||
|
||||
@Schema(description = "是否关键决策人")
|
||||
@ExcelProperty(value = "是否关键决策人", converter = DictConvert.class, order = 3)
|
||||
@DictFormat(DictTypeConstants.BOOLEAN_STRING)
|
||||
@DiffLogField(name = "关键决策人", function = SysBooleanParseFunction.NAME)
|
||||
private Boolean master;
|
||||
|
||||
@Schema(description = "直属上级", example = "23457")
|
||||
@DiffLogField(name = "直属上级", function = CrmContactParseFunction.NAME)
|
||||
private Long parentId;
|
||||
|
||||
@Schema(description = "手机号",example = "1387171766")
|
||||
@Schema(description = "手机号", example = "1387171766")
|
||||
@Mobile
|
||||
@ExcelProperty(value = "手机号",order = 4)
|
||||
@DiffLogField(name = "手机号")
|
||||
private String mobile;
|
||||
|
||||
@Schema(description = "座机",example = "021-0029922")
|
||||
@Schema(description = "电话", example = "021-0029922")
|
||||
@Telephone
|
||||
@ExcelProperty(value = "座机",order = 4)
|
||||
@DiffLogField(name = "电话")
|
||||
private String telephone;
|
||||
|
||||
@ExcelProperty(value = "QQ",order = 4)
|
||||
@Schema(description = "QQ",example = "197272662")
|
||||
@Schema(description = "QQ", example = "197272662")
|
||||
@DiffLogField(name = "QQ")
|
||||
private Long qq;
|
||||
|
||||
@ExcelProperty(value = "微信",order = 4)
|
||||
@Schema(description = "微信",example = "zzz3883")
|
||||
@Schema(description = "微信", example = "zzz3883")
|
||||
@DiffLogField(name = "微信")
|
||||
private String wechat;
|
||||
|
||||
@Schema(description = "电子邮箱",example = "1111@22.com")
|
||||
@Schema(description = "电子邮箱", example = "1111@22.com")
|
||||
@DiffLogField(name = "邮箱")
|
||||
@Email
|
||||
@ExcelProperty(value = "邮箱",order = 4)
|
||||
private String email;
|
||||
|
||||
@ExcelProperty(value = "地址",order = 5)
|
||||
@Schema(description = "地址")
|
||||
private String address;
|
||||
@Schema(description = "地区编号", example = "20158")
|
||||
@DiffLogField(name = "所在地", function = SysAreaParseFunction.NAME)
|
||||
private Integer areaId;
|
||||
|
||||
@Schema(description = "下次联系时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
@ExcelProperty(value = "下次联系时间",order = 6)
|
||||
private LocalDateTime nextTime;
|
||||
@Schema(description = "地址")
|
||||
@DiffLogField(name = "地址")
|
||||
private String detailAddress;
|
||||
|
||||
@Schema(description = "备注", example = "你说的对")
|
||||
@ExcelProperty(value = "备注",order = 6)
|
||||
@DiffLogField(name = "备注")
|
||||
private String remark;
|
||||
|
||||
@Schema(description = "最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@ExcelProperty(value = "最后跟进时间",order = 6)
|
||||
private LocalDateTime lastTime;
|
||||
|
||||
@Schema(description = "负责人用户编号", example = "14334")
|
||||
@NotNull(message = "负责人不能为空")
|
||||
@DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME)
|
||||
private Long ownerUserId;
|
||||
|
||||
@Schema(description = "地区编号", example = "20158")
|
||||
private Integer areaId;
|
||||
@Schema(description = "最后跟进时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
@DiffLogField(name = "最后跟进时间")
|
||||
private LocalDateTime contactLastTime;
|
||||
|
||||
@Schema(description = "下次联系时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
@DiffLogField(name = "下次联系时间")
|
||||
private LocalDateTime contactNextTime;
|
||||
|
||||
@Schema(description = "关联商机 ID", example = "122233")
|
||||
private Long businessId; // 注意:该字段用于在【商机】详情界面「新建联系人」时,自动进行关联
|
||||
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人的精简 Response VO")
|
||||
@Data
|
||||
@ToString(callSuper = true)
|
||||
public class CrmContactSimpleRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "姓名", example = "芋艿")
|
||||
private String name;
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人更新 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class CrmContactUpdateReqVO extends CrmContactBaseVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "3167")
|
||||
@NotNull(message = "主键不能为空")
|
||||
private Long id;
|
||||
|
||||
}
|
@ -1,115 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.CrmBusinessRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkPageReqVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkRespVO;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo.CrmContactBusinessLinkSaveReqVO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.business.CrmBusinessDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contactbusinesslink.CrmContactBusinessLinkDO;
|
||||
import cn.iocoder.yudao.module.crm.service.business.CrmBusinessService;
|
||||
import cn.iocoder.yudao.module.crm.service.contactbusinesslink.CrmContactBusinessLinkService;
|
||||
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.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.BUSINESS_NOT_EXISTS;
|
||||
|
||||
@Tag(name = "管理后台 - CRM 联系人商机关联")
|
||||
@RestController
|
||||
@RequestMapping("/crm/contact-business-link")
|
||||
@Validated
|
||||
public class CrmContactBusinessLinkController {
|
||||
|
||||
@Resource
|
||||
private CrmContactBusinessLinkService contactBusinessLinkService;
|
||||
@Resource
|
||||
private CrmBusinessService crmBusinessService;
|
||||
|
||||
// TODO @zyna:createContactBusinessLink 和 createContactBusinessLinkBatch 是不是合并成一个接口?contactId、List<businessId>
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建联系人商机关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
||||
public CommonResult<Long> createContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO createReqVO) {
|
||||
return success(contactBusinessLinkService.createContactBusinessLink(createReqVO));
|
||||
}
|
||||
|
||||
@PostMapping("/create-batch")
|
||||
@Operation(summary = "创建联系人商机关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:create')")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CommonResult<Boolean> createContactBusinessLinkBatch(
|
||||
@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> createReqVO) {
|
||||
createReqVO.stream().forEach(item -> {
|
||||
CrmBusinessDO crmBusinessDO = crmBusinessService.getBusiness(item.getBusinessId());
|
||||
if(crmBusinessDO == null){
|
||||
throw exception(BUSINESS_NOT_EXISTS);
|
||||
}
|
||||
});
|
||||
contactBusinessLinkService.createContactBusinessLinkBatch(createReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO @zyna:这个接口是不是可以删除掉了哈?应该不存在更新。
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新联系人商机关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:update')")
|
||||
public CommonResult<Boolean> updateContactBusinessLink(@Valid @RequestBody CrmContactBusinessLinkSaveReqVO updateReqVO) {
|
||||
contactBusinessLinkService.updateContactBusinessLink(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO @zyna:删除,是不是传递 ids?
|
||||
@DeleteMapping("/delete-batch")
|
||||
@Operation(summary = "批量删除联系人商机关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:delete')")
|
||||
public CommonResult<Boolean> deleteContactBusinessLinkBatch(@Valid @RequestBody List<CrmContactBusinessLinkSaveReqVO> deleteList) {
|
||||
contactBusinessLinkService.deleteContactBusinessLink(deleteList);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
// TODO @zyna:这个接口是不是可以删除掉了哈?应该不存在单个读取;
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得联系人商机关联")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
||||
public CommonResult<CrmContactBusinessLinkRespVO> getContactBusinessLink(@RequestParam("id") Long id) {
|
||||
CrmContactBusinessLinkDO contactBusinessLink = contactBusinessLinkService.getContactBusinessLink(id);
|
||||
return success(BeanUtils.toBean(contactBusinessLink, CrmContactBusinessLinkRespVO.class));
|
||||
}
|
||||
|
||||
// TODO @zyna:这个可以转化下,使用客户编号去查询,就是使用 CrmBusinessController 的 getBusinessPageByCustomer 接口;目的是:复用
|
||||
@GetMapping("/page-by-contact")
|
||||
@Operation(summary = "获得联系人商机关联")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
||||
public CommonResult<PageResult<CrmBusinessRespVO>> getContactBusinessLinkByContact(
|
||||
@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||
PageResult<CrmBusinessRespVO> contactBusinessLink = contactBusinessLinkService.getContactBusinessLinkPageByContact(pageReqVO);
|
||||
return success(contactBusinessLink);
|
||||
}
|
||||
|
||||
// TODO @zyna:这个优化下,搞到 CrmBusinessController 里去,加一个 CrmBusinessController 的 getBusinessPageByContact 接口;目的是:
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得联系人商机关联分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contact-business-link:query')")
|
||||
public CommonResult<PageResult<CrmContactBusinessLinkRespVO>> getContactBusinessLinkPage(
|
||||
@Valid CrmContactBusinessLinkPageReqVO pageReqVO) {
|
||||
PageResult<CrmContactBusinessLinkDO> pageResult = contactBusinessLinkService.getContactBusinessLinkPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, CrmContactBusinessLinkRespVO.class));
|
||||
}
|
||||
|
||||
// TODO @zyna:最终梳理完后,应该就 2 个接口,要不直接合并到 CrmContactController 中,不作为独立模块,就关联、接触关联。其实和 user 设置它有哪些岗位、部门是类似的。
|
||||
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人商机关联 Response VO")
|
||||
@Data
|
||||
public class CrmContactBusinessLinkRespVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
|
||||
@ExcelProperty("主键")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878")
|
||||
private Long contactId;
|
||||
|
||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638")
|
||||
private Long businessId;
|
||||
|
||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
package cn.iocoder.yudao.module.crm.controller.admin.contactbusinesslink.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@Schema(description = "管理后台 - CRM 联系人商机关联新增/修改 Request VO")
|
||||
@Data
|
||||
public class CrmContactBusinessLinkSaveReqVO {
|
||||
|
||||
@Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "17220")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "联系人编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20878")
|
||||
@NotNull(message="联系人不能为空")
|
||||
private Long contactId;
|
||||
|
||||
@Schema(description = "商机编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7638")
|
||||
@NotNull(message="商机不能为空")
|
||||
private Long businessId;
|
||||
|
||||
}
|
@ -5,10 +5,11 @@ import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.number.NumberUtils;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||
import cn.iocoder.yudao.module.crm.controller.admin.contract.vo.*;
|
||||
import cn.iocoder.yudao.module.crm.convert.contract.ContractConvert;
|
||||
import cn.iocoder.yudao.module.crm.convert.contract.CrmContractConvert;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.contract.CrmContractDO;
|
||||
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
|
||||
import cn.iocoder.yudao.module.crm.service.contract.CrmContractService;
|
||||
@ -18,13 +19,13 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.Valid;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -53,14 +54,14 @@ public class CrmContractController {
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建合同")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contract:create')")
|
||||
public CommonResult<Long> createContract(@Valid @RequestBody CrmContractCreateReqVO createReqVO) {
|
||||
public CommonResult<Long> createContract(@Valid @RequestBody CrmContractSaveReqVO createReqVO) {
|
||||
return success(contractService.createContract(createReqVO, getLoginUserId()));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新合同")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contract:update')")
|
||||
public CommonResult<Boolean> updateContract(@Valid @RequestBody CrmContractUpdateReqVO updateReqVO) {
|
||||
public CommonResult<Boolean> updateContract(@Valid @RequestBody CrmContractSaveReqVO updateReqVO) {
|
||||
contractService.updateContract(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
@ -78,25 +79,25 @@ public class CrmContractController {
|
||||
@Operation(summary = "获得合同")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contract:query')")
|
||||
public CommonResult<ContractRespVO> getContract(@RequestParam("id") Long id) {
|
||||
public CommonResult<CrmContractRespVO> getContract(@RequestParam("id") Long id) {
|
||||
CrmContractDO contract = contractService.getContract(id);
|
||||
return success(ContractConvert.INSTANCE.convert(contract));
|
||||
return success(BeanUtils.toBean(contract, CrmContractRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得合同分页")
|
||||
@PreAuthorize("@ss.hasPermission('crm:contract:query')")
|
||||
public CommonResult<PageResult<ContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) {
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO);
|
||||
return success(convertDetailContractPage(pageResult));
|
||||
public CommonResult<PageResult<CrmContractRespVO>> getContractPage(@Valid CrmContractPageReqVO pageVO) {
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(pageVO, getLoginUserId());
|
||||
return success(buildContractDetailPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/page-by-customer")
|
||||
@Operation(summary = "获得联系人分页,基于指定客户")
|
||||
public CommonResult<PageResult<ContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) {
|
||||
public CommonResult<PageResult<CrmContractRespVO>> getContractPageByCustomer(@Valid CrmContractPageReqVO pageVO) {
|
||||
Assert.notNull(pageVO.getCustomerId(), "客户编号不能为空");
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomer(pageVO);
|
||||
return success(convertDetailContractPage(pageResult));
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPageByCustomerId(pageVO);
|
||||
return success(buildContractDetailPage(pageResult));
|
||||
}
|
||||
|
||||
@GetMapping("/export-excel")
|
||||
@ -105,19 +106,19 @@ public class CrmContractController {
|
||||
@OperateLog(type = EXPORT)
|
||||
public void exportContractExcel(@Valid CrmContractPageReqVO exportReqVO,
|
||||
HttpServletResponse response) throws IOException {
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO);
|
||||
PageResult<CrmContractDO> pageResult = contractService.getContractPage(exportReqVO, getLoginUserId());
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "合同.xls", "数据", CrmContractExcelVO.class,
|
||||
ContractConvert.INSTANCE.convertList02(pageResult.getList()));
|
||||
BeanUtils.toBean(pageResult.getList(), CrmContractExcelVO.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换成详细的合同分页,即读取关联信息
|
||||
* 构建详细的合同分页结果
|
||||
*
|
||||
* @param pageResult 合同分页
|
||||
* @return 详细的合同分页
|
||||
* @param pageResult 简单的合同分页结果
|
||||
* @return 详细的合同分页结果
|
||||
*/
|
||||
private PageResult<ContractRespVO> convertDetailContractPage(PageResult<CrmContractDO> pageResult) {
|
||||
private PageResult<CrmContractRespVO> buildContractDetailPage(PageResult<CrmContractDO> pageResult) {
|
||||
List<CrmContractDO> contactList = pageResult.getList();
|
||||
if (CollUtil.isEmpty(contactList)) {
|
||||
return PageResult.empty(pageResult.getTotal());
|
||||
@ -128,7 +129,7 @@ public class CrmContractController {
|
||||
// 2. 获取创建人、负责人列表
|
||||
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(contactList,
|
||||
contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getOwnerUserId())));
|
||||
return ContractConvert.INSTANCE.convertPage(pageResult, userMap, customerList);
|
||||
return CrmContractConvert.INSTANCE.convertPage(pageResult, userMap, customerList);
|
||||
}
|
||||
|
||||
@PutMapping("/transfer")
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user