From fb74d22a6e29ad8bf92c1f18345d0a965a7a3bc2 Mon Sep 17 00:00:00 2001 From: "LAPTOP-0SF788NU\\admin" <3306174053@qq.com> Date: Fri, 22 Sep 2023 09:07:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=9A=E8=AE=A1=E8=B4=A6=E7=B0=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../file/core/client/s3/S3FileClientTest.java | 30 ++-- .../accounting/enums/ErrorCodeConstants.java | 2 + .../AccountingBookController.java | 162 ++++++++++++++++++ .../vo/AccountingBookBaseVO.java | 53 ++++++ .../vo/AccountingBookCreateReqVO.java | 14 ++ .../vo/AccountingBookExcelVO.java | 62 +++++++ .../vo/AccountingBookExportReqVO.java | 56 ++++++ .../vo/AccountingBookPageReqVO.java | 64 +++++++ .../vo/AccountingBookRespVO.java | 25 +++ .../vo/AccountingBookUpdateReqVO.java | 18 ++ .../accountingbook/AccountingBookConvert.java | 36 ++++ .../accountingbook/AccountingBookDO.java | 91 ++++++++++ .../accountingbook/AccountingBookMapper.java | 62 +++++++ .../accountingbook/AccountingBookService.java | 76 ++++++++ .../AccountingBookServiceImpl.java | 113 ++++++++++++ .../accountingbook/AccountingBookMapper.xml | 12 ++ .../dal/dataobject/db/DataSourceConfigDO.java | 2 +- .../src/main/resources/application.yaml | 6 + 18 files changed, 867 insertions(+), 17 deletions(-) create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/AccountingBookController.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookBaseVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookCreateReqVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookExcelVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookExportReqVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookPageReqVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookRespVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookUpdateReqVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/accountingbook/AccountingBookConvert.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/accountingbook/AccountingBookDO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/accountingbook/AccountingBookMapper.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingbook/AccountingBookService.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingbook/AccountingBookServiceImpl.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/accountingbook/AccountingBookMapper.xml diff --git a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientTest.java b/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientTest.java index d6098f4a..e5da9750 100644 --- a/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientTest.java +++ b/yudao-framework/yudao-spring-boot-starter-file/src/test/java/cn/iocoder/yudao/framework/file/core/client/s3/S3FileClientTest.java @@ -5,7 +5,6 @@ import cn.hutool.core.util.IdUtil; import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; -import org.springframework.web.multipart.MultipartFile; import javax.validation.Validation; @@ -13,7 +12,7 @@ public class S3FileClientTest { @Test @Disabled // MinIO,如果要集成测试,可以注释本行 - public void testMinIO(MultipartFile file) throws Exception { + public void testMinIO() throws Exception { S3FileClientConfig config = new S3FileClientConfig(); // 配置成你自己的 config.setAccessKey("minioadmin"); @@ -24,12 +23,12 @@ public class S3FileClientTest { config.setEndpoint("https://www.lyrfp.com"); // 执行上传 - testExecuteUpload(config,file); + testExecuteUpload(config); } @Test @Disabled // 阿里云 OSS,如果要集成测试,可以注释本行 - public void testAliyun(MultipartFile file) throws Exception { + public void testAliyun() throws Exception { S3FileClientConfig config = new S3FileClientConfig(); // 配置成你自己的 config.setAccessKey(System.getenv("ALIYUN_ACCESS_KEY")); @@ -40,12 +39,12 @@ public class S3FileClientTest { config.setEndpoint("oss-cn-beijing.aliyuncs.com"); // 执行上传 - testExecuteUpload(config,file); + testExecuteUpload(config); } @Test @Disabled // 腾讯云 COS,如果要集成测试,可以注释本行 - public void testQCloud(MultipartFile file) throws Exception { + public void testQCloud() throws Exception { S3FileClientConfig config = new S3FileClientConfig(); // 配置成你自己的 config.setAccessKey(System.getenv("QCLOUD_ACCESS_KEY")); @@ -56,12 +55,12 @@ public class S3FileClientTest { config.setEndpoint("cos.ap-shanghai.myqcloud.com"); // 执行上传 - testExecuteUpload(config,file); + testExecuteUpload(config); } @Test @Disabled // 七牛云存储,如果要集成测试,可以注释本行 - public void testQiniu(MultipartFile file) throws Exception { + public void testQiniu() throws Exception { S3FileClientConfig config = new S3FileClientConfig(); // 配置成你自己的 // config.setAccessKey(System.getenv("QINIU_ACCESS_KEY")); @@ -74,12 +73,12 @@ public class S3FileClientTest { config.setEndpoint("s3-cn-south-1.qiniucs.com"); // 执行上传 - testExecuteUpload(config,file); + testExecuteUpload(config); } @Test @Disabled // 华为云存储,如果要集成测试,可以注释本行 - public void testHuaweiCloud(MultipartFile file) throws Exception { + public void testHuaweiCloud() throws Exception { S3FileClientConfig config = new S3FileClientConfig(); // 配置成你自己的 // config.setAccessKey(System.getenv("HUAWEI_CLOUD_ACCESS_KEY")); @@ -90,19 +89,19 @@ public class S3FileClientTest { config.setEndpoint("obs.cn-east-3.myhuaweicloud.com"); // 执行上传 - testExecuteUpload(config,file); + testExecuteUpload(config); } - private String testExecuteUpload(S3FileClientConfig config,MultipartFile file) throws Exception { + private void testExecuteUpload(S3FileClientConfig config) throws Exception { // 校验配置 ValidationUtils.validate(Validation.buildDefaultValidatorFactory().getValidator(), config); // 创建 Client S3FileClient client = new S3FileClient(0L, config); client.init(); // 上传文件 - String path = IdUtil.fastSimpleUUID() + ".xlsx"; -// byte[] content = ResourceUtil.readBytes(file); - String fullPath = client.upload(file.getBytes(), path, "xlsx"); + String path = IdUtil.fastSimpleUUID() + ".jpg"; + byte[] content = ResourceUtil.readBytes("file/erweima.jpg"); + String fullPath = client.upload(content, path, "image/jpeg"); System.out.println("访问地址:" + fullPath); // 读取文件 if (true) { @@ -113,7 +112,6 @@ public class S3FileClientTest { if (false) { client.delete(path); } - return fullPath; } } 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 index e6d3c045..7b39b1d6 100644 --- 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 @@ -4,4 +4,6 @@ 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, "凭证详情不存在"); + + ErrorCode ACCOUNTING_BOOK_NOT_EXISTS = new ErrorCode(400100, "会计账簿不存在"); } \ No newline at end of file diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/AccountingBookController.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/AccountingBookController.java new file mode 100644 index 00000000..df565542 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/AccountingBookController.java @@ -0,0 +1,162 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook; + +import cn.hutool.core.util.IdUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; +import cn.iocoder.yudao.framework.file.core.client.s3.S3FileClient; +import cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.*; +import cn.iocoder.yudao.module.accounting.convert.accountingbook.AccountingBookConvert; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO; +import cn.iocoder.yudao.module.accounting.service.accountingbook.AccountingBookService; +import cn.iocoder.yudao.module.infra.service.file.FileService; +import org.springframework.data.redis.core.RedisTemplate; +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.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; +import java.util.concurrent.TimeUnit; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; +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 org.springframework.web.multipart.MultipartFile; + +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; + +@Tag(name = "管理后台 - 会计账簿") +@RestController +@RequestMapping("/archives/accounting-book") +@Validated +public class AccountingBookController { + + @Resource + private AccountingBookService accountingBookService; + + @Resource + private FileService fileService; + + @Resource + private RedisTemplate redisTemplate; + + + @PostMapping("/create") + @Operation(summary = "创建会计账簿") + @PreAuthorize("@ss.hasPermission('archives:accounting-book:create')") + public CommonResult createAccountingBook(AccountingBookCreateReqVO createReqVO) { + return success(accountingBookService.createAccountingBook(createReqVO)); + } + + /** + * 账簿上传 + */ + @PostMapping("/upload") + @Operation(summary = "上传会计账簿") + @PreAuthorize("@ss.hasPermission('archives:accounting-book:create')") + public String uploadAccountingBook(@RequestPart("file") MultipartFile multipartFile,@RequestParam("type") String type) { + try { + //TODO minio配置 后续修改 + S3FileClientConfig config = new S3FileClientConfig(); + // 配置成你自己的 + config.setAccessKey("minioadmin"); + config.setAccessSecret("minioadmin"); + config.setBucket("ktg-mes"); + config.setDomain(null); + // 默认 9000 endpoint + config.setEndpoint("https://www.lyrfp.com"); + + // 执行上传 + String uri = testExecuteUpload(config, multipartFile); +// String uri = fileService.createFile(multipartFile.getOriginalFilename(), multipartFile.getOriginalFilename(), multipartFile.getBytes()); + //加入redis缓存 + redisTemplate.boundValueOps("fileUrlKey").set(uri); + redisTemplate.boundValueOps("fileKeyName").set(multipartFile.getOriginalFilename()); + redisTemplate.boundValueOps("fileKeyType").set(type); + return uri; + } catch (Exception e){ + e.printStackTrace(); + } + return "vo"; + } + + //TODO minio上传函数 后续封装为公用方法 + private String testExecuteUpload(S3FileClientConfig config,MultipartFile file) throws Exception { + // 校验配置 + ValidationUtils.validate(Validation.buildDefaultValidatorFactory().getValidator(), config); + // 创建 Client + S3FileClient client = new S3FileClient(0L, config); + client.init(); + // 上传文件 + String path = file.getOriginalFilename(); +// byte[] content = ResourceUtil.readBytes(file); + return client.upload(file.getBytes(), path, "xls/xlsx"); + } + @PutMapping("/update") + @Operation(summary = "更新会计账簿") + @PreAuthorize("@ss.hasPermission('archives:accounting-book:update')") + public CommonResult updateAccountingBook(@Valid @RequestBody AccountingBookUpdateReqVO updateReqVO) { + accountingBookService.updateAccountingBook(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除会计账簿") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('archives:accounting-book:delete')") + public CommonResult deleteAccountingBook(@RequestParam("id") Long id) { + accountingBookService.deleteAccountingBook(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得会计账簿") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('archives:accounting-book:query')") + public CommonResult getAccountingBook(@RequestParam("id") Long id) { + AccountingBookDO accountingBook = accountingBookService.getAccountingBook(id); + return success(AccountingBookConvert.INSTANCE.convert(accountingBook)); + } + + @GetMapping("/list") + @Operation(summary = "获得会计账簿列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('archives:accounting-book:query')") + public CommonResult> getAccountingBookList(@RequestParam("ids") Collection ids) { + List list = accountingBookService.getAccountingBookList(ids); + return success(AccountingBookConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得会计账簿分页") + @PreAuthorize("@ss.hasPermission('archives:accounting-book:query')") + public CommonResult> getAccountingBookPage(@Valid AccountingBookPageReqVO pageVO) { + PageResult pageResult = accountingBookService.getAccountingBookPage(pageVO); + return success(AccountingBookConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出会计账簿 Excel") + @PreAuthorize("@ss.hasPermission('archives:accounting-book:export')") + @OperateLog(type = EXPORT) + public void exportAccountingBookExcel(@Valid AccountingBookExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = accountingBookService.getAccountingBookList(exportReqVO); + // 导出 Excel + List datas = AccountingBookConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "会计账簿.xls", "数据", AccountingBookExcelVO.class, datas); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookBaseVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookBaseVO.java new file mode 100644 index 00000000..bebc2308 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookBaseVO.java @@ -0,0 +1,53 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; + +/** + * 会计账簿 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class AccountingBookBaseVO { + + @Schema(description = "业务实体名称", example = "4767") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "细分类型", example = "2") + private String type; + + @Schema(description = "会计年度") + private String year; + + @Schema(description = "会计期间") + private String period; + + @Schema(description = "账簿来源") + private String source; + + @Schema(description = "摘要") + private String digest; + + @Schema(description = "加密") + private String encrypt; + + @Schema(description = "归档id", example = "26310") + private Long archiveId; + + @Schema(description = "归档状态") + private String archiveState; + + @Schema(description = "部门id", example = "15870") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookCreateReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookCreateReqVO.java new file mode 100644 index 00000000..9c985b97 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.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 AccountingBookCreateReqVO extends AccountingBookBaseVO { + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookExcelVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookExcelVO.java new file mode 100644 index 00000000..bd755ed3 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookExcelVO.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 会计账簿 Excel VO + * + * @author 芋道源码 + */ +@Data +public class AccountingBookExcelVO { + + @ExcelProperty("账簿id") + private Long id; + + @ExcelProperty("业务实体名称") + private Long companyId; + + @ExcelProperty("业务实体") + private String company; + + @ExcelProperty("细分类型") + private String type; + + @ExcelProperty("会计年度") + private String year; + + @ExcelProperty("会计期间") + private String period; + + @ExcelProperty("账簿来源") + private String source; + + @ExcelProperty("摘要") + private String digest; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("加密") + private String encrypt; + + @ExcelProperty("归档id") + private Long archiveId; + + @ExcelProperty("归档状态") + private String archiveState; + + @ExcelProperty("部门id") + private Long deptId; + + @ExcelProperty("所属部门") + private String deptName; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookExportReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookExportReqVO.java new file mode 100644 index 00000000..5e29e2d0 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookExportReqVO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.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,参数和 AccountingBookPageReqVO 是一致的") +@Data +public class AccountingBookExportReqVO { + + @Schema(description = "业务实体名称", example = "4767") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "细分类型", example = "2") + private String type; + + @Schema(description = "会计年度") + private String year; + + @Schema(description = "会计期间") + private String period; + + @Schema(description = "账簿来源") + private String source; + + @Schema(description = "摘要") + private String digest; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "加密") + private String encrypt; + + @Schema(description = "归档id", example = "26310") + private Long archiveId; + + @Schema(description = "归档状态") + private String archiveState; + + @Schema(description = "部门id", example = "15870") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookPageReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookPageReqVO.java new file mode 100644 index 00000000..db842916 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookPageReqVO.java @@ -0,0 +1,64 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.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 AccountingBookPageReqVO extends PageParam { + + @Schema(description = "业务实体名称", example = "4767") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "账簿文件url") + private String uri; + + @Schema(description = "账簿文件名称") + private String name; + + @Schema(description = "细分类型", example = "2") + private String type; + + @Schema(description = "会计年度") + private String year; + + @Schema(description = "会计期间") + private String period; + + @Schema(description = "账簿来源") + private String source; + + @Schema(description = "摘要") + private String digest; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "加密") + private String encrypt; + + @Schema(description = "归档id", example = "26310") + private Long archiveId; + + @Schema(description = "归档状态") + private String archiveState; + + @Schema(description = "部门id", example = "15870") + private Long deptId; + + @Schema(description = "所属部门", example = "张三") + private String deptName; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookRespVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookRespVO.java new file mode 100644 index 00000000..cef8bfa7 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookRespVO.java @@ -0,0 +1,25 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.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 AccountingBookRespVO extends AccountingBookBaseVO { + + @Schema(description = "账簿id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26750") + private Long id; + + @Schema(description = "账簿文件uri") + private String uri; + + @Schema(description = "账簿文件名称") + private String name; + + @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/accountingbook/vo/AccountingBookUpdateReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookUpdateReqVO.java new file mode 100644 index 00000000..136c9723 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.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 AccountingBookUpdateReqVO extends AccountingBookBaseVO { + + @Schema(description = "账簿id", requiredMode = Schema.RequiredMode.REQUIRED, example = "26750") + @NotNull(message = "账簿id不能为空") + private Long id; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/accountingbook/AccountingBookConvert.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/accountingbook/AccountingBookConvert.java new file mode 100644 index 00000000..f23c392f --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/accountingbook/AccountingBookConvert.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.accounting.convert.accountingbook; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookCreateReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookExcelVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookRespVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookUpdateReqVO; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 会计账簿 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface AccountingBookConvert { + + AccountingBookConvert INSTANCE = Mappers.getMapper(AccountingBookConvert.class); + + AccountingBookDO convert(AccountingBookCreateReqVO bean); + + AccountingBookDO convert(AccountingBookUpdateReqVO bean); + + AccountingBookRespVO convert(AccountingBookDO 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/accountingbook/AccountingBookDO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/accountingbook/AccountingBookDO.java new file mode 100644 index 00000000..8e9af16c --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/accountingbook/AccountingBookDO.java @@ -0,0 +1,91 @@ +package cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +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("archives_accounting_book") +@KeySequence("archives_accounting_book_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AccountingBookDO extends BaseDO { + + /** + * 账簿id + */ + @TableId + private Long id; + + /** + * 账簿文件uri + */ + private String uri; + + /** + * 账簿文件uri + */ + private String name; + + /** + * 业务实体名称 + */ + private Long companyId; + /** + * 业务实体 + */ + private String company; + /** + * 细分类型 + */ + private String type; + /** + * 会计年度 + */ + private String year; + /** + * 会计期间 + */ + private String period; + /** + * 账簿来源 + */ + private String source; + /** + * 摘要 + */ + private String digest; + /** + * 加密 + */ + private String encrypt; + /** + * 归档id + */ + private Long archiveId; + /** + * 归档状态 + */ + private String archiveState; + /** + * 部门id + */ + private Long deptId; + /** + * 所属部门 + */ + private String deptName; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/accountingbook/AccountingBookMapper.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/accountingbook/AccountingBookMapper.java new file mode 100644 index 00000000..0848eef8 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/accountingbook/AccountingBookMapper.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.module.accounting.dal.mysql.accountingbook; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookExportReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookPageReqVO; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + + +/** + * 会计账簿 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface AccountingBookMapper extends BaseMapperX { + + default PageResult selectPage(AccountingBookPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(AccountingBookDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(AccountingBookDO::getName, reqVO.getName()) + .eqIfPresent(AccountingBookDO::getUri, reqVO.getUri()) + .eqIfPresent(AccountingBookDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(AccountingBookDO::getCompany, reqVO.getCompany()) + .eqIfPresent(AccountingBookDO::getType, reqVO.getType()) + .eqIfPresent(AccountingBookDO::getYear, reqVO.getYear()) + .eqIfPresent(AccountingBookDO::getPeriod, reqVO.getPeriod()) + .eqIfPresent(AccountingBookDO::getSource, reqVO.getSource()) + .eqIfPresent(AccountingBookDO::getDigest, reqVO.getDigest()) + .betweenIfPresent(AccountingBookDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(AccountingBookDO::getEncrypt, reqVO.getEncrypt()) + .eqIfPresent(AccountingBookDO::getArchiveId, reqVO.getArchiveId()) + .eqIfPresent(AccountingBookDO::getArchiveState, reqVO.getArchiveState()) + .eqIfPresent(AccountingBookDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(AccountingBookDO::getName,reqVO.getName()) + .likeIfPresent(AccountingBookDO::getDeptName, reqVO.getDeptName()) + .orderByDesc(AccountingBookDO::getId)); + } + + default List selectList(AccountingBookExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .eqIfPresent(AccountingBookDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(AccountingBookDO::getCompany, reqVO.getCompany()) + .eqIfPresent(AccountingBookDO::getType, reqVO.getType()) + .eqIfPresent(AccountingBookDO::getYear, reqVO.getYear()) + .eqIfPresent(AccountingBookDO::getPeriod, reqVO.getPeriod()) + .eqIfPresent(AccountingBookDO::getSource, reqVO.getSource()) + .eqIfPresent(AccountingBookDO::getDigest, reqVO.getDigest()) + .betweenIfPresent(AccountingBookDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(AccountingBookDO::getEncrypt, reqVO.getEncrypt()) + .eqIfPresent(AccountingBookDO::getArchiveId, reqVO.getArchiveId()) + .eqIfPresent(AccountingBookDO::getArchiveState, reqVO.getArchiveState()) + .eqIfPresent(AccountingBookDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(AccountingBookDO::getDeptName, reqVO.getDeptName()) + .orderByDesc(AccountingBookDO::getId)); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingbook/AccountingBookService.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingbook/AccountingBookService.java new file mode 100644 index 00000000..86a758cb --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingbook/AccountingBookService.java @@ -0,0 +1,76 @@ +package cn.iocoder.yudao.module.accounting.service.accountingbook; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookCreateReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookExportReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookPageReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookUpdateReqVO; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.*; +import javax.validation.*; + +/** + * 会计账簿 Service 接口 + * + * @author 芋道源码 + */ +public interface AccountingBookService { + + /** + * 创建会计账簿 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + AccountingBookDO createAccountingBook(@Valid AccountingBookCreateReqVO createReqVO); + + /** + * 更新会计账簿 + * + * @param updateReqVO 更新信息 + */ + void updateAccountingBook(@Valid AccountingBookUpdateReqVO updateReqVO); + + /** + * 删除会计账簿 + * + * @param id 编号 + */ + void deleteAccountingBook(Long id); + + /** + * 获得会计账簿 + * + * @param id 编号 + * @return 会计账簿 + */ + AccountingBookDO getAccountingBook(Long id); + + /** + * 获得会计账簿列表 + * + * @param ids 编号 + * @return 会计账簿列表 + */ + List getAccountingBookList(Collection ids); + + /** + * 获得会计账簿分页 + * + * @param pageReqVO 分页查询 + * @return 会计账簿分页 + */ + PageResult getAccountingBookPage(AccountingBookPageReqVO pageReqVO); + + /** + * 获得会计账簿列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 会计账簿列表 + */ + List getAccountingBookList(AccountingBookExportReqVO exportReqVO); + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingbook/AccountingBookServiceImpl.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingbook/AccountingBookServiceImpl.java new file mode 100644 index 00000000..707fc113 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingbook/AccountingBookServiceImpl.java @@ -0,0 +1,113 @@ +package cn.iocoder.yudao.module.accounting.service.accountingbook; + +import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookCreateReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookExportReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookPageReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingbook.vo.AccountingBookUpdateReqVO; +import cn.iocoder.yudao.module.accounting.convert.accountingbook.AccountingBookConvert; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingbook.AccountingBookDO; +import cn.iocoder.yudao.module.accounting.dal.mysql.accountingbook.AccountingBookMapper; +import cn.iocoder.yudao.module.infra.service.file.FileService; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.*; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.accounting.enums.ErrorCodeConstants.ACCOUNTING_BOOK_NOT_EXISTS; + + +/** + * 会计账簿 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class AccountingBookServiceImpl implements AccountingBookService { + + @Resource + private AccountingBookMapper accountingBookMapper; + + @Resource + private RedisTemplate redisTemplate; + + @Override + public AccountingBookDO createAccountingBook(AccountingBookCreateReqVO createReqVO) { + // 插入 + AccountingBookDO accountingBook = AccountingBookConvert.INSTANCE.convert(createReqVO); +// if (ObjectUtil.isNotNull(accountingBook)){ +// redisTemplate.boundValueOps("Company").set(createReqVO.getCompany()); +// redisTemplate.boundValueOps("Year").set(createReqVO.getYear()); +// redisTemplate.boundValueOps("Period").set(createReqVO.getPeriod()); +// } +// accountingBook.setCompany((String) redisTemplate.boundValueOps("Company").get()); +// accountingBook.setYear((String) redisTemplate.boundValueOps("Year").get()); +// accountingBook.setPeriod((String) redisTemplate.boundValueOps("Period").get()); + //如果要优化可以改成redis存储一个包含 uri name type字段的对象 也可以查询 infra_file 表获得 uri地址和文件名称 redis只缓存type字段 + String uri =(String) redisTemplate.boundValueOps("fileUrlKey").get(); + String name =(String) redisTemplate.boundValueOps("fileKeyName").get(); + String type =(String) redisTemplate.boundValueOps("fileKeyType").get(); + if (ObjectUtil.isNotNull(uri) && ObjectUtil.isNotNull(name) && ObjectUtil.isNotNull(type)){ + accountingBook.setUri(uri); + accountingBook.setName(name); + accountingBook.setType(type); + + } + accountingBookMapper.insert(accountingBook); + // 返回 + return accountingBook; + } + + @Override + public void updateAccountingBook(AccountingBookUpdateReqVO updateReqVO) { + // 校验存在 + validateAccountingBookExists(updateReqVO.getId()); + // 更新 + AccountingBookDO updateObj = AccountingBookConvert.INSTANCE.convert(updateReqVO); + accountingBookMapper.updateById(updateObj); + } + + @Override + public void deleteAccountingBook(Long id) { + // 校验存在 + validateAccountingBookExists(id); + // 删除 + accountingBookMapper.deleteById(id); + } + + private void validateAccountingBookExists(Long id) { + if (accountingBookMapper.selectById(id) == null) { + throw exception(ACCOUNTING_BOOK_NOT_EXISTS); + } + } + + @Override + public AccountingBookDO getAccountingBook(Long id) { + return accountingBookMapper.selectById(id); + } + + @Override + public List getAccountingBookList(Collection ids) { + return accountingBookMapper.selectBatchIds(ids); + } + + @Override + public PageResult getAccountingBookPage(AccountingBookPageReqVO pageReqVO) { + return accountingBookMapper.selectPage(pageReqVO); + } + + @Override + public List getAccountingBookList(AccountingBookExportReqVO exportReqVO) { + return accountingBookMapper.selectList(exportReqVO); + } + + + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/accountingbook/AccountingBookMapper.xml b/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/accountingbook/AccountingBookMapper.xml new file mode 100644 index 00000000..1beb8f30 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/accountingbook/AccountingBookMapper.xml @@ -0,0 +1,12 @@ + + + + + + + diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/db/DataSourceConfigDO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/db/DataSourceConfigDO.java index 138babe5..6f556ee7 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/db/DataSourceConfigDO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/dal/dataobject/db/DataSourceConfigDO.java @@ -42,7 +42,7 @@ public class DataSourceConfigDO extends BaseDO { /** * 密码 */ - @TableField(typeHandler = EncryptTypeHandler.class) +// @TableField(typeHandler = EncryptTypeHandler.class) private String password; } diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index 3ee218cc..9c69b003 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -206,3 +206,9 @@ debug: false minidao : base-package: org.jeecg.modules.jmreport.desreport.dao* db-type: mysql + +# 接口超时时间 +spring: + mvc: + async: + request-timeout: 20000 \ No newline at end of file From 1b12610c966de6759fddaecd8e5ae65d402dc1c7 Mon Sep 17 00:00:00 2001 From: "LAPTOP-0SF788NU\\admin" <3306174053@qq.com> Date: Fri, 22 Sep 2023 13:23:21 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=9A=E8=AE=A1=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/book20230922Js.sql | 35 ++++ .../accounting/enums/ErrorCodeConstants.java | 2 + .../AccountingBookController.java | 2 + .../vo/AccountingBookUpdateReqVO.java | 6 + .../AccountingReportController.java | 153 ++++++++++++++++++ .../vo/AccountingReportBaseVO.java | 57 +++++++ .../vo/AccountingReportCreateReqVO.java | 14 ++ .../vo/AccountingReportExcelVO.java | 65 ++++++++ .../vo/AccountingReportExportReqVO.java | 59 +++++++ .../vo/AccountingReportPageReqVO.java | 61 +++++++ .../vo/AccountingReportRespVO.java | 19 +++ .../vo/AccountingReportUpdateReqVO.java | 18 +++ .../AccountingReportConvert.java | 37 +++++ .../accountingreport/AccountingReportDO.java | 84 ++++++++++ .../AccountingReportMapper.java | 60 +++++++ .../AccountingReportService.java | 74 +++++++++ .../AccountingReportServiceImpl.java | 96 +++++++++++ .../AccountingReportMapper.xml | 12 ++ 18 files changed, 854 insertions(+) create mode 100644 sql/book20230922Js.sql create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/AccountingReportController.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportBaseVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportCreateReqVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportExcelVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportExportReqVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportPageReqVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportRespVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportUpdateReqVO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/accountingreport/AccountingReportConvert.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/accountingreport/AccountingReportDO.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/accountingreport/AccountingReportMapper.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingreport/AccountingReportService.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingreport/AccountingReportServiceImpl.java create mode 100644 yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/accountingreport/AccountingReportMapper.xml diff --git a/sql/book20230922Js.sql b/sql/book20230922Js.sql new file mode 100644 index 00000000..58680f24 --- /dev/null +++ b/sql/book20230922Js.sql @@ -0,0 +1,35 @@ +-- 创建会计账簿表 +CREATE TABLE `lyr-one`.`Untitled` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '账簿id', + `uri` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账簿文件uri', + `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账簿文件名称', + `company_id` bigint(20) NULL DEFAULT NULL COMMENT '业务实体名称', + `company` varchar(255) 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 '细分类型', + `year` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会计年度', + `period` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '会计期间', + `source` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '账簿来源', + `digest` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '摘要', + `creator` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '创建者', + `create_time` datetime NULL DEFAULT NULL COMMENT '创建时间', + `updater` datetime NULL DEFAULT NULL COMMENT '修改者', + `update_time` datetime NULL DEFAULT NULL COMMENT '更新时间', + `deleted` bit(1) NULL DEFAULT b'0' COMMENT '是否删除', + `encrypt` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '加密', + `archive_id` bigint(20) NULL DEFAULT NULL COMMENT '归档id', + `archive_state` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '归档状态', + `dept_id` bigint(20) NULL DEFAULT NULL COMMENT '部门id', + `dept_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所属部门', + `tenant_id` bigint(20) NULL DEFAULT NULL COMMENT '住户编号', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = MyISAM AUTO_INCREMENT = 90 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '会计账簿表' ROW_FORMAT = Dynamic; + + +SELECT `id` INTO @menuId FROM system_menu WHERE `name` = '会计档案'; + +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, 1, @menuId, 'book', 'education', 'accounting/book/index', 'Book', 0, b'1', b'1', b'1', '', '2023-09-20 15:09:58', '', '2023-09-20 15:09:58', b'0'); +SET @menuId2 = 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 ('创建会计账簿', 'archives:accounting-book:create', 3, 1, @menuId2 , '', '', '', '', 0, b'1', b'1', b'1', '', '2023-09-22 11:20:21', '', '2023-09-22 11:20:21', b'0'); +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 ('获取会计账簿列表', 'archives:accounting-book:query', 3, 2, @menuId2 , '', '', '', '', 0, b'1', b'1', b'1', '', '2023-09-22 11:21:56', '', '2023-09-22 11:22:38', b'0'); +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 ('删除会计账簿', 'archives:accounting-book:delete', 3, 3, @menuId2 , '', '', '', '', 0, b'1', b'1', b'1', '', '2023-09-22 11:22:50', '', '2023-09-22 11:22:50', b'0'); +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 ('修改会计账簿', 'archives:accounting-book:update', 3, 4, @menuId2 , '', '', '', '', 0, b'1', b'1', b'1', '', '2023-09-22 11:23:18', '', '2023-09-22 11:23:18', b'0'); 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 index 7b39b1d6..b412c5a3 100644 --- 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 @@ -6,4 +6,6 @@ public interface ErrorCodeConstants { ErrorCode VOUCHER_DETAILS_NOT_EXISTS = new ErrorCode(300100, "凭证详情不存在"); ErrorCode ACCOUNTING_BOOK_NOT_EXISTS = new ErrorCode(400100, "会计账簿不存在"); + + ErrorCode ACCOUNTING_REPORT_NOT_EXISTS = new ErrorCode(500100, "会计报表不存在"); } \ No newline at end of file diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/AccountingBookController.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/AccountingBookController.java index df565542..4b74d3f0 100644 --- a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/AccountingBookController.java +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/AccountingBookController.java @@ -104,6 +104,8 @@ public class AccountingBookController { // byte[] content = ResourceUtil.readBytes(file); return client.upload(file.getBytes(), path, "xls/xlsx"); } + + @PutMapping("/update") @Operation(summary = "更新会计账簿") @PreAuthorize("@ss.hasPermission('archives:accounting-book:update')") diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookUpdateReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookUpdateReqVO.java index 136c9723..0b988e08 100644 --- a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookUpdateReqVO.java +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingbook/vo/AccountingBookUpdateReqVO.java @@ -15,4 +15,10 @@ public class AccountingBookUpdateReqVO extends AccountingBookBaseVO { @NotNull(message = "账簿id不能为空") private Long id; + @Schema(description = "账簿文件uri") + private String uri; + + @Schema(description = "账簿文件名称") + private String name; + } diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/AccountingReportController.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/AccountingReportController.java new file mode 100644 index 00000000..452c4dd6 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/AccountingReportController.java @@ -0,0 +1,153 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingreport; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; +import cn.iocoder.yudao.framework.file.core.client.s3.S3FileClient; +import cn.iocoder.yudao.framework.file.core.client.s3.S3FileClientConfig; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.*; +import cn.iocoder.yudao.module.accounting.convert.accountingreport.AccountingReportConvert; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingreport.AccountingReportDO; +import cn.iocoder.yudao.module.accounting.service.accountingreport.AccountingReportService; +import org.springframework.data.redis.core.RedisTemplate; +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.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +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 org.springframework.web.multipart.MultipartFile; + +import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; +@Tag(name = "管理后台 - 会计报表") +@RestController +@RequestMapping("/archives/accounting-report") +@Validated +public class AccountingReportController { + + @Resource + private AccountingReportService accountingReportService; + + @Resource + private RedisTemplate redisTemplate; + + @PostMapping("/create") + @Operation(summary = "创建会计报表") + @PreAuthorize("@ss.hasPermission('archives:accounting-report:create')") + public CommonResult createAccountingReport(@Valid @RequestBody AccountingReportCreateReqVO createReqVO) { + return success(accountingReportService.createAccountingReport(createReqVO)); + } + + /** + * 账簿上传 + */ + @PostMapping("/upload") + @Operation(summary = "上传会计报表") + @PreAuthorize("@ss.hasPermission('archives:accounting-report:create')") + public String uploadAccountingBook(@RequestPart("file") MultipartFile multipartFile, @RequestParam("type") String type) { + try { + //TODO minio配置 后续修改 + S3FileClientConfig config = new S3FileClientConfig(); + // 配置成你自己的 + config.setAccessKey("minioadmin"); + config.setAccessSecret("minioadmin"); + config.setBucket("ktg-mes"); + config.setDomain(null); + // 默认 9000 endpoint + config.setEndpoint("https://www.lyrfp.com"); + + // 执行上传 + String uri = testExecuteUpload(config, multipartFile); +// String uri = fileService.createFile(multipartFile.getOriginalFilename(), multipartFile.getOriginalFilename(), multipartFile.getBytes()); + //加入redis缓存 + redisTemplate.boundValueOps("reportFileUrlKey").set(uri); + redisTemplate.boundValueOps("reportFileKeyName").set(multipartFile.getOriginalFilename()); + redisTemplate.boundValueOps("reportFileKeyType").set(type); + return uri; + } catch (Exception e){ + e.printStackTrace(); + } + return "vo"; + } + + //TODO minio上传函数 后续封装为公用方法 + private String testExecuteUpload(S3FileClientConfig config,MultipartFile file) throws Exception { + // 校验配置 + ValidationUtils.validate(Validation.buildDefaultValidatorFactory().getValidator(), config); + // 创建 Client + S3FileClient client = new S3FileClient(0L, config); + client.init(); + // 上传文件 + String path = file.getOriginalFilename(); +// byte[] content = ResourceUtil.readBytes(file); + return client.upload(file.getBytes(), path, "xls/xlsx"); + } + + @PutMapping("/update") + @Operation(summary = "更新会计报表") + @PreAuthorize("@ss.hasPermission('archives:accounting-report:update')") + public CommonResult updateAccountingReport(@Valid @RequestBody AccountingReportUpdateReqVO updateReqVO) { + accountingReportService.updateAccountingReport(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除会计报表") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('archives:accounting-report:delete')") + public CommonResult deleteAccountingReport(@RequestParam("id") Long id) { + accountingReportService.deleteAccountingReport(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得会计报表") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('archives:accounting-report:query')") + public CommonResult getAccountingReport(@RequestParam("id") Long id) { + AccountingReportDO accountingReport = accountingReportService.getAccountingReport(id); + return success(AccountingReportConvert.INSTANCE.convert(accountingReport)); + } + + @GetMapping("/list") + @Operation(summary = "获得会计报表列表") + @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048") + @PreAuthorize("@ss.hasPermission('archives:accounting-report:query')") + public CommonResult> getAccountingReportList(@RequestParam("ids") Collection ids) { + List list = accountingReportService.getAccountingReportList(ids); + return success(AccountingReportConvert.INSTANCE.convertList(list)); + } + + @GetMapping("/page") + @Operation(summary = "获得会计报表分页") + @PreAuthorize("@ss.hasPermission('archives:accounting-report:query')") + public CommonResult> getAccountingReportPage(@Valid AccountingReportPageReqVO pageVO) { + PageResult pageResult = accountingReportService.getAccountingReportPage(pageVO); + return success(AccountingReportConvert.INSTANCE.convertPage(pageResult)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出会计报表 Excel") + @PreAuthorize("@ss.hasPermission('archives:accounting-report:export')") + @OperateLog(type = EXPORT) + public void exportAccountingReportExcel(@Valid AccountingReportExportReqVO exportReqVO, + HttpServletResponse response) throws IOException { + List list = accountingReportService.getAccountingReportList(exportReqVO); + // 导出 Excel + List datas = AccountingReportConvert.INSTANCE.convertList02(list); + ExcelUtils.write(response, "会计报表.xls", "数据", AccountingReportExcelVO.class, datas); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportBaseVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportBaseVO.java new file mode 100644 index 00000000..a9d0bc6f --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportBaseVO.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import javax.validation.constraints.*; + +/** + * 会计报表 Base VO,提供给添加、修改、详细的子 VO 使用 + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 + */ +@Data +public class AccountingReportBaseVO { + + @Schema(description = "报表文件名称", example = "赵六") + private String name; + + @Schema(description = "报表文件url", example = "https://www.iocoder.cn") + private String url; + + @Schema(description = "业务实体id", example = "9885") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "细分类型", example = "1") + private String type; + + @Schema(description = "账套编号") + private String bookCode; + + @Schema(description = "会计年度") + private String year; + + @Schema(description = "会计期间") + private String period; + + @Schema(description = "加密") + private String encrypt; + + @Schema(description = "归档id", example = "25739") + private Long archiveId; + + @Schema(description = "归档状态") + private String archiveState; + + @Schema(description = "部门id", example = "6314") + private Long deptId; + + @Schema(description = "所属部门", example = "赵六") + private String deptName; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportCreateReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportCreateReqVO.java new file mode 100644 index 00000000..83af25d4 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportCreateReqVO.java @@ -0,0 +1,14 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.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 AccountingReportCreateReqVO extends AccountingReportBaseVO { + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportExcelVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportExcelVO.java new file mode 100644 index 00000000..5eed0dd3 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportExcelVO.java @@ -0,0 +1,65 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import java.time.LocalDateTime; + +import com.alibaba.excel.annotation.ExcelProperty; + +/** + * 会计报表 Excel VO + * + * @author 芋道源码 + */ +@Data +public class AccountingReportExcelVO { + + @ExcelProperty("报表id") + private Long id; + + @ExcelProperty("报表文件名称") + private String name; + + @ExcelProperty("报表文件url") + private String url; + + @ExcelProperty("业务实体id") + private Long companyId; + + @ExcelProperty("业务实体") + private String company; + + @ExcelProperty("细分类型") + private String type; + + @ExcelProperty("账套编号") + private String bookCode; + + @ExcelProperty("会计年度") + private String year; + + @ExcelProperty("会计期间") + private String period; + + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("加密") + private String encrypt; + + @ExcelProperty("归档id") + private Long archiveId; + + @ExcelProperty("归档状态") + private String archiveState; + + @ExcelProperty("部门id") + private Long deptId; + + @ExcelProperty("所属部门") + private String deptName; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportExportReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportExportReqVO.java new file mode 100644 index 00000000..4172d719 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportExportReqVO.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.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,参数和 AccountingReportPageReqVO 是一致的") +@Data +public class AccountingReportExportReqVO { + + @Schema(description = "报表文件名称", example = "赵六") + private String name; + + @Schema(description = "报表文件url", example = "https://www.iocoder.cn") + private String url; + + @Schema(description = "业务实体id", example = "9885") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "细分类型", example = "1") + private String type; + + @Schema(description = "账套编号") + private String bookCode; + + @Schema(description = "会计年度") + private String year; + + @Schema(description = "会计期间") + private String period; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "加密") + private String encrypt; + + @Schema(description = "归档id", example = "25739") + private Long archiveId; + + @Schema(description = "归档状态") + private String archiveState; + + @Schema(description = "部门id", example = "6314") + private Long deptId; + + @Schema(description = "所属部门", example = "赵六") + private String deptName; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportPageReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportPageReqVO.java new file mode 100644 index 00000000..3a8c31e8 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportPageReqVO.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.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 AccountingReportPageReqVO extends PageParam { + + @Schema(description = "报表文件名称", example = "赵六") + private String name; + + @Schema(description = "报表文件url", example = "https://www.iocoder.cn") + private String url; + + @Schema(description = "业务实体id", example = "9885") + private Long companyId; + + @Schema(description = "业务实体") + private String company; + + @Schema(description = "细分类型", example = "1") + private String type; + + @Schema(description = "账套编号") + private String bookCode; + + @Schema(description = "会计年度") + private String year; + + @Schema(description = "会计期间") + private String period; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + + @Schema(description = "加密") + private String encrypt; + + @Schema(description = "归档id", example = "25739") + private Long archiveId; + + @Schema(description = "归档状态") + private String archiveState; + + @Schema(description = "部门id", example = "6314") + private Long deptId; + + @Schema(description = "所属部门", example = "赵六") + private String deptName; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportRespVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportRespVO.java new file mode 100644 index 00000000..f9e77f0f --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportRespVO.java @@ -0,0 +1,19 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.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 AccountingReportRespVO extends AccountingReportBaseVO { + + @Schema(description = "报表id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23780") + 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/accountingreport/vo/AccountingReportUpdateReqVO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportUpdateReqVO.java new file mode 100644 index 00000000..363ef47a --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/controller/admin/accountingreport/vo/AccountingReportUpdateReqVO.java @@ -0,0 +1,18 @@ +package cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.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 AccountingReportUpdateReqVO extends AccountingReportBaseVO { + + @Schema(description = "报表id", requiredMode = Schema.RequiredMode.REQUIRED, example = "23780") + @NotNull(message = "报表id不能为空") + private Long id; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/accountingreport/AccountingReportConvert.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/accountingreport/AccountingReportConvert.java new file mode 100644 index 00000000..cda4fece --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/convert/accountingreport/AccountingReportConvert.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.accounting.convert.accountingreport; + + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportCreateReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportExcelVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportRespVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportUpdateReqVO; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingreport.AccountingReportDO; +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import java.util.List; + +/** + * 会计报表 Convert + * + * @author 芋道源码 + */ +@Mapper +public interface AccountingReportConvert { + + AccountingReportConvert INSTANCE = Mappers.getMapper(AccountingReportConvert.class); + + AccountingReportDO convert(AccountingReportCreateReqVO bean); + + AccountingReportDO convert(AccountingReportUpdateReqVO bean); + + AccountingReportRespVO convert(AccountingReportDO 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/accountingreport/AccountingReportDO.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/accountingreport/AccountingReportDO.java new file mode 100644 index 00000000..27734a8c --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/dataobject/accountingreport/AccountingReportDO.java @@ -0,0 +1,84 @@ +package cn.iocoder.yudao.module.accounting.dal.dataobject.accountingreport; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +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("archives_accounting_report") +@KeySequence("archives_accounting_report_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class AccountingReportDO extends BaseDO { + + /** + * 报表id + */ + @TableId + private Long id; + /** + * 报表文件名称 + */ + private String name; + /** + * 报表文件url + */ + private String url; + /** + * 业务实体id + */ + private Long companyId; + /** + * 业务实体 + */ + private String company; + /** + * 细分类型 + */ + private String type; + /** + * 账套编号 + */ + private String bookCode; + /** + * 会计年度 + */ + private String year; + /** + * 会计期间 + */ + private String period; + /** + * 加密 + */ + private String encrypt; + /** + * 归档id + */ + private Long archiveId; + /** + * 归档状态 + */ + private String archiveState; + /** + * 部门id + */ + private Long deptId; + /** + * 所属部门 + */ + private String deptName; + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/accountingreport/AccountingReportMapper.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/accountingreport/AccountingReportMapper.java new file mode 100644 index 00000000..93e50967 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/dal/mysql/accountingreport/AccountingReportMapper.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.accounting.dal.mysql.accountingreport; + + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportExportReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportPageReqVO; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingreport.AccountingReportDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 会计报表 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface AccountingReportMapper extends BaseMapperX { + + default PageResult selectPage(AccountingReportPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(AccountingReportDO::getName, reqVO.getName()) + .eqIfPresent(AccountingReportDO::getUrl, reqVO.getUrl()) + .eqIfPresent(AccountingReportDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(AccountingReportDO::getCompany, reqVO.getCompany()) + .eqIfPresent(AccountingReportDO::getType, reqVO.getType()) + .eqIfPresent(AccountingReportDO::getBookCode, reqVO.getBookCode()) + .eqIfPresent(AccountingReportDO::getYear, reqVO.getYear()) + .eqIfPresent(AccountingReportDO::getPeriod, reqVO.getPeriod()) + .betweenIfPresent(AccountingReportDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(AccountingReportDO::getEncrypt, reqVO.getEncrypt()) + .eqIfPresent(AccountingReportDO::getArchiveId, reqVO.getArchiveId()) + .eqIfPresent(AccountingReportDO::getArchiveState, reqVO.getArchiveState()) + .eqIfPresent(AccountingReportDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(AccountingReportDO::getDeptName, reqVO.getDeptName()) + .orderByDesc(AccountingReportDO::getId)); + } + + default List selectList(AccountingReportExportReqVO reqVO) { + return selectList(new LambdaQueryWrapperX() + .likeIfPresent(AccountingReportDO::getName, reqVO.getName()) + .eqIfPresent(AccountingReportDO::getUrl, reqVO.getUrl()) + .eqIfPresent(AccountingReportDO::getCompanyId, reqVO.getCompanyId()) + .eqIfPresent(AccountingReportDO::getCompany, reqVO.getCompany()) + .eqIfPresent(AccountingReportDO::getType, reqVO.getType()) + .eqIfPresent(AccountingReportDO::getBookCode, reqVO.getBookCode()) + .eqIfPresent(AccountingReportDO::getYear, reqVO.getYear()) + .eqIfPresent(AccountingReportDO::getPeriod, reqVO.getPeriod()) + .betweenIfPresent(AccountingReportDO::getCreateTime, reqVO.getCreateTime()) + .eqIfPresent(AccountingReportDO::getEncrypt, reqVO.getEncrypt()) + .eqIfPresent(AccountingReportDO::getArchiveId, reqVO.getArchiveId()) + .eqIfPresent(AccountingReportDO::getArchiveState, reqVO.getArchiveState()) + .eqIfPresent(AccountingReportDO::getDeptId, reqVO.getDeptId()) + .likeIfPresent(AccountingReportDO::getDeptName, reqVO.getDeptName()) + .orderByDesc(AccountingReportDO::getId)); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingreport/AccountingReportService.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingreport/AccountingReportService.java new file mode 100644 index 00000000..479dfc4c --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingreport/AccountingReportService.java @@ -0,0 +1,74 @@ +package cn.iocoder.yudao.module.accounting.service.accountingreport; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportCreateReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportExportReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportPageReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportUpdateReqVO; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingreport.AccountingReportDO; + +import java.util.*; +import javax.validation.*; + +/** + * 会计报表 Service 接口 + * + * @author 芋道源码 + */ +public interface AccountingReportService { + + /** + * 创建会计报表 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createAccountingReport(@Valid AccountingReportCreateReqVO createReqVO); + + /** + * 更新会计报表 + * + * @param updateReqVO 更新信息 + */ + void updateAccountingReport(@Valid AccountingReportUpdateReqVO updateReqVO); + + /** + * 删除会计报表 + * + * @param id 编号 + */ + void deleteAccountingReport(Long id); + + /** + * 获得会计报表 + * + * @param id 编号 + * @return 会计报表 + */ + AccountingReportDO getAccountingReport(Long id); + + /** + * 获得会计报表列表 + * + * @param ids 编号 + * @return 会计报表列表 + */ + List getAccountingReportList(Collection ids); + + /** + * 获得会计报表分页 + * + * @param pageReqVO 分页查询 + * @return 会计报表分页 + */ + PageResult getAccountingReportPage(AccountingReportPageReqVO pageReqVO); + + /** + * 获得会计报表列表, 用于 Excel 导出 + * + * @param exportReqVO 查询条件 + * @return 会计报表列表 + */ + List getAccountingReportList(AccountingReportExportReqVO exportReqVO); + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingreport/AccountingReportServiceImpl.java b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingreport/AccountingReportServiceImpl.java new file mode 100644 index 00000000..b48a2ef0 --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/java/cn/iocoder/yudao/module/accounting/service/accountingreport/AccountingReportServiceImpl.java @@ -0,0 +1,96 @@ +package cn.iocoder.yudao.module.accounting.service.accountingreport; + +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportCreateReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportExportReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportPageReqVO; +import cn.iocoder.yudao.module.accounting.controller.admin.accountingreport.vo.AccountingReportUpdateReqVO; +import cn.iocoder.yudao.module.accounting.convert.accountingreport.AccountingReportConvert; +import cn.iocoder.yudao.module.accounting.dal.dataobject.accountingreport.AccountingReportDO; +import cn.iocoder.yudao.module.accounting.dal.mysql.accountingreport.AccountingReportMapper; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; +import java.util.*; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.accounting.enums.ErrorCodeConstants.ACCOUNTING_REPORT_NOT_EXISTS; + +/** + * 会计报表 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class AccountingReportServiceImpl implements AccountingReportService { + + @Resource + private AccountingReportMapper accountingReportMapper; + + @Resource + private RedisTemplate redisTemplate; + + @Override + public Long createAccountingReport(AccountingReportCreateReqVO createReqVO) { + // 插入 + AccountingReportDO accountingReport = AccountingReportConvert.INSTANCE.convert(createReqVO); + String uri =(String) redisTemplate.boundValueOps("reportFileUrlKey").get(); + String name =(String) redisTemplate.boundValueOps("reportFileKeyName").get(); + String type =(String) redisTemplate.boundValueOps("reportFileKeyType").get(); + if (ObjectUtil.isNotNull(uri) && ObjectUtil.isNotNull(name) && ObjectUtil.isNotNull(type)){ + accountingReport.setUrl(uri); + accountingReport.setName(name); + accountingReport.setType(type); + } + accountingReportMapper.insert(accountingReport); + // 返回 + return accountingReport.getId(); + } + + @Override + public void updateAccountingReport(AccountingReportUpdateReqVO updateReqVO) { + // 校验存在 + validateAccountingReportExists(updateReqVO.getId()); + // 更新 + AccountingReportDO updateObj = AccountingReportConvert.INSTANCE.convert(updateReqVO); + accountingReportMapper.updateById(updateObj); + } + + @Override + public void deleteAccountingReport(Long id) { + // 校验存在 + validateAccountingReportExists(id); + // 删除 + accountingReportMapper.deleteById(id); + } + + private void validateAccountingReportExists(Long id) { + if (accountingReportMapper.selectById(id) == null) { + throw exception(ACCOUNTING_REPORT_NOT_EXISTS); + } + } + + @Override + public AccountingReportDO getAccountingReport(Long id) { + return accountingReportMapper.selectById(id); + } + + @Override + public List getAccountingReportList(Collection ids) { + return accountingReportMapper.selectBatchIds(ids); + } + + @Override + public PageResult getAccountingReportPage(AccountingReportPageReqVO pageReqVO) { + return accountingReportMapper.selectPage(pageReqVO); + } + + @Override + public List getAccountingReportList(AccountingReportExportReqVO exportReqVO) { + return accountingReportMapper.selectList(exportReqVO); + } + +} diff --git a/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/accountingreport/AccountingReportMapper.xml b/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/accountingreport/AccountingReportMapper.xml new file mode 100644 index 00000000..ffbae5bc --- /dev/null +++ b/yudao-module-accounting/yudao-module-accounting-biz/src/main/resources/mapper/accountingreport/AccountingReportMapper.xml @@ -0,0 +1,12 @@ + + + + + + +