第三期装柜验收优化修改

This commit is contained in:
2026-08-12 13:34:26 +08:00
parent d2704f68a6
commit c2b1ab92ff
27 changed files with 258 additions and 71 deletions
@@ -83,6 +83,15 @@ public class InternalPalletLocationController {
return ApiResponse.success(service.settle(request));
}
@GetMapping("/settlements/target")
@Operation(summary = "查询 PDA 结算目标", description = "跨服务补偿时复用已登记的子入库单资源 ID")
public ApiResponse<Long> settlementTarget(
@RequestHeader(value = "X-Internal-Service-Token", required = false) String token,
@RequestParam long sourceBusinessId, @RequestParam String idempotencyKey) {
verify(token);
return ApiResponse.success(service.settlementTarget(sourceBusinessId, idempotencyKey));
}
@GetMapping("/occupied-resources")
@Operation(summary = "查询业务当前占用资源", description = "PDA提交前使用的只读实时库存事实")
public ApiResponse<List<LocationDtos.OccupiedResource>> occupiedResources(
@@ -30,6 +30,13 @@ public interface PalletLocationSettlementOperationMapper extends BaseMapper<Pall
@Param("sourceService") String sourceService, @Param("sourceBusinessId") long sourceBusinessId,
@Param("idempotencyKey") String idempotencyKey);
@Select("SELECT target_business_id FROM wh_pallet_location_settlement_operation "
+ "WHERE tenant_id = #{tenantId} AND source_service = #{sourceService} "
+ "AND source_business_id = #{sourceBusinessId} AND idempotency_key = #{idempotencyKey} LIMIT 1")
Long findTargetBusinessId(@Param("tenantId") long tenantId, @Param("sourceService") String sourceService,
@Param("sourceBusinessId") long sourceBusinessId,
@Param("idempotencyKey") String idempotencyKey);
@Update("""
UPDATE wh_pallet_location_settlement_operation
SET operation_status = 'COMPLETED', response_snapshot = #{responseSnapshot},
@@ -31,6 +31,11 @@ public class PalletLocationSettlementOperationRepository {
return mapper.lockByKey(PLATFORM_RESOURCE_TENANT_ID, FIRSTLEG_SOURCE_SERVICE, sourceBusinessId, idempotencyKey);
}
public Long findTargetBusinessId(long sourceBusinessId, String idempotencyKey) {
return mapper.findTargetBusinessId(PLATFORM_RESOURCE_TENANT_ID, FIRSTLEG_SOURCE_SERVICE,
sourceBusinessId, idempotencyKey);
}
public void complete(long id, String responseSnapshot) {
mapper.complete(id, responseSnapshot);
}
@@ -238,6 +238,14 @@ public class PalletLocationAllocationService {
return result;
}
/** 查询已创建的结算目标,供头程在跨服务事务回滚后恢复同一子入库单 ID。 */
public Long settlementTarget(long sourceBusinessId, String idempotencyKey) {
if (sourceBusinessId < 1 || idempotencyKey == null || idempotencyKey.isBlank()) {
throw new BizException(ResultCode.BAD_REQUEST, "结算查询参数不能为空");
}
return settlementOperations.findTargetBusinessId(sourceBusinessId, idempotencyKey.trim());
}
@Transactional
@BusinessAudit(event = "PALLET_LOCATION_REBIND_TEMPORARY", resourceType = "LOCATION_OCCUPANCY",
resourceId = "#request.occupancyId", description = "A0临时库位换绑到普通库位")