skyouc
1 天以前 f56457b75944ef2def631ad5ed07f302123d3f75
rsf-server/src/main/java/com/vincent/rsf/server/api/service/impl/PdaOutStockServiceImpl.java
@@ -98,7 +98,7 @@
        if (null == task) {
            throw new CoolException("未找到容器号对应任务");
        }
        if (!task.getTaskStatus().equals(TaskStsType.AWAIT.id)) {
        if (!task.getTaskStatus().equals(TaskStsType.WAVE_SEED.id)) {
            return R.error("任务状态不是等待确认");
        }
        List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()));
@@ -280,10 +280,10 @@
            if (Objects.isNull(orderItem)) {
                throw new CoolException("数据错误,拣料不在单据需求中!!");
            }
            //taskItems为拣货明细,作参数上报
            Double summed = items.stream().mapToDouble(TaskItem::getAnfme).sum();
            //加上历史拣料数量
            Double pickQty = Math.round((orderItem.getQty() + summed) * 100) / 100.0;
            Double pickQty = Math.round((orderItem.getQty() + summed) * 1000000) / 1000000.0;
            Config config = configService.getOne(new LambdaQueryWrapper<Config>().eq(Config::getFlag, GlobalConfigCode.ALLOW_OVER_CHANGE));
            //判断是否允许超收,不允许超收添加拒收判断
            if (!Objects.isNull(config)) {
@@ -326,20 +326,33 @@
                TaskItem item = taskItemService.getById(taskItem.getId());
                //判断是否允许超收,不允许超收添加拒收判断
                if (!Objects.isNull(config)) {
                    LocItemWorking serviceOne = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getFieldsIndex, item.getFieldsIndex()));
                    if (Objects.isNull(serviceOne)) {
                        throw new CoolException("缓存数据丢失!!");
                    }
                    //不管是否允许超收,都需判断是否超出库存范围
                    if (taskItem.getAnfme().compareTo(serviceOne.getAnfme()) > 0) {
                        throw new CoolException("拣货数量超出当前票号库存数量!!");
                    }
                    if (!Boolean.parseBoolean(config.getVal())) {
                        if (item.getAnfme().compareTo(item.getQty() + taskItem.getAnfme()) < 0.0) {
                        Double v = Math.round((item.getQty() + taskItem.getAnfme()) * 1000000) / 1000000.0;
                        if (item.getAnfme().compareTo(v) < 0.0) {
                            throw new CoolException("前当物料已超出可拣范围,请核对后再操作!!");
                        }
                    }
                }
                item.setQty(item.getQty() + taskItem.getAnfme()).setOrderId(order.getId()).setOrderItemId(orderItem.getId());
                Double picQty = Math.round((item.getQty() + taskItem.getAnfme()) * 1000000) / 1000000.0;
                item.setQty(picQty).setOrderId(order.getId()).setOrderItemId(orderItem.getId());
                if (!taskItemService.updateById(item)) {
                    throw new CoolException("状态完成失败!!");
                }
                StockItem stockItem = new StockItem();
                BeanUtils.copyProperties(taskItem, stockItem);
                stockItem.setStockId(stock.getId()).setStockCode(stock.getCode()).setSourceItemId(orderItem.getId());
                BeanUtils.copyProperties(item, stockItem);
                //taskItem为上报数据
                stockItem.setStockId(stock.getId()).setAnfme(taskItem.getAnfme()).setStockCode(stock.getCode()).setSourceItemId(orderItem.getId());
                stockItems.add(stockItem);
            });
            if (!stockItemService.saveBatch(stockItems)) {
@@ -348,9 +361,10 @@
        });
        List<WkOrderItem> orderItems = asnOrderItemService.list(new LambdaQueryWrapper<WkOrderItem>().eq(WkOrderItem::getOrderId, params.getOrderId()));
        double total = orderItems.stream().mapToDouble(WkOrderItem::getQty).sum();
        Double total = orderItems.stream().mapToDouble(WkOrderItem::getQty).sum();
        Double wkQty = orderItems.stream().mapToDouble(WkOrderItem::getWorkQty).sum();
        order.setQty(total).setWorkQty(order.getWorkQty().compareTo(wkQty) < 0 ? 0.0 : (total - wkQty));
        double v = order.getWorkQty().compareTo(wkQty) < 0 ? 0.0 : Math.round((total - wkQty) * 1000000) / 1000000.0;
        order.setQty(total).setWorkQty(v);
        if (!asnOrderService.updateById(order)) {
            throw new CoolException("订单数量更新失败!!");
        }