暂扣 标记合托功能
This commit is contained in:
@@ -14,6 +14,7 @@ import com.baiyue.lastleg.entity.LastlegOrderFee;
|
||||
import com.baiyue.lastleg.entity.LastlegOrderOperationLog;
|
||||
import com.baiyue.lastleg.inboundplan.entity.InboundPlanCarton;
|
||||
import com.baiyue.lastleg.inboundplan.mapper.InboundPlanCartonMapper;
|
||||
import com.baiyue.lastleg.inventory.command.service.InventoryCommandService;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderDetailMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderMapper;
|
||||
import com.baiyue.lastleg.mapper.LastlegOrderStatusHistoryMapper;
|
||||
@@ -38,6 +39,8 @@ public class LastlegOrderService {
|
||||
public static final String PENDING_ASSIGNMENT = "PENDING_ASSIGNMENT";
|
||||
public static final String DESTINATION_ASSIGNED = "DESTINATION_ASSIGNED";
|
||||
public static final String INBOUND_PLANNED = "INBOUND_PLANNED";
|
||||
public static final String PALLET_MERGE_REQUIRED = "REQUIRED";
|
||||
public static final String PALLET_MERGED = "MERGED";
|
||||
|
||||
@Resource private LastlegOrderMapper orderMapper;
|
||||
@Resource private LastlegOrderDetailMapper detailMapper;
|
||||
@@ -45,6 +48,7 @@ public class LastlegOrderService {
|
||||
@Resource private LastlegOrderFeeMapper feeMapper;
|
||||
@Resource private LastlegOrderOperationLogMapper operationLogMapper;
|
||||
@Resource private InboundPlanCartonMapper cartonMapper;
|
||||
@Resource private InventoryCommandService inventory;
|
||||
|
||||
public PageResult<LastlegOrderSummary> page(String customerId, LastlegOrderRequests.Query query) {
|
||||
Page<LastlegOrder> page = orderMapper.selectPage(
|
||||
@@ -110,6 +114,70 @@ public class LastlegOrderService {
|
||||
return fee;
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void setDetained(String customerId, long orderId, LastlegOrderRequests.SetDetained request,
|
||||
String operatorName) {
|
||||
LastlegOrder current = findOwned(customerId, orderId);
|
||||
LastlegOrder order = orderMapper.lockById(current.getCustomerId(), orderId);
|
||||
if (order == null) throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Tail-leg order not found");
|
||||
boolean detained = request.detained();
|
||||
if (Boolean.TRUE.equals(order.getDetained()) == detained) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, detained ? "Order is already held" : "Order is not held");
|
||||
}
|
||||
if (detained && "INBOUND_COMPLETED".equals(order.getCurrentStatus())) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "Completed inbound orders cannot be newly held");
|
||||
}
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
order.setDetained(detained);
|
||||
order.setUpdatedAt(now);
|
||||
orderMapper.updateById(order);
|
||||
if (!detained && "INBOUND_COMPLETED".equals(order.getCurrentStatus())) {
|
||||
inventory.releaseInboundOrderHold(order.getCustomerId(), operatorName, orderId, order.getOrderNo(), request.remark().trim());
|
||||
}
|
||||
LastlegOrderOperationLog operation = new LastlegOrderOperationLog();
|
||||
operation.setId(IdWorker.getId());
|
||||
operation.setCustomerId(order.getCustomerId());
|
||||
operation.setOrderId(orderId);
|
||||
operation.setOperationNode(detained ? "暂扣" : "解除暂扣");
|
||||
operation.setOperatorName(operatorName);
|
||||
operation.setResult(request.remark().trim());
|
||||
operation.setCreatedAt(now);
|
||||
operationLogMapper.insert(operation);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void setPalletMergeRequired(String customerId, long orderId,
|
||||
LastlegOrderRequests.SetPalletMergeRequired request,
|
||||
String operatorName) {
|
||||
LastlegOrder current = findOwned(customerId, orderId);
|
||||
LastlegOrder order = orderMapper.lockById(current.getCustomerId(), orderId);
|
||||
if (order == null) throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Tail-leg order not found");
|
||||
if ("INBOUND_COMPLETED".equals(order.getCurrentStatus())) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT,
|
||||
"Completed inbound orders cannot change the pallet merge mark");
|
||||
}
|
||||
if (PALLET_MERGED.equals(order.getPalletMergeFlag())) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT,
|
||||
"A completed pallet merge cannot be unmarked");
|
||||
}
|
||||
String target = request.palletMergeRequired() ? PALLET_MERGE_REQUIRED : null;
|
||||
if (Objects.equals(target, order.getPalletMergeFlag())) return;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (orderMapper.updatePalletMergeFlag(order.getCustomerId(), orderId, target, now) != 1) {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "Pallet merge mark was not updated");
|
||||
}
|
||||
LastlegOrderOperationLog operation = new LastlegOrderOperationLog();
|
||||
operation.setId(IdWorker.getId());
|
||||
operation.setCustomerId(order.getCustomerId());
|
||||
operation.setOrderId(orderId);
|
||||
operation.setOperationNode(request.palletMergeRequired() ? "标记合托" : "取消合托标记");
|
||||
operation.setOperatorName(operatorName);
|
||||
operation.setResult(request.palletMergeRequired()
|
||||
? "PDA扫描本单箱唛时提示需要合托" : "已取消PDA合托提示");
|
||||
operation.setCreatedAt(now);
|
||||
operationLogMapper.insert(operation);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public int transferDestination(String customerId, LastlegOrderRequests.TransferDestination request) {
|
||||
List<Long> ids = request.orderIds().stream().filter(Objects::nonNull).distinct().toList();
|
||||
|
||||
Reference in New Issue
Block a user