修改提交
This commit is contained in:
@@ -10,6 +10,7 @@ public record LastlegOrderSummary(
|
||||
Long id,
|
||||
String orderNo,
|
||||
String orderType,
|
||||
String orderTypeName,
|
||||
String sourceInboundId,
|
||||
String inboundCode,
|
||||
String sourceOrderNo,
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.baiyue.lastleg.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("ll_inbound_order")
|
||||
public class LastlegInboundOrder {
|
||||
@TableId private Long id;
|
||||
private String tenantId;
|
||||
private String customerId;
|
||||
private String sourceRegion;
|
||||
private String sourceInboundId;
|
||||
private String rootInboundId;
|
||||
private String sourceOrderId;
|
||||
private String sourceOrderNo;
|
||||
private String rootOrderId;
|
||||
private String inboundCode;
|
||||
private String destinationWarehouseId;
|
||||
private String destinationWarehouseCode;
|
||||
private String destinationWarehouseName;
|
||||
private Integer packageCount;
|
||||
private Integer productQuantity;
|
||||
private Integer palletCount;
|
||||
private BigDecimal grossWeightKg;
|
||||
private BigDecimal netWeightKg;
|
||||
private BigDecimal volumeCbm;
|
||||
private String sourceEventId;
|
||||
private String sourceLoadingPlanId;
|
||||
private Long sourceLoadingPlanVersion;
|
||||
private Long handoverVersion;
|
||||
private String payloadHash;
|
||||
private String status;
|
||||
private String exceptionFlag;
|
||||
private LocalDateTime createdAt;
|
||||
private LocalDateTime updatedAt;
|
||||
}
|
||||
@@ -1,3 +1,12 @@
|
||||
package com.baiyue.lastleg.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import java.math.BigDecimal;
|
||||
@Data @TableName("ll_order_detail") public class LastlegOrderDetail { @TableId(type=IdType.AUTO) private Long id; private Long orderId; private String sourceInboundDetailId; private String skuCode; private String productNameZh; private String productNameEn; private Integer packageCount; private Integer productQuantity; private Integer palletCount; private BigDecimal grossWeightKg; private BigDecimal netWeightKg; private BigDecimal dimensionalWeightKg; private BigDecimal volumeCbm; private String destinationWarehouseId; private String destinationWarehouseCode; private String destinationWarehouseName; private String fbaTrackingNo; private String shipmentNo; private String shippingMark; }
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
@Data @TableName("ll_order_detail") public class LastlegOrderDetail {
|
||||
@TableId(type=IdType.AUTO) private Long id; private String customerId; private Long orderId;
|
||||
private String sourceInboundDetailId; private String skuCode; private String productNameZh; private String productNameEn;
|
||||
private Integer packageCount; private Integer productQuantity; private Integer palletCount; private BigDecimal grossWeightKg;
|
||||
private BigDecimal netWeightKg; private BigDecimal dimensionalWeightKg; private BigDecimal volumeCbm;
|
||||
private String destinationWarehouseId; private String destinationWarehouseCode; private String destinationWarehouseName;
|
||||
private String fbaTrackingNo; private String shipmentNo; private String shippingMark;
|
||||
}
|
||||
|
||||
+4
-1
@@ -1,3 +1,6 @@
|
||||
package com.baiyue.lastleg.entity;
|
||||
import com.baomidou.mybatisplus.annotation.*; import lombok.Data; import java.time.LocalDateTime;
|
||||
@Data @TableName("ll_loading_order_status_history") public class LastlegOrderStatusHistory { @TableId(type=IdType.AUTO) private Long id; private Long orderId; private String fromStatus; private String toStatus; private String eventId; private String remark; private LocalDateTime createdAt; }
|
||||
@Data @TableName("ll_loading_order_status_history") public class LastlegOrderStatusHistory {
|
||||
@TableId(type=IdType.AUTO) private Long id; private String customerId; private Long orderId;
|
||||
private String fromStatus; private String toStatus; private String eventId; private String remark; private LocalDateTime createdAt;
|
||||
}
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ import java.math.BigDecimal;
|
||||
public class InboundPlanLine {
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long id;
|
||||
private String customerId;
|
||||
private Long planId;
|
||||
private Long orderId;
|
||||
private String inboundCode;
|
||||
|
||||
+1
@@ -13,6 +13,7 @@ import java.time.LocalDateTime;
|
||||
public class InboundPlanPallet {
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long id;
|
||||
private String customerId;
|
||||
private Long planId;
|
||||
private String palletNo;
|
||||
private String destinationWarehouseId;
|
||||
|
||||
+1
@@ -12,6 +12,7 @@ import java.math.BigDecimal;
|
||||
public class InboundPlanPalletAllocation {
|
||||
@TableId(type = IdType.INPUT)
|
||||
private Long id;
|
||||
private String customerId;
|
||||
private Long planId;
|
||||
private Long lineId;
|
||||
private Long palletId;
|
||||
|
||||
+3
-3
@@ -43,8 +43,8 @@ public interface InboundPlanOrderMapper {
|
||||
@Param("planNo") String planNo, @Param("palletCount") int palletCount,
|
||||
@Param("updatedAt") LocalDateTime updatedAt);
|
||||
|
||||
@Insert("INSERT INTO ll_loading_order_status_history(order_id,from_status,to_status,remark,created_at) " +
|
||||
"VALUES(#{orderId},#{fromStatus},'INBOUND_PLANNED',#{remark},#{createdAt})")
|
||||
int insertHistory(@Param("orderId") Long orderId, @Param("fromStatus") String fromStatus,
|
||||
@Insert("INSERT INTO ll_loading_order_status_history(customer_id,order_id,from_status,to_status,remark,created_at) " +
|
||||
"VALUES(#{customerId},#{orderId},#{fromStatus},'INBOUND_PLANNED',#{remark},#{createdAt})")
|
||||
int insertHistory(@Param("customerId") String customerId, @Param("orderId") Long orderId, @Param("fromStatus") String fromStatus,
|
||||
@Param("remark") String remark, @Param("createdAt") LocalDateTime createdAt);
|
||||
}
|
||||
|
||||
+4
-1
@@ -108,7 +108,7 @@ public class InboundPlanService {
|
||||
if (orderMapper.markPlanned(customerId, order.orderId(), plan.getPlanNo(), count, now) != 1) {
|
||||
throw new IllegalStateException("Failed to update order " + order.orderId());
|
||||
}
|
||||
orderMapper.insertHistory(order.orderId(), order.currentStatus(),
|
||||
orderMapper.insertHistory(customerId, order.orderId(), order.currentStatus(),
|
||||
"Inbound order converted to inbound plan " + plan.getPlanNo(), now);
|
||||
}
|
||||
return detail(customerId, plan);
|
||||
@@ -158,6 +158,7 @@ public class InboundPlanService {
|
||||
for (SourceOrderSnapshot order : orders) {
|
||||
InboundPlanLine line = new InboundPlanLine();
|
||||
line.setId(IdWorker.getId());
|
||||
line.setCustomerId(order.customerId());
|
||||
line.setPlanId(plan.getId());
|
||||
line.setOrderId(order.orderId());
|
||||
line.setInboundCode(order.inboundCode());
|
||||
@@ -182,6 +183,7 @@ public class InboundPlanService {
|
||||
SourceOrderSnapshot sample = warehouseSamples.get(draft.warehouseKey());
|
||||
InboundPlanPallet pallet = new InboundPlanPallet();
|
||||
pallet.setId(IdWorker.getId());
|
||||
pallet.setCustomerId(plan.getCustomerId());
|
||||
pallet.setPlanId(plan.getId());
|
||||
pallet.setPalletNo(plan.getPlanNo() + "-P" + String.format("%03d", result.size() + 1));
|
||||
pallet.setDestinationWarehouseId(sample.destinationWarehouseId());
|
||||
@@ -205,6 +207,7 @@ public class InboundPlanService {
|
||||
for (PalletAllocator.AllocationDraft draft : allocation.allocations()) {
|
||||
InboundPlanPalletAllocation item = new InboundPlanPalletAllocation();
|
||||
item.setId(IdWorker.getId());
|
||||
item.setCustomerId(plan.getCustomerId());
|
||||
item.setPlanId(plan.getId());
|
||||
item.setLineId(lineByOrder.get(draft.orderId()).getId());
|
||||
item.setPalletId(pallets.get(draft.pallet()).getId());
|
||||
|
||||
+1
@@ -14,6 +14,7 @@ import java.time.LocalDateTime;
|
||||
public class LocalLooseboardOrder {
|
||||
@TableId(type = IdType.INPUT) private Long id;
|
||||
private String customerId;
|
||||
private Long lastlegOrderId;
|
||||
private String orderNo;
|
||||
private String transportMode;
|
||||
private String palletRequired;
|
||||
|
||||
+65
@@ -4,12 +4,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baiyue.common.core.api.PageResult;
|
||||
import com.baiyue.lastleg.entity.LastlegOrder;
|
||||
import com.baiyue.lastleg.entity.LastlegOrderStatusHistory;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderStatusHistoryMapper;
|
||||
import com.baiyue.lastleg.looseboard.dto.LocalLooseboardRequests;
|
||||
import com.baiyue.lastleg.looseboard.dto.LocalLooseboardResponses;
|
||||
import com.baiyue.lastleg.looseboard.entity.LocalLooseboardHistory;
|
||||
import com.baiyue.lastleg.looseboard.entity.LocalLooseboardOrder;
|
||||
import com.baiyue.lastleg.looseboard.mapper.LocalLooseboardHistoryMapper;
|
||||
import com.baiyue.lastleg.looseboard.mapper.LocalLooseboardOrderMapper;
|
||||
import com.baiyue.lastleg.service.LastlegOrderNoGenerator;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
@@ -46,6 +51,9 @@ public class LocalLooseboardService {
|
||||
|
||||
@Resource private LocalLooseboardOrderMapper orders;
|
||||
@Resource private LocalLooseboardHistoryMapper histories;
|
||||
@Resource private LastlegOrderMapper lastlegOrders;
|
||||
@Resource private LastlegOrderStatusHistoryMapper lastlegHistories;
|
||||
@Resource private LastlegOrderNoGenerator lastlegOrderNoGenerator;
|
||||
@Resource private ObjectMapper objectMapper;
|
||||
|
||||
@Transactional
|
||||
@@ -71,6 +79,8 @@ public class LocalLooseboardService {
|
||||
order.setVersion(0L);
|
||||
order.setCreatedAt(now);
|
||||
order.setUpdatedAt(now);
|
||||
LastlegOrder lastlegOrder = createLastlegOrder(order, requestHash, now);
|
||||
order.setLastlegOrderId(lastlegOrder.getId());
|
||||
try {
|
||||
orders.insert(order);
|
||||
} catch (DuplicateKeyException exception) {
|
||||
@@ -79,6 +89,8 @@ public class LocalLooseboardService {
|
||||
throw exception;
|
||||
}
|
||||
history(order, "CREATE", null, PENDING_ACCEPTANCE, operatorId, null, request.remark(), now);
|
||||
lastlegHistory(customerId, lastlegOrder.getId(), null, lastlegOrder.getCurrentStatus(),
|
||||
"Local looseboard order submitted", now);
|
||||
return detail(customerId, order.getOrderNo());
|
||||
}
|
||||
|
||||
@@ -147,6 +159,7 @@ public class LocalLooseboardService {
|
||||
order.setStatus(next);
|
||||
touch(order, now);
|
||||
orders.updateById(order);
|
||||
syncLastlegOrder(order, next, now);
|
||||
history(order, "STATUS", from, next, operatorId, null, request.remark(), now);
|
||||
return response(order);
|
||||
}
|
||||
@@ -220,6 +233,58 @@ public class LocalLooseboardService {
|
||||
histories.insert(history);
|
||||
}
|
||||
|
||||
private LastlegOrder createLastlegOrder(LocalLooseboardOrder source, String requestHash, LocalDateTime now) {
|
||||
LastlegOrder order = new LastlegOrder();
|
||||
order.setId(IdWorker.getId());
|
||||
order.setOrderNo(lastlegOrderNoGenerator.next());
|
||||
order.setCustomerId(source.getCustomerId());
|
||||
order.setOrderType("LOCAL_LOOSEBOARD");
|
||||
order.setInboundCode(source.getOrderNo());
|
||||
order.setSourceRegion("OVERSEAS_LOCAL");
|
||||
order.setSourceInboundId("LOCAL_LOOSEBOARD:" + source.getId());
|
||||
order.setSourceOrderId(String.valueOf(source.getId()));
|
||||
order.setSourceOrderNo(source.getOrderNo());
|
||||
order.setPalletCount(0);
|
||||
order.setPackageCount(Objects.requireNonNullElse(source.getPackageCount(), 0));
|
||||
order.setPickedPackageCount(0);
|
||||
order.setShippedPackageCount(0);
|
||||
order.setVolumeCbm(source.getTotalVolumeCbm());
|
||||
order.setCurrentStatus("PENDING_ASSIGNMENT");
|
||||
order.setSubOrderStatus("LOCAL_LOOSEBOARD:" + PENDING_ACCEPTANCE);
|
||||
order.setCustomerRemark(source.getRemark());
|
||||
order.setSourceEventId("LOCAL_LOOSEBOARD:" + source.getId());
|
||||
order.setSourceLoadingPlanId("LOCAL_LOOSEBOARD");
|
||||
order.setSourcePayloadHash("sha256:" + requestHash);
|
||||
order.setCreatedAt(now);
|
||||
order.setUpdatedAt(now);
|
||||
lastlegOrders.insert(order);
|
||||
return order;
|
||||
}
|
||||
|
||||
private void syncLastlegOrder(LocalLooseboardOrder source, String status, LocalDateTime now) {
|
||||
if (source.getLastlegOrderId() == null) return;
|
||||
LastlegOrder order = lastlegOrders.selectById(source.getLastlegOrderId());
|
||||
if (order == null || !source.getCustomerId().equals(order.getCustomerId())) {
|
||||
throw conflict("Linked tail-leg order is missing");
|
||||
}
|
||||
order.setSubOrderStatus("LOCAL_LOOSEBOARD:" + status);
|
||||
order.setUpdatedAt(now);
|
||||
lastlegOrders.updateById(order);
|
||||
}
|
||||
|
||||
private void lastlegHistory(String customerId, Long orderId, String from, String to, String remark,
|
||||
LocalDateTime now) {
|
||||
LastlegOrderStatusHistory history = new LastlegOrderStatusHistory();
|
||||
history.setCustomerId(customerId);
|
||||
history.setOrderId(orderId);
|
||||
history.setFromStatus(from);
|
||||
history.setToStatus(to);
|
||||
history.setEventId("LOCAL_LOOSEBOARD");
|
||||
history.setRemark(remark);
|
||||
history.setCreatedAt(now);
|
||||
lastlegHistories.insert(history);
|
||||
}
|
||||
|
||||
private void validateQuery(LocalLooseboardRequests.Query query) {
|
||||
if (StringUtils.hasText(query.status()) && !STATUSES.contains(norm(query.status()))) {
|
||||
throw badRequest("Unsupported looseboard order status");
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.baiyue.lastleg.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baiyue.lastleg.entity.LastlegInboundOrder;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface LastlegInboundOrderMapper extends BaseMapper<LastlegInboundOrder> {
|
||||
}
|
||||
@@ -24,4 +24,13 @@ public enum LastlegOrderType {
|
||||
public String label() {
|
||||
return label;
|
||||
}
|
||||
|
||||
public static String labelOf(String code) {
|
||||
if (code == null || code.isBlank()) return code;
|
||||
try {
|
||||
return valueOf(code.trim()).label;
|
||||
} catch (IllegalArgumentException exception) {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -118,7 +118,8 @@ public class RelabelApplicationService {
|
||||
|
||||
for (RelabelRequests.Item source : request.items()) insertItem(customerId, applicationId, source, now);
|
||||
insertHistory(customerId, applicationId, null, PENDING_PROCESSING, operatorId, "Relabel application submitted", now);
|
||||
insertOrderHistory(order.getId(), null, order.getCurrentStatus(), "Relabel application submitted", now);
|
||||
insertOrderHistory(customerId, order.getId(), null, order.getCurrentStatus(),
|
||||
"Relabel application submitted", now);
|
||||
return detail(customerId, relabelNo);
|
||||
}
|
||||
|
||||
@@ -194,7 +195,7 @@ public class RelabelApplicationService {
|
||||
orders.updateById(order);
|
||||
insertHistory(customerId, application.getId(), before, next, operatorId, request.remark(), now);
|
||||
if (!Objects.equals(orderBefore, orderStatus)) {
|
||||
insertOrderHistory(order.getId(), orderBefore, orderStatus, request.remark(), now);
|
||||
insertOrderHistory(customerId, order.getId(), orderBefore, orderStatus, request.remark(), now);
|
||||
}
|
||||
return detail(customerId, relabelNo);
|
||||
}
|
||||
@@ -248,8 +249,9 @@ public class RelabelApplicationService {
|
||||
value.setApplicationId(id); value.setFromStatus(from); value.setToStatus(to); value.setOperatorId(trim(operator));
|
||||
value.setRemark(trim(remark)); value.setCreatedAt(now); histories.insert(value);
|
||||
}
|
||||
private void insertOrderHistory(Long id, String from, String to, String remark, LocalDateTime now) {
|
||||
LastlegOrderStatusHistory value = new LastlegOrderStatusHistory(); value.setOrderId(id); value.setFromStatus(from);
|
||||
private void insertOrderHistory(String customerId, Long id, String from, String to, String remark,
|
||||
LocalDateTime now) {
|
||||
LastlegOrderStatusHistory value = new LastlegOrderStatusHistory(); value.setCustomerId(customerId); value.setOrderId(id); value.setFromStatus(from);
|
||||
value.setToStatus(to); value.setEventId("RELABEL_APPLICATION"); value.setRemark(trim(remark)); value.setCreatedAt(now);
|
||||
orderHistories.insert(value);
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.baiyue.lastleg.entity.LastlegOrderStatusHistory;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderDetailMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderStatusHistoryMapper;
|
||||
import com.baiyue.lastleg.model.LastlegOrderType;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -106,7 +107,8 @@ public class LastlegOrderService {
|
||||
lines.add("ID,尾程单号,订单类型,入仓码,头程单号,货主,海外仓,转仓,转仓编码,FBA仓库,集装箱号,货柜状态,是否异常,是否暂扣,托数,箱数,体积(m3),数量,体积重量,预计到港时间,实际到港时间,预计到仓,入库单号,换标单号,换标状态,合托标记,主流程状态,子单状态,备注(仅自己),备注(客户),备注(仓库)");
|
||||
for (LastlegOrder order : orders) {
|
||||
lines.add(String.join(",", List.of(
|
||||
csv(order.getId()), csv(order.getOrderNo()), csv(order.getOrderType()), csv(order.getInboundCode()),
|
||||
csv(order.getId()), csv(order.getOrderNo()), csv(LastlegOrderType.labelOf(order.getOrderType())),
|
||||
csv(order.getInboundCode()),
|
||||
csv(order.getSourceOrderNo()), csv(order.getCustomerName()), csv(order.getOverseasWarehouseName()),
|
||||
csv(order.getTransferWarehouseName()), csv(order.getTransferWarehouseCode()), csv(order.getFbaWarehouseCode()),
|
||||
csv(order.getContainerNo()), csv(order.getContainerStatus()), csv(order.getAbnormal()), csv(order.getDetained()),
|
||||
@@ -161,7 +163,8 @@ public class LastlegOrderService {
|
||||
}
|
||||
|
||||
private LastlegOrderSummary summary(LastlegOrder o) {
|
||||
return new LastlegOrderSummary(o.getId(), o.getOrderNo(), o.getOrderType(), o.getSourceInboundId(),
|
||||
return new LastlegOrderSummary(o.getId(), o.getOrderNo(), o.getOrderType(),
|
||||
LastlegOrderType.labelOf(o.getOrderType()), o.getSourceInboundId(),
|
||||
o.getInboundCode(), o.getSourceOrderNo(), o.getCustomerId(), o.getCustomerName(), o.getOverseasWarehouseId(),
|
||||
o.getOverseasWarehouseName(), o.getTransferWarehouseId(), o.getTransferWarehouseCode(),
|
||||
o.getTransferWarehouseName(), o.getFbaWarehouseCode(), o.getContainerNo(), o.getContainerStatus(),
|
||||
|
||||
+26
-1
@@ -31,6 +31,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
public class LoadingCompletedConsumer {
|
||||
@Resource private LastlegEventInboxMapper inboxMapper;
|
||||
@Resource private LastlegOrderMapper orderMapper;
|
||||
@Resource private LastlegInboundOrderMapper inboundOrderMapper;
|
||||
@Resource private LastlegOrderDetailMapper detailMapper;
|
||||
@Resource private LastlegOrderStatusHistoryMapper historyMapper;
|
||||
@Resource private InboundPlanCartonMapper cartonMapper;
|
||||
@@ -173,9 +174,11 @@ public class LoadingCompletedConsumer {
|
||||
if (raced != null && Objects.equals(raced.getSourcePayloadHash(), orderHash)) return;
|
||||
throw exception;
|
||||
}
|
||||
createInboundOrderSnapshot(event, payload, source, order, orderHash);
|
||||
|
||||
for(var item:source.items()) {
|
||||
LastlegOrderDetail detail=new LastlegOrderDetail();
|
||||
detail.setCustomerId(customerId);
|
||||
detail.setOrderId(order.getId()); detail.setSourceInboundDetailId(item.sourceInboundDetailId()); detail.setSkuCode(item.skuCode());
|
||||
detail.setProductNameZh(item.productNameZh()); detail.setProductNameEn(item.productNameEn()); detail.setPackageCount(item.packageCount());
|
||||
detail.setProductQuantity(item.productQuantity()); detail.setPalletCount(item.palletCount()); detail.setGrossWeightKg(item.grossWeightKg());
|
||||
@@ -185,7 +188,7 @@ public class LoadingCompletedConsumer {
|
||||
detail.setShipmentNo(item.shipmentNo()); detail.setShippingMark(item.shippingMark()); detailMapper.insert(detail);
|
||||
createCartonLabels(customerId, order.getId(), item);
|
||||
}
|
||||
LastlegOrderStatusHistory history=new LastlegOrderStatusHistory();
|
||||
LastlegOrderStatusHistory history=new LastlegOrderStatusHistory(); history.setCustomerId(customerId);
|
||||
history.setOrderId(order.getId()); history.setToStatus("PENDING_ASSIGNMENT"); history.setEventId(event.eventId());
|
||||
history.setRemark("头程装柜完成自动生成"); history.setCreatedAt(LocalDateTime.now()); historyMapper.insert(history);
|
||||
if ("FIRST_LEG".equals(orderType)) {
|
||||
@@ -201,6 +204,28 @@ public class LoadingCompletedConsumer {
|
||||
}
|
||||
}
|
||||
|
||||
private void createInboundOrderSnapshot(EventEnvelope event, FirstLegLoadingPlanCompletedV1 payload,
|
||||
FirstLegLoadingPlanCompletedV1.Order source, LastlegOrder order,
|
||||
String orderHash) {
|
||||
LastlegInboundOrder snapshot = new LastlegInboundOrder();
|
||||
snapshot.setId(order.getId()); snapshot.setTenantId("BAIYUE");
|
||||
snapshot.setCustomerId(order.getCustomerId()); snapshot.setSourceRegion(event.sourceRegion().name());
|
||||
snapshot.setSourceInboundId(source.sourceInboundId()); snapshot.setRootInboundId(source.rootInboundId());
|
||||
snapshot.setSourceOrderId(source.sourceOrderId()); snapshot.setSourceOrderNo(source.sourceOrderNo());
|
||||
snapshot.setRootOrderId(source.rootOrderId()); snapshot.setInboundCode(source.inboundCode());
|
||||
snapshot.setDestinationWarehouseId(source.destinationWarehouseId());
|
||||
snapshot.setDestinationWarehouseCode(source.destinationWarehouseCode());
|
||||
snapshot.setDestinationWarehouseName(source.destinationWarehouseName());
|
||||
snapshot.setPackageCount(source.packageCount()); snapshot.setProductQuantity(source.productQuantity());
|
||||
snapshot.setPalletCount(source.palletCount()); snapshot.setGrossWeightKg(source.grossWeightKg());
|
||||
snapshot.setNetWeightKg(source.netWeightKg()); snapshot.setVolumeCbm(source.volumeCbm());
|
||||
snapshot.setSourceEventId(event.eventId()); snapshot.setSourceLoadingPlanId(payload.loadingPlanId());
|
||||
snapshot.setSourceLoadingPlanVersion(event.aggregateVersion()); snapshot.setHandoverVersion(event.handoverVersion());
|
||||
snapshot.setPayloadHash(orderHash); snapshot.setStatus("READY"); snapshot.setExceptionFlag("NONE");
|
||||
snapshot.setCreatedAt(order.getCreatedAt()); snapshot.setUpdatedAt(order.getUpdatedAt());
|
||||
inboundOrderMapper.insert(snapshot);
|
||||
}
|
||||
|
||||
private void registerInTransit(EventEnvelope event, FirstLegLoadingPlanCompletedV1 payload,
|
||||
FirstLegLoadingPlanCompletedV1.Order source, LastlegOrder order,
|
||||
String inboundOrderNo) {
|
||||
|
||||
+11
-9
@@ -152,9 +152,9 @@ public class WarehouseTransferService {
|
||||
for (int index = 0; index < request.items().size(); index++) {
|
||||
WarehouseTransferRequests.Item source = request.items().get(index);
|
||||
insertTransferItem(customerId, transferId, source, now);
|
||||
insertOrderDetail(order.getId(), transferNo, index, source, request, now);
|
||||
insertOrderDetail(customerId, order.getId(), transferNo, index, source, request, now);
|
||||
}
|
||||
insertOrderHistory(order.getId(), null, PENDING_REVIEW, transferNo,
|
||||
insertOrderHistory(customerId, order.getId(), null, PENDING_REVIEW, transferNo,
|
||||
"Warehouse transfer submitted for review", now);
|
||||
if (request.needRelabel()) createRelabel(customerId, operatorId, transfer, order, request, now);
|
||||
return detail(customerId, transferNo);
|
||||
@@ -258,7 +258,7 @@ public class WarehouseTransferService {
|
||||
order.setSubOrderStatus("WAREHOUSE_TRANSFER:" + next);
|
||||
order.setUpdatedAt(now); orders.updateById(order);
|
||||
if (!java.util.Objects.equals(before, orderStatus)) {
|
||||
insertOrderHistory(order.getId(), before, orderStatus, transferNo,
|
||||
insertOrderHistory(customerId, order.getId(), before, orderStatus, transferNo,
|
||||
"Warehouse transfer reviewed: " + next, now);
|
||||
}
|
||||
return detail(customerId, transferNo);
|
||||
@@ -337,7 +337,7 @@ public class WarehouseTransferService {
|
||||
String before = order.getCurrentStatus(); order.setCurrentStatus("WAIT_OUTBOUND");
|
||||
order.setSubOrderStatus("WAREHOUSE_TRANSFER:ALLOCATED"); order.setUpdatedAt(now);
|
||||
orders.updateById(order);
|
||||
insertOrderHistory(order.getId(), before, order.getCurrentStatus(), transferNo,
|
||||
insertOrderHistory(customerId, order.getId(), before, order.getCurrentStatus(), transferNo,
|
||||
"Warehouse transfer inventory allocated", now);
|
||||
return detail(customerId, transferNo);
|
||||
}
|
||||
@@ -388,7 +388,7 @@ public class WarehouseTransferService {
|
||||
String before = order.getCurrentStatus(); order.setCurrentStatus("IN_TRANSIT");
|
||||
order.setSubOrderStatus("WAREHOUSE_TRANSFER:OUTBOUNDED"); order.setUpdatedAt(now);
|
||||
orders.updateById(order);
|
||||
insertOrderHistory(order.getId(), before, order.getCurrentStatus(), transferNo,
|
||||
insertOrderHistory(customerId, order.getId(), before, order.getCurrentStatus(), transferNo,
|
||||
"Warehouse transfer left source warehouse", now);
|
||||
return detail(customerId, transferNo);
|
||||
}
|
||||
@@ -455,7 +455,7 @@ public class WarehouseTransferService {
|
||||
String before = order.getCurrentStatus(); order.setCurrentStatus(complete ? "COMPLETED" : "IN_TRANSIT");
|
||||
order.setSubOrderStatus("WAREHOUSE_TRANSFER:" + (complete ? RECEIVED : PARTIALLY_RECEIVED));
|
||||
order.setUpdatedAt(now); orders.updateById(order);
|
||||
insertOrderHistory(order.getId(), before, order.getCurrentStatus(), transferNo,
|
||||
insertOrderHistory(customerId, order.getId(), before, order.getCurrentStatus(), transferNo,
|
||||
"Warehouse transfer inventory received at destination", now);
|
||||
return detail(customerId, transferNo);
|
||||
}
|
||||
@@ -490,9 +490,10 @@ public class WarehouseTransferService {
|
||||
transferItems.insert(item);
|
||||
}
|
||||
|
||||
private void insertOrderDetail(long orderId, String transferNo, int index, WarehouseTransferRequests.Item source,
|
||||
private void insertOrderDetail(String customerId, long orderId, String transferNo, int index, WarehouseTransferRequests.Item source,
|
||||
WarehouseTransferRequests.Create request, LocalDateTime now) {
|
||||
LastlegOrderDetail detail = new LastlegOrderDetail();
|
||||
detail.setCustomerId(customerId);
|
||||
detail.setOrderId(orderId); detail.setSourceInboundDetailId(transferNo + ":" + index);
|
||||
detail.setSkuCode(source.skuCode().trim()); detail.setProductNameZh(source.productNameZh().trim());
|
||||
detail.setPackageCount(source.packageCount()); detail.setDestinationWarehouseCode(request.fbaWarehouseCode().trim());
|
||||
@@ -537,9 +538,10 @@ public class WarehouseTransferService {
|
||||
order.setUpdatedAt(now); orders.updateById(order);
|
||||
}
|
||||
|
||||
private void insertOrderHistory(long orderId, String fromStatus, String toStatus, String transferNo,
|
||||
String remark, LocalDateTime now) {
|
||||
private void insertOrderHistory(String customerId, long orderId, String fromStatus, String toStatus,
|
||||
String transferNo, String remark, LocalDateTime now) {
|
||||
LastlegOrderStatusHistory history = new LastlegOrderStatusHistory();
|
||||
history.setCustomerId(customerId);
|
||||
history.setOrderId(orderId); history.setFromStatus(fromStatus); history.setToStatus(toStatus);
|
||||
history.setEventId("WAREHOUSE_TRANSFER:" + transferNo); history.setRemark(remark);
|
||||
history.setCreatedAt(now); orderHistories.insert(history);
|
||||
|
||||
Reference in New Issue
Block a user