|
@@ -2,11 +2,7 @@ package com.sd.business.listener;
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.rabbitmq.client.Channel;
|
|
|
-import com.sd.business.entity.order.enums.OrderStatusEnum;
|
|
|
-import com.sd.business.entity.order.po.OrderInfo;
|
|
|
import com.sd.business.entity.production.po.ProductionWorkOrder;
|
|
|
-import com.sd.business.service.inventory.InventoryFinishedService;
|
|
|
-import com.sd.business.service.order.OrderService;
|
|
|
import com.sd.business.service.production.ProductionWorkOrderService;
|
|
|
import com.sd.mq.config.WorkOrderConfig;
|
|
|
import com.sd.mq.entity.EditWorkOrderMessage;
|
|
@@ -21,7 +17,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.Collections;
|
|
|
import java.util.Objects;
|
|
|
|
|
|
|
|
@@ -34,12 +29,6 @@ public class AddWorkOrderListener {
|
|
|
@Autowired
|
|
|
private ProductionWorkOrderService productionWorkOrderService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private InventoryFinishedService inventoryFinishedService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private OrderService orderService;
|
|
|
-
|
|
|
@RabbitListener(bindings = {
|
|
|
@QueueBinding(value = @Queue(WorkOrderConfig.EDIT_WORK_ORDER_QUEUE_NAME), exchange = @Exchange(WorkOrderConfig.DIRECT_EXCHANGE_NAME))
|
|
|
})
|
|
@@ -86,7 +75,7 @@ public class AddWorkOrderListener {
|
|
|
productionWorkOrderService.updateById(productionWorkOrder);
|
|
|
|
|
|
|
|
|
- completeOrder(productionWorkOrder.getOrderId());
|
|
|
+ productionWorkOrderService.completeOrder(productionWorkOrder.getOrderId());
|
|
|
}
|
|
|
break;
|
|
|
|
|
@@ -100,7 +89,6 @@ public class AddWorkOrderListener {
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
channel.basicAck(deliveryTag, true);
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -110,38 +98,4 @@ public class AddWorkOrderListener {
|
|
|
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- * 查询订单所有工单是否完成,若完成,修改订单状态为已完成
|
|
|
- */
|
|
|
- private void completeOrder(Long orderId) {
|
|
|
-
|
|
|
-
|
|
|
- long count = productionWorkOrderService.count(q -> q
|
|
|
- .in(ProductionWorkOrder::getStatus,
|
|
|
- WorkOrderStatusEnum.TO_BE_PRODUCED.getKey(),
|
|
|
- WorkOrderStatusEnum.SCANNED.getKey(),
|
|
|
- WorkOrderStatusEnum.IN_PRODUCTION.getKey(),
|
|
|
- WorkOrderStatusEnum.PRODUCTION_ANOMALY.getKey())
|
|
|
- .last("limit 1")
|
|
|
- );
|
|
|
-
|
|
|
- if (count != 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- OrderInfo orderInfo = orderService.getById(orderId);
|
|
|
- if (Objects.equals(orderInfo.getStatus(), OrderStatusEnum.COMPLETION_PRODUCTION.getKey())
|
|
|
- || Objects.equals(orderInfo.getStatus(), OrderStatusEnum.HAVE_BEEN_SHIPPED.getKey())) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- inventoryFinishedService.productionWarehousing(Collections.singletonList(orderId));
|
|
|
-
|
|
|
-
|
|
|
- orderInfo.setStatus(OrderStatusEnum.COMPLETION_PRODUCTION.getKey());
|
|
|
- orderService.updateById(orderInfo);
|
|
|
- }
|
|
|
-
|
|
|
}
|