fix(firstleg): defer PDA allocation release transition

This commit is contained in:
2026-08-10 18:00:24 +08:00
parent 84209bffd7
commit 3bfc11a94d
2 changed files with 23 additions and 4 deletions
@@ -24,10 +24,11 @@ public interface InboundPalletAllocationMapper extends BaseMapper<InboundPalletA
@Update("""
UPDATE fl_inbound_pallet_allocation
SET picked_package_count = picked_package_count + #{count},
allocation_status = CASE
WHEN picked_package_count + #{count} = allocated_package_count THEN 'RELEASED'
ELSE 'CONFIRMED'
END,
/* Keep the snapshot confirmed until the atomic warehouse release
succeeds. markReleased is the single owner of this transition;
changing it here makes the subsequent idempotent release update
affect zero rows and surfaces as S0500 from PDA pick. */
allocation_status = 'CONFIRMED',
updated_at = CURRENT_TIMESTAMP(3)
WHERE id = #{id}
AND tenant_id = #{tenantId}
@@ -1,6 +1,7 @@
package com.baiyue.firstleg.repository;
import com.baiyue.firstleg.mapper.InboundSplitSettlementMapper;
import com.baiyue.firstleg.mapper.InboundPalletAllocationMapper;
import com.baiyue.firstleg.mapper.SmartLoadingCandidateMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
@@ -89,4 +90,21 @@ class PdaSplitSettlementSqlContractTest {
.getAnnotation(Update.class).value()[0];
assertThat(markRoot).contains("process_status IN ('INBOUNDED','LOADING')");
}
@Test
void keepsAllocationConfirmedUntilReleaseStep() throws Exception {
String consume = InboundPalletAllocationMapper.class.getMethod("consume",
long.class, long.class, long.class, int.class)
.getAnnotation(Update.class).value()[0];
assertThat(consume)
.contains("allocation_status = 'CONFIRMED'")
.doesNotContain("THEN 'RELEASED'");
String release = InboundPalletAllocationMapper.class.getMethod("markReleased",
long.class, long.class, long.class)
.getAnnotation(Update.class).value()[0];
assertThat(release)
.contains("allocation_status = 'RELEASED'")
.contains("allocation_status = 'CONFIRMED'");
}
}