From 5baf583924bc274d9cfe609fe71b497e46e1188e Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 19 十月 2022 10:56:08 +0800
Subject: [PATCH] 用户关联(用户、客户、物料)

---
 WebAPI/ListModels.cs                        |   36 ++++++
 WebAPI/Models/Gy_UserMater.cs               |   14 ++
 WebAPI/Controllers/BLL/Xt_UserController.cs |  250 +++++++++++++++++++++++++++++++++++++++++
 WebAPI/Models/Gy_UserCustomer.cs            |   14 ++
 WebAPI/Models/Gy_UserUser.cs                |   14 ++
 WebAPI/WebAPI.csproj                        |    3 
 6 files changed, 331 insertions(+), 0 deletions(-)

diff --git a/WebAPI/Controllers/BLL/Xt_UserController.cs b/WebAPI/Controllers/BLL/Xt_UserController.cs
index 38d1af4..2ffba78 100644
--- a/WebAPI/Controllers/BLL/Xt_UserController.cs
+++ b/WebAPI/Controllers/BLL/Xt_UserController.cs
@@ -852,5 +852,255 @@
             }
         }
         #endregion
+
+        #region  鏍规嵁鐢ㄦ埛缂栫爜鏌ユ壘宸插垎閰嶇敤鎴峰垪琛�
+        [Route("Xt_User/UserPlaylist")]
+        [HttpGet]
+        public object UserPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HUserID2,鐢ㄦ埛浠g爜 HUserNumber2,鐢ㄦ埛鍚嶇О HUserName2 from h_v_Gy_UserUserList where HUserID='" + HUserID + "' ", "h_v_Gy_UserUserList");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犵敤鎴蜂俊鎭紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈鐢ㄦ埛淇濆瓨
+        [Route("Xt_User/SaveUserUser")]
+        [HttpPost]
+        public object SaveUserUser([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+
+            ListModels oListModels = new ListModels();
+            try
+            {
+                List<Models.Gy_UserUser> lsmain = new List<Models.Gy_UserUser>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Gy_UserUser(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserByUserRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Gy_UserUser oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserByUserRelation (HUserID2,HUserID,HBillType,HUseFlag) values ('" + oItem.HUserID2 + "','" + msg3.ToString() + "','" + "" + "','" + "" + "')");
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region  鏍规嵁鐢ㄦ埛缂栫爜鏌ユ壘宸插垎閰嶇墿鏂欏垪琛�
+        [Route("Xt_User/MaterPlaylist")]
+        [HttpGet]
+        public object MaterPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HMaterID,鐗╂枡浠g爜 HMaterNumber,鐗╂枡鍚嶇О HMaterName from h_v_Gy_UserMaterList where HUserID='" + HUserID + "' ", "h_v_Gy_UserMaterList");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犵墿鏂欎俊鎭紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈鐗╂枡淇濆瓨
+        [Route("Xt_User/SaveUserMater")]
+        [HttpPost]
+        public object SaveUserMater([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+
+            ListModels oListModels = new ListModels();
+            try
+            {
+                List<Models.Gy_UserMater> lsmain = new List<Models.Gy_UserMater>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Gy_UserMater(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserMaterRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Gy_UserMater oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserMaterRelation (HMaterID,HUserID) values ('" + oItem.HMaterID + "','" + msg3.ToString() + "')");
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region  鏍规嵁鐢ㄦ埛缂栫爜鏌ユ壘宸插垎閰嶅鎴峰垪琛�
+        [Route("Xt_User/CustomerPlaylist")]
+        [HttpGet]
+        public object CustomerPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HCusID,瀹㈡埛浠g爜 HCustomerNumber,瀹㈡埛鍚嶇О HCustomerName from h_v_Gy_UserCustomerList where HUserID='" + HUserID + "' ", "h_v_Gy_UserCustomerList");
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲鎴蜂俊鎭紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈鐗╂枡淇濆瓨
+        [Route("Xt_User/SaveUserCustomer")]
+        [HttpPost]
+        public object SaveUserCustomer([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
+
+            ListModels oListModels = new ListModels();
+            try
+            {
+                List<Models.Gy_UserCustomer> lsmain = new List<Models.Gy_UserCustomer>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Gy_UserCustomer(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserCustomerRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Gy_UserCustomer oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserCustomerRelation (HCusID,HUserID) values ('" + oItem.HCusID + "','" + msg3.ToString() + "')");
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
     }
 }
\ No newline at end of file
diff --git a/WebAPI/ListModels.cs b/WebAPI/ListModels.cs
index 96bdf0b..2733854 100644
--- a/WebAPI/ListModels.cs
+++ b/WebAPI/ListModels.cs
@@ -1794,6 +1794,42 @@
         }
 
         /// <summary>
+        /// 鐢ㄦ埛-鐢ㄦ埛鍏崇郴淇℃伅琛ㄧ殑json
+        /// </summary>
+        /// <param name="jsonString"></param>
+        /// <returns></returns>
+        public List<Models.Gy_UserUser> getObjectByJson_Gy_UserUser(string jsonString)
+        {
+            jsonString = "[" + jsonString.ToString() + "]";
+            List<Models.Gy_UserUser> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Gy_UserUser>>(jsonString);
+            return list;
+        }
+
+        /// <summary>
+        /// 鐢ㄦ埛鐗╂枡鍏崇郴淇℃伅琛ㄧ殑json
+        /// </summary>
+        /// <param name="jsonString"></param>
+        /// <returns></returns>
+        public List<Models.Gy_UserMater> getObjectByJson_Gy_UserMater(string jsonString)
+        {
+            jsonString = "[" + jsonString.ToString() + "]";
+            List<Models.Gy_UserMater> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Gy_UserMater>>(jsonString);
+            return list;
+        }
+
+        /// <summary>
+        /// 鐢ㄦ埛瀹㈡埛鍏崇郴淇℃伅琛ㄧ殑json
+        /// </summary>
+        /// <param name="jsonString"></param>
+        /// <returns></returns>
+        public List<Models.Gy_UserCustomer> getObjectByJson_Gy_UserCustomer(string jsonString)
+        {
+            jsonString = "[" + jsonString.ToString() + "]";
+            List<Models.Gy_UserCustomer> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Models.Gy_UserCustomer>>(jsonString);
+            return list;
+        }
+
+        /// <summary>
         /// 鐢ㄦ埛缁勭粐鍏崇郴淇℃伅琛ㄧ殑json
         /// </summary>
         /// <param name="jsonString"></param>
diff --git a/WebAPI/Models/Gy_UserCustomer.cs b/WebAPI/Models/Gy_UserCustomer.cs
new file mode 100644
index 0000000..a1abffa
--- /dev/null
+++ b/WebAPI/Models/Gy_UserCustomer.cs
@@ -0,0 +1,14 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace WebAPI.Models
+{
+    public class Gy_UserCustomer
+    {
+        public int HCusID { get; set; }
+        public string HCustomerNumber { get; set; }
+        public string HCustomerName { get; set; }
+    }
+}
\ No newline at end of file
diff --git a/WebAPI/Models/Gy_UserMater.cs b/WebAPI/Models/Gy_UserMater.cs
new file mode 100644
index 0000000..0accfa1
--- /dev/null
+++ b/WebAPI/Models/Gy_UserMater.cs
@@ -0,0 +1,14 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace WebAPI.Models
+{
+    public class Gy_UserMater
+    {
+        public int HMaterID { get; set; }
+        public string HMaterNumber { get; set; }
+        public string HMaterName { get; set; }
+    }
+}
\ No newline at end of file
diff --git a/WebAPI/Models/Gy_UserUser.cs b/WebAPI/Models/Gy_UserUser.cs
new file mode 100644
index 0000000..35daf64
--- /dev/null
+++ b/WebAPI/Models/Gy_UserUser.cs
@@ -0,0 +1,14 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+
+namespace WebAPI.Models
+{
+    public class Gy_UserUser
+    {
+        public int HUserID2 { get; set; }
+        public string HUserNumber2 { get; set; }
+        public string HUserName2 { get; set; }
+    }
+}
\ No newline at end of file
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index 7652f0c..d6a79a9 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -560,6 +560,9 @@
     <Compile Include="Models\ClsSc_AssemblyBillMain.cs" />
     <Compile Include="Models\ClsSc_AssemblyBillSub.cs" />
     <Compile Include="Models\Employee.cs" />
+    <Compile Include="Models\Gy_UserCustomer.cs" />
+    <Compile Include="Models\Gy_UserMater.cs" />
+    <Compile Include="Models\Gy_UserUser.cs" />
     <Compile Include="Models\JIT_Cg_PODemandPlanBillMain.cs" />
     <Compile Include="Models\JIT_Cg_PODemandPlanBillSub.cs" />
     <Compile Include="Models\Cg_PODemandPlanConfigBillSub.cs" />

--
Gitblit v1.9.1