From 842155bfbd16915692cba4519b6255d2647c6789 Mon Sep 17 00:00:00 2001 From: chenbowen Date: Wed, 3 Dec 2025 12:09:14 +0800 Subject: [PATCH] =?UTF-8?q?1.=20iwork=20=E5=9B=9E=E8=B0=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=B8=8D=E5=B8=A6=E7=A7=9F=E6=88=B7=E4=B8=8E=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E9=99=90=E5=88=B6=EF=BC=8C=E6=94=AF=E6=8C=81=E9=80=9A?= =?UTF-8?q?=E8=BF=87=E4=B8=9A=E5=8A=A1=E7=BC=96=E5=8F=B7=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E9=99=84=E4=BB=B6=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../businessfile/dto/BusinessFileRespDTO.java | 5 +++++ .../businessfile/vo/BusinessFileRespVO.java | 4 ++++ .../businessfile/BusinessFileDO.java | 5 +++++ .../businessfile/BusinessFileServiceImpl.java | 2 ++ .../iwork/IWorkIntegrationController.java | 4 +++- .../impl/IWorkIntegrationServiceImpl.java | 20 +++++++++++++++---- 6 files changed, 35 insertions(+), 5 deletions(-) diff --git a/zt-module-infra/zt-module-infra-api/src/main/java/com/zt/plat/module/infra/api/businessfile/dto/BusinessFileRespDTO.java b/zt-module-infra/zt-module-infra-api/src/main/java/com/zt/plat/module/infra/api/businessfile/dto/BusinessFileRespDTO.java index 82605536..d6f33774 100644 --- a/zt-module-infra/zt-module-infra-api/src/main/java/com/zt/plat/module/infra/api/businessfile/dto/BusinessFileRespDTO.java +++ b/zt-module-infra/zt-module-infra-api/src/main/java/com/zt/plat/module/infra/api/businessfile/dto/BusinessFileRespDTO.java @@ -24,6 +24,11 @@ public class BusinessFileRespDTO implements Serializable { */ private Long id; + /** + * 租户编号 + */ + private Long tenantId; + /** * 业务Id */ diff --git a/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/controller/admin/businessfile/vo/BusinessFileRespVO.java b/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/controller/admin/businessfile/vo/BusinessFileRespVO.java index c9990c42..a99ec881 100644 --- a/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/controller/admin/businessfile/vo/BusinessFileRespVO.java +++ b/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/controller/admin/businessfile/vo/BusinessFileRespVO.java @@ -16,6 +16,10 @@ public class BusinessFileRespVO { @ExcelProperty("主键ID") private Long id; + @Schema(description = "租户编号", example = "1024") + @ExcelProperty("租户编号") + private Long tenantId; + @Schema(description = "业务Id", requiredMode = Schema.RequiredMode.REQUIRED, example = "24322") @ExcelProperty("业务Id") private Long businessId; diff --git a/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/dal/dataobject/businessfile/BusinessFileDO.java b/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/dal/dataobject/businessfile/BusinessFileDO.java index 84df46e9..4c067913 100644 --- a/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/dal/dataobject/businessfile/BusinessFileDO.java +++ b/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/dal/dataobject/businessfile/BusinessFileDO.java @@ -24,6 +24,11 @@ public class BusinessFileDO extends BaseDO { @TableId(type = IdType.ASSIGN_ID) private Long id; /** + * 租户编号 + */ + @TableField("TENANT_ID") + private Long tenantId; + /** * 业务Id */ @TableField("BSN_ID") diff --git a/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/service/businessfile/BusinessFileServiceImpl.java b/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/service/businessfile/BusinessFileServiceImpl.java index 4a30d7fa..92722f96 100644 --- a/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/service/businessfile/BusinessFileServiceImpl.java +++ b/zt-module-infra/zt-module-infra-server/src/main/java/com/zt/plat/module/infra/service/businessfile/BusinessFileServiceImpl.java @@ -5,6 +5,7 @@ import com.zt.plat.framework.common.pojo.PageResult; import com.zt.plat.framework.common.util.object.BeanUtils; import com.zt.plat.framework.common.util.user.UserNameEnrichUtils; import com.zt.plat.framework.mybatis.core.query.LambdaQueryWrapperX; +import com.zt.plat.framework.tenant.core.aop.TenantIgnore; import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFilePageReqVO; import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFileRespVO; import com.zt.plat.module.infra.controller.admin.businessfile.vo.BusinessFileSaveReqVO; @@ -101,6 +102,7 @@ public class BusinessFileServiceImpl implements BusinessFileService { } @Override + @TenantIgnore public BusinessFileDO getBusinessFileByBusinessCode(String businessCode) { if (!StringUtils.hasText(businessCode)) { throw exception(BUSINESS_FILE_NOT_EXISTS); diff --git a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/controller/admin/integration/iwork/IWorkIntegrationController.java b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/controller/admin/integration/iwork/IWorkIntegrationController.java index fb69b185..e69863fe 100644 --- a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/controller/admin/integration/iwork/IWorkIntegrationController.java +++ b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/controller/admin/integration/iwork/IWorkIntegrationController.java @@ -1,12 +1,14 @@ package com.zt.plat.module.system.controller.admin.integration.iwork; import com.zt.plat.framework.common.pojo.CommonResult; +import com.zt.plat.framework.tenant.core.aop.TenantIgnore; import com.zt.plat.module.system.controller.admin.integration.iwork.vo.*; import com.zt.plat.module.system.service.integration.iwork.IWorkIntegrationService; import com.zt.plat.module.system.service.integration.iwork.IWorkOrgRestService; import com.zt.plat.module.system.service.integration.iwork.IWorkSyncService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.security.PermitAll; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; @@ -14,7 +16,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import jakarta.annotation.security.PermitAll; import static com.zt.plat.framework.common.pojo.CommonResult.success; @@ -57,6 +58,7 @@ public class IWorkIntegrationController { } @PermitAll + @TenantIgnore @PostMapping("/callback/file") @Operation(summary = "iWork 文件回调:根据文件 URL 保存为附件并创建业务附件关联") public CommonResult callbackFile(@Valid @RequestBody IWorkFileCallbackReqVO reqVO) { diff --git a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkIntegrationServiceImpl.java b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkIntegrationServiceImpl.java index d1d7108a..c3a7a5cd 100644 --- a/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkIntegrationServiceImpl.java +++ b/zt-module-system/zt-module-system-server/src/main/java/com/zt/plat/module/system/service/integration/iwork/impl/IWorkIntegrationServiceImpl.java @@ -19,6 +19,7 @@ import com.zt.plat.module.infra.api.file.dto.FileRespDTO; import com.zt.plat.module.system.controller.admin.integration.iwork.vo.*; import com.zt.plat.module.system.framework.integration.iwork.config.IWorkProperties; import com.zt.plat.module.system.service.integration.iwork.IWorkIntegrationService; +import com.zt.plat.framework.tenant.core.util.TenantUtils; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -37,6 +38,7 @@ import java.security.*; import java.security.spec.X509EncodedKeySpec; import java.time.Instant; import java.util.*; +import java.util.concurrent.atomic.AtomicReference; import static com.zt.plat.module.system.service.integration.iwork.IWorkIntegrationErrorCodeConstants.*; @@ -171,11 +173,21 @@ public class IWorkIntegrationServiceImpl implements IWorkIntegrationService { } BusinessFileRespDTO referenceBusinessFile = loadBusinessFileByBusinessCode(businessCode); + Long tenantId = referenceBusinessFile.getTenantId(); + if (tenantId == null) { + throw new ServiceException(IWORK_CONFIGURATION_INVALID.getCode(), "业务附件缺少租户信息,无法创建回调附件: " + businessCode); + } + + AtomicReference attachmentIdRef = new AtomicReference<>(); + TenantUtils.execute(tenantId, () -> attachmentIdRef.set(saveCallbackAttachment(fileUrl, reqVO.getFileName(), referenceBusinessFile))); + return attachmentIdRef.get(); + } + + private Long saveCallbackAttachment(String fileUrl, String overrideFileName, BusinessFileRespDTO referenceBusinessFile) { Long businessId = referenceBusinessFile.getBusinessId(); - // 通过文件 API 创建文件 FileCreateReqDTO fileCreateReqDTO = new FileCreateReqDTO(); - fileCreateReqDTO.setName(resolveFileName(reqVO.getFileName(), fileUrl)); + fileCreateReqDTO.setName(resolveFileName(overrideFileName, fileUrl)); fileCreateReqDTO.setDirectory(null); fileCreateReqDTO.setType(null); fileCreateReqDTO.setContent(downloadFileBytes(fileUrl)); @@ -188,8 +200,8 @@ public class IWorkIntegrationServiceImpl implements IWorkIntegrationService { Long fileId = fileResult.getData().getId(); BusinessFileSaveReqDTO businessReq = BusinessFileSaveReqDTO.builder() - .businessId(businessId) - .businessCode(referenceBusinessFile.getBusinessCode()) + .businessId(businessId) + .businessCode(referenceBusinessFile.getBusinessCode()) .fileId(fileId) .fileName(fileResult.getData().getName()) .source("iwork")