using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using Model.ModelDto.BllSoDto; using SqlSugar; using WMS.DAL; using WMS.Entity.BllSoEntity; using WMS.Entity.Context; using WMS.Entity.SysEntity; using WMS.IBLL.IBllSoServer; namespace WMS.BLL.BllSoServer { public class CompleteDetailServer: DbHelper,ICompleteDetailServer { private static readonly SqlSugarScope Db = DataContext.Db; public CompleteDetailServer():base(Db) { } //查询拣货明细箱码信息(分组后) public List GetCompleteDetailList(int id, int page, int limit, out int count) { try { var total = 0; Expression> item = Expressionable.Create() .And(it => it.ExportAllotId == id) .And(it => it.IsDel == "0") .ToExpression();//注意 这一句 不能少 var data = GetAllWhereAsync(item) .GroupBy(m=>new { m.SONo, m.SODetailNo, m.StockId, m.ExportAllotId, m.BoxNo, m.LotNo, m.LotText, m.SupplierLot, m.SkuNo, m.SkuName, m.Standard, m.PalletNo, m.NowPalletNo }) .Select(a => new CompleteDetailDto() { SONo = a.SONo, SODetailNo = a.SODetailNo, StockId = a.StockId, ExportAllotId = a.ExportAllotId, BoxNo = a.BoxNo, LotNo = a.LotNo, LotText = a.LotText, SupplierLot = a.SupplierLot, SkuNo = a.SkuNo, SkuName = a.SkuName, Standard = a.Standard, PalletNo = a.PalletNo, CompleteQty = SqlFunc.AggregateSum(a.CompleteQty), NowPalletNo = a.NowPalletNo }).ToOffsetPage(page, limit, ref total); count = total; return data; } catch (Exception e) { throw new Exception(e.Message); } } //查询拣货明细支码详细信息 public List GetCompBoxInfoList(string boxNo, string boxNo3) { try { Expression> item = Expressionable.Create() .AndIF(!string.IsNullOrWhiteSpace(boxNo), it => it.BoxNo == boxNo.Trim()) .AndIF(!string.IsNullOrWhiteSpace(boxNo3), it => it.BoxNo3.Contains(boxNo3.Trim())) .ToExpression(); var data = GetAllWhereAsync(item) .LeftJoin((a, b) => a.CreateUser == b.Id) .LeftJoin((a, b, c) => a.UpdateUser == c.Id) .Select((a, b, c) => new CompleteDetailDto() { Id = a.Id, SONo = a.SONo, SODetailNo = a.SODetailNo, StockId = a.StockId, ExportAllotId = a.ExportAllotId, BoxNo = a.BoxNo, BoxNo3 = a.BoxNo3, LotNo = a.LotNo, LotText = a.LotText, SupplierLot = a.SupplierLot, SkuNo = a.SkuNo, SkuName = a.SkuName, Standard = a.Standard, PalletNo = a.PalletNo, CompleteQty = a.CompleteQty, NowPalletNo = a.NowPalletNo, CreateUserName = b.RealName, UpdateUserName = c.RealName, CreateTime = a.CreateTime, UpdateTime = a.UpdateTime, }).ToList(); return data; } catch (Exception e) { throw new Exception(e.Message); } } } }