wangxinhui
2024-12-18 a44d4ac81a863fb3b93e1c8ad8526ef754c24615
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_StockService/StockInfoService.cs
@@ -1,4 +1,5 @@
using AutoMapper;
using MailKit.Search;
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
using SqlSugar;
using System;
@@ -70,7 +71,54 @@
            }
        }
        public StockOutboundOrderDTO GetStockOutboundOrder(SaveModel saveModel)
        {
            try
            {
                var palletCode = saveModel.MainData["barcode"].ToString();
                Dt_StockInfo stockInfo = BaseDal.Db.Queryable<Dt_StockInfo>().Where(x => x.PalletCode == palletCode).Includes(x => x.Details).First();
                if (stockInfo == null)
                {
                    throw new Exception($"未找到库存信息");
                }
                Dt_StockInfoDetail stockInfoDetail = stockInfo.Details.FirstOrDefault();
                if (stockInfoDetail == null)
                {
                    throw new Exception($"未找到库存详情");
                }
                BaseDal.QueryTabs<Dt_OutboundOrder, Dt_OutboundOrderDetail, StockOutboundOrderDTO>((a, b) => a.Id == b.OrderId, (a, b) => new StockOutboundOrderDTO
                {
                    OrderNo = a.OrderNo,
                    MaterielCode = b.MaterielCode,
                    MaterielName = b.MaterielName,
                    PalletCode = stockInfo.PalletCode,
                    BatchNo = b.BatchNo,
                    OrderQuantity = b.OrderQuantity,
                    OverOutQuantity = b.OverOutQuantity,
                    OutboundQuantity = stockInfoDetail.OutboundQuantity,
                    SerialNumber = stockInfoDetail.SerialNumber,
                    StockQuantity = stockInfoDetail.StockQuantity,
                }, a => true, b => b.BatchNo == stockInfoDetail.BatchNo && b.MaterielCode == stockInfoDetail.MaterielCode, x => true).Select(x => new StockOutboundOrderDTO
                {
                    OrderNo = x.OrderNo,
                    MaterielCode = x.MaterielCode,
                    MaterielName = x.MaterielName,
                    PalletCode = x.PalletCode,
                    BatchNo = x.BatchNo,
                    OrderQuantity = x.OrderQuantity,
                    OverOutQuantity = x.OverOutQuantity,
                    OutboundQuantity = x.OutboundQuantity,
                    SerialNumber = x.SerialNumber,
                    StockQuantity = x.StockQuantity,
                }).ToList();
                return new StockOutboundOrderDTO();
            }
            catch (Exception ex)
            {
                return null;
            }
        }
        public List<Dt_StockInfo> GetOutboundStocks(List<Dt_StockInfo> stockInfos, string materielCode, float needQuantity, out float residueQuantity)
        {
            List<Dt_StockInfo> outStocks = new List<Dt_StockInfo>();