优化
This commit is contained in:
+12
@@ -129,6 +129,18 @@ public class PlatformDropshipPalletizationController {
|
||||
return printService.generateDropshipPallet(pallet, task.inboundCode(), requestId);
|
||||
}
|
||||
|
||||
@GetMapping("/tasks/{taskId}/pallets/print")
|
||||
@PreAuthorize("hasAuthority('platform:firstleg:pda:view')")
|
||||
public ResponseEntity<byte[]> printTaskPallets(@AuthenticationPrincipal AuthenticatedUser user,
|
||||
@PathVariable @Positive long taskId,
|
||||
@RequestParam @Positive long warehouseId,
|
||||
@RequestHeader(value = "X-Request-Id", required = false) String requestId) {
|
||||
FirstlegScopeGuard.platform(user);
|
||||
Task task = service.task(taskId, warehouseId, user.userId());
|
||||
return printService.generateDropshipPallets(
|
||||
service.generatedPallets(taskId, warehouseId, user.userId()), task.inboundCode(), requestId);
|
||||
}
|
||||
|
||||
@GetMapping("/inbound-orders/{inboundId}/pallets")
|
||||
@PreAuthorize("hasAuthority('firstleg:inbound:list')")
|
||||
public ApiResponse<List<Pallet>> inboundPallets(@AuthenticationPrincipal AuthenticatedUser user,
|
||||
|
||||
@@ -67,10 +67,11 @@ public interface DropshipPalletizationMapper {
|
||||
PalletRow pallet(@Param("taskId") long taskId,@Param("palletId") long palletId,@Param("warehouseId") long warehouseId);
|
||||
@Select("""
|
||||
SELECT p.* FROM fl_dropship_pallet p
|
||||
WHERE p.task_id=#{taskId}
|
||||
OR EXISTS(SELECT 1 FROM fl_dropship_pallet_carton c WHERE c.pallet_id=p.id AND c.task_id=#{taskId})
|
||||
WHERE EXISTS(SELECT 1 FROM fl_dropship_pallet_carton c WHERE c.pallet_id=p.id AND c.task_id=#{taskId})
|
||||
ORDER BY p.id
|
||||
""") List<PalletRow> pallets(@Param("taskId") long taskId);
|
||||
@Select("SELECT * FROM fl_dropship_pallet WHERE task_id=#{taskId} ORDER BY id")
|
||||
List<PalletRow> generatedPallets(@Param("taskId") long taskId);
|
||||
@Select("""
|
||||
SELECT p.* FROM fl_dropship_pallet p
|
||||
WHERE ((p.tenant_id=#{tenantId} AND p.inbound_id=#{inboundId})
|
||||
|
||||
@@ -156,6 +156,12 @@ public class DropshipPalletizationService {
|
||||
return code;
|
||||
}
|
||||
|
||||
public List<Pallet> generatedPallets(long taskId,long warehouseId,long operatorId){
|
||||
TaskRow task=requireTask(taskId,warehouseId);
|
||||
if(task.getAssigneeId()!=null && task.getAssigneeId()!=operatorId) throw conflict("任务已由其他人员领取");
|
||||
return mapper.generatedPallets(taskId).stream().map(p->palletView(p,task.getInboundCode())).toList();
|
||||
}
|
||||
|
||||
private PalletRow requireAssignablePallet(TaskRow task,String palletNo){
|
||||
PalletRow existing=mapper.palletByNo(palletNo);
|
||||
if(existing==null) throw new BizException(ResultCode.NOT_FOUND,"托盘码不存在,请扫描测量审核后生成的 DP 托盘码");
|
||||
|
||||
+25
-9
@@ -117,6 +117,30 @@ public class InboundCartonLabelPrintService {
|
||||
|
||||
/** 一件代发 A4 托盘信息单:托盘号、Code 128 一维码和 SKU 归托明细。 */
|
||||
public ResponseEntity<byte[]> generateDropshipPallet(Pallet pallet, String inboundCode, String requestId) {
|
||||
return generateDropshipPallets(List.of(pallet), inboundCode, requestId);
|
||||
}
|
||||
|
||||
/** 一票预生成托盘码合并为一个多页 PDF,避免 PDA 展开或逐个下载大量空托盘。 */
|
||||
public ResponseEntity<byte[]> generateDropshipPallets(List<Pallet> pallets, String inboundCode, String requestId) {
|
||||
if (pallets == null || pallets.isEmpty()) {
|
||||
throw new BizException(ResultCode.CONFLICT, "托盘码尚未生成,不能打印");
|
||||
}
|
||||
List<PrintPdfClient.DropshipPalletDocument> documents = pallets.stream()
|
||||
.map(pallet -> dropshipPalletDocument(pallet, inboundCode)).toList();
|
||||
String fileName = pallets.size() == 1
|
||||
? pallets.get(0).palletNo() + "-A4托盘信息单.pdf"
|
||||
: inboundCode + "-" + pallets.size() + "托-A4托盘信息单.pdf";
|
||||
PrintPdfClient.DropshipPalletA4PdfRequest request = new PrintPdfClient.DropshipPalletA4PdfRequest(
|
||||
"DROPSHIP_PALLET_A4_V1", new PrintPdfClient.PageSpec(A4_WIDTH_MM, A4_HEIGHT_MM),
|
||||
fileName, documents);
|
||||
try {
|
||||
return requirePdf(printClient.generateDropshipPalletA4Documents(internalToken, requestId, request));
|
||||
} catch (FeignException | NoFallbackAvailableException exception) {
|
||||
throw new BizException(ResultCode.SERVICE_UNAVAILABLE, "打印服务暂不可用,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
private PrintPdfClient.DropshipPalletDocument dropshipPalletDocument(Pallet pallet, String inboundCode) {
|
||||
if (pallet == null || !StringUtils.hasText(pallet.palletNo())) {
|
||||
throw new BizException(ResultCode.CONFLICT, "托盘码尚未生成,不能打印");
|
||||
}
|
||||
@@ -127,17 +151,9 @@ public class InboundCartonLabelPrintService {
|
||||
.map(item -> new PrintPdfClient.DropshipPalletSkuRow(item.inboundCode(), item.skuCode(),
|
||||
item.cargoName(), number(item.cartonCount()), number(item.skuQuantity())))
|
||||
.toList();
|
||||
PrintPdfClient.DropshipPalletDocument document = new PrintPdfClient.DropshipPalletDocument(
|
||||
return new PrintPdfClient.DropshipPalletDocument(
|
||||
pallet.palletNo(), inboundCodes, number(pallet.cartonCount()), number(pallet.skuCount()),
|
||||
pallet.weightKg(), pallet.volumeCbm(), pallet.palletNo(), skuRows);
|
||||
PrintPdfClient.DropshipPalletA4PdfRequest request = new PrintPdfClient.DropshipPalletA4PdfRequest(
|
||||
"DROPSHIP_PALLET_A4_V1", new PrintPdfClient.PageSpec(A4_WIDTH_MM, A4_HEIGHT_MM),
|
||||
pallet.palletNo() + "-A4托盘信息单.pdf", List.of(document));
|
||||
try {
|
||||
return requirePdf(printClient.generateDropshipPalletA4Documents(internalToken, requestId, request));
|
||||
} catch (FeignException | NoFallbackAvailableException exception) {
|
||||
throw new BizException(ResultCode.SERVICE_UNAVAILABLE, "打印服务暂不可用,请稍后重试");
|
||||
}
|
||||
}
|
||||
|
||||
private int number(Integer value) {
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
openapi: 3.0.3
|
||||
info:
|
||||
title: Platform dashboard operational metrics
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/api/platform/v1/first-leg/dashboard/operational-metrics:
|
||||
get:
|
||||
summary: 查询首页货柜与清关实时指标
|
||||
description: >-
|
||||
在途柜量按已实际开船且尚未到达海外仓的有效物理柜去重,TEU 按 20*=1、40*=2、45*=2.25
|
||||
折算,未知箱型不计入 TEU;待清关票数按已进入整柜清关且清关未完成的去重订单统计。
|
||||
本接口只返回当前时点事实,不提供历史环比。
|
||||
responses:
|
||||
'200':
|
||||
description: 查询成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/OperationalMetricsEnvelope'
|
||||
'401': {description: 需要登录}
|
||||
'403': {description: 需要货柜列表与报关列表权限}
|
||||
components:
|
||||
schemas:
|
||||
OperationalMetricsEnvelope:
|
||||
type: object
|
||||
required: [code, message, data]
|
||||
properties:
|
||||
code: {type: string, example: '200'}
|
||||
message: {type: string}
|
||||
data: {$ref: '#/components/schemas/OperationalMetrics'}
|
||||
OperationalMetrics:
|
||||
type: object
|
||||
required:
|
||||
- inTransitContainerCount
|
||||
- inTransitTeu
|
||||
- unknownContainerTypeCount
|
||||
- pendingCustomsOrderCount
|
||||
properties:
|
||||
inTransitContainerCount:
|
||||
type: integer
|
||||
format: int64
|
||||
minimum: 0
|
||||
description: 已开船未到海外仓的物理柜数
|
||||
inTransitTeu:
|
||||
type: number
|
||||
format: decimal
|
||||
multipleOf: 0.01
|
||||
minimum: 0
|
||||
description: 已知箱型的在途柜 TEU 合计
|
||||
unknownContainerTypeCount:
|
||||
type: integer
|
||||
format: int64
|
||||
minimum: 0
|
||||
description: 未计入 TEU 的未知箱型在途柜数
|
||||
pendingCustomsOrderCount:
|
||||
type: integer
|
||||
format: int64
|
||||
minimum: 0
|
||||
description: 已进入整柜清关且清关未完成的去重订单数
|
||||
asOf:
|
||||
type: string
|
||||
format: date-time
|
||||
nullable: true
|
||||
description: 数据库统计时点
|
||||
@@ -76,6 +76,14 @@ paths:
|
||||
- {$ref: '#/components/parameters/WarehouseId'}
|
||||
responses:
|
||||
'200': {description: A4 托盘信息单 PDF, content: {application/pdf: {schema: {type: string, format: binary}}}}
|
||||
/api/platform/v1/first-leg/pda-dropship/tasks/{taskId}/pallets/print:
|
||||
get:
|
||||
summary: 合并获取本票全部预生成托盘码的多页 A4 PDF
|
||||
description: 每个预生成托盘固定一页,PDA 无需展开托盘列表或逐个下载,最多按本票预计托数生成。
|
||||
x-required-authority: platform:firstleg:pda:view
|
||||
parameters: [{$ref: '#/components/parameters/TaskId'}, {$ref: '#/components/parameters/WarehouseId'}]
|
||||
responses:
|
||||
'200': {description: 多页 A4 托盘信息单 PDF, content: {application/pdf: {schema: {type: string, format: binary}}}}
|
||||
/api/platform/v1/first-leg/pda-dropship/inbound-orders/{inboundId}/pallets:
|
||||
get:
|
||||
summary: Admin 查询入仓单权威托盘结果
|
||||
|
||||
Reference in New Issue
Block a user