test: automate overseas wallet and pallet cost closure
This commit is contained in:
+2
-1
@@ -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
|
||||
|
||||
+6
-4
@@ -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) {
|
||||
|
||||
@@ -56,6 +56,9 @@ baiyue:
|
||||
customer-visit-file:
|
||||
connect-timeout: ${LASTLEG_CUSTOMER_VISIT_FILE_CONNECT_TIMEOUT:3s}
|
||||
read-timeout: ${LASTLEG_CUSTOMER_VISIT_FILE_READ_TIMEOUT:30s}
|
||||
procurement-file:
|
||||
connect-timeout: ${LASTLEG_PROCUREMENT_FILE_CONNECT_TIMEOUT:3s}
|
||||
read-timeout: ${LASTLEG_PROCUREMENT_FILE_READ_TIMEOUT:30s}
|
||||
warehouse-resource:
|
||||
connect-timeout: ${LASTLEG_WAREHOUSE_RESOURCE_CONNECT_TIMEOUT:3s}
|
||||
read-timeout: ${LASTLEG_WAREHOUSE_RESOURCE_READ_TIMEOUT:5s}
|
||||
|
||||
+5
@@ -7,6 +7,11 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
|
||||
class DestuffingPalletCostServiceTest {
|
||||
@Test void newestCompletedBookingsAreNotStarvedByOldUnbillableRows() {
|
||||
assertThat(DestuffingPalletCostService.READY_BOOKINGS_SQL)
|
||||
.contains("ORDER BY MAX(t.completed_at) DESC LIMIT 50")
|
||||
.doesNotContain("ORDER BY MIN(t.completed_at)");
|
||||
}
|
||||
@Test void preservesTotalAndLetsFinalCustomerAbsorbRoundingRemainder() {
|
||||
List<BigDecimal> result = DestuffingPalletCostService.allocate(new BigDecimal("10.00"),
|
||||
List.of(new BigDecimal("1"), new BigDecimal("1"), new BigDecimal("1")));
|
||||
|
||||
Reference in New Issue
Block a user