test: automate overseas wallet and pallet cost closure

This commit is contained in:
2026-09-06 11:00:06 +08:00
parent 64bf5aa0fe
commit 20b3074cb1
21 changed files with 506 additions and 103 deletions
@@ -22,13 +22,14 @@ import java.util.Map;
@Service
@RequiredArgsConstructor
public class DestuffingPalletCostService {
static final String READY_BOOKINGS_SQL = "SELECT o.source_container_booking_id FROM ll_inbound_plan p JOIN ll_order o ON o.id=p.source_order_id JOIN ll_inbound_pda_task t ON t.plan_id=p.id AND t.customer_id=p.customer_id LEFT JOIN ll_destuff_pallet_cost c ON c.source_container_booking_id=o.source_container_booking_id WHERE o.source_container_booking_id IS NOT NULL AND c.id IS NULL GROUP BY o.source_container_booking_id HAVING COUNT(*)=SUM(CASE WHEN t.status='COMPLETED' THEN 1 ELSE 0 END) ORDER BY MAX(t.completed_at) DESC LIMIT 50";
private final JdbcTemplate jdbc;
private final PalletPhysicalGateway pallets;
private final OverseasFeeSourceMapper feeSources;
private final OverseasFeeOutboxService feeOutbox;
public List<String> readyBookingIds() {
return jdbc.queryForList("SELECT o.source_container_booking_id FROM ll_inbound_plan p JOIN ll_order o ON o.id=p.source_order_id JOIN ll_inbound_pda_task t ON t.plan_id=p.id AND t.customer_id=p.customer_id LEFT JOIN ll_destuff_pallet_cost c ON c.source_container_booking_id=o.source_container_booking_id WHERE o.source_container_booking_id IS NOT NULL AND c.id IS NULL GROUP BY o.source_container_booking_id HAVING COUNT(*)=SUM(CASE WHEN t.status='COMPLETED' THEN 1 ELSE 0 END) ORDER BY MIN(t.completed_at) LIMIT 50", String.class);
return jdbc.queryForList(READY_BOOKINGS_SQL, String.class);
}
@Transactional
@@ -18,13 +18,15 @@ import org.springframework.web.server.ResponseStatusException;
@Component
@RequiredArgsConstructor
public class HttpProcurementFileGateway implements ProcurementFileGateway {
private final RestClient.Builder builder;
private final LastlegRestClientFactory factory;
private final LastlegRestClientProperties properties;
private final RestClient.Builder restClientBuilder;
private final LastlegRestClientFactory restClientFactory;
private final LastlegRestClientProperties restClientProperties;
@Value("${baiyue.clients.file.url:http://127.0.0.1:9205}") private String baseUrl;
@Value("${baiyue.security.internal-service-token:}") private String token;
private RestClient client;
@PostConstruct void initialize() { client = factory.build(builder, baseUrl, properties.getProcurementFile()); }
@PostConstruct void initialize() {
client = restClientFactory.build(restClientBuilder, baseUrl, restClientProperties.getProcurementFile());
}
@Override
public UploadedFile upload(String customerId, long orderId, long operatorId, String category, MultipartFile file) {