fix: complete phase4 receiving acceptance chain
This commit is contained in:
+4
@@ -1,6 +1,8 @@
|
||||
package com.baiyue.lastleg.inboundplan.pda.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.Version;
|
||||
@@ -19,7 +21,9 @@ public class ReceivingContainerSession {
|
||||
private String overseasWarehouseName;
|
||||
private String operatorKey;
|
||||
private String operatorName;
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String activeOperatorKey;
|
||||
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||
private String activeContainerKey;
|
||||
private String status;
|
||||
private String signPhotos;
|
||||
|
||||
+12
-2
@@ -201,10 +201,15 @@ public class ReceivingContainerService {
|
||||
ReceivingContainerRequests.CartonResolve request) {
|
||||
ReceivingContainerSession session = requireSigned(operatorKey);
|
||||
String customerId = session.getCustomerId();
|
||||
List<InboundRef> currentRefs = refs(customerId, session.getContainerNo());
|
||||
if (currentRefs.stream().noneMatch(value ->
|
||||
"OVERSEAS".equals(destinationType(value.line(), value.order())))) {
|
||||
throw conflict("FBA destination must use bulk count");
|
||||
}
|
||||
InboundPlanCarton carton = cartons.selectOne(new LambdaQueryWrapper<InboundPlanCarton>()
|
||||
.eq(InboundPlanCarton::getCustomerId, customerId).eq(InboundPlanCarton::getCartonMark, request.cartonMark()));
|
||||
if (carton == null) throw notFound("Carton mark was not found");
|
||||
InboundRef ref = refs(customerId, session.getContainerNo()).stream()
|
||||
InboundRef ref = currentRefs.stream()
|
||||
.filter(value -> Objects.equals(value.line().getOrderId(), carton.getOrderId())).findFirst()
|
||||
.orElseThrow(() -> conflict("Carton mark belongs to another container"));
|
||||
if (!"OVERSEAS".equals(destinationType(ref.line(), ref.order()))) {
|
||||
@@ -285,10 +290,15 @@ public class ReceivingContainerService {
|
||||
if (replay != null) return read(replay, ReceivingContainerResponses.Receipt.class);
|
||||
ReceivingContainerSession session = requireSigned(operatorKey);
|
||||
String customerId = session.getCustomerId();
|
||||
List<InboundRef> currentRefs = refs(customerId, session.getContainerNo());
|
||||
if (currentRefs.stream().noneMatch(value ->
|
||||
"OVERSEAS".equals(destinationType(value.line(), value.order())))) {
|
||||
throw conflict("FBA destination must use bulk count");
|
||||
}
|
||||
InboundPlanCarton carton = cartons.selectOne(new LambdaQueryWrapper<InboundPlanCarton>()
|
||||
.eq(InboundPlanCarton::getCustomerId, customerId).eq(InboundPlanCarton::getCartonMark, request.cartonMark()));
|
||||
if (carton == null) throw notFound("Carton mark was not found");
|
||||
InboundRef ref = refs(customerId, session.getContainerNo()).stream()
|
||||
InboundRef ref = currentRefs.stream()
|
||||
.filter(value -> Objects.equals(value.line().getOrderId(), carton.getOrderId())).findFirst()
|
||||
.orElseThrow(() -> conflict("Carton mark belongs to another container"));
|
||||
if (!"OVERSEAS".equals(destinationType(ref.line(), ref.order()))) {
|
||||
|
||||
+13
@@ -1,7 +1,10 @@
|
||||
package com.baiyue.lastleg.inboundplan.pda;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baiyue.lastleg.inboundplan.pda.controller.ReceivingContainerController;
|
||||
import com.baiyue.lastleg.inboundplan.pda.dto.ReceivingContainerRequests;
|
||||
import com.baiyue.lastleg.inboundplan.pda.entity.ReceivingContainerSession;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import jakarta.validation.constraints.Size;
|
||||
@@ -46,6 +49,15 @@ class ReceivingContainerContractTest {
|
||||
assertTrue("hasAuthority('lastleg:pda:operate')".equals(permission.value()));
|
||||
}
|
||||
|
||||
@Test
|
||||
void completedSessionAlwaysPersistsClearedGlobalLockKeys() throws NoSuchFieldException {
|
||||
for (String fieldName : List.of("activeOperatorKey", "activeContainerKey")) {
|
||||
TableField field = ReceivingContainerSession.class.getDeclaredField(fieldName)
|
||||
.getAnnotation(TableField.class);
|
||||
assertTrue(field != null && field.updateStrategy() == FieldStrategy.ALWAYS, fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void schemaContainsCustomerScopedPlanChildrenAndGlobalPlatformPickerLocks() throws IOException {
|
||||
String schema = resource("db/lastleg.sql").toLowerCase();
|
||||
@@ -81,6 +93,7 @@ class ReceivingContainerContractTest {
|
||||
assertTrue(unified.contains("customer_id is null or a.customer_id=''"));
|
||||
assertTrue(unified.contains("signal sqlstate '45000'"));
|
||||
assertTrue(unified.contains("assert_receiving_global_locks_migratable"));
|
||||
assertTrue(unified.contains("where status='completed' and (active_operator_key is not null or active_container_key is not null)"));
|
||||
assertTrue(unified.contains("concat('operator:',operator_key)"));
|
||||
assertTrue(unified.contains("concat('container:',upper(trim(container_no)))"));
|
||||
assertTrue(unified.contains("assert_receiving_operation_global_key_migratable"));
|
||||
|
||||
+1
-2
@@ -172,11 +172,10 @@ class ReceivingContainerServiceBehaviorTest {
|
||||
|
||||
org.mockito.Mockito.reset(plans, lines, orders, sessions, operations, cartons, warehouse);
|
||||
stubCurrent("FBA", "CONT-A");
|
||||
InboundPlanCarton carton = carton(1L, "BOX-1");
|
||||
when(cartons.selectOne(any())).thenReturn(carton);
|
||||
assertThatThrownBy(() -> service.receiveCarton("7", "receiver",
|
||||
new ReceivingContainerRequests.CartonReceive("BOX-1", "PAL-1", "carton-key")))
|
||||
.isInstanceOf(ResponseStatusException.class).hasMessageContaining("409");
|
||||
verifyNoInteractions(cartons);
|
||||
verifyNoInteractions(warehouse);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user