|
@@ -24,7 +24,9 @@ import com.sd.business.service.order.OrderService;
|
|
|
import com.sd.business.service.order.OrderSkuService;
|
|
|
import com.sd.business.service.production.ProductionWorkOrderService;
|
|
|
import com.sd.business.service.sku.SkuSpecService;
|
|
|
+import com.sd.business.util.CodeEnum;
|
|
|
import com.sd.mq.config.WorkOrderConfig;
|
|
|
+import com.sd.mq.entity.CombinedWorkOrderMessage;
|
|
|
import com.sd.mq.entity.WorkOrderDetail;
|
|
|
import com.sd.mq.entity.WorkOrderMessage;
|
|
|
import com.sd.mq.enums.WorkOrderStatusEnum;
|
|
@@ -63,27 +65,17 @@ public class ProductionWorkOrderServiceImpl extends ServiceImpl<ProductionWorkOr
|
|
|
@Autowired
|
|
|
private InventoryFinishedService inventoryFinishedService;
|
|
|
|
|
|
- @Override
|
|
|
- public Page<ProductionWorkOrderVo> getPage(ProductionWorkOrderSelectDto dto) {
|
|
|
- IWrapper<ProductionWorkOrder> wrapper = getWrapper();
|
|
|
- wrapper.orderByDesc("pwo", ProductionWorkOrder::getId);
|
|
|
- wrapper.eq("oi", OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey());
|
|
|
-
|
|
|
- wrapper.like("oi", OrderInfo::getCode, dto.getOrderCode());
|
|
|
- wrapper.like("oi", OrderInfo::getWlnCode, dto.getOrderWlnCode());
|
|
|
-
|
|
|
- wrapper.like("pwo", ProductionWorkOrder::getCode, dto.getProductionWorkOrderCode());
|
|
|
-
|
|
|
- wrapper.like("ss", SkuSpec::getCode, dto.getSkuSpecCode());
|
|
|
- wrapper.like("ss", SkuSpec::getName, dto.getSkuSpecName());
|
|
|
-
|
|
|
- wrapper.like("bs", BomSpec::getCode, dto.getBomSpecCode());
|
|
|
- wrapper.like("bs", BomSpec::getName, dto.getBomSpecName());
|
|
|
-
|
|
|
- wrapper.ge("oi", OrderInfo::getDeliveryTime, dto.getBeginTime());
|
|
|
- wrapper.le("oi", OrderInfo::getDeliveryTime, dto.getEndTime());
|
|
|
-
|
|
|
- return this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
+ private static ProductionWorkOrder getProductionWorkOrder(ProductionWorkOrder temp) {
|
|
|
+ String code = CodeEnum.BATH_PRODUCTION_WORK_ORDER_CODE.getCode();
|
|
|
+ ProductionWorkOrder productionWorkOrder = new ProductionWorkOrder();
|
|
|
+ productionWorkOrder.setCode(code);
|
|
|
+ productionWorkOrder.setSkuSpecId(temp.getSkuSpecId());
|
|
|
+ productionWorkOrder.setBomSpecId(temp.getBomSpecId());
|
|
|
+ productionWorkOrder.setPrintType(temp.getPrintType());
|
|
|
+ productionWorkOrder.setMachinedPanel(temp.getMachinedPanel());
|
|
|
+ productionWorkOrder.setStatus(0);
|
|
|
+ productionWorkOrder.setType(2);
|
|
|
+ return productionWorkOrder;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -215,15 +207,29 @@ public class ProductionWorkOrderServiceImpl extends ServiceImpl<ProductionWorkOr
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void complete(BaseSelectDto dto) {
|
|
|
- ProductionWorkOrder productionWorkOrder = getById(dto.getId());
|
|
|
- productionWorkOrder.setCompleteTime(new Date());
|
|
|
- productionWorkOrder.setStatus(WorkOrderStatusEnum.PRODUCTION_COMPLETION.getKey());
|
|
|
- updateById(productionWorkOrder);
|
|
|
+ public Page<ProductionWorkOrderVo> getPage(ProductionWorkOrderSelectDto dto) {
|
|
|
+ IWrapper<ProductionWorkOrder> wrapper = getWrapper();
|
|
|
+ wrapper.orderByDesc("pwo", ProductionWorkOrder::getId);
|
|
|
+ wrapper.eq("oi", OrderInfo::getStatus, OrderStatusEnum.IN_PRODUCTION.getKey());
|
|
|
|
|
|
- completeOrder(productionWorkOrder.getOrderId());
|
|
|
+ wrapper.like("oi", OrderInfo::getCode, dto.getOrderCode());
|
|
|
+ wrapper.like("oi", OrderInfo::getWlnCode, dto.getOrderWlnCode());
|
|
|
+
|
|
|
+ wrapper.like("pwo", ProductionWorkOrder::getCode, dto.getProductionWorkOrderCode());
|
|
|
+
|
|
|
+ wrapper.like("ss", SkuSpec::getCode, dto.getSkuSpecCode());
|
|
|
+ wrapper.like("ss", SkuSpec::getName, dto.getSkuSpecName());
|
|
|
+
|
|
|
+ wrapper.like("bs", BomSpec::getCode, dto.getBomSpecCode());
|
|
|
+ wrapper.like("bs", BomSpec::getName, dto.getBomSpecName());
|
|
|
+
|
|
|
+ wrapper.ge("oi", OrderInfo::getDeliveryTime, dto.getBeginTime());
|
|
|
+ wrapper.le("oi", OrderInfo::getDeliveryTime, dto.getEndTime());
|
|
|
+
|
|
|
+ wrapper.isNull("pwo.master_id");
|
|
|
+
|
|
|
+ return this.baseMapper.getPage(dto.getPage(), wrapper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -261,4 +267,80 @@ public class ProductionWorkOrderServiceImpl extends ServiceImpl<ProductionWorkOr
|
|
|
orderService.updateById(orderInfo);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void complete(BaseSelectDto dto) {
|
|
|
+
|
|
|
+ ProductionWorkOrder productionWorkOrder = getById(dto.getId());
|
|
|
+ productionWorkOrder.setCompleteTime(new Date());
|
|
|
+ productionWorkOrder.setStatus(WorkOrderStatusEnum.PRODUCTION_COMPLETION.getKey());
|
|
|
+ updateById(productionWorkOrder);
|
|
|
+
|
|
|
+ // 单片
|
|
|
+ if (productionWorkOrder.getType() == 1) {
|
|
|
+ completeOrder(productionWorkOrder.getOrderId());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 批量
|
|
|
+ else {
|
|
|
+ List<ProductionWorkOrder> list = list(q -> q.eq(ProductionWorkOrder::getMasterId, dto.getId()));
|
|
|
+ for (ProductionWorkOrder item : list) {
|
|
|
+ item.setCompleteTime(new Date());
|
|
|
+ item.setStatus(WorkOrderStatusEnum.PRODUCTION_COMPLETION.getKey());
|
|
|
+ }
|
|
|
+ updateBatchById(list);
|
|
|
+
|
|
|
+ List<Long> orderIdList = list.stream().map(ProductionWorkOrder::getOrderId).distinct().collect(Collectors.toList());
|
|
|
+ for (Long orderId : orderIdList) {
|
|
|
+ completeOrder(orderId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public synchronized void combined(List<Long> idList) {
|
|
|
+ if (idList.isEmpty()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ProductionWorkOrder> productionWorkOrderList = listByIds(idList);
|
|
|
+
|
|
|
+ if (idList.size() != productionWorkOrderList.size()) {
|
|
|
+ throw new ServiceException("存在未知工单");
|
|
|
+ }
|
|
|
+
|
|
|
+ ProductionWorkOrder temp = productionWorkOrderList.get(0);
|
|
|
+ for (ProductionWorkOrder productionWorkOrder : productionWorkOrderList) {
|
|
|
+ if (Objects.equals(temp.getType(), 2)) {
|
|
|
+ throw new ServiceException("批量工单无法合并");
|
|
|
+ }
|
|
|
+ if (productionWorkOrder.getMasterId() != null) {
|
|
|
+ throw new ServiceException("存在已合并的工单");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(temp.getSkuSpecId(), productionWorkOrder.getSkuSpecId())) {
|
|
|
+ throw new ServiceException("存在不同sku");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(temp.getBomSpecId(), productionWorkOrder.getBomSpecId())) {
|
|
|
+ throw new ServiceException("存在不同bom");
|
|
|
+ }
|
|
|
+ if (!Objects.equals(productionWorkOrder.getStatus(), WorkOrderStatusEnum.TO_BE_PRODUCED.getKey())) {
|
|
|
+ throw new ServiceException("存在工单不在待投产状态");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 创建批量工单
|
|
|
+ ProductionWorkOrder productionWorkOrder = getProductionWorkOrder(temp);
|
|
|
+ save(productionWorkOrder);
|
|
|
+
|
|
|
+ // 单片工单关联批量工单
|
|
|
+ productionWorkOrderList.forEach(item -> item.setMasterId(productionWorkOrder.getId()));
|
|
|
+
|
|
|
+ // 发送mq
|
|
|
+ RabbitMqUtil.send(WorkOrderConfig.DIRECT_EXCHANGE_NAME, WorkOrderConfig.COMBINED_WORK_ORDER_QUEUE_NAME,
|
|
|
+ new CombinedWorkOrderMessage(productionWorkOrder.getId(), idList));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|