647556386
2026-01-28 f506ae008db19791fd211c4c7ca8041a2bf00874
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_InboundService/InboundService.cs
@@ -440,13 +440,24 @@
                    //}
                }
                _mesReturnRecord.UpdateData(returnRecords);
                //重新回调完成的单据,更新库存状态
                foreach (var returnRecord in returnRecords)
                {
                    if (returnRecord.ReturnStatus == 1)
                    {
                        _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
                        {
                            Status = StockStatusEmun.入库完成.ObjToInt()
                        }).Where(it => it.OrderNo == returnRecord.OrderNo && returnRecord.RequestData.Contains(it.Barcode)).ExecuteCommand();
                    }
                }
                var inboundOrderDetail = _inboundOrderRepository.Db.Queryable<Dt_InboundOrderDetail>()
                                        .Where(x => x.OrderId == inboundOrder.Id && x.OrderDetailStatus==(int)OrderDetailStatusEnum.Over && x.ReturnToMESStatus == 0)
                                        .ToList();
                var stocks = _stockInfoRepository.Db.Queryable<Dt_StockInfo>().Where(x => x.StockStatus == (int)StockStatusEmun.入库完成)
                                            .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == inboundOrder.InboundOrderNo).Any())
                                            .Where(it => SqlFunc.Subqueryable<Dt_StockInfoDetail>().Where(s => s.StockId == it.Id && s.OrderNo == inboundOrder.InboundOrderNo && s.Status == StockStatusEmun.入库确认.ObjToInt()).Any())
                                            .ToList();
                var stockIds = stocks.Select(s => s.Id).ToList();
@@ -467,6 +478,13 @@
                                    inbound => inbound.Barcode,
                                    stockdetail => stockdetail.Barcode,
                                    (inbound, stockdetail) => inbound.Id)
                                .ToList();
                var inbounddetailBarcode = inboundOrderDetail
                                .Join(allDetailsData,
                                    inbound => inbound.Barcode,
                                    stockdetail => stockdetail.Barcode,
                                    (inbound, stockdetail) => stockdetail.Barcode)
                                .ToList();
                var detail = allDetailsData.Where(x => matchedData.Contains(x.Barcode)).ToList();
@@ -512,6 +530,11 @@
                    {
                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                        .Where(it => it.OrderId == inboundOrder.Id && inbounddetailID.Contains(it.Id)).ExecuteCommand();
                        _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
                        {
                            Status = StockStatusEmun.入库完成.ObjToInt()
                        }).Where(it => it.OrderNo == inboundOrder.InboundOrderNo && inbounddetailBarcode.Contains(it.Barcode)).ExecuteCommand();
                    }
                    else
                    {
@@ -558,6 +581,11 @@
                    {
                        _inboundOrderRepository.Db.Updateable<Dt_InboundOrderDetail>().SetColumns(it => new Dt_InboundOrderDetail { ReturnToMESStatus = 1 })
                        .Where(it => inbounddetailID.Contains(it.Id)).ExecuteCommand();
                        _stockInfoRepository.Db.Updateable<Dt_StockInfoDetail>().SetColumns(it => new Dt_StockInfoDetail
                        {
                            Status = StockStatusEmun.入库完成.ObjToInt()
                        }).Where(it => it.OrderNo == inboundOrder.InboundOrderNo && inbounddetailBarcode.Contains(it.Barcode)).ExecuteCommand();
                    }
                    else
                    {
@@ -575,6 +603,7 @@
            }
        }
        public List<AllocateDtoDetail> GetAllocateDtoDetails(List<Dt_StockInfoDetail> stockInfoDetails)
        {
            var groupedData = stockInfoDetails.GroupBy(item => new { item.MaterielCode, item.InboundOrderRowNo, item.BarcodeUnit, item.WarehouseCode })