From e19f8a13e2b35e6836ce46c17402c44327814a00 Mon Sep 17 00:00:00 2001
From: wbc <2597324127@qq.com>
Date: 星期四, 18 十二月 2025 09:14:36 +0800
Subject: [PATCH] 产能排产漏更新

---
 WebApi/Gs.Warehouse/Services/MesDepotSectionsManager.cs |  100 +++++++++++++++++++++++++++++++++++--------------
 1 files changed, 71 insertions(+), 29 deletions(-)

diff --git a/WebApi/Gs.Warehouse/Services/MesDepotSectionsManager.cs b/WebApi/Gs.Warehouse/Services/MesDepotSectionsManager.cs
index 3e8c2fc..b81d0b3 100644
--- a/WebApi/Gs.Warehouse/Services/MesDepotSectionsManager.cs
+++ b/WebApi/Gs.Warehouse/Services/MesDepotSectionsManager.cs
@@ -1,11 +1,11 @@
-锘縰sing System.Data;
-using System.Text;
-using Gs.Entity.BaseInfo;
+锘縰sing Gs.Entity.BaseInfo;
 using Gs.Toolbox;
 using Gs.Toolbox.ApiCore.Abstract.Mvc;
 using Gs.Toolbox.ApiCore.Common.Mvc;
 using Gs.Toolbox.ApiCore.Group;
 using Microsoft.AspNetCore.Http;
+using System.Data;
+using System.Text;
 
 namespace Gs.Warehouse.Services;
 
@@ -16,6 +16,58 @@
     private readonly IHttpContextAccessor _http;
 
     private readonly string _userCode, _userGuid, _orgFids;
+
+    public MesDepotSectionsManager()
+    {
+        //_http = httpContextAccessor;
+        //(_userCode, _userGuid, _orgFids) =
+        //    UtilityHelper.GetUserGuidAndOrgGuid(_http);
+    }
+
+      /// <summary>
+    ///     鏌ヨ鍒楄〃锛屾敮鎸佸垎椤�
+    /// </summary>
+    /// <param name="query"></param>
+    /// <returns></returns>
+    [RequestMethod(RequestMethods.POST)]
+    public ReturnDto<PageList<MesDepotSections>> GetListPage(PageQuery query)
+    {
+        var pageList = new PageList<MesDepotSections>();
+        try
+        {
+            var _sbWhere = new StringBuilder(" 1=1" + query.keyWhere);
+            var _sbBy = new StringBuilder(query.sortName + " " + query.sortOrder);
+            var totalCount = 0;
+            // 鍏堟瀯寤哄熀纭�鏌ヨ
+            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);
+            return ReturnDto<PageList<MesDepotSections>>.QuickReturn(pageList,
+                ReturnCode.Success, "璇诲彇鎴愬姛");
+        }
+        catch (Exception ex)
+        {
+            return ReturnDto<PageList<MesDepotSections>>.QuickReturn(pageList,
+                ReturnCode.Default, ex.Message);
+        }
+    }
 
 
     /// <summary>
