From c14b27035aee532ddbafb44295cd5256e86299e1 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 09 八月 2024 17:08:54 +0800
Subject: [PATCH] 供应商,客户分类

---
 WebAPI/Properties/PublishProfiles/FolderProfile.pubxml.user |   34 ++--
 WebAPI/Controllers/BaseSet/Gy_CustomerController.cs         |  161 ++++++++++++++++++++++++++
 WebAPI/Controllers/BaseSet/Gy_SupplierController.cs         |  109 ++++++++++++++++++
 3 files changed, 287 insertions(+), 17 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs
index 3f4c8fa..f507d8a 100644
--- a/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_CustomerController.cs
@@ -1175,5 +1175,166 @@
         }
         #endregion
 
+         #region 瀹㈡埛鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�)
+
+        [Route("Gy_BadReason/Gy_CusrTypeTreeList")]
+        [HttpGet]
+        public object Gy_CusrTypeTreeList()
+        {
+            try
+            {
+                string sql1 = string.Format("select hitemid,hnumber,hname from Gy_MaterType order by hnumber");
+
+                ds = oCN.RunProcReturn(sql1, "Gy_MaterType");
+
+                List<TreeModel> treeModels = new List<TreeModel>();
+                TreeModel first = new TreeModel();
+                first.id = "0";
+                first.title = "瀹㈡埛鍒嗙被璁剧疆";
+                treeModels.Add(first);
+
+                foreach (DataRow row in ds.Tables[0].Rows)
+                {
+                    var strLen = row["hnumber"].ToString().Split('.');
+                    if (strLen.Length == 1)
+                    {
+                        TreeModel tree = new TreeModel();
+                        tree.id = row["hitemid"].ToString();
+                        tree.title = row["hname"].ToString();
+                        treeModels[0].children.Add(tree);
+                    }
+                }
+                digui(ds.Tables[0], treeModels[0].children, 2);
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels);
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鏍规嵁鐖秈d鍜岀瓑绾ц幏寰楁爲鐘跺浘閫掑綊
+
+        [Route("Gy_BadReason/Gy_CusTypeTreeListByLevel")]
+        [HttpGet]
+        public object Gy_CusTypeTreeListByLevel()
+        {
+            try
+            {
+                string sql1 = string.Format("select hitemid,hnumber,hname,hparentid,hlevel from Gy_CusType order by hnumber");
+
+                ds = oCN.RunProcReturn(sql1, "Gy_CusType");
+
+                List<TreeModel> treeModels = new List<TreeModel>();
+                TreeModel first = new TreeModel();
+                first.id = "0";
+                first.title = "瀹㈡埛鍒嗙被璁剧疆";
+                treeModels.Add(first);
+
+                foreach (DataRow row in ds.Tables[0].Rows)
+                {
+                    var HLevel = (int)row["hlevel"];
+                    if (HLevel == 1)
+                    {
+                        TreeModel tree = new TreeModel();
+                        tree.id = row["hitemid"].ToString();
+                        tree.title = row["hname"].ToString();
+                        treeModels[0].children.Add(tree);
+                    }
+                }
+                getTreeByLevel(ds.Tables[0], treeModels[0].children, 2);
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels);
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+
+
+        #region 鐗╂枡鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�)
+
+        public void getTreeByLevel(DataTable dt, List<TreeModel> tree, int num)
+        {
+            for (int m = 0; m < tree.Count; m++)
+            {
+                tree[m].children = new List<TreeModel>();
+                for (int i = 0; i < dt.Rows.Count; i++)//绗竴娆″惊鐜紝寰楀埌鎵�鏈夋牴鑺傜偣鐨勫瓙闆�
+                {
+                    var HLevel = (int)dt.Rows[i]["hlevel"];
+                    var HParentID = dt.Rows[i]["hparentid"].ToString();
+                    if (HLevel == num && HParentID == tree[m].id)
+                    {
+                        TreeModel tbjson = new TreeModel();
+                        tbjson.id = dt.Rows[i]["hitemid"].ToString();
+                        tbjson.title = dt.Rows[i]["hname"].ToString();
+                        tree[m].children.Add(tbjson);
+                    }
+                }
+                for (int i = 0; i < tree[m].children.Count; i++)
+                {
+                    getTreeByLevel(dt, tree[m].children, num + 1);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦
+                }
+            }
+
+        }
+        public class TreeModel
+        {
+            public string id { get; set; }
+            public string title { get; set; }
+            public List<TreeModel> children = new List<TreeModel>();
+        }
+
+        #endregion
+
+        /// <summary>
+        /// 閫掑綊鍑芥暟
+        /// </summary>
+        public void digui(DataTable dt, List<TreeModel> tree, int num)
+        {
+            for (int m = 0; m < tree.Count; m++)
+            {
+                tree[m].children = new List<TreeModel>();
+                for (int i = 0; i < dt.Rows.Count; i++)//绗竴娆″惊鐜紝寰楀埌鎵�鏈夋牴鑺傜偣鐨勫瓙闆�
+                {
+                    var strLen = dt.Rows[i]["hnumber"].ToString().Split('.');
+                    if (strLen.Length == num && dt.Rows[i]["hnumber"].ToString().Contains(tree[m].id + "."))
+                    {
+                        TreeModel tbjson = new TreeModel();
+                        tbjson.id = dt.Rows[i]["hitemid"].ToString();
+                        tbjson.title = dt.Rows[i]["hname"].ToString();
+                        tree[m].children.Add(tbjson);
+                    }
+                }
+                var strLens = tree[m].id.Split('.');
+                for (int i = 0; i < tree[m].children.Count; i++)
+                {
+                    digui(dt, tree[m].children, strLens.Length + 2);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦
+                }
+            }
+
+        }
+
     }
 }
