| | |
| | | import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderProcessService; |
| | | import cn.iocoder.yudao.module.mes.service.pro.task.MesProTaskService; |
| | | import cn.iocoder.yudao.module.mes.service.cal.holiday.MesCalHolidayService; |
| | | import cn.iocoder.yudao.module.mes.util.MesOutputItemUtils; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | result.setPreviewTime(now()); |
| | | var orders = workOrderMapper.selectByIds(request.getWorkOrderIds()); |
| | | var orderMap = orders.stream().collect(Collectors.toMap(MesProWorkOrderDO::getId, order -> order)); |
| | | List<Long> permitted = customerApi.getPermittedCustomerIds(); |
| | | var stations = workstationService.getWorkstationListByStatus(0).stream() |
| | | .sorted(Comparator.comparing(MesMdWorkstationDO::getId)).toList(); |
| | | var machineMap = machineryMapper.selectList().stream().collect(Collectors.toMap(MesDvMachineryDO::getId, machine -> machine)); |
| | |
| | | result.getOrders().add(orderPlan); |
| | | try { |
| | | if (order == null) throw new IllegalArgumentException("工单不存在或已删除"); |
| | | if (permitted != null && order.getClientId() != null && !permitted.contains(order.getClientId())) { |
| | | throw new IllegalArgumentException("无权操作该客户的工单"); |
| | | } |
| | | orderPlan.setWorkOrderCode(order.getCode()); |
| | | orderPlan.setWorkOrderName(order.getName()); |
| | | orderPlan.setQuantity(order.getQuantity()); |
| | |
| | | } |
| | | Long itemId = order.getProductId(); |
| | | if (process.getOutputItemId() != null && !process.getOutputItemId().isBlank()) { |
| | | String[] output = process.getOutputItemId().split(","); |
| | | if (output.length != 1) throw new IllegalArgumentException("多产出工序请使用手工排产确认各产出数量"); |
| | | itemId = Long.valueOf(output[0].trim()); |
| | | List<Long> outputIds = MesOutputItemUtils.parseItemIds(process.getOutputItemId()); |
| | | if (outputIds.size() != 1) throw new IllegalArgumentException("多产出工序请使用手工排产确认各产出数量"); |
| | | itemId = outputIds.get(0); |
| | | } |
| | | var item = itemService.validateItemExists(itemId); |
| | | if (!Objects.equals(item.getStatus(), 0)) throw new IllegalArgumentException("工序产出产品已停用"); |