fix(lastleg): keep unconfirmed container resources recoverable
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
package com.baiyue.lastleg.inboundplan.mapper;
|
||||
|
||||
import com.baiyue.lastleg.dto.LastlegOrderRequests;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.scripting.xmltags.XMLLanguageDriver;
|
||||
import org.apache.ibatis.session.Configuration;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import java.util.Map;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
class UnconfirmedContainerResourcesContractTest {
|
||||
@Test
|
||||
void localPalletRowsCannotHideAnUnconfirmedCommandInPreviewOrCabinetCandidate() throws Exception {
|
||||
String preview = String.join("", InboundPlanOrderMapper.class.getMethod("containerPreviewOrders", String.class)
|
||||
.getAnnotation(Select.class).value());
|
||||
String progress = String.join("", LastlegOrderMapper.class.getMethod("pageContainerProgress",
|
||||
LastlegOrderRequests.ContainerProgressQuery.class, long.class, long.class).getAnnotation(Select.class).value());
|
||||
for (String sql : new String[]{preview, progress}) {
|
||||
assertTrue(sql.contains("JSON_TABLE"));
|
||||
assertTrue(sql.contains("rc.status='LOCAL_COMMITTED'"));
|
||||
assertTrue(sql.contains("resource_item.plan_id=p.id"));
|
||||
assertTrue(sql.contains("CAST(resource_item.customer_id AS BINARY)=CAST(p.customer_id AS BINARY)"));
|
||||
assertTrue(sql.contains("rc.source_container_booking_id=o.source_container_booking_id"));
|
||||
assertFalse(sql.contains("rc.status='COMPLETED'"));
|
||||
}
|
||||
assertTrue(preview.contains("AND NOT EXISTS"));
|
||||
String rendered = new XMLLanguageDriver().createSqlSource(new Configuration(), progress, Map.class)
|
||||
.getBoundSql(Map.of("q", new LastlegOrderRequests.ContainerProgressQuery(1,20,null,null,null),
|
||||
"limit",20L,"offset",0L)).getSql();
|
||||
assertTrue(rendered.contains("JSON_TABLE"));
|
||||
assertFalse(rendered.contains("<"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void pdaResourceGateUsesTheExactPlanAndCustomerRatherThanEveryPlanInTheCabinet() throws Exception {
|
||||
String sql = String.join("", InboundPlanMapper.class.getMethod("countUnconfirmedResourcePlans", String.class, long.class)
|
||||
.getAnnotation(Select.class).value());
|
||||
assertTrue(sql.contains("p.customer_id=#{customerId}"));
|
||||
assertTrue(sql.contains("p.id=#{planId}"));
|
||||
assertTrue(sql.contains("resource_item.plan_id=p.id"));
|
||||
assertTrue(sql.contains("CAST(resource_item.customer_id AS BINARY)=CAST(p.customer_id AS BINARY)"));
|
||||
assertFalse(sql.contains("CAST(resource_item.customer_id AS UNSIGNED)"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user