\ No newline at end of file
diff --git a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs
index 8f11c57..348db1d 100644
--- a/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_SupplierController.cs
@@ -932,5 +932,114 @@
         }
         #endregion
 
+        #region 鏍规嵁鐖秈d鍜岀瓑绾ц幏寰楁爲鐘跺浘閫掑綊
+
+        [Route("Gy_BadReason/Gy_SupTypeTreeListByLevel")]
+        [HttpGet]
+        public object Gy_MaterTypeTreeListByLevel()
+        {
+            try
+            {
+                string sql1 = string.Format("select hitemid,hnumber,hname,hparentid,hlevel from Gy_SupType order by hnumber");
+
+                ds = oCN.RunProcReturn(sql1, "Gy_SupType");
+
+                List<TreeModel> treeModels = new List<TreeModel>();
+                TreeModel first = new TreeModel();
+                first.id = "0";
+                first.title = "渚涘簲鍟嗗垎绫昏缃�";
+                treeModels.Add(first);
+
+                foreach (DataRow row in ds.Tables[0].Rows)
+                {
+                    var HLevel = (int)row["hlevel"];
+                    if (HLevel == 1)
+                    {
+                        TreeModel tree = new TreeModel();
+                        tree.id = row["hitemid"].ToString();
+                        tree.title = row["hname"].ToString();
+                        treeModels[0].children.Add(tree);
+                    }
+                }
+                getTreeByLevel(ds.Tables[0], treeModels[0].children, 2);
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = Newtonsoft.Json.JsonConvert.SerializeObject(treeModels);
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+        public void getTreeByLevel(DataTable dt, List<TreeModel> tree, int num)
+        {
+            for (int m = 0; m < tree.Count; m++)
+            {
+                tree[m].children = new List<TreeModel>();
+                for (int i = 0; i < dt.Rows.Count; i++)//绗竴娆″惊鐜紝寰楀埌鎵�鏈夋牴鑺傜偣鐨勫瓙闆�
+                {
+                    var HLevel = (int)dt.Rows[i]["hlevel"];
+                    var HParentID = dt.Rows[i]["hparentid"].ToString();
+                    if (HLevel == num && HParentID == tree[m].id)
+                    {
+                        TreeModel tbjson = new TreeModel();
+                        tbjson.id = dt.Rows[i]["hitemid"].ToString();
+                        tbjson.title = dt.Rows[i]["hname"].ToString();
+                        tree[m].children.Add(tbjson);
+                    }
+                }
+                for (int i = 0; i < tree[m].children.Count; i++)
+                {
+                    getTreeByLevel(dt, tree[m].children, num + 1);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦
+                }
+            }
+
+        }
+        #endregion
+
+        #region 鐗╂枡鍒嗙被 鏍戝舰鍥�(鏍规嵁浠g爜灞曞紑鏍戠姸鍥�)
+        public class TreeModel
+        {
+            public string id { get; set; }
+            public string title { get; set; }
+            public List<TreeModel> children = new List<TreeModel>();
+        }
+        /// <summary>
+        /// 閫掑綊鍑芥暟
+        /// </summary>
+        public void digui(DataTable dt, List<TreeModel> tree, int num)
+        {
+            for (int m = 0; m < tree.Count; m++)
+            {
+                tree[m].children = new List<TreeModel>();
+                for (int i = 0; i < dt.Rows.Count; i++)//绗竴娆″惊鐜紝寰楀埌鎵�鏈夋牴鑺傜偣鐨勫瓙闆�
+                {
+                    var strLen = dt.Rows[i]["hnumber"].ToString().Split('.');
+                    if (strLen.Length == num && dt.Rows[i]["hnumber"].ToString().Contains(tree[m].id + "."))
+                    {
+                        TreeModel tbjson = new TreeModel();
+                        tbjson.id = dt.Rows[i]["hitemid"].ToString();
+                        tbjson.title = dt.Rows[i]["hname"].ToString();
+                        tree[m].children.Add(tbjson);
+                    }
+                }
+                var strLens = tree[m].id.Split('.');
+                for (int i = 0; i < tree[m].children.Count; i++)
+                {
+                    digui(dt, tree[m].children, strLens.Length + 2);//鍐嶆鐢ㄥ瓙闆嗗幓寰幆锛屾嬁鍑哄瓙闆嗙殑瀛愰泦
+                }
+            }
+
+        }
+
+        #endregion
     }
 }
