feat(file-print): support ocean booking documents

This commit is contained in:
2026-08-31 19:30:37 +08:00
parent 01385c4bc7
commit 47ce84d122
17 changed files with 418 additions and 49 deletions
@@ -8,6 +8,7 @@ import java.util.Arrays;
/** File-owned storage policy. Business visibility and lifecycle remain in the calling service. */
enum BusinessFileCategory {
TRUCK_APPOINTMENT_ATTACHMENT(false, false),
OCEAN_BOOKING_DOCUMENT(true, false),
CUSTOMS_DOCUMENT(false, false),
CUSTOMS_RECEIPT(false, false),
FINANCE_VOUCHER(false, false),
@@ -93,11 +93,12 @@ public class InternalBusinessFileService {
}
private static Metadata metadata(FileObjectEntity value) {
return new Metadata(value.getId(), value.getTenantId(), value.getBusinessType(), value.getBusinessId(),
return new Metadata(value.getId(), value.getTenantId() == 0 ? "PLATFORM" : "CUSTOMER",
value.getTenantId(), value.getBusinessType(), value.getBusinessId(),
value.getOriginalName(), value.getSha256(), value.getContentType(), value.getSizeBytes());
}
public record Metadata(Long fileId, Long tenantId, String businessType, String businessId,
public record Metadata(Long fileId, String ownerScope, Long tenantId, String businessType, String businessId,
String fileName, String sha256, String contentType, Long sizeBytes) {}
public record Download(String fileName, String contentType, byte[] content) {}
}
@@ -107,9 +107,10 @@ components:
data: {$ref: '#/components/schemas/BusinessFileMetadata'}
BusinessFileMetadata:
type: object
required: [fileId, tenantId, businessType, businessId, fileName, sha256, contentType, sizeBytes]
required: [fileId, ownerScope, tenantId, businessType, businessId, fileName, sha256, contentType, sizeBytes]
properties:
fileId: {type: string, description: File不可变对象ID,跨前端按字符串传输}
ownerScope: {type: string, enum: [CUSTOMER]}
tenantId: {type: string, description: CUSTOMER owner scope客户ID}
businessType: {type: string, description: fileCategory}
businessId: {type: string, description: loadingPlanId}
@@ -0,0 +1,112 @@
openapi: 3.0.3
info:
title: Ocean Booking Document Internal API
version: 1.0.0
description: >-
订舱文件归属订舱聚合,不归属拖车。固定ownerScope=CUSTOMER、tenantId=订舱customerId、
businessType=OCEAN_BOOKING_DOCUMENT、businessId=oceanBookingId。BOOKING_CONFIRMATION与
BILL_OF_LADING文档类型、版本和有效状态归Firstleg;File不判断订舱业务状态。
x-firstleg-document-types: [BOOKING_CONFIRMATION, BILL_OF_LADING]
paths:
/internal/file/v1/business-files/{tenantId}/OCEAN_BOOKING_DOCUMENT/{oceanBookingId}:
post:
summary: Firstleg上传订舱附件
security: [{internalServiceToken: []}]
parameters:
- {$ref: '#/components/parameters/OperatorId'}
- {$ref: '#/components/parameters/TenantId'}
- {$ref: '#/components/parameters/OceanBookingId'}
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
required: [file]
properties:
file:
type: string
format: binary
description: TXT/PDF/JPG/PNG,最大10MiB
responses:
'200': {$ref: '#/components/responses/Metadata'}
/internal/file/v1/business-files/{tenantId}/OCEAN_BOOKING_DOCUMENT/{oceanBookingId}/{fileId}:
get:
summary: Firstleg校验订舱附件元数据
security: [{internalServiceToken: []}]
parameters:
- {$ref: '#/components/parameters/TenantId'}
- {$ref: '#/components/parameters/OceanBookingId'}
- {$ref: '#/components/parameters/FileId'}
responses:
'200': {$ref: '#/components/responses/Metadata'}
/internal/file/v1/business-files/{tenantId}/OCEAN_BOOKING_DOCUMENT/{oceanBookingId}/{fileId}/content:
get:
summary: Firstleg下载订舱附件
security: [{internalServiceToken: []}]
parameters:
- {$ref: '#/components/parameters/TenantId'}
- {$ref: '#/components/parameters/OceanBookingId'}
- {$ref: '#/components/parameters/FileId'}
responses:
'200':
description: 附件内容;错误订舱ID、拖车业务类型或文件ID不得命中
headers:
Cache-Control: {schema: {type: string, enum: [no-store]}}
content:
application/octet-stream: {schema: {type: string, format: binary}}
components:
securitySchemes:
internalServiceToken: {type: apiKey, in: header, name: X-Internal-Service-Token}
parameters:
OperatorId:
name: X-Operator-Id
in: header
required: true
schema: {$ref: '#/components/schemas/Id'}
TenantId:
name: tenantId
in: path
required: true
description: 订舱customerId
schema: {$ref: '#/components/schemas/Id'}
OceanBookingId:
name: oceanBookingId
in: path
required: true
schema: {$ref: '#/components/schemas/Id'}
FileId:
name: fileId
in: path
required: true
schema: {$ref: '#/components/schemas/Id'}
responses:
Metadata:
description: 精确订舱归属元数据
content:
application/json:
schema:
type: object
required: [code, data]
properties:
code: {type: string, enum: ['200']}
data: {$ref: '#/components/schemas/Metadata'}
schemas:
Id: {type: string, pattern: '^[1-9][0-9]*$'}
Metadata:
type: object
required: [fileId, ownerScope, tenantId, businessType, businessId, fileName, sha256, contentType, sizeBytes]
properties:
fileId: {$ref: '#/components/schemas/Id'}
ownerScope: {type: string, enum: [CUSTOMER]}
tenantId:
allOf: [{$ref: '#/components/schemas/Id'}]
description: 订舱customerId
businessType: {type: string, enum: [OCEAN_BOOKING_DOCUMENT]}
businessId:
allOf: [{$ref: '#/components/schemas/Id'}]
description: oceanBookingId
fileName: {type: string}
sha256: {type: string, pattern: '^[0-9a-f]{64}$'}
contentType: {type: string, enum: [text/plain, application/pdf, image/jpeg, image/png]}
sizeBytes: {type: integer, format: int64, minimum: 1, maximum: 10485760}