wangxinhui
2025-06-25 e1dd1dc9ba7135e3d64a65587d6c1be2c3e18c5a
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_CheckService/CheckOrderResultService.cs
@@ -206,7 +206,8 @@
                    {
                        return content.Error($"数量超出");
                    }
                    if (checkResult.Result == InspectResultEnum.Return.ToString())//退货
                    //判断检验结果
                    if (checkResult.Result == InspectResultEnum.Return.ToString())
                    {
                        checkOrder.DefectedNote = checkResult.Note;
                        checkOrder.ReturnQuantity += checkResult.Quantity;
@@ -234,32 +235,25 @@
                        Note = checkResult.Note,
                        SampleCount = checkResult.SampleCount,
                    };
                    if (Math.Round(checkResult.Quantity,2) == Math.Round(stockInfoDetails.Sum(x=>x.StockQuantity),2))
                    foreach (var item in stockInfo.Details)
                    {
                        DelStockDetails = stockInfo.Details;
                    }
                    else
                    {
                        foreach (var item in stockInfo.Details)
                        if (checkResult.Quantity == 0)
                        {
                            if (checkResult.Quantity == 0)
                            {
                                break;
                            }
                            else if(checkResult.Quantity< item.StockQuantity)
                            {
                                checkResult.Quantity = 0;
                                item.StockQuantity -= checkResult.Quantity;
                                stockInfoDetails.Add(item);
                            }
                            else if (checkResult.Quantity >= item.StockQuantity)
                            {
                                checkResult.Quantity = (float)Math.Round((checkResult.Quantity-item.StockQuantity), 2);
                                DelStockDetails.Add(item);
                            }
                            break;
                        }
                        else if (checkResult.Quantity < item.StockQuantity)
                        {
                            item.StockQuantity -= checkResult.Quantity;
                            item.OutboundQuantity = 0;
                            checkResult.Quantity = 0;
                            stockInfoDetails.Add(item);
                        }
                        else if (checkResult.Quantity >= item.StockQuantity)
                        {
                            checkResult.Quantity = (float)Math.Round((checkResult.Quantity - item.StockQuantity), 2);
                            DelStockDetails.Add(item);
                        }
                    }
                }
                if (IsAccept == InspectAcceptEnum.Accept.ObjToInt())
                {
@@ -287,6 +281,7 @@
                    checkOrder.QualifiedQuantity = checkOrder.ReceivedQuantity;
                }
                checkOrder.CheckUserName = App.User.UserName;
                List<Dt_StockInfoDetail> initialStockDetails = stockInfo.Details.Where(x=> !(stockInfoDetails.Select(v=>v.Id).ToList()).Contains(x.Id)).ToList();
                _unitOfWorkManage.BeginTran();
                if (checkOrderResult != null)
@@ -296,7 +291,20 @@
                //清除库存数量
                if (stockInfoDetails.Count>0)
                {
                    stockInfoDetails.ForEach(x =>
                    {
                        x.Status = StockStatusEmun.送检库存完成.ObjToInt();
                    });
                    _stockRepository.StockInfoDetailRepository.UpdateData(stockInfoDetails);
                }
                if (initialStockDetails.Count>0)
                {
                    initialStockDetails.ForEach(x =>
                    {
                        x.OutboundQuantity = 0;
                        x.Status = StockStatusEmun.送检库存完成.ObjToInt();
                    });
                    _stockRepository.StockInfoDetailRepository.UpdateData(initialStockDetails);
                }
                if (DelStockDetails.Count>0)
                {
@@ -306,6 +314,11 @@
                {
                    _stockRepository.StockInfoRepository.DeleteAndMoveIntoHty(stockInfo, App.User.UserId == 0 ? OperateTypeEnum.自动完成 : OperateTypeEnum.人工完成);
                }
                else
                {
                    stockInfo.StockStatus = StockStatusEmun.送检库存完成.ObjToInt();
                    _stockRepository.StockInfoRepository.UpdateData(stockInfo);
                }
                //ERP上报
                WebResponseContent responseContent = _checkOrderService.FeedbackInspectResult(checkOrder, checkOrderResult != null ? new List<Dt_CheckOrderResult> { checkOrderResult } : new List<Dt_CheckOrderResult>());
                if (!responseContent.Status)