\ No newline at end of file
diff --git a/WebAPI/Properties/PublishProfiles/FolderProfile.pubxml.user b/WebAPI/Properties/PublishProfiles/FolderProfile.pubxml.user
index c6f5e87..bd4f2ba 100644
--- a/WebAPI/Properties/PublishProfiles/FolderProfile.pubxml.user
+++ b/WebAPI/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -23,12 +23,12 @@
     <File Include="bin/BLL.dll">
       <publishTime>11/09/2022 16:02:08</publishTime>
       <publishTime>11/02/2022 22:03:01</publishTime>
-      <publishTime>08/08/2024 10:24:31</publishTime>
+      <publishTime>08/09/2024 17:06:15</publishTime>
     </File>
     <File Include="bin/BLL.pdb">
       <publishTime>11/09/2022 16:02:08</publishTime>
       <publishTime>11/02/2022 22:03:01</publishTime>
-      <publishTime>08/08/2024 10:24:31</publishTime>
+      <publishTime>08/09/2024 17:06:15</publishTime>
     </File>
     <File Include="bin/BouncyCastle.Crypto.dll">
       <publishTime>12/18/2020 05:32:28</publishTime>
@@ -36,12 +36,12 @@
     <File Include="bin/DAL.dll">
       <publishTime>11/09/2022 16:02:06</publishTime>
       <publishTime>11/02/2022 22:02:58</publishTime>
-      <publishTime>08/08/2024 10:24:29</publishTime>
+      <publishTime>08/09/2024 17:06:12</publishTime>
     </File>
     <File Include="bin/DAL.pdb">
       <publishTime>11/09/2022 16:02:06</publishTime>
       <publishTime>11/02/2022 22:02:58</publishTime>
-      <publishTime>08/08/2024 10:24:29</publishTime>
+      <publishTime>08/09/2024 17:06:12</publishTime>
     </File>
     <File Include="bin/Dapper.dll">
       <publishTime>07/22/2016 22:52:40</publishTime>
@@ -49,12 +49,12 @@
     <File Include="bin/DBUtility.dll">
       <publishTime>11/02/2022 22:02:56</publishTime>
       <publishTime>11/15/2022 13:55:23</publishTime>
-      <publishTime>08/08/2024 10:24:24</publishTime>
+      <publishTime>08/09/2024 17:06:06</publishTime>
     </File>
     <File Include="bin/DBUtility.pdb">
       <publishTime>11/09/2022 16:01:58</publishTime>
       <publishTime>11/02/2022 22:02:56</publishTime>
-      <publishTime>08/08/2024 10:24:24</publishTime>
+      <publishTime>08/09/2024 17:06:06</publishTime>
     </File>
     <File Include="bin/Grpc.Core.Api.dll">
       <publishTime>03/22/2022 13:17:26</publishTime>
