cnf
2025-08-23 2b4019cdae3d1abbd47bb2524a620e23cd8806e3
WebApi/Gs.Warehouse/Services/MesDepotSectionsManager.cs
@@ -1,4 +1,5 @@
using Gs.Entity.BaseInfo;
using AngleSharp.Text;
using Gs.Entity.BaseInfo;
using Gs.Entity.Sys;
using Gs.Toolbox;
using Gs.Toolbox.ApiCore.Abstract.Mvc;
@@ -29,27 +30,24 @@
            var _sbWhere = new StringBuilder(" 1=1" + query.keyWhere);
            var _sbBy = new StringBuilder(query.sortName + " " + query.sortOrder);
            var totalCount = 0;
            var itemsList = Db.Queryable<MesDepots,MesDepotSections, SysOrganization, MesStaff, MesCustomer, MesSupplier, SysDepartment>(
                    (a, b,Org, c, d, f, g) => new object[]
                    {
                        JoinType.Left, a.Guid == b.DepotGuid,
                        JoinType.Left, a.FSubsidiary == Org.Fid,
                        JoinType.Left, a.CreateBy == c.Id.ToString(),
                        JoinType.Left,d.Id.ToString()==a.ClientId.ToString(),
                        JoinType.Left,f.Id.ToString()==a.SuppLierId.ToString(),
                        JoinType.Left,g.Id.ToString()==a.department.ToString(),
                    }).Select((a, b, Org, c, d, f, g) => new MesDepotSections
                    {
                        Guid=b.Guid,
                        DepotSectionCode=b.DepotSectionCode.ToString(),
                        DepotSectionName=b.DepotSectionName.ToString(),
                        CreateBy = c.StaffName.ToString()
                    }, true)
                .Where(_sbWhere.ToString())
                .OrderBy(_sbBy.ToString())
                .ToPageList(query.currentPage, query.everyPageSize,
                    ref totalCount);
            // 先构建基础查询
            var queryBase = Db.Queryable<MesDepots>()
                .LeftJoin<MesDepotSections>((a, b) => a.Guid == b.DepotGuid);
                //.LeftJoin<SysOrganization>((a, b, c) => a.FSubsidiary == c.Fid)
                //.LeftJoin<MesStaff>((a, b, c, d) => a.CreateBy == d.Id.ToString())
                //.LeftJoin<MesCustomer>((a, b, c, d, e) => e.Id.ToString() == a.ClientId)
                //.LeftJoin<MesSupplier>((a, b, c, d, e, f) => f.Id.ToString() == a.SuppLierId)
                //.LeftJoin<SysDepartment>((a, b, c, d, e, f, g) => g.Id.ToString() == a.department);
            // 然后进行选择和分页
            var itemsList = queryBase.Select((a, b) => new MesDepotSections
            {
                Guid = b.Guid,
                DepotSectionCode = b.DepotSectionCode,
                DepotSectionName = b.DepotSectionName
            })
            .Where(_sbWhere.ToString())
            .OrderBy(_sbBy.ToString())
            .ToPageList(query.currentPage, query.everyPageSize, ref totalCount);
            pageList = new PageList<MesDepotSections>(itemsList, totalCount,
                query.everyPageSize);