From c052ad24c92376477a960141b605134bac669001 Mon Sep 17 00:00:00 2001 From: lihongjie0209 Date: Tue, 25 Feb 2025 23:12:52 +0800 Subject: [PATCH] =?UTF-8?q?refactor(file):=20=E4=BC=98=E5=8C=96=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E4=B8=8A=E4=BC=A0=E9=80=BB=E8=BE=91=E5=B9=B6=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=BB=84=E7=BB=87ID=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 FileService 中添加了新的 upload 方法,支持传入组织ID参数 - 修改了现有的 upload 方法,使其支持组织ID - 在 SmartCamCarLicenseSnapshotDataService 中为捕获的图片添加了组织ID设置 - 优化了日期格式解析 - 更新了 SmartCamCarLicenseSnapshotDataDto 中的图片字段类型 - 修复了 InvoiceService 中的 findOne 方法返回值问题 --- .../coal/file/service/FileService.java | 26 ++++++++++++++----- .../coal/invoice/service/InvoiceService.java | 9 ++++++- .../SmartCamCarLicenseSnapshotDataDto.java | 5 ++-- ...SmartCamCarLicenseSnapshotDataService.java | 10 +++---- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/main/java/cn/lihongjie/coal/file/service/FileService.java b/src/main/java/cn/lihongjie/coal/file/service/FileService.java index 5821598d..2095cc8d 100644 --- a/src/main/java/cn/lihongjie/coal/file/service/FileService.java +++ b/src/main/java/cn/lihongjie/coal/file/service/FileService.java @@ -174,7 +174,8 @@ public class FileService extends BaseService { extension = config.getMimeRepository() .getRegisteredMimeType(fileEntity.getMimeType()) - .getExtension().replace(".", ""); + .getExtension() + .replace(".", ""); } } catch (Exception e) { log.warn("获取文件扩展名失败", e); @@ -224,11 +225,8 @@ public class FileService extends BaseService { } @SneakyThrows - public FileDto upload( - InputStream file, - String name, - String dir) { - return upload(file, name, dir, null, null, null); + public FileDto upload(InputStream file, String name, String dir, String organizationId) { + return upload(file, name, dir, null, null, null, organizationId); } @SneakyThrows @@ -239,11 +237,27 @@ public class FileService extends BaseService { String sortKey, String code, String remarks) { + return upload(file, name, dir, sortKey, code, remarks, null); + } + + @SneakyThrows + public FileDto upload( + InputStream file, + String name, + String dir, + String sortKey, + String code, + String remarks, + String organizationId) { FileEntity fileEntity = new FileEntity(); fileEntity.setFileName(name); fileEntity.setFileSize(Long.valueOf(file.available())); fileEntity.setCode(code); fileEntity.setRemarks(remarks); + if (organizationId != null) { + + fileEntity.setOrganizationId(organizationId); + } try { fileEntity.setSortKey(Integer.parseInt(sortKey)); diff --git a/src/main/java/cn/lihongjie/coal/invoice/service/InvoiceService.java b/src/main/java/cn/lihongjie/coal/invoice/service/InvoiceService.java index c4daa744..4fe61f77 100644 --- a/src/main/java/cn/lihongjie/coal/invoice/service/InvoiceService.java +++ b/src/main/java/cn/lihongjie/coal/invoice/service/InvoiceService.java @@ -39,6 +39,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.io.InputStream; +import java.util.Optional; @Service @Slf4j @@ -120,7 +121,7 @@ public class InvoiceService extends BaseService one = this.repository.findOne( new Specification() { @Override public Predicate toPredicate( @@ -138,6 +139,12 @@ public class InvoiceService extends BaseService