| | |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | | import com.vincent.rsf.server.manager.enums.OrderType; |
| | | import com.vincent.rsf.server.manager.enums.OrderWorkType; |
| | | import com.vincent.rsf.server.manager.enums.POExceStatus; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.manager.service.impl.TransferOrderServiceImpl; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | |
| | | private AsnOrderLogService asnOrderLogService; |
| | | @Autowired |
| | | private AsnOrderItemLogService asnOrderItemLogService; |
| | | @Autowired |
| | | private TransferOrderService transferOrderService; |
| | | |
| | | /** |
| | | * @param |
| | |
| | | */ |
| | | @Scheduled(cron = "0/35 * * * * ? ") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void moveOrderToLog() { |
| | | public void InStockToLog() { |
| | | List<WkOrder> wkOrders = asnOrderService.list(new LambdaQueryWrapper<WkOrder>() |
| | | .eq(WkOrder::getType, OrderType.ORDER_IN.type) |
| | | .eq(WkOrder::getExceStatus, AsnExceStatus.ASN_EXCE_STATUS_TASK_DONE.val)); |
| | | .eq(WkOrder::getExceStatus, AsnExceStatus.ASN_EXCE_STATUS_TASK_EXCE.val)); |
| | | if (wkOrders.isEmpty()) { |
| | | return; |
| | | } |
| | |
| | | public void outStockComplete() { |
| | | List<WkOrder> wkOrders = asnOrderService.list(new LambdaQueryWrapper<WkOrder>() |
| | | .eq(WkOrder::getType, OrderType.ORDER_OUT.type) |
| | | .eq(WkOrder::getExceStatus, AsnExceStatus.OUT_STOCK_STATUS_TASK_DONE.val) |
| | | .apply("anfme = work_qty") |
| | | .eq(WkOrder::getExceStatus, AsnExceStatus.OUT_STOCK_STATUS_TASK_WORKING.val) |
| | | .apply("anfme = qty") |
| | | ); |
| | | if (wkOrders.isEmpty()) { |
| | | return; |
| | |
| | | * @time 2025/6/16 08:56 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void moveOrderToLog(List<WkOrder> wkOrders, String type) throws Exception{ |
| | | public void moveOrderToLog(List<WkOrder> wkOrders, String type) { |
| | | Set<Long> longSet = wkOrders.stream().map(WkOrder::getId).collect(Collectors.toSet()); |
| | | List<WkOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<WkOrderItem>() |
| | | .in(WkOrderItem::getOrderId, longSet)); |
| | |
| | | } |
| | | |
| | | for (WkOrder order : wkOrders) { |
| | | AsnOrderLog one = asnOrderLogService.getOne(new LambdaQueryWrapper<AsnOrderLog>().eq(AsnOrderLog::getCode, order.getCode()), false); |
| | | if (Objects.isNull(one)) { |
| | | AsnOrderLog orderLog = new AsnOrderLog(); |
| | | if (type.equals(OrderType.ORDER_OUT.type)) { |
| | | order.setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_TASK_DONE.val); |
| | |
| | | |
| | | //更新PO/DO单执行状态 |
| | | if (type.equals(OrderType.ORDER_IN.type)) { |
| | | if (order.getWkType().equals(OrderWorkType.ORDER_WORK_TYPE_OTHER_TERANSFER.type)) { |
| | | order.setExceStatus(AsnExceStatus.ASN_EXCE_STATUS_TASK_DONE.val); |
| | | if (!asnOrderService.updateById(order)) { |
| | | throw new CoolException("单据状态更新失败!!"); |
| | | } |
| | | |
| | | List<TransferOrder> orders = transferOrderService.list(new LambdaQueryWrapper<TransferOrder>().eq(TransferOrder::getTransferId, order.getPoId())); |
| | | if (orders.isEmpty()) { |
| | | throw new CoolException("数据错误:关联表信息不存在!!"); |
| | | } |
| | | Set<Long> orderIds = orders.stream().map(TransferOrder::getOrderId).collect(Collectors.toSet()); |
| | | if (!asnOrderItemService.remove(new LambdaQueryWrapper<WkOrderItem>() |
| | | .in(WkOrderItem::getOrderId, orderIds))) { |
| | | throw new CoolException("原单据明细删除失败!!"); |
| | | } |
| | | if (!this.asnOrderService.removeByIds(orderIds)) { |
| | | throw new CoolException("原单据删除失败!!"); |
| | | } |
| | | return; |
| | | } else { |
| | | if (!Objects.isNull(order.getPoId())) { |
| | | if (!purchaseService.update(new LambdaUpdateWrapper<Purchase>() |
| | | purchaseService.update(new LambdaUpdateWrapper<Purchase>() |
| | | .set(Purchase::getExceStatus, POExceStatus.PO_EXCE_STATUS_ALL_DONE.val) |
| | | .eq(Purchase::getId, order.getPoId()))) { |
| | | throw new CoolException("PO单更新状态更新失败!!"); |
| | | .eq(Purchase::getId, order.getPoId())); |
| | | } |
| | | } |
| | | } else { |
| | | if (order.getWkType().equals(OrderWorkType.ORDER_WORK_TYPE_STOCK_TERANSFER.type)) { |
| | | order.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_DONE.val); |
| | | if (!asnOrderService.updateById(order)) { |
| | | throw new CoolException("单据状态更新失败!!"); |
| | | } |
| | | //如果为调拔单执行完成,需检查调拔入库单是否完成,完成后才能删除单据信息 |
| | | return; |
| | | } else { |
| | | if (!Objects.isNull(order.getPoId())) { |
| | | if (!deliveryService.update(new LambdaUpdateWrapper<Delivery>() |
| | | deliveryService.update(new LambdaUpdateWrapper<Delivery>() |
| | | .eq(Delivery::getId, order.getPoId()) |
| | | .set(Delivery::getExceStatus, POExceStatus.PO_EXCE_STATUS_ALL_DONE.val))) { |
| | | throw new CoolException("DO单更新状态更新失败"); |
| | | .set(Delivery::getExceStatus, POExceStatus.PO_EXCE_STATUS_ALL_DONE.val)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // if (!asnOrderItemService.remove(new LambdaQueryWrapper<WkOrderItem>() |
| | | // .in(WkOrderItem::getOrderId, longSet))) { |
| | | // throw new CoolException("原单据明细删除失败!!"); |
| | | // } |
| | | // if (!this.asnOrderService.removeByIds(longSet)) { |
| | | // throw new CoolException("原单据删除失败!!"); |
| | | // } |
| | | if (!asnOrderItemService.remove(new LambdaQueryWrapper<WkOrderItem>() |
| | | .eq(WkOrderItem::getOrderId, order.getId()))) { |
| | | throw new CoolException("原单据明细删除失败!!"); |
| | | } |
| | | if (!this.asnOrderService.removeById(order.getId())) { |
| | | throw new CoolException("原单据删除失败!!"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |