| | |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.AsnExceStatus; |
| | | import com.vincent.rsf.server.manager.enums.TaskStsType; |
| | | import com.vincent.rsf.server.manager.enums.TaskType; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.manager.service.impl.StockItemServiceImpl; |
| | | import com.vincent.rsf.server.manager.service.impl.StockServiceImpl; |
| | |
| | | if (null == task) { |
| | | throw new CoolException("未找到容器号对应任务"); |
| | | } |
| | | if (!task.getTaskStatus().equals(TaskStsType.AWAIT.id)) { |
| | | return R.error("任务状态不是等待确认"); |
| | | if (!task.getTaskStatus().equals(TaskStsType.WAVE_SEED.id)) { |
| | | return R.error("任务状态不是揀料狀態"); |
| | | } |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | Set<Long> longSet = taskItems.stream().map(TaskItem::getSourceId).collect(Collectors.toSet()); |
| | |
| | | if (null == task) { |
| | | return R.error("未找到托盘对应的任务"); |
| | | } |
| | | if (!task.getTaskStatus().equals(TaskStsType.AWAIT.id)) { |
| | | return R.error("任务状态不是等待确认"); |
| | | if (!task.getTaskStatus().equals(TaskStsType.WAVE_SEED.id)) { |
| | | return R.error("任务状态不是揀料狀態"); |
| | | } |
| | | WkOrder order = asnOrderService.getById(params.getOrderId()); |
| | | if (Objects.isNull(order)) { |
| | |
| | | } |
| | | Double summed = items.stream().mapToDouble(TaskItem::getAnfme).sum(); |
| | | //加上历史拣料数量 |
| | | Double pickQty = Math.round((orderItem.getQty() + summed) * 10000) / 10000.0; |
| | | Double pickQty = Math.round((orderItem.getQty() + summed) * 100) / 100.0; |
| | | if (pickQty.compareTo(orderItem.getAnfme()) > 0.0) { |
| | | throw new CoolException("播种数量不能超出订单需求数量"); |
| | | } |
| | |
| | | throw new CoolException("订单数量更新失败!!"); |
| | | } |
| | | //检查单据是否完成 |
| | | if (order.getAnfme().compareTo(order.getQty()) == 0) { |
| | | order.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_DONE.val); |
| | | if (!asnOrderService.updateById(order)) { |
| | | throw new CoolException("出库单更新状态失败"); |
| | | } |
| | | } |
| | | // if (order.getAnfme().compareTo(order.getQty()) == 0) { |
| | | // order.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_DONE.val); |
| | | // if (!asnOrderService.updateById(order)) { |
| | | // throw new CoolException("出库单更新状态失败"); |
| | | // } |
| | | // } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | private void saveOrderToStock(Order order) { |
| | | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * @author Ryan |
| | |
| | | if (null == task) { |
| | | return R.error("未找到托盘对应的任务"); |
| | | } |
| | | if (!task.getTaskStatus().equals(TaskStsType.AWAIT.id)) { |
| | | return R.error("任务状态不是等待确认"); |
| | | if (!task.getTaskStatus().equals(TaskStsType.WAVE_SEED.id)) { |
| | | return R.error("任务状态不是待揀狀態"); |
| | | } |
| | | |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | |
| | | } |
| | | }); |
| | | |
| | | // orderItems.forEach(orderItem -> { |
| | | // try { |
| | | // taskService.saveOutStockItem(taskItems, orderItem, null, null, SystemAuthUtils.getLoginUserId()); |
| | | // } catch (Exception e) { |
| | | // throw new RuntimeException(e); |
| | | // } |
| | | // }); |
| | | |
| | | // containerWaveParam.getOrderItems().forEach(orderItem -> { |
| | | // |
| | | // }); |
| | | // for (ContainerWaveDto containerWaveDto : containerWaveParam.getContainerWaveDtos()) { |
| | | // //做一次校验,判断前端所有出库数量是否超过本托出库数量 |
| | | // double sum = containerWaveDto.getWkOrderItems().stream().mapToDouble(WkOrderItem::getDemandQty).sum(); |
| | | // BigDecimal total = new BigDecimal(String.valueOf(sum)); |
| | | // BigDecimal anfme = new BigDecimal(containerWaveDto.getTaskItem().getAnfme().toString()); |
| | | // if (!anfme.equals(total)) { |
| | | // throw new CoolException("播种数量不等于容器出库数量,请检查"); |
| | | // } |
| | | // for (WkOrderItem oldOrderItem : containerWaveDto.getWkOrderItems()) { |
| | | // if (Double.compare(oldOrderItem.getDemandQty(), 0.0) == 0) { |
| | | // continue; |
| | | // } |
| | | // WkOrderItem orderItem = asnOrderItemService.getById(oldOrderItem.getId()); |
| | | // BigDecimal num = new BigDecimal(orderItem.getWorkQty().toString()).subtract(new BigDecimal(orderItem.getQty().toString())); |
| | | // BigDecimal orderDemandQty = new BigDecimal(oldOrderItem.getDemandQty().toString()); |
| | | // if (num.compareTo(orderDemandQty) < 0) { |
| | | // throw new CoolException("播种数量大于单据出库数量,请检查"); |
| | | // } |
| | | // WkOrder wkOrder = asnOrderService.getById(orderItem.getOrderId()); |
| | | // if (Cools.isEmpty(wkOrder)) { |
| | | // throw new CoolException("出库单主单未找到"); |
| | | // } |
| | | // wkOrder.setQty(new BigDecimal(wkOrder.getQty().toString()).add(orderDemandQty).doubleValue()); |
| | | // if (!asnOrderService.updateById(wkOrder)) { |
| | | // throw new CoolException("出库单更新状态失败"); |
| | | // } |
| | | // |
| | | // if (Objects.isNull(oldOrderItem.getFieldsIndex())) { |
| | | // throw new CoolException("票号不能为空!!"); |
| | | // } |
| | | // //Fix 这里只针对希日项目的票号功能,票号和uuid为一对一的情况,不会出现重复的情况 |
| | | // FieldsItem fieldsItem = fieldsItemService.getOne(new LambdaQueryWrapper<FieldsItem>().eq(FieldsItem::getValue, oldOrderItem.getFieldsIndex()).last("limit 1")); |
| | | // if (!Objects.isNull(fieldsItem)) { |
| | | // orderItem.setFieldsIndex(fieldsItem.getUuid()); |
| | | // } |
| | | // orderItem.setQty(new BigDecimal(orderItem.getQty().toString()).add(orderDemandQty).doubleValue()); |
| | | // if (!asnOrderItemService.updateById(orderItem)) { |
| | | // throw new CoolException("单据明细更新失败"); |
| | | // } |
| | | // //检查单据是否完成 |
| | | // Boolean orderChecked = checkOrderComplete(orderItem); |
| | | // if (orderChecked) { |
| | | // wkOrder.setExceStatus(AsnExceStatus.OUT_STOCK_STATUS_TASK_DONE.val); |
| | | // if (!asnOrderService.updateById(wkOrder)) { |
| | | // throw new CoolException("出库单更新状态失败"); |
| | | // } |
| | | // } |
| | | // } |
| | | // //检查波次是否完成 |
| | | //// Boolean waveChecked = checkWaveComplete(containerWaveDto.getTaskItem()); |
| | | //// if (waveChecked){ |
| | | //// Wave wave = waveService.getById(containerWaveDto.getTaskItem().getSourceId()); |
| | | //// if (null == wave){ |
| | | //// throw new CoolException("未找到容器号对应波次"); |
| | | //// } |
| | | //// wave.setExceStatus(WaveExceStatus.WAVE_EXCE_STATUS_TASK.val); |
| | | //// if (!waveService.updateById(wave)){ |
| | | //// throw new CoolException("波次单更新状态失败"); |
| | | //// } |
| | | //// } |
| | | // } |
| | | |
| | | task.setTaskStatus(TaskStsType.COMPLETE_OUT.id); |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("任务状态更新失败"); |
| | | try { |
| | | if (task.getTaskType().equals(TaskType.TASK_TYPE_PICK_AGAIN_OUT.type) || task.getTaskType().equals(TaskType.TASK_TYPE_CHECK_OUT.type)) { |
| | | taskService.pickOrCheckTask(task.getId(), ""); |
| | | } else { |
| | | task.setTaskStatus(TaskStsType.UPDATED_OUT.id); |
| | | if (!taskService.updateById(task)) { |
| | | throw new CoolException("任务状态更新失败"); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | throw new CoolException("分揀失败"); |
| | | } |
| | | |
| | | return R.ok(); |
| | | } |
| | | |