From 85f0ffc4d6720177d672e93c9f1190bf8e614c99 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 28 九月 2022 16:09:38 +0800
Subject: [PATCH] 获取 用户关联职员 信息

---
 WebAPI/Controllers/BLL/Xt_UserController.cs |  498 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 495 insertions(+), 3 deletions(-)

diff --git a/WebAPI/Controllers/BLL/Xt_UserController.cs b/WebAPI/Controllers/BLL/Xt_UserController.cs
index e3701a6..38d1af4 100644
--- a/WebAPI/Controllers/BLL/Xt_UserController.cs
+++ b/WebAPI/Controllers/BLL/Xt_UserController.cs
@@ -86,9 +86,9 @@
                 //    return objJsonResult;
                 //}
 
-                Int64 lngBillKey = 0;
-                lngBillKey = DBUtility.ClsPub.isLong(HCzybm);
-                if (lngBillKey == 0)
+                string lngBillKey = "";
+                lngBillKey = DBUtility.ClsPub.isStrNull(HCzybm);
+                if (lngBillKey == "")
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
@@ -360,5 +360,497 @@
             }
         }
         #endregion
+
+        #region  鏍规嵁鐢ㄦ埛缂栫爜鏌ユ壘宸插垎閰嶇粍缁囧垪琛�
+        [Route("Xt_User/UserByOrgPlaylist")]
+        [HttpGet]
+        public object UserByOrgPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HOrgID HItemID,瀵瑰簲缁勭粐浠g爜 HNumber,瀵瑰簲缁勭粐鍚嶇О HName from h_v_Gy_UserByOrgRelationList where 鐢ㄦ埛缂栫爜='" + HUserID + "' ", "h_v_Gy_UserByOrgRelationList");
+                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/SaveUserByOrg")]
+        [HttpPost]
+        public object SaveUserByOrg([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.Xt_ORGANIZATIONS> lsmain = new List<Models.Xt_ORGANIZATIONS>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Xt_ORGANIZATIONS(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserByOrgRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Xt_ORGANIZATIONS oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserByOrgRelation (HOrgID,HBillType,HUserID) values ('" + oItem.HItemID + "','','" + msg3.ToString() + "')");
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                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/UserStocklistPlaylist")]
+        [HttpGet]
+        public object UserStocklistPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HWHID HItemID,浠撳簱浠g爜 HNumber,浠撳簱鍚嶇О HName from h_v_Gy_UserStockRelationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserStockRelationList");
+                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/SaveUserStock")]
+        [HttpPost]
+        public object SaveUserStock([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.Warehouse> lsmain = new List<Models.Warehouse>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Warehouse(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserStockRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Warehouse oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserStockRelation (HWHID,HUserID) values ('" + oItem.HItemID + "','" + msg3.ToString() + "')");
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                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/UserGrouplistPlaylist")]
+        [HttpGet]
+        public object UserGrouplistPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HGroupID HItemID,鐝粍浠g爜 HNumber,鐝粍鍚嶇О HName from h_v_Gy_UserGroupRelationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserGroupRelationList");
+                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/SaveUserGroup")]
+        [HttpPost]
+        public object SaveUserGroup([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_Group> lsmain = new List<Models.Gy_Group>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Gy_Group(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserGroupRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Gy_Group oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserGroupRelation (HGroupID,HUserID) values ('" + oItem.HItemID + "','" + msg3.ToString() + "')");
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                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/UserDeptlistPlaylist")]
+        [HttpGet]
+        public object UserDeptlistPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HDeptID HItemID,閮ㄩ棬浠g爜 HNumber,閮ㄩ棬鍚嶇О HName from h_v_Gy_UserDeptRelationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserDeptRelationList");
+                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/SaveUserDept")]
+        [HttpPost]
+        public object SaveUserDept([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.Department> lsmain = new List<Models.Department>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Department(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserDeptRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Department oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserDeptRelation (HDeptID,HUserID) values ('" + oItem.HItemID + "','" + msg3.ToString() + "')");
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                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/UserByWorkStationlistPlaylist")]
+        [HttpGet]
+        public object UserByWorkStationlistPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HWorkStationID HItemID,宸ヤ綅浠g爜 HNumber,宸ヤ綅鍚嶇О HName from h_v_Gy_UserByWorkStationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserByWorkStationList");
+                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/SaveUserByWorkStation")]
+        [HttpPost]
+        public object SaveUserByWorkStation([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.Department> lsmain = new List<Models.Department>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Department(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserByWorkStationRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Department oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserByWorkStationRelation (HWorkStationID,HUserID) values ('" + oItem.HItemID + "','" + msg3.ToString() + "')");
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                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/UserEmployeelistPlaylist")]
+        [HttpGet]
+        public object UserEmployeelistPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HEmployeeID HItemID,鑱屽憳浠g爜 HNumber,鑱屽憳鍚嶇О HName from h_v_Gy_UserEmployeeRelationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserEmployeeRelationList");
+                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/SaveUserEmployee")]
+        [HttpPost]
+        public object SaveUserEmployee([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.Employee> lsmain = new List<Models.Employee>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Employee(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserEmployeeRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Employee oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserEmployeeRelation (HEmployeeID,HUserID) values ('" + oItem.HItemID + "','" + msg3.ToString() + "')");
+                }
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                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

--
Gitblit v1.9.1