@@ -110,12 +110,12 @@
     <File Include="bin/Model.dll">
       <publishTime>11/09/2022 16:02:01</publishTime>
       <publishTime>11/02/2022 22:02:56</publishTime>
-      <publishTime>08/08/2024 10:24:25</publishTime>
+      <publishTime>08/09/2024 17:06:07</publishTime>
     </File>
     <File Include="bin/Model.pdb">
       <publishTime>11/09/2022 16:02:01</publishTime>
       <publishTime>11/02/2022 22:02:56</publishTime>
-      <publishTime>08/08/2024 10:24:25</publishTime>
+      <publishTime>08/09/2024 17:06:07</publishTime>
     </File>
     <File Include="bin/Models/ClsSc_MouldScrapOutBillMain.cs">
       <publishTime>04/15/2024 12:55:45</publishTime>
@@ -150,33 +150,33 @@
     <File Include="bin/Pub_Class.dll">
       <publishTime>11/09/2022 16:01:56</publishTime>
       <publishTime>11/02/2022 22:02:54</publishTime>
-      <publishTime>08/08/2024 10:24:22</publishTime>
+      <publishTime>08/09/2024 17:06:05</publishTime>
     </File>
     <File Include="bin/Pub_Class.pdb">
       <publishTime>11/09/2022 16:01:56</publishTime>
       <publishTime>11/02/2022 22:02:54</publishTime>
-      <publishTime>08/08/2024 10:24:22</publishTime>
+      <publishTime>08/09/2024 17:06:05</publishTime>
     </File>
     <File Include="bin/Pub_Control.dll">
       <publishTime>11/09/2022 16:01:57</publishTime>
       <publishTime>11/02/2022 22:02:55</publishTime>
-      <publishTime>08/08/2024 10:24:24</publishTime>
+      <publishTime>08/09/2024 17:06:05</publishTime>
     </File>
     <File Include="bin/Pub_Control.pdb">
       <publishTime>11/09/2022 16:01:57</publishTime>
       <publishTime>11/02/2022 22:02:55</publishTime>
-      <publishTime>08/08/2024 10:24:24</publishTime>
+      <publishTime>08/09/2024 17:06:05</publishTime>
     </File>
     <File Include="bin/RestSharp.dll">
       <publishTime>08/31/2012 06:22:50</publishTime>
     </File>
     <File Include="bin/SQLHelper.dll">
-      <publishTime>08/08/2024 10:24:24</publishTime>
+      <publishTime>08/09/2024 17:06:05</publishTime>
     </File>
     <File Include="bin/SQLHelper.pdb">
       <publishTime>11/09/2022 16:01:57</publishTime>
       <publishTime>11/02/2022 22:02:55</publishTime>
-      <publishTime>08/08/2024 10:24:24</publishTime>
+      <publishTime>08/09/2024 17:06:05</publishTime>
     </File>
     <File Include="bin/stdole.dll">
       <publishTime>05/09/2021 13:35:37</publishTime>
@@ -295,7 +295,7 @@
     <File Include="bin/WebAPI.dll">
       <publishTime>11/14/2022 11:23:59</publishTime>
       <publishTime>11/02/2022 22:03:04</publishTime>
-      <publishTime>08/08/2024 10:24:39</publishTime>
+      <publishTime>08/09/2024 17:06:21</publishTime>
     </File>
     <File Include="bin/WebAPI.dll.config">
       <publishTime>12/15/2021 17:59:43</publishTime>
@@ -303,7 +303,7 @@
     <File Include="bin/WebAPI.pdb">
       <publishTime>11/14/2022 11:23:59</publishTime>
       <publishTime>11/02/2022 22:03:04</publishTime>
-      <publishTime>08/08/2024 10:24:39</publishTime>
+      <publishTime>08/09/2024 17:06:21</publishTime>
     </File>
     <File Include="bin/WebGrease.dll">
       <publishTime>07/18/2013 01:03:52</publishTime>
@@ -512,7 +512,7 @@
     <File Include="Web.config">
       <publishTime>11/14/2022 11:24:08</publishTime>
       <publishTime>11/02/2022 22:03:20</publishTime>
-      <publishTime>08/08/2024 10:31:57</publishTime>
+      <publishTime>08/09/2024 17:07:33</publishTime>
     </File>
   </ItemGroup>
 </Project>
\ No newline at end of file

--
Gitblit v1.9.1