@@ -28,37 +80,28 @@
     {
         var currentPage = model.currentPage;
         var everyPageSize = model.everyPageSize;
-        var sortName = string.IsNullOrEmpty(model.sortName)
-            ? "a.USER_NAME"
-            : model.sortName;
+        var sortName = string.IsNullOrEmpty(model.sortName) ? "a.USER_NAME" : model.sortName;
         var keyWhere = model.keyWhere;
-        var keyType = model.keyType;
-        var sbJoin = new StringBuilder();
+        string keyType = model.keyType;
+        System.Text.StringBuilder sbJoin = new StringBuilder();
         sbJoin.Append(" from [dbo].[MES_DEPOT_SECTIONS] a ");
-        sbJoin.Append(
-            " left join [dbo].[MES_DEPOTS] d on a.depot_guid=d.depot_id");
-        sbJoin.Append(
-            " left join SYS_ORGANIZATION org on d.FSubsidiary=org.FID");
+        sbJoin.Append(" left join [dbo].[MES_DEPOTS] d on a.depot_guid=d.depot_id");
+        sbJoin.Append(" left join SYS_ORGANIZATION org on d.FSubsidiary=org.FID");
         sbJoin.Append(keyWhere);
         var sbSql = new StringBuilder();
         sbSql.Append("  SELECT * FROM ");
-        sbSql.Append(
-            " (SELECT N'(' +[Org].[FNumber] + N')'  +[Org].[NAME]  AS [FSubsidiary2]");
-        sbSql.Append(
-            ", a.depot_section_code as cwCode,a.depot_section_name as cwName,d.depot_name as ckName,d.depot_id as ckId,d.depot_code as ckCode ,ROW_NUMBER() OVER(ORDER BY a.depot_section_code asc) AS RowIndex ");
+        sbSql.Append(" (SELECT N'(' +[Org].[FNumber] + N')'  +[Org].[NAME]  AS [FSubsidiary2]");
+        sbSql.Append(", a.depot_section_code as cwCode,a.depot_section_name as cwName,d.depot_name as ckName,d.depot_id as ckId,d.depot_code as ckCode ,ROW_NUMBER() OVER(ORDER BY a.depot_section_code asc) AS RowIndex ");
         //濡傛灉鏃犲叧閿瓧锛屾棤闇�鎵炬煡缁戝畾
         if (string.IsNullOrEmpty(keyType))
+        {
             sbSql.Append(",cast(0 as bit) as chkInt");
+        }
         else
-            sbSql.Append(
-                ",cast( (select count(1)  from SYS_USER_BIND bind where bind.userGuid='" +
-                keyType +
-                "' and bind.aboutGuid=a.depot_section_code  and bind.fType='搴撲綅')  as bit) as chkInt ");
+            sbSql.Append(",cast( (select count(1)  from SYS_USER_BIND bind where bind.userGuid='" + keyType + "' and bind.aboutGuid=a.depot_section_code  and bind.fType='搴撲綅')  as bit) as chkInt ");
         sbSql.Append(sbJoin);
         sbSql.Append(") T");
-        sbSql.Append(" where T.rowindex>(" + currentPage + "-1)*" +
-                     everyPageSize + " and  T.rowindex<=" + currentPage + "*" +
-                     everyPageSize);
+        sbSql.Append(" where T.rowindex>(" + currentPage + "-1)*" + everyPageSize + " and  T.rowindex<=" + currentPage + "*" + everyPageSize);
         sbSql.Append(" select count(1) as intTotal ");
         sbSql.Append(sbJoin);
         var dset = new DataSet();
@@ -69,10 +112,8 @@
         catch (Exception ex)
         {
             LogHelper.Debug(ToString(), "GetListPage error锛�" + ex.Message);
-            return ReturnDto<PageList<dynamic>>.QuickReturn(
-                default(PageList<dynamic>), ReturnCode.Exception, "璇诲彇澶辫触");
+            return ReturnDto<PageList<dynamic>>.QuickReturn(default(PageList<dynamic>), ReturnCode.Exception, "璇诲彇澶辫触");
         }
-
         var _pglist = new PageList<dynamic>
         {
             total = 0,
@@ -83,8 +124,7 @@
         if (dset != null && dset.Tables.Count > 0 &&
             dset.Tables[0].Rows.Count > 0) //鏈夋暟鎹�
         {
-            var intTotal =
-                int.Parse(dset.Tables[1].Rows[0]["intTotal"].ToString());
+            var intTotal = int.Parse(dset.Tables[1].Rows[0]["intTotal"].ToString());
             var pages = intTotal % everyPageSize != 0
                 ? intTotal / everyPageSize + 1
                 : intTotal / everyPageSize;
@@ -94,8 +134,10 @@
             var _dy = dset.Tables[0].TableToDynamicList();
             _pglist.list = _dy;
         }
-
         return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist,
             ReturnCode.Success, "璇诲彇鎴愬姛");
     }
+
+
+
 }
\ No newline at end of file

--
Gitblit v1.9.3