diff --git a/pom.xml b/pom.xml index fc1e35eb..c44bf0c2 100644 --- a/pom.xml +++ b/pom.xml @@ -25,6 +25,7 @@ yudao-module-bs yudao-module-archives + yudao-module-accounting yudao-module-electronic yudao-module-setting diff --git a/sql/accounting20230920JilingLee.sql b/sql/accounting20230920JilingLee.sql new file mode 100644 index 00000000..94c93b81 --- /dev/null +++ b/sql/accounting20230920JilingLee.sql @@ -0,0 +1,114 @@ +-- 插入字典 +INSERT INTO `lyr-one`.`system_dict_type`(`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (NULL, '归档状态', 'archives_file_status', 0, NULL, '1', '2023-09-08 11:16:23', '1', '2023-09-08 11:16:23', b'0', '1970-01-01 00:00:00'); +INSERT INTO `lyr-one`.`system_dict_type`(`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (NULL, '会计凭证完整性', 'accounting_file_status', 0, NULL, '1', '2023-09-19 15:17:27', '1', '2023-09-19 15:41:11', b'0', '1970-01-01 00:00:00'); +INSERT INTO `lyr-one`.`system_dict_type`(`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (NULL, '会计凭证借阅状态', 'accounting_borrow_stauts', 0, NULL, '1', '2023-09-19 15:21:18', '1', '2023-09-19 15:41:12', b'0', '1970-01-01 00:00:00'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 0, '不完整', '0', 'accounting_file_status', 0, 'warning', '', NULL, '', '2023-09-19 15:18:27', '', '2023-09-19 15:18:39', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 0, '完整', '1', 'accounting_file_status', 0, 'success', '', NULL, '', '2023-09-19 15:18:56', '', '2023-09-19 15:18:56', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 0, '未借阅', '0', 'accounting_borrow_stauts', 0, 'info', '', NULL, '', '2023-09-19 15:22:06', '', '2023-09-19 15:22:06', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 0, '已借阅', '1', 'accounting_borrow_stauts', 0, 'danger', '', NULL, '', '2023-09-19 15:22:29', '', '2023-09-19 15:22:29', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 0, '未归档', '0', 'archives_file_status', 0, 'warning', '', NULL, '1', '2023-09-08 11:18:38', '1', '2023-09-08 11:18:38', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 0, '已归档', '1', 'archives_file_status', 0, 'success', '', NULL, '1', '2023-09-08 11:18:53', '1', '2023-09-08 11:18:53', b'0'); +INSERT INTO `lyr-one`.`system_dict_type`(`id`, `name`, `type`, `status`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`, `deleted_time`) VALUES (NULL, '档案类型', 'archives_file_type', 0, NULL, '1', '2023-09-08 11:13:18', '1', '2023-09-08 11:13:18', b'0', '1970-01-01 00:00:00'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 0, '资产档案', 'electronic_assets', 'archives_file_type', 0, 'default', '', NULL, '136', '2023-09-08 15:35:38', '136', '2023-09-08 16:05:31', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 1, '咨询档案', 'electronic_consultation', 'archives_file_type', 0, 'default', '', NULL, '136', '2023-09-08 16:05:42', '136', '2023-09-08 16:06:24', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 2, '合同档案', 'electronic_contracts', 'archives_file_type', 0, 'default', '', NULL, '136', '2023-09-08 16:06:06', '136', '2023-09-08 16:06:48', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 3, '客诉档案', 'electronic_customer_complaint', 'archives_file_type', 0, 'default', '', NULL, '136', '2023-09-08 16:06:20', '136', '2023-09-08 16:06:58', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 4, '员工档案', 'electronic_employee', 'archives_file_type', 0, 'default', '', NULL, '136', '2023-09-08 16:07:12', '136', '2023-09-08 16:07:17', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 5, '其它电子档案', 'electronic_other', 'archives_file_type', 0, 'default', '', NULL, '136', '2023-09-08 16:07:35', '136', '2023-09-08 16:10:18', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 6, '会计凭证档案', 'accounting_voucher', 'archives_file_type', 0, 'default', '', NULL, '136', '2023-09-08 16:08:02', '136', '2023-09-08 16:09:34', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 7, '会计账簿档案', 'accounting_book', 'archives_file_type', 0, 'default', '', NULL, '136', '2023-09-08 16:08:30', '136', '2023-09-08 16:09:27', b'0'); +INSERT INTO `lyr-one`.`system_dict_data`(`id`, `sort`, `label`, `value`, `dict_type`, `status`, `color_type`, `css_class`, `remark`, `creator`, `create_time`, `updater`, `update_time`, `deleted`) VALUES (NULL, 8, '其它会计档案', 'archives_other', 'archives_file_type', 0, 'default', '', NULL, '136', '2023-09-08 16:10:01', '136', '2023-09-08 16:10:01', b'0'); + +-- ---------------------------- +-- 会计凭证表 for accounting_voucher +-- ---------------------------- +DROP TABLE IF EXISTS `accounting_voucher`; +CREATE TABLE `accounting_voucher` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '制单人', + `creator` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建日期', + `company_id` bigint(20) NULL DEFAULT NULL COMMENT '业务实体id', + `company` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '业务实体', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新日期', + `dept_id` bigint(20) NULL DEFAULT NULL COMMENT '所属部门id', + `dept_name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属部门', + `voucher_time` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '凭证日期', + `voucher_num` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '凭证号', + `digest` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '摘要', + `audit` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '审核人', + `checker` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '核准人', + `handle` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '经办人', + `service_id` bigint(20) NULL DEFAULT NULL COMMENT '业务标识', + `service_explain` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '业务说明', + `type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '凭证类型', + `flow_id` bigint(20) NULL DEFAULT NULL COMMENT '流程号/文件号', + `source` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '文件来源', + `year` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '年度', + `period` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会计期间', + `borrow_status` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '借阅状态', + `record_time` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '归档时间', + `position` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '纸档位置', + `cherks` int(10) NULL DEFAULT NULL COMMENT '完整性', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `deleted` bit(1) NULL DEFAULT b'0' COMMENT '是否删除', + `updater` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者', + `record_id` bigint(20) NULL DEFAULT NULL COMMENT '归档id,一个归档id对应多个凭证号', + `file_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '0' COMMENT '归档状态', + `tenant_id` bigint(20) NOT NULL COMMENT '租户编号,一个集团/总公司对应一个租户', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段1', + `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段2', + `attr3` int(11) NULL DEFAULT NULL COMMENT '预留字段3', + `attr4` int(11) NULL DEFAULT NULL COMMENT '预留字段4', + `organization_id` bigint(20) NULL DEFAULT NULL COMMENT '立档单位ID', + `depot_id` bigint(20) NULL DEFAULT NULL COMMENT '库房ID', + `cabinet_id` bigint(20) NULL DEFAULT NULL COMMENT '档案柜ID', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = MyISAM AUTO_INCREMENT = 5 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '凭证表头' ROW_FORMAT = Dynamic; + + +-- ---------------------------- +-- 凭证详情表 accounting_voucher_details +-- ---------------------------- +DROP TABLE IF EXISTS `accounting_voucher_details`; +CREATE TABLE `accounting_voucher_details` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键', + `line_num` int(11) NULL DEFAULT NULL COMMENT '条目顺序号', + `create_by` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '制单人', + `creator` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建人', + `create_time` datetime(0) NULL DEFAULT NULL COMMENT '创建日期', + `update_time` datetime(0) NULL DEFAULT NULL COMMENT '更新日期', + `digest` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '摘要', + `voucher_type` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '凭证类型', + `subject_code` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '科目编码', + `subject_name` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '科目名称', + `assist_check` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '辅助核算', + `debit_money` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '借方金额', + `creditor_money` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '贷方金额', + `flow_id` bigint(20) NULL DEFAULT NULL COMMENT '相关单据关联号', + `voucher_id` bigint(20) NOT NULL COMMENT '凭证id,一个凭证对应多个凭证详情', + `voucher_num` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '凭证号', + `user_id` bigint(20) NULL DEFAULT NULL COMMENT '用户id', + `deleted` bit(1) NULL DEFAULT b'0' COMMENT '是否删除', + `updater` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '更新者', + `file_status` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '归档状态', + `tenant_id` bigint(20) NOT NULL COMMENT '租户编号,一个集团/总公司对应一个租户', + `remark` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '备注', + `attr1` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段1', + `attr2` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '预留字段2', + `attr3` int(11) NULL DEFAULT NULL COMMENT '预留字段3', + `attr4` int(11) NULL DEFAULT NULL COMMENT '预留字段4', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = MyISAM AUTO_INCREMENT = 2 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '凭证详情' ROW_FORMAT = Dynamic; + +-- 插入会计档案菜单 +INSERT INTO `lyr-one`.`system_menu`(`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 ('会计档案', '', 1, 1, 0, '/accounting', 'pay', NULL, NULL, 0, b'1', b'1', b'1', '1', '2023-09-06 16:14:44', '126', '2023-09-19 14:26:20', b'0'); +SET @menuId = LAST_INSERT_ID(); +INSERT INTO `lyr-one`.`system_menu`(`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 ('会计凭证管理', '', 2, 0, @menuId, 'voucher', '', 'accounting/voucher/index', 'Voucher', 0, b'1', b'1', b'1', '', '2023-09-19 14:33:30', '', '2023-09-19 14:33:30', b'0'); +SET @menuId2 = LAST_INSERT_ID(); +INSERT INTO `lyr-one`.`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 (NULL, '会计凭证查询', 'accounting:voucher:query', 3, 1, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-19 14:33:30', '', '2023-09-19 14:33:30', b'0'); +INSERT INTO `lyr-one`.`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 (NULL, '会计凭证创建', 'accounting:voucher:create', 3, 2, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-19 14:33:30', '', '2023-09-19 14:33:30', b'0'); +INSERT INTO `lyr-one`.`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 (NULL, '会计凭证更新', 'accounting:voucher:update', 3, 3, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-19 14:33:30', '', '2023-09-19 14:33:30', b'0'); +INSERT INTO `lyr-one`.`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 (NULL, '会计凭证删除', 'accounting:voucher:delete', 3, 4, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-19 14:33:30', '', '2023-09-19 14:33:30', b'0'); +INSERT INTO `lyr-one`.`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 (NULL, '会计凭证导出', 'accounting:voucher:export', 3, 5, @menuId2, '', '', '', NULL, 0, b'1', b'1', b'1', '', '2023-09-19 14:33:30', '', '2023-09-19 14:33:30', b'0'); diff --git a/yudao-module-accounting/pom.xml b/yudao-module-accounting/pom.xml new file mode 100644 index 00000000..1512cd1c --- /dev/null +++ b/yudao-module-accounting/pom.xml @@ -0,0 +1,43 @@ + + + + cn.iocoder.boot + yudao + ${revision} + + 4.0.0 + + yudao-module-accounting-api + yudao-module-accounting-biz + + yudao-module-accounting + pom + + ${project.artifactId} + + 会计档案模块 + + + + com.baidu.aip + java-sdk + 4.8.0 + + + + commons-io + commons-io + 2.6 + + + + com.alibaba + fastjson + 1.2.80 + + + + + diff --git a/yudao-module-accounting/yudao-module-accounting-api/pom.xml b/yudao-module-accounting/yudao-module-accounting-api/pom.xml new file mode 100644 index 00000000..1240c317 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-api/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + cn.iocoder.boot + yudao-module-accounting + ${revision} + + + yudao-module-accounting-api + jar + + ${project.artifactId} + + accounting 模块 API,暴露给其它模块调用 + + + + + cn.iocoder.boot + yudao-common + + + + + org.springframework.boot + spring-boot-starter-validation + true + + + + diff --git a/yudao-module-accounting/yudao-module-accounting-api/src/main/java/cn/iocoder/yudao/module/accounting/enums/AccountingStatusEnum.java b/yudao-module-accounting/yudao-module-accounting-api/src/main/java/cn/iocoder/yudao/module/accounting/enums/AccountingStatusEnum.java new file mode 100644 index 00000000..19d76943 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-api/src/main/java/cn/iocoder/yudao/module/accounting/enums/AccountingStatusEnum.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.accounting.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * 会计凭证枚举 + */ +@AllArgsConstructor +@Getter +public enum AccountingStatusEnum { + + INCOMPLETE("0", "不完整"), + COMPLETE("1", "完整"), + UNLOGFILE("0", "未归档"), + LOGFILE("1", "已归档"), + UNBORROWED("0", "未借阅"), + BORROWED("1", "已借阅"); + + + /** + * 类型 + */ + private final String value; + /** + * 类型名 + */ + private final String name; + + +} diff --git a/yudao-module-accounting/yudao-module-accounting-api/src/main/java/cn/iocoder/yudao/module/accounting/enums/ErrorCodeConstants.java b/yudao-module-accounting/yudao-module-accounting-api/src/main/java/cn/iocoder/yudao/module/accounting/enums/ErrorCodeConstants.java new file mode 100644 index 00000000..e6d3c045 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-api/src/main/java/cn/iocoder/yudao/module/accounting/enums/ErrorCodeConstants.java @@ -0,0 +1,7 @@ +package cn.iocoder.yudao.module.accounting.enums; + +import cn.iocoder.yudao.framework.common.exception.ErrorCode; +public interface ErrorCodeConstants { + ErrorCode VOUCHER_NOT_EXISTS = new ErrorCode(200100, "会计凭证不存在"); + ErrorCode VOUCHER_DETAILS_NOT_EXISTS = new ErrorCode(300100, "凭证详情不存在"); +} \ No newline at end of file diff --git a/yudao-module-accounting/yudao-module-accounting-biz/pom.xml b/yudao-module-accounting/yudao-module-accounting-biz/pom.xml new file mode 100644 index 00000000..43394b44 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/pom.xml @@ -0,0 +1,95 @@ + + + + cn.iocoder.boot + yudao-module-accounting + ${revision} + + 4.0.0 + yudao-module-accounting-biz + jar + + ${project.artifactId} + + accounting 模块,主要实现商品相关功能 + 例如:品牌、商品分类、spu、sku等功能。 + + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-tenant + + + cn.iocoder.boot + yudao-module-accounting-api + ${revision} + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-data-permission + + + + + cn.iocoder.boot + yudao-spring-boot-starter-biz-operatelog + + + + + + cn.iocoder.boot + yudao-spring-boot-starter-web + + + cn.iocoder.boot + yudao-spring-boot-starter-security + + + + + cn.iocoder.boot + yudao-spring-boot-starter-mybatis + + + + + cn.iocoder.boot + yudao-spring-boot-starter-test + + + + + cn.iocoder.boot + yudao-spring-boot-starter-excel + + + cn.iocoder.boot + yudao-module-bpm-api + 1.7.3-snapshot + compile + + + cn.iocoder.boot + yudao-module-system-biz + 1.7.3-snapshot + compile + + + cn.iocoder.boot + yudao-module-bpm-biz + 1.7.3-snapshot + compile + + + cn.iocoder.boot + yudao-module-infra-biz + 1.7.3-snapshot + compile + + + + diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/VoucherController.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/VoucherController.java new file mode 100644 index 00000000..1dd5870b --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/VoucherController.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucher; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO; +import cn.iocoder.yudao.module.accounting.convert.voucher.VoucherConvert; +import cn.iocoder.yudao.module.accounting.service.voucher.VoucherService; + +@Tag(name = "管理后台 - 会计凭证") +@RestController +@RequestMapping("/accounting/voucher") +@Validated +public class VoucherController { + + @Resource + private VoucherService voucherService; + + @PostMapping("/create") + @Operation(summary = "创建会计凭证") + @PreAuthorize("@ss.hasPermission('accounting:voucher:create')") + public CommonResult createVoucher(@Valid @RequestBody VoucherCreateReqVO createReqVO) { + return success(voucherService.createVoucher(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新会计凭证") + @PreAuthorize("@ss.hasPermission('accounting:voucher:update')") + public CommonResult updateVoucher(@Valid @RequestBody VoucherUpdateReqVO updateReqVO) { + voucherService.updateVoucher(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除会计凭证") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('accounting:voucher:delete')") + public CommonResult deleteVoucher(@RequestParam("id") Long id) { + voucherService.deleteVoucher(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得会计凭证") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('accounting:voucher:query')") + public CommonResult getVoucher(@RequestParam("id") Long id) { + VoucherDO voucher = voucherService.getVoucher(id); + return success(VoucherConvert.INSTANCE.convert(voucher)); + } + + @GetMapping("/list") + @Operation(summary = "获得会计凭证列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('accounting:voucher:query')") + public CommonResult> getVoucherList(@RequestParam("ids") Collection ids) { + List list = voucherService.getVoucherList(ids); + return success(VoucherConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得会计凭证分页") + @PreAuthorize("@ss.hasPermission('accounting:voucher:query')") + public CommonResult> getVoucherPage(@Valid VoucherPageReqVO pageVO) { + PageResult pageResult = voucherService.getVoucherPage(pageVO); + return success(VoucherConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出会计凭证 Excel") + @PreAuthorize("@ss.hasPermission('accounting:voucher:export')") + @OperateLog(type = EXPORT) + public void exportVoucherExcel(@Valid VoucherExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = voucherService.getVoucherList(exportReqVO); + // 导出 Excel + List datas = VoucherConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "会计凭证.xls", "数据", VoucherExcelVO.class, datas); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherBaseVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherBaseVO.java new file mode 100644 index 00000000..ababbc04 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherBaseVO.java @@ -0,0 +1,104 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; + +/** + * 会计凭证 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class VoucherBaseVO { + + @Schema(description = "制单人") + private String createBy; + + @Schema(description = "业务实体id", example = "3855") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "所属部门id", example = "2006") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "凭证日期") + private String voucherTime; + + @Schema(description = "凭证号") + private String voucherNum; + + @Schema(description = "摘要") + private String digest; + + @Schema(description = "审核人") + private String audit; + + @Schema(description = "核准人") + private String checker; + + @Schema(description = "经办人") + private String handle; + + @Schema(description = "业务标识", example = "5041") + private Long serviceId; + + @Schema(description = "业务说明") + private String serviceExplain; + + @Schema(description = "凭证类型", example = "1") + private String type; + + @Schema(description = "流程号/文件号", example = "32123") + private Long flowId; + + @Schema(description = "文件来源") + private String source; + + @Schema(description = "年度") + private String year; + + @Schema(description = "会计期间") + private String period; + + @Schema(description = "借阅状态", example = "1") + private String borrowStatus; + + @Schema(description = "归档时间") + private String recordTime; + + @Schema(description = "纸档位置") + private String position; + + @Schema(description = "完整性") + private Integer cherks; + + @Schema(description = "用户id", example = "10915") + private Long userId; + + @Schema(description = "归档id,一个归档id对应多个凭证号", example = "14667") + private Long recordId; + + @Schema(description = "归档状态", example = "2") + private String fileStatus; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "立档单位ID", example = "24728") + private Long organizationId; + + @Schema(description = "库房ID", example = "24050") + private Long depotId; + + @Schema(description = "档案柜ID", example = "1586") + private Long cabinetId; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherCreateReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherCreateReqVO.java new file mode 100644 index 00000000..7e0d26b3 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 会计凭证创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class VoucherCreateReqVO extends VoucherBaseVO { + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherExcelVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherExcelVO.java new file mode 100644 index 00000000..705524ed --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherExcelVO.java @@ -0,0 +1,112 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 会计凭证 Excel VO + * + * @author 芋道源码 + */ +@Data +public class VoucherExcelVO { + + @ExcelProperty("主键") + private Long id; + + @ExcelProperty("制单人") + private String createBy; + + @ExcelProperty("创建日期") + private LocalDateTime createTime; + + @ExcelProperty("业务实体id") + private Long companyId; + + @ExcelProperty("业务实体") + private String company; + + @ExcelProperty("所属部门id") + private Long deptId; + + @ExcelProperty("所属部门") + private String deptName; + + @ExcelProperty("凭证日期") + private String voucherTime; + + @ExcelProperty("凭证号") + private String voucherNum; + + @ExcelProperty("摘要") + private String digest; + + @ExcelProperty("审核人") + private String audit; + + @ExcelProperty("核准人") + private String checker; + + @ExcelProperty("经办人") + private String handle; + + @ExcelProperty("业务标识") + private Long serviceId; + + @ExcelProperty("业务说明") + private String serviceExplain; + + @ExcelProperty("凭证类型") + private String type; + + @ExcelProperty("流程号/文件号") + private Long flowId; + + @ExcelProperty("文件来源") + private String source; + + @ExcelProperty("年度") + private String year; + + @ExcelProperty("会计期间") + private String period; + + @ExcelProperty("借阅状态") + private String borrowStatus; + + @ExcelProperty("归档时间") + private String recordTime; + + @ExcelProperty("纸档位置") + private String position; + + @ExcelProperty("完整性") + private Integer cherks; + + @ExcelProperty("用户id") + private Long userId; + + @ExcelProperty("归档id,一个归档id对应多个凭证号") + private Long recordId; + + @ExcelProperty("归档状态") + private String fileStatus; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("立档单位ID") + private Long organizationId; + + @ExcelProperty("库房ID") + private Long depotId; + + @ExcelProperty("档案柜ID") + private Long cabinetId; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherExportReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherExportReqVO.java new file mode 100644 index 00000000..a04f6c14 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherExportReqVO.java @@ -0,0 +1,109 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucher.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,参数和 VoucherPageReqVO 是一致的") +@Data +public class VoucherExportReqVO { + + @Schema(description = "制单人") + private String createBy; + + @Schema(description = "创建日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "业务实体id", example = "3855") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "所属部门id", example = "2006") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "凭证日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] voucherTime; + + @Schema(description = "凭证号") + private String voucherNum; + + @Schema(description = "摘要") + private String digest; + + @Schema(description = "审核人") + private String audit; + + @Schema(description = "核准人") + private String checker; + + @Schema(description = "经办人") + private String handle; + + @Schema(description = "业务标识", example = "5041") + private Long serviceId; + + @Schema(description = "业务说明") + private String serviceExplain; + + @Schema(description = "凭证类型", example = "1") + private String type; + + @Schema(description = "流程号/文件号", example = "32123") + private Long flowId; + + @Schema(description = "文件来源") + private String source; + + @Schema(description = "年度") + private String year; + + @Schema(description = "会计期间") + private String period; + + @Schema(description = "借阅状态", example = "1") + private String borrowStatus; + + @Schema(description = "归档时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] recordTime; + + @Schema(description = "纸档位置") + private String position; + + @Schema(description = "完整性") + private Integer cherks; + + @Schema(description = "用户id", example = "10915") + private Long userId; + + @Schema(description = "归档id,一个归档id对应多个凭证号", example = "14667") + private Long recordId; + + @Schema(description = "归档状态", example = "2") + private String fileStatus; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "立档单位ID", example = "24728") + private Long organizationId; + + @Schema(description = "库房ID", example = "24050") + private Long depotId; + + @Schema(description = "档案柜ID", example = "1586") + private Long cabinetId; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherPageReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherPageReqVO.java new file mode 100644 index 00000000..4671f2a4 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherPageReqVO.java @@ -0,0 +1,111 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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; + +@Schema(description = "管理后台 - 会计凭证分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class VoucherPageReqVO extends PageParam { + + @Schema(description = "制单人") + private String createBy; + + @Schema(description = "创建日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "业务实体id", example = "3855") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "所属部门id", example = "2006") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + + @Schema(description = "凭证日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] voucherTime; + + @Schema(description = "凭证号") + private String voucherNum; + + @Schema(description = "摘要") + private String digest; + + @Schema(description = "审核人") + private String audit; + + @Schema(description = "核准人") + private String checker; + + @Schema(description = "经办人") + private String handle; + + @Schema(description = "业务标识", example = "5041") + private Long serviceId; + + @Schema(description = "业务说明") + private String serviceExplain; + + @Schema(description = "凭证类型", example = "1") + private String type; + + @Schema(description = "流程号/文件号", example = "32123") + private Long flowId; + + @Schema(description = "文件来源") + private String source; + + @Schema(description = "年度") + private String year; + + @Schema(description = "会计期间") + private String period; + + @Schema(description = "借阅状态", example = "1") + private String borrowStatus; + + @Schema(description = "归档时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] recordTime; + + @Schema(description = "纸档位置") + private String position; + + @Schema(description = "完整性") + private Integer cherks; + + @Schema(description = "用户id", example = "10915") + private Long userId; + + @Schema(description = "归档id,一个归档id对应多个凭证号", example = "14667") + private Long recordId; + + @Schema(description = "归档状态", example = "2") + private String fileStatus; + + @Schema(description = "备注", example = "你猜") + private String remark; + + @Schema(description = "立档单位ID", example = "24728") + private Long organizationId; + + @Schema(description = "库房ID", example = "24050") + private Long depotId; + + @Schema(description = "档案柜ID", example = "1586") + private Long cabinetId; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherRespVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherRespVO.java new file mode 100644 index 00000000..516844c2 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 会计凭证 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class VoucherRespVO extends VoucherBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "6174") + private Long id; + + @Schema(description = "创建日期") + private LocalDateTime createTime; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherUpdateReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherUpdateReqVO.java new file mode 100644 index 00000000..689d6e19 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucher/vo/VoucherUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 会计凭证更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class VoucherUpdateReqVO extends VoucherBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "6174") + @NotNull(message = "主键不能为空") + private Long id; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/VoucherDetailsController.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/VoucherDetailsController.java new file mode 100644 index 00000000..66d77465 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/VoucherDetailsController.java @@ -0,0 +1,102 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails; + +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +import cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO; +import cn.iocoder.yudao.module.accounting.convert.voucherdetails.VoucherDetailsConvert; +import cn.iocoder.yudao.module.accounting.service.voucherdetails.VoucherDetailsService; + +@Tag(name = "管理后台 - 凭证详情") +@RestController +@RequestMapping("/accounting/voucher-details") +@Validated +public class VoucherDetailsController { + + @Resource + private VoucherDetailsService voucherDetailsService; + + @PostMapping("/create") + @Operation(summary = "创建凭证详情") + @PreAuthorize("@ss.hasPermission('accounting:voucher-details:create')") + public CommonResult createVoucherDetails(@Valid @RequestBody VoucherDetailsCreateReqVO createReqVO) { + return success(voucherDetailsService.createVoucherDetails(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新凭证详情") + @PreAuthorize("@ss.hasPermission('accounting:voucher-details:update')") + public CommonResult updateVoucherDetails(@Valid @RequestBody VoucherDetailsUpdateReqVO updateReqVO) { + voucherDetailsService.updateVoucherDetails(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除凭证详情") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('accounting:voucher-details:delete')") + public CommonResult deleteVoucherDetails(@RequestParam("id") Long id) { + voucherDetailsService.deleteVoucherDetails(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得凭证详情") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('accounting:voucher-details:query')") + public CommonResult getVoucherDetails(@RequestParam("id") Long id) { + VoucherDetailsDO voucherDetails = voucherDetailsService.getVoucherDetails(id); + return success(VoucherDetailsConvert.INSTANCE.convert(voucherDetails)); + } + + @GetMapping("/list") + @Operation(summary = "获得凭证详情列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('accounting:voucher-details:query')") + public CommonResult> getVoucherDetailsList(@RequestParam("ids") Collection ids) { + List list = voucherDetailsService.getVoucherDetailsList(ids); + return success(VoucherDetailsConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得凭证详情分页") + @PreAuthorize("@ss.hasPermission('accounting:voucher-details:query')") + public CommonResult> getVoucherDetailsPage(@Valid VoucherDetailsPageReqVO pageVO) { + PageResult pageResult = voucherDetailsService.getVoucherDetailsPage(pageVO); + return success(VoucherDetailsConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出凭证详情 Excel") + @PreAuthorize("@ss.hasPermission('accounting:voucher-details:export')") + @OperateLog(type = EXPORT) + public void exportVoucherDetailsExcel(@Valid VoucherDetailsExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = voucherDetailsService.getVoucherDetailsList(exportReqVO); + // 导出 Excel + List datas = VoucherDetailsConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "凭证详情.xls", "数据", VoucherDetailsExcelVO.class, datas); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsBaseVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsBaseVO.java new file mode 100644 index 00000000..296c6212 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsBaseVO.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; + +/** + * 凭证详情 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class VoucherDetailsBaseVO { + + @Schema(description = "条目顺序号") + private Integer lineNum; + + @Schema(description = "制单人") + private String createBy; + + @Schema(description = "摘要") + private String digest; + + @Schema(description = "凭证类型", example = "1") + private String voucherType; + + @Schema(description = "科目编码") + private String subjectCode; + + @Schema(description = "科目名称", example = "李四") + private String subjectName; + + @Schema(description = "辅助核算") + private String assistCheck; + + @Schema(description = "借方金额") + private String debitMoney; + + @Schema(description = "贷方金额") + private String creditorMoney; + + @Schema(description = "相关单据关联号", example = "17322") + private Long flowId; + + @Schema(description = "凭证id,一个凭证对应多个凭证详情", requiredMode = Schema.RequiredMode.REQUIRED, example = "31093") + @NotNull(message = "凭证id,一个凭证对应多个凭证详情不能为空") + private Long voucherId; + + @Schema(description = "凭证号", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "凭证号不能为空") + private String voucherNum; + + @Schema(description = "用户id", example = "11976") + private Long userId; + + @Schema(description = "归档状态", example = "2") + private String fileStatus; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsCreateReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsCreateReqVO.java new file mode 100644 index 00000000..6c7297cf --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 凭证详情创建 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class VoucherDetailsCreateReqVO extends VoucherDetailsBaseVO { + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsExcelVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsExcelVO.java new file mode 100644 index 00000000..80c74c23 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsExcelVO.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +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 芋道源码 + */ +@Data +public class VoucherDetailsExcelVO { + + @ExcelProperty("主键") + private Long id; + + @ExcelProperty("条目顺序号") + private Integer lineNum; + + @ExcelProperty("制单人") + private String createBy; + + @ExcelProperty("创建日期") + private LocalDateTime createTime; + + @ExcelProperty("摘要") + private String digest; + + @ExcelProperty("凭证类型") + private String voucherType; + + @ExcelProperty("科目编码") + private String subjectCode; + + @ExcelProperty("科目名称") + private String subjectName; + + @ExcelProperty("辅助核算") + private String assistCheck; + + @ExcelProperty("借方金额") + private String debitMoney; + + @ExcelProperty("贷方金额") + private String creditorMoney; + + @ExcelProperty("相关单据关联号") + private Long flowId; + + @ExcelProperty("凭证id,一个凭证对应多个凭证详情") + private Long voucherId; + + @ExcelProperty("凭证号") + private String voucherNum; + + @ExcelProperty("用户id") + private Long userId; + + @ExcelProperty(value = "归档状态", converter = DictConvert.class) + @DictFormat("archives_file_status") // TODO 代码优化:建议设置到对应的 XXXDictTypeConstants 枚举类中 + private String fileStatus; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsExportReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsExportReqVO.java new file mode 100644 index 00000000..d73a1a3c --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsExportReqVO.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.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,参数和 VoucherDetailsPageReqVO 是一致的") +@Data +public class VoucherDetailsExportReqVO { + + @Schema(description = "条目顺序号") + private Integer lineNum; + + @Schema(description = "制单人") + private String createBy; + + @Schema(description = "创建日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "摘要") + private String digest; + + @Schema(description = "凭证类型", example = "1") + private String voucherType; + + @Schema(description = "科目编码") + private String subjectCode; + + @Schema(description = "科目名称", example = "李四") + private String subjectName; + + @Schema(description = "辅助核算") + private String assistCheck; + + @Schema(description = "借方金额") + private String debitMoney; + + @Schema(description = "贷方金额") + private String creditorMoney; + + @Schema(description = "相关单据关联号", example = "17322") + private Long flowId; + + @Schema(description = "凭证id,一个凭证对应多个凭证详情", example = "31093") + private Long voucherId; + + @Schema(description = "凭证号") + private String voucherNum; + + @Schema(description = "用户id", example = "11976") + private Long userId; + + @Schema(description = "归档状态", example = "2") + private String fileStatus; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsPageReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsPageReqVO.java new file mode 100644 index 00000000..579a575a --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsPageReqVO.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +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; + +@Schema(description = "管理后台 - 凭证详情分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class VoucherDetailsPageReqVO extends PageParam { + + @Schema(description = "条目顺序号") + private Integer lineNum; + + @Schema(description = "制单人") + private String createBy; + + @Schema(description = "创建日期") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "摘要") + private String digest; + + @Schema(description = "凭证类型", example = "1") + private String voucherType; + + @Schema(description = "科目编码") + private String subjectCode; + + @Schema(description = "科目名称", example = "李四") + private String subjectName; + + @Schema(description = "辅助核算") + private String assistCheck; + + @Schema(description = "借方金额") + private String debitMoney; + + @Schema(description = "贷方金额") + private String creditorMoney; + + @Schema(description = "相关单据关联号", example = "17322") + private Long flowId; + + @Schema(description = "凭证id,一个凭证对应多个凭证详情", example = "31093") + private Long voucherId; + + @Schema(description = "凭证号") + private String voucherNum; + + @Schema(description = "用户id", example = "11976") + private Long userId; + + @Schema(description = "归档状态", example = "2") + private String fileStatus; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsRespVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsRespVO.java new file mode 100644 index 00000000..e50821d0 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 凭证详情 Response VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class VoucherDetailsRespVO extends VoucherDetailsBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31664") + private Long id; + + @Schema(description = "创建日期") + private LocalDateTime createTime; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsUpdateReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsUpdateReqVO.java new file mode 100644 index 00000000..bbb68953 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/voucherdetails/vo/VoucherDetailsUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 凭证详情更新 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class VoucherDetailsUpdateReqVO extends VoucherDetailsBaseVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "31664") + @NotNull(message = "主键不能为空") + private Long id; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/voucher/VoucherConvert.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/voucher/VoucherConvert.java new file mode 100644 index 00000000..d07a09c3 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/voucher/VoucherConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.accounting.convert.voucher; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO; + +/** + * 会计凭证 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface VoucherConvert { + + VoucherConvert INSTANCE = Mappers.getMapper(VoucherConvert.class); + + VoucherDO convert(VoucherCreateReqVO bean); + + VoucherDO convert(VoucherUpdateReqVO bean); + + VoucherRespVO convert(VoucherDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/voucherdetails/VoucherDetailsConvert.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/voucherdetails/VoucherDetailsConvert.java new file mode 100644 index 00000000..cd31c9d1 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/voucherdetails/VoucherDetailsConvert.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.accounting.convert.voucherdetails; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; +import cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO; + +/** + * 凭证详情 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface VoucherDetailsConvert { + + VoucherDetailsConvert INSTANCE = Mappers.getMapper(VoucherDetailsConvert.class); + + VoucherDetailsDO convert(VoucherDetailsCreateReqVO bean); + + VoucherDetailsDO convert(VoucherDetailsUpdateReqVO bean); + + VoucherDetailsRespVO convert(VoucherDetailsDO bean); + + List convertList(List list); + + PageResult convertPage(PageResult page); + + List convertList02(List list); + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/voucher/VoucherDO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/voucher/VoucherDO.java new file mode 100644 index 00000000..d03fda37 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/voucher/VoucherDO.java @@ -0,0 +1,163 @@ +package cn.iocoder.yudao.module.accounting.dal.dataobject.voucher; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 会计凭证 DO + * + * @author 芋道源码 + */ +@TableName("accounting_voucher") +@KeySequence("accounting_voucher_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VoucherDO extends BaseDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 制单人 + */ + private String createBy; + /** + * 业务实体id + */ + private Long companyId; + /** + * 业务实体 + */ + private String company; + /** + * 所属部门id + */ + private Long deptId; + /** + * 所属部门 + */ + private String deptName; + /** + * 凭证日期 + */ + private String voucherTime; + /** + * 凭证号 + */ + private String voucherNum; + /** + * 摘要 + */ + private String digest; + /** + * 审核人 + */ + private String audit; + /** + * 核准人 + */ + private String checker; + /** + * 经办人 + */ + private String handle; + /** + * 业务标识 + */ + private Long serviceId; + /** + * 业务说明 + */ + private String serviceExplain; + /** + * 凭证类型 + */ + private String type; + /** + * 流程号/文件号 + */ + private Long flowId; + /** + * 文件来源 + */ + private String source; + /** + * 年度 + */ + private String year; + /** + * 会计期间 + */ + private String period; + /** + * 借阅状态 + */ + private String borrowStatus; + /** + * 归档时间 + */ + private String recordTime; + /** + * 纸档位置 + */ + private String position; + /** + * 完整性 + */ + private Integer cherks; + /** + * 用户id + */ + private Long userId; + /** + * 归档id,一个归档id对应多个凭证号 + */ + private Long recordId; + /** + * 归档状态 + */ + private String fileStatus; + /** + * 备注 + */ + private String remark; + /** + * 预留字段1 + */ + private String attr1; + /** + * 预留字段2 + */ + private String attr2; + /** + * 预留字段3 + */ + private Integer attr3; + /** + * 预留字段4 + */ + private Integer attr4; + /** + * 立档单位ID + */ + private Long organizationId; + /** + * 库房ID + */ + private Long depotId; + /** + * 档案柜ID + */ + private Long cabinetId; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/voucherdetails/VoucherDetailsDO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/voucherdetails/VoucherDetailsDO.java new file mode 100644 index 00000000..95090626 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/voucherdetails/VoucherDetailsDO.java @@ -0,0 +1,109 @@ +package cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 凭证详情 DO + * + * @author 芋道源码 + */ +@TableName("accounting_voucher_details") +@KeySequence("accounting_voucher_details_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class VoucherDetailsDO extends BaseDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 条目顺序号 + */ + private Integer lineNum; + /** + * 制单人 + */ + private String createBy; + /** + * 摘要 + */ + private String digest; + /** + * 凭证类型 + */ + private String voucherType; + /** + * 科目编码 + */ + private String subjectCode; + /** + * 科目名称 + */ + private String subjectName; + /** + * 辅助核算 + */ + private String assistCheck; + /** + * 借方金额 + */ + private String debitMoney; + /** + * 贷方金额 + */ + private String creditorMoney; + /** + * 相关单据关联号 + */ + private Long flowId; + /** + * 凭证id,一个凭证对应多个凭证详情 + */ + private Long voucherId; + /** + * 凭证号 + */ + private String voucherNum; + /** + * 用户id + */ + private Long userId; + /** + * 归档状态 + * + * 枚举 {@link TODO archives_file_status 对应的类} + */ + private String fileStatus; + /** + * 备注 + */ + private String remark; + /** + * 预留字段1 + */ + private String attr1; + /** + * 预留字段2 + */ + private String attr2; + /** + * 预留字段3 + */ + private Integer attr3; + /** + * 预留字段4 + */ + private Integer attr4; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/voucher/VoucherMapper.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/voucher/VoucherMapper.java new file mode 100644 index 00000000..e568c656 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/voucher/VoucherMapper.java @@ -0,0 +1,90 @@ +package cn.iocoder.yudao.module.accounting.dal.mysql.voucher; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.*; + +/** + * 会计凭证 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface VoucherMapper extends BaseMapperX { + + default PageResult selectPage(VoucherPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(VoucherDO::getCreateBy, reqVO.getCreateBy()) + .betweenIfPresent(VoucherDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(VoucherDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(VoucherDO::getCompany, reqVO.getCompany()) + .eqIfPresent(VoucherDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(VoucherDO::getDeptName, reqVO.getDeptName()) + .betweenIfPresent(VoucherDO::getVoucherTime, reqVO.getVoucherTime()) + .eqIfPresent(VoucherDO::getVoucherNum, reqVO.getVoucherNum()) + .eqIfPresent(VoucherDO::getDigest, reqVO.getDigest()) + .eqIfPresent(VoucherDO::getAudit, reqVO.getAudit()) + .eqIfPresent(VoucherDO::getChecker, reqVO.getChecker()) + .eqIfPresent(VoucherDO::getHandle, reqVO.getHandle()) + .eqIfPresent(VoucherDO::getServiceId, reqVO.getServiceId()) + .eqIfPresent(VoucherDO::getServiceExplain, reqVO.getServiceExplain()) + .eqIfPresent(VoucherDO::getType, reqVO.getType()) + .eqIfPresent(VoucherDO::getFlowId, reqVO.getFlowId()) + .eqIfPresent(VoucherDO::getSource, reqVO.getSource()) + .eqIfPresent(VoucherDO::getYear, reqVO.getYear()) + .eqIfPresent(VoucherDO::getPeriod, reqVO.getPeriod()) + .eqIfPresent(VoucherDO::getBorrowStatus, reqVO.getBorrowStatus()) + .betweenIfPresent(VoucherDO::getRecordTime, reqVO.getRecordTime()) + .eqIfPresent(VoucherDO::getPosition, reqVO.getPosition()) + .eqIfPresent(VoucherDO::getCherks, reqVO.getCherks()) + .eqIfPresent(VoucherDO::getUserId, reqVO.getUserId()) + .eqIfPresent(VoucherDO::getRecordId, reqVO.getRecordId()) + .eqIfPresent(VoucherDO::getFileStatus, reqVO.getFileStatus()) + .eqIfPresent(VoucherDO::getRemark, reqVO.getRemark()) + .eqIfPresent(VoucherDO::getOrganizationId, reqVO.getOrganizationId()) + .eqIfPresent(VoucherDO::getDepotId, reqVO.getDepotId()) + .eqIfPresent(VoucherDO::getCabinetId, reqVO.getCabinetId()) + .orderByDesc(VoucherDO::getId)); + } + + default List selectList(VoucherExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(VoucherDO::getCreateBy, reqVO.getCreateBy()) + .betweenIfPresent(VoucherDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(VoucherDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(VoucherDO::getCompany, reqVO.getCompany()) + .eqIfPresent(VoucherDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(VoucherDO::getDeptName, reqVO.getDeptName()) + .betweenIfPresent(VoucherDO::getVoucherTime, reqVO.getVoucherTime()) + .eqIfPresent(VoucherDO::getVoucherNum, reqVO.getVoucherNum()) + .eqIfPresent(VoucherDO::getDigest, reqVO.getDigest()) + .eqIfPresent(VoucherDO::getAudit, reqVO.getAudit()) + .eqIfPresent(VoucherDO::getChecker, reqVO.getChecker()) + .eqIfPresent(VoucherDO::getHandle, reqVO.getHandle()) + .eqIfPresent(VoucherDO::getServiceId, reqVO.getServiceId()) + .eqIfPresent(VoucherDO::getServiceExplain, reqVO.getServiceExplain()) + .eqIfPresent(VoucherDO::getType, reqVO.getType()) + .eqIfPresent(VoucherDO::getFlowId, reqVO.getFlowId()) + .eqIfPresent(VoucherDO::getSource, reqVO.getSource()) + .eqIfPresent(VoucherDO::getYear, reqVO.getYear()) + .eqIfPresent(VoucherDO::getPeriod, reqVO.getPeriod()) + .eqIfPresent(VoucherDO::getBorrowStatus, reqVO.getBorrowStatus()) + .betweenIfPresent(VoucherDO::getRecordTime, reqVO.getRecordTime()) + .eqIfPresent(VoucherDO::getPosition, reqVO.getPosition()) + .eqIfPresent(VoucherDO::getCherks, reqVO.getCherks()) + .eqIfPresent(VoucherDO::getUserId, reqVO.getUserId()) + .eqIfPresent(VoucherDO::getRecordId, reqVO.getRecordId()) + .eqIfPresent(VoucherDO::getFileStatus, reqVO.getFileStatus()) + .eqIfPresent(VoucherDO::getRemark, reqVO.getRemark()) + .eqIfPresent(VoucherDO::getOrganizationId, reqVO.getOrganizationId()) + .eqIfPresent(VoucherDO::getDepotId, reqVO.getDepotId()) + .eqIfPresent(VoucherDO::getCabinetId, reqVO.getCabinetId()) + .orderByDesc(VoucherDO::getId)); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/voucherdetails/VoucherDetailsMapper.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/voucherdetails/VoucherDetailsMapper.java new file mode 100644 index 00000000..14684d47 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/voucherdetails/VoucherDetailsMapper.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.accounting.dal.mysql.voucherdetails; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo.*; + +/** + * 凭证详情 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface VoucherDetailsMapper extends BaseMapperX { + + default PageResult selectPage(VoucherDetailsPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(VoucherDetailsDO::getLineNum, reqVO.getLineNum()) + .eqIfPresent(VoucherDetailsDO::getCreateBy, reqVO.getCreateBy()) + .betweenIfPresent(VoucherDetailsDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(VoucherDetailsDO::getDigest, reqVO.getDigest()) + .eqIfPresent(VoucherDetailsDO::getVoucherType, reqVO.getVoucherType()) + .eqIfPresent(VoucherDetailsDO::getSubjectCode, reqVO.getSubjectCode()) + .likeIfPresent(VoucherDetailsDO::getSubjectName, reqVO.getSubjectName()) + .eqIfPresent(VoucherDetailsDO::getAssistCheck, reqVO.getAssistCheck()) + .eqIfPresent(VoucherDetailsDO::getDebitMoney, reqVO.getDebitMoney()) + .eqIfPresent(VoucherDetailsDO::getCreditorMoney, reqVO.getCreditorMoney()) + .eqIfPresent(VoucherDetailsDO::getFlowId, reqVO.getFlowId()) + .eqIfPresent(VoucherDetailsDO::getVoucherId, reqVO.getVoucherId()) + .eqIfPresent(VoucherDetailsDO::getVoucherNum, reqVO.getVoucherNum()) + .eqIfPresent(VoucherDetailsDO::getUserId, reqVO.getUserId()) + .eqIfPresent(VoucherDetailsDO::getFileStatus, reqVO.getFileStatus()) + .orderByDesc(VoucherDetailsDO::getId)); + } + + default List selectList(VoucherDetailsExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(VoucherDetailsDO::getLineNum, reqVO.getLineNum()) + .eqIfPresent(VoucherDetailsDO::getCreateBy, reqVO.getCreateBy()) + .betweenIfPresent(VoucherDetailsDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(VoucherDetailsDO::getDigest, reqVO.getDigest()) + .eqIfPresent(VoucherDetailsDO::getVoucherType, reqVO.getVoucherType()) + .eqIfPresent(VoucherDetailsDO::getSubjectCode, reqVO.getSubjectCode()) + .likeIfPresent(VoucherDetailsDO::getSubjectName, reqVO.getSubjectName()) + .eqIfPresent(VoucherDetailsDO::getAssistCheck, reqVO.getAssistCheck()) + .eqIfPresent(VoucherDetailsDO::getDebitMoney, reqVO.getDebitMoney()) + .eqIfPresent(VoucherDetailsDO::getCreditorMoney, reqVO.getCreditorMoney()) + .eqIfPresent(VoucherDetailsDO::getFlowId, reqVO.getFlowId()) + .eqIfPresent(VoucherDetailsDO::getVoucherId, reqVO.getVoucherId()) + .eqIfPresent(VoucherDetailsDO::getVoucherNum, reqVO.getVoucherNum()) + .eqIfPresent(VoucherDetailsDO::getUserId, reqVO.getUserId()) + .eqIfPresent(VoucherDetailsDO::getFileStatus, reqVO.getFileStatus()) + .orderByDesc(VoucherDetailsDO::getId)); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherService.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherService.java new file mode 100644 index 00000000..9c441896 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.accounting.service.voucher; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 会计凭证 Service 接口 + * + * @author 芋道源码 + */ +public interface VoucherService { + + /** + * 创建会计凭证 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createVoucher(@Valid VoucherCreateReqVO createReqVO); + + /** + * 更新会计凭证 + * + * @param updateReqVO 更新信息 + */ + void updateVoucher(@Valid VoucherUpdateReqVO updateReqVO); + + /** + * 删除会计凭证 + * + * @param id 编号 + */ + void deleteVoucher(Long id); + + /** + * 获得会计凭证 + * + * @param id 编号 + * @return 会计凭证 + */ + VoucherDO getVoucher(Long id); + + /** + * 获得会计凭证列表 + * + * @param ids 编号 + * @return 会计凭证列表 + */ + List getVoucherList(Collection ids); + + /** + * 获得会计凭证分页 + * + * @param pageReqVO 分页查询 + * @return 会计凭证分页 + */ + PageResult getVoucherPage(VoucherPageReqVO pageReqVO); + + /** + * 获得会计凭证列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 会计凭证列表 + */ + List getVoucherList(VoucherExportReqVO exportReqVO); + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImpl.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImpl.java new file mode 100644 index 00000000..62c09991 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImpl.java @@ -0,0 +1,82 @@ +package cn.iocoder.yudao.module.accounting.service.voucher; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.accounting.convert.voucher.VoucherConvert; +import cn.iocoder.yudao.module.accounting.dal.mysql.voucher.VoucherMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.accounting.enums.ErrorCodeConstants.*; + +/** + * 会计凭证 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class VoucherServiceImpl implements VoucherService { + + @Resource + private VoucherMapper voucherMapper; + + @Override + public Long createVoucher(VoucherCreateReqVO createReqVO) { + // 插入 + VoucherDO voucher = VoucherConvert.INSTANCE.convert(createReqVO); + voucherMapper.insert(voucher); + // 返回 + return voucher.getId(); + } + + @Override + public void updateVoucher(VoucherUpdateReqVO updateReqVO) { + // 校验存在 + validateVoucherExists(updateReqVO.getId()); + // 更新 + VoucherDO updateObj = VoucherConvert.INSTANCE.convert(updateReqVO); + voucherMapper.updateById(updateObj); + } + + @Override + public void deleteVoucher(Long id) { + // 校验存在 + validateVoucherExists(id); + // 删除 + voucherMapper.deleteById(id); + } + + private void validateVoucherExists(Long id) { + if (voucherMapper.selectById(id) == null) { + throw exception(VOUCHER_NOT_EXISTS); + } + } + + @Override + public VoucherDO getVoucher(Long id) { + return voucherMapper.selectById(id); + } + + @Override + public List getVoucherList(Collection ids) { + return voucherMapper.selectBatchIds(ids); + } + + @Override + public PageResult getVoucherPage(VoucherPageReqVO pageReqVO) { + return voucherMapper.selectPage(pageReqVO); + } + + @Override + public List getVoucherList(VoucherExportReqVO exportReqVO) { + return voucherMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucherdetails/VoucherDetailsService.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucherdetails/VoucherDetailsService.java new file mode 100644 index 00000000..f39f258e --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucherdetails/VoucherDetailsService.java @@ -0,0 +1,70 @@ +package cn.iocoder.yudao.module.accounting.service.voucherdetails; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +/** + * 凭证详情 Service 接口 + * + * @author 芋道源码 + */ +public interface VoucherDetailsService { + + /** + * 创建凭证详情 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createVoucherDetails(@Valid VoucherDetailsCreateReqVO createReqVO); + + /** + * 更新凭证详情 + * + * @param updateReqVO 更新信息 + */ + void updateVoucherDetails(@Valid VoucherDetailsUpdateReqVO updateReqVO); + + /** + * 删除凭证详情 + * + * @param id 编号 + */ + void deleteVoucherDetails(Long id); + + /** + * 获得凭证详情 + * + * @param id 编号 + * @return 凭证详情 + */ + VoucherDetailsDO getVoucherDetails(Long id); + + /** + * 获得凭证详情列表 + * + * @param ids 编号 + * @return 凭证详情列表 + */ + List getVoucherDetailsList(Collection ids); + + /** + * 获得凭证详情分页 + * + * @param pageReqVO 分页查询 + * @return 凭证详情分页 + */ + PageResult getVoucherDetailsPage(VoucherDetailsPageReqVO pageReqVO); + + /** + * 获得凭证详情列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 凭证详情列表 + */ + List getVoucherDetailsList(VoucherDetailsExportReqVO exportReqVO); + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucherdetails/VoucherDetailsServiceImpl.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucherdetails/VoucherDetailsServiceImpl.java new file mode 100644 index 00000000..36a1fe5f --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/voucherdetails/VoucherDetailsServiceImpl.java @@ -0,0 +1,82 @@ +package cn.iocoder.yudao.module.accounting.service.voucherdetails; + +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; + +import java.util.*; +import cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import cn.iocoder.yudao.module.accounting.convert.voucherdetails.VoucherDetailsConvert; +import cn.iocoder.yudao.module.accounting.dal.mysql.voucherdetails.VoucherDetailsMapper; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.accounting.enums.ErrorCodeConstants.*; + +/** + * 凭证详情 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class VoucherDetailsServiceImpl implements VoucherDetailsService { + + @Resource + private VoucherDetailsMapper voucherDetailsMapper; + + @Override + public Long createVoucherDetails(VoucherDetailsCreateReqVO createReqVO) { + // 插入 + VoucherDetailsDO voucherDetails = VoucherDetailsConvert.INSTANCE.convert(createReqVO); + voucherDetailsMapper.insert(voucherDetails); + // 返回 + return voucherDetails.getId(); + } + + @Override + public void updateVoucherDetails(VoucherDetailsUpdateReqVO updateReqVO) { + // 校验存在 + validateVoucherDetailsExists(updateReqVO.getId()); + // 更新 + VoucherDetailsDO updateObj = VoucherDetailsConvert.INSTANCE.convert(updateReqVO); + voucherDetailsMapper.updateById(updateObj); + } + + @Override + public void deleteVoucherDetails(Long id) { + // 校验存在 + validateVoucherDetailsExists(id); + // 删除 + voucherDetailsMapper.deleteById(id); + } + + private void validateVoucherDetailsExists(Long id) { + if (voucherDetailsMapper.selectById(id) == null) { + throw exception(VOUCHER_DETAILS_NOT_EXISTS); + } + } + + @Override + public VoucherDetailsDO getVoucherDetails(Long id) { + return voucherDetailsMapper.selectById(id); + } + + @Override + public List getVoucherDetailsList(Collection ids) { + return voucherDetailsMapper.selectBatchIds(ids); + } + + @Override + public PageResult getVoucherDetailsPage(VoucherDetailsPageReqVO pageReqVO) { + return voucherDetailsMapper.selectPage(pageReqVO); + } + + @Override + public List getVoucherDetailsList(VoucherDetailsExportReqVO exportReqVO) { + return voucherDetailsMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/voucher/VoucherMapper.xml b/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/voucher/VoucherMapper.xml new file mode 100644 index 00000000..d2ed7c9c --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/voucher/VoucherMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/voucherdetails/VoucherDetailsMapper.xml b/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/voucherdetails/VoucherDetailsMapper.xml new file mode 100644 index 00000000..738a4f88 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/voucherdetails/VoucherDetailsMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/test/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImplTest.java b/yudao-module-accounting/yudao-module-accounting-biz/src/test/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImplTest.java new file mode 100644 index 00000000..adbba6e6 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/test/java/cn/iocoder/yudao/module/accounting/service/voucher/VoucherServiceImplTest.java @@ -0,0 +1,383 @@ +package cn.iocoder.yudao.module.accounting.service.voucher; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.accounting.controller.admin.voucher.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucher.VoucherDO; +import cn.iocoder.yudao.module.accounting.dal.mysql.voucher.VoucherMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.accounting.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link VoucherServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(VoucherServiceImpl.class) +public class VoucherServiceImplTest extends BaseDbUnitTest { + + @Resource + private VoucherServiceImpl voucherService; + + @Resource + private VoucherMapper voucherMapper; + + @Test + public void testCreateVoucher_success() { + // 准备参数 + VoucherCreateReqVO reqVO = randomPojo(VoucherCreateReqVO.class); + + // 调用 + Long voucherId = voucherService.createVoucher(reqVO); + // 断言 + assertNotNull(voucherId); + // 校验记录的属性是否正确 + VoucherDO voucher = voucherMapper.selectById(voucherId); + assertPojoEquals(reqVO, voucher); + } + + @Test + public void testUpdateVoucher_success() { + // mock 数据 + VoucherDO dbVoucher = randomPojo(VoucherDO.class); + voucherMapper.insert(dbVoucher);// @Sql: 先插入出一条存在的数据 + // 准备参数 + VoucherUpdateReqVO reqVO = randomPojo(VoucherUpdateReqVO.class, o -> { + o.setId(dbVoucher.getId()); // 设置更新的 ID + }); + + // 调用 + voucherService.updateVoucher(reqVO); + // 校验是否更新正确 + VoucherDO voucher = voucherMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, voucher); + } + + @Test + public void testUpdateVoucher_notExists() { + // 准备参数 + VoucherUpdateReqVO reqVO = randomPojo(VoucherUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> voucherService.updateVoucher(reqVO), VOUCHER_NOT_EXISTS); + } + + @Test + public void testDeleteVoucher_success() { + // mock 数据 + VoucherDO dbVoucher = randomPojo(VoucherDO.class); + voucherMapper.insert(dbVoucher);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbVoucher.getId(); + + // 调用 + voucherService.deleteVoucher(id); + // 校验数据不存在了 + assertNull(voucherMapper.selectById(id)); + } + + @Test + public void testDeleteVoucher_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> voucherService.deleteVoucher(id), VOUCHER_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetVoucherPage() { + // mock 数据 + VoucherDO dbVoucher = randomPojo(VoucherDO.class, o -> { // 等会查询到 + o.setCreateBy(null); + o.setCreateTime(null); + o.setCompanyId(null); + o.setCompany(null); + o.setDeptId(null); + o.setDeptName(null); + o.setVoucherTime(null); + o.setVoucherNum(null); + o.setDigest(null); + o.setAudit(null); + o.setChecker(null); + o.setHandle(null); + o.setServiceId(null); + o.setServiceExplain(null); + o.setType(null); + o.setFlowId(null); + o.setSource(null); + o.setYear(null); + o.setPeriod(null); + o.setBorrowStatus(null); + o.setRecordTime(null); + o.setPosition(null); + o.setCherks(null); + o.setUserId(null); + o.setRecordId(null); + o.setFileStatus(null); + o.setRemark(null); + o.setOrganizationId(null); + o.setDepotId(null); + o.setCabinetId(null); + }); + voucherMapper.insert(dbVoucher); + // 测试 createBy 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCreateBy(null))); + // 测试 createTime 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCreateTime(null))); + // 测试 companyId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCompanyId(null))); + // 测试 company 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCompany(null))); + // 测试 deptId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDeptName(null))); + // 测试 voucherTime 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setVoucherTime(null))); + // 测试 voucherNum 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setVoucherNum(null))); + // 测试 digest 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDigest(null))); + // 测试 audit 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setAudit(null))); + // 测试 checker 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setChecker(null))); + // 测试 handle 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setHandle(null))); + // 测试 serviceId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setServiceId(null))); + // 测试 serviceExplain 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setServiceExplain(null))); + // 测试 type 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setType(null))); + // 测试 flowId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setFlowId(null))); + // 测试 source 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setSource(null))); + // 测试 year 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setYear(null))); + // 测试 period 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setPeriod(null))); + // 测试 borrowStatus 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setBorrowStatus(null))); + // 测试 recordTime 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRecordTime(null))); + // 测试 position 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setPosition(null))); + // 测试 cherks 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCherks(null))); + // 测试 userId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setUserId(null))); + // 测试 recordId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRecordId(null))); + // 测试 fileStatus 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setFileStatus(null))); + // 测试 remark 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRemark(null))); + // 测试 organizationId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setOrganizationId(null))); + // 测试 depotId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDepotId(null))); + // 测试 cabinetId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCabinetId(null))); + // 准备参数 + VoucherPageReqVO reqVO = new VoucherPageReqVO(); + reqVO.setCreateBy(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCompanyId(null); + reqVO.setCompany(null); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setVoucherTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setVoucherNum(null); + reqVO.setDigest(null); + reqVO.setAudit(null); + reqVO.setChecker(null); + reqVO.setHandle(null); + reqVO.setServiceId(null); + reqVO.setServiceExplain(null); + reqVO.setType(null); + reqVO.setFlowId(null); + reqVO.setSource(null); + reqVO.setYear(null); + reqVO.setPeriod(null); + reqVO.setBorrowStatus(null); + reqVO.setRecordTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setPosition(null); + reqVO.setCherks(null); + reqVO.setUserId(null); + reqVO.setRecordId(null); + reqVO.setFileStatus(null); + reqVO.setRemark(null); + reqVO.setOrganizationId(null); + reqVO.setDepotId(null); + reqVO.setCabinetId(null); + + // 调用 + PageResult pageResult = voucherService.getVoucherPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbVoucher, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetVoucherList() { + // mock 数据 + VoucherDO dbVoucher = randomPojo(VoucherDO.class, o -> { // 等会查询到 + o.setCreateBy(null); + o.setCreateTime(null); + o.setCompanyId(null); + o.setCompany(null); + o.setDeptId(null); + o.setDeptName(null); + o.setVoucherTime(null); + o.setVoucherNum(null); + o.setDigest(null); + o.setAudit(null); + o.setChecker(null); + o.setHandle(null); + o.setServiceId(null); + o.setServiceExplain(null); + o.setType(null); + o.setFlowId(null); + o.setSource(null); + o.setYear(null); + o.setPeriod(null); + o.setBorrowStatus(null); + o.setRecordTime(null); + o.setPosition(null); + o.setCherks(null); + o.setUserId(null); + o.setRecordId(null); + o.setFileStatus(null); + o.setRemark(null); + o.setOrganizationId(null); + o.setDepotId(null); + o.setCabinetId(null); + }); + voucherMapper.insert(dbVoucher); + // 测试 createBy 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCreateBy(null))); + // 测试 createTime 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCreateTime(null))); + // 测试 companyId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCompanyId(null))); + // 测试 company 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCompany(null))); + // 测试 deptId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDeptId(null))); + // 测试 deptName 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDeptName(null))); + // 测试 voucherTime 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setVoucherTime(null))); + // 测试 voucherNum 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setVoucherNum(null))); + // 测试 digest 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDigest(null))); + // 测试 audit 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setAudit(null))); + // 测试 checker 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setChecker(null))); + // 测试 handle 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setHandle(null))); + // 测试 serviceId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setServiceId(null))); + // 测试 serviceExplain 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setServiceExplain(null))); + // 测试 type 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setType(null))); + // 测试 flowId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setFlowId(null))); + // 测试 source 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setSource(null))); + // 测试 year 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setYear(null))); + // 测试 period 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setPeriod(null))); + // 测试 borrowStatus 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setBorrowStatus(null))); + // 测试 recordTime 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRecordTime(null))); + // 测试 position 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setPosition(null))); + // 测试 cherks 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCherks(null))); + // 测试 userId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setUserId(null))); + // 测试 recordId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRecordId(null))); + // 测试 fileStatus 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setFileStatus(null))); + // 测试 remark 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setRemark(null))); + // 测试 organizationId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setOrganizationId(null))); + // 测试 depotId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setDepotId(null))); + // 测试 cabinetId 不匹配 + voucherMapper.insert(cloneIgnoreId(dbVoucher, o -> o.setCabinetId(null))); + // 准备参数 + VoucherExportReqVO reqVO = new VoucherExportReqVO(); + reqVO.setCreateBy(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setCompanyId(null); + reqVO.setCompany(null); + reqVO.setDeptId(null); + reqVO.setDeptName(null); + reqVO.setVoucherTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setVoucherNum(null); + reqVO.setDigest(null); + reqVO.setAudit(null); + reqVO.setChecker(null); + reqVO.setHandle(null); + reqVO.setServiceId(null); + reqVO.setServiceExplain(null); + reqVO.setType(null); + reqVO.setFlowId(null); + reqVO.setSource(null); + reqVO.setYear(null); + reqVO.setPeriod(null); + reqVO.setBorrowStatus(null); + reqVO.setRecordTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setPosition(null); + reqVO.setCherks(null); + reqVO.setUserId(null); + reqVO.setRecordId(null); + reqVO.setFileStatus(null); + reqVO.setRemark(null); + reqVO.setOrganizationId(null); + reqVO.setDepotId(null); + reqVO.setCabinetId(null); + + // 调用 + List list = voucherService.getVoucherList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbVoucher, list.get(0)); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/test/java/cn/iocoder/yudao/module/accounting/service/voucherdetails/VoucherDetailsServiceImplTest.java b/yudao-module-accounting/yudao-module-accounting-biz/src/test/java/cn/iocoder/yudao/module/accounting/service/voucherdetails/VoucherDetailsServiceImplTest.java new file mode 100644 index 00000000..a1e2ef1d --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/test/java/cn/iocoder/yudao/module/accounting/service/voucherdetails/VoucherDetailsServiceImplTest.java @@ -0,0 +1,263 @@ +package cn.iocoder.yudao.module.accounting.service.voucherdetails; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.mock.mockito.MockBean; + +import javax.annotation.Resource; + +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; + +import cn.iocoder.yudao.module.accounting.controller.admin.voucherdetails.vo.*; +import cn.iocoder.yudao.module.accounting.dal.dataobject.voucherdetails.VoucherDetailsDO; +import cn.iocoder.yudao.module.accounting.dal.mysql.voucherdetails.VoucherDetailsMapper; +import cn.iocoder.yudao.framework.common.pojo.PageResult; + +import javax.annotation.Resource; +import org.springframework.context.annotation.Import; +import java.util.*; +import java.time.LocalDateTime; + +import static cn.hutool.core.util.RandomUtil.*; +import static cn.iocoder.yudao.module.accounting.enums.ErrorCodeConstants.*; +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.*; +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.*; +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.*; +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; + +/** + * {@link VoucherDetailsServiceImpl} 的单元测试类 + * + * @author 芋道源码 + */ +@Import(VoucherDetailsServiceImpl.class) +public class VoucherDetailsServiceImplTest extends BaseDbUnitTest { + + @Resource + private VoucherDetailsServiceImpl voucherDetailsService; + + @Resource + private VoucherDetailsMapper voucherDetailsMapper; + + @Test + public void testCreateVoucherDetails_success() { + // 准备参数 + VoucherDetailsCreateReqVO reqVO = randomPojo(VoucherDetailsCreateReqVO.class); + + // 调用 + Long voucherDetailsId = voucherDetailsService.createVoucherDetails(reqVO); + // 断言 + assertNotNull(voucherDetailsId); + // 校验记录的属性是否正确 + VoucherDetailsDO voucherDetails = voucherDetailsMapper.selectById(voucherDetailsId); + assertPojoEquals(reqVO, voucherDetails); + } + + @Test + public void testUpdateVoucherDetails_success() { + // mock 数据 + VoucherDetailsDO dbVoucherDetails = randomPojo(VoucherDetailsDO.class); + voucherDetailsMapper.insert(dbVoucherDetails);// @Sql: 先插入出一条存在的数据 + // 准备参数 + VoucherDetailsUpdateReqVO reqVO = randomPojo(VoucherDetailsUpdateReqVO.class, o -> { + o.setId(dbVoucherDetails.getId()); // 设置更新的 ID + }); + + // 调用 + voucherDetailsService.updateVoucherDetails(reqVO); + // 校验是否更新正确 + VoucherDetailsDO voucherDetails = voucherDetailsMapper.selectById(reqVO.getId()); // 获取最新的 + assertPojoEquals(reqVO, voucherDetails); + } + + @Test + public void testUpdateVoucherDetails_notExists() { + // 准备参数 + VoucherDetailsUpdateReqVO reqVO = randomPojo(VoucherDetailsUpdateReqVO.class); + + // 调用, 并断言异常 + assertServiceException(() -> voucherDetailsService.updateVoucherDetails(reqVO), VOUCHER_DETAILS_NOT_EXISTS); + } + + @Test + public void testDeleteVoucherDetails_success() { + // mock 数据 + VoucherDetailsDO dbVoucherDetails = randomPojo(VoucherDetailsDO.class); + voucherDetailsMapper.insert(dbVoucherDetails);// @Sql: 先插入出一条存在的数据 + // 准备参数 + Long id = dbVoucherDetails.getId(); + + // 调用 + voucherDetailsService.deleteVoucherDetails(id); + // 校验数据不存在了 + assertNull(voucherDetailsMapper.selectById(id)); + } + + @Test + public void testDeleteVoucherDetails_notExists() { + // 准备参数 + Long id = randomLongId(); + + // 调用, 并断言异常 + assertServiceException(() -> voucherDetailsService.deleteVoucherDetails(id), VOUCHER_DETAILS_NOT_EXISTS); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetVoucherDetailsPage() { + // mock 数据 + VoucherDetailsDO dbVoucherDetails = randomPojo(VoucherDetailsDO.class, o -> { // 等会查询到 + o.setLineNum(null); + o.setCreateBy(null); + o.setCreateTime(null); + o.setDigest(null); + o.setVoucherType(null); + o.setSubjectCode(null); + o.setSubjectName(null); + o.setAssistCheck(null); + o.setDebitMoney(null); + o.setCreditorMoney(null); + o.setFlowId(null); + o.setVoucherId(null); + o.setVoucherNum(null); + o.setUserId(null); + o.setFileStatus(null); + }); + voucherDetailsMapper.insert(dbVoucherDetails); + // 测试 lineNum 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setLineNum(null))); + // 测试 createBy 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreateBy(null))); + // 测试 createTime 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreateTime(null))); + // 测试 digest 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setDigest(null))); + // 测试 voucherType 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherType(null))); + // 测试 subjectCode 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setSubjectCode(null))); + // 测试 subjectName 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setSubjectName(null))); + // 测试 assistCheck 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setAssistCheck(null))); + // 测试 debitMoney 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setDebitMoney(null))); + // 测试 creditorMoney 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreditorMoney(null))); + // 测试 flowId 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setFlowId(null))); + // 测试 voucherId 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherId(null))); + // 测试 voucherNum 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherNum(null))); + // 测试 userId 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setUserId(null))); + // 测试 fileStatus 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setFileStatus(null))); + // 准备参数 + VoucherDetailsPageReqVO reqVO = new VoucherDetailsPageReqVO(); + reqVO.setLineNum(null); + reqVO.setCreateBy(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setDigest(null); + reqVO.setVoucherType(null); + reqVO.setSubjectCode(null); + reqVO.setSubjectName(null); + reqVO.setAssistCheck(null); + reqVO.setDebitMoney(null); + reqVO.setCreditorMoney(null); + reqVO.setFlowId(null); + reqVO.setVoucherId(null); + reqVO.setVoucherNum(null); + reqVO.setUserId(null); + reqVO.setFileStatus(null); + + // 调用 + PageResult pageResult = voucherDetailsService.getVoucherDetailsPage(reqVO); + // 断言 + assertEquals(1, pageResult.getTotal()); + assertEquals(1, pageResult.getList().size()); + assertPojoEquals(dbVoucherDetails, pageResult.getList().get(0)); + } + + @Test + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 + public void testGetVoucherDetailsList() { + // mock 数据 + VoucherDetailsDO dbVoucherDetails = randomPojo(VoucherDetailsDO.class, o -> { // 等会查询到 + o.setLineNum(null); + o.setCreateBy(null); + o.setCreateTime(null); + o.setDigest(null); + o.setVoucherType(null); + o.setSubjectCode(null); + o.setSubjectName(null); + o.setAssistCheck(null); + o.setDebitMoney(null); + o.setCreditorMoney(null); + o.setFlowId(null); + o.setVoucherId(null); + o.setVoucherNum(null); + o.setUserId(null); + o.setFileStatus(null); + }); + voucherDetailsMapper.insert(dbVoucherDetails); + // 测试 lineNum 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setLineNum(null))); + // 测试 createBy 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreateBy(null))); + // 测试 createTime 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreateTime(null))); + // 测试 digest 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setDigest(null))); + // 测试 voucherType 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherType(null))); + // 测试 subjectCode 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setSubjectCode(null))); + // 测试 subjectName 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setSubjectName(null))); + // 测试 assistCheck 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setAssistCheck(null))); + // 测试 debitMoney 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setDebitMoney(null))); + // 测试 creditorMoney 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setCreditorMoney(null))); + // 测试 flowId 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setFlowId(null))); + // 测试 voucherId 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherId(null))); + // 测试 voucherNum 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setVoucherNum(null))); + // 测试 userId 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setUserId(null))); + // 测试 fileStatus 不匹配 + voucherDetailsMapper.insert(cloneIgnoreId(dbVoucherDetails, o -> o.setFileStatus(null))); + // 准备参数 + VoucherDetailsExportReqVO reqVO = new VoucherDetailsExportReqVO(); + reqVO.setLineNum(null); + reqVO.setCreateBy(null); + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); + reqVO.setDigest(null); + reqVO.setVoucherType(null); + reqVO.setSubjectCode(null); + reqVO.setSubjectName(null); + reqVO.setAssistCheck(null); + reqVO.setDebitMoney(null); + reqVO.setCreditorMoney(null); + reqVO.setFlowId(null); + reqVO.setVoucherId(null); + reqVO.setVoucherNum(null); + reqVO.setUserId(null); + reqVO.setFileStatus(null); + + // 调用 + List list = voucherDetailsService.getVoucherDetailsList(reqVO); + // 断言 + assertEquals(1, list.size()); + assertPojoEquals(dbVoucherDetails, list.get(0)); + } + +} diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/passwords/PasswordsController.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/passwords/PasswordsController.java index bd0ee547..d12a0703 100644 --- a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/passwords/PasswordsController.java +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/controller/admin/passwords/PasswordsController.java @@ -74,6 +74,14 @@ public class PasswordsController { return success(PasswordsConvert.INSTANCE.convert(passwords)); } + @GetMapping("/getLastPasswords") + @Operation(summary = "获得最新数据密码") + @PreAuthorize("@ss.hasPermission('setting:passwords:query')") + public CommonResult getLastPasswords() { + PasswordsDO passwords = passwordsService.getLastPasswords(); + return success(PasswordsConvert.INSTANCE.convert(passwords)); + } + @GetMapping("/jsonToXmlConverter") @Operation(summary = "json带密码转xml") @PreAuthorize("@ss.hasPermission('setting:passwords:query')") diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsService.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsService.java index 973f3553..c85adfc5 100644 --- a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsService.java +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsService.java @@ -60,6 +60,13 @@ public interface PasswordsService { */ PasswordsDO getPasswords(Long id); + /** + * 获得数据密码最新一条 + * + * @return 数据密码 + */ + PasswordsDO getLastPasswords(); + /** * 获得数据密码列表 * diff --git a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsServiceImpl.java b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsServiceImpl.java index 83193119..31109172 100644 --- a/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsServiceImpl.java +++ b/yudao-module-setting/yudao-module-setting-biz/src/main/java/cn/iocoder/yudao/module/setting/service/passwords/PasswordsServiceImpl.java @@ -159,6 +159,13 @@ public class PasswordsServiceImpl implements PasswordsService { return passwordsMapper.selectById(id); } + @Override + public PasswordsDO getLastPasswords() { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.orderByDesc("create_time").last("LIMIT 1"); + return passwordsMapper.selectOne(wrapper); + } + @Override public List getPasswordsList(Collection ids) { return passwordsMapper.selectBatchIds(ids); diff --git a/yudao-server/pom.xml b/yudao-server/pom.xml index 2abc4f9d..de270ccf 100644 --- a/yudao-server/pom.xml +++ b/yudao-server/pom.xml @@ -27,6 +27,12 @@ yudao-module-bs-biz ${revision} + + + cn.iocoder.boot + yudao-module-accounting-biz + ${revision} + cn.iocoder.boot