From e1cbefad8e411d8305c6730c2e1e0221a7525c9d Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期三, 09 十月 2024 16:32:34 +0800
Subject: [PATCH] 增加斯莫尔质量报表增加过滤条件查询,质量月度目标单增加 字段  HProcTarGetVal  money  --各工序目标值,

---
 WebAPI/Controllers/BLL/Xt_UserController.cs | 3726 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 3,721 insertions(+), 5 deletions(-)

diff --git a/WebAPI/Controllers/BLL/Xt_UserController.cs b/WebAPI/Controllers/BLL/Xt_UserController.cs
index e04db05..04cbab1 100644
--- a/WebAPI/Controllers/BLL/Xt_UserController.cs
+++ b/WebAPI/Controllers/BLL/Xt_UserController.cs
@@ -1,12 +1,16 @@
 锘縰sing Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using Pub_Class;
+using SyntacticSugar.constant;
 using System;
 using System.Collections;
 using System.Collections.Generic;
 using System.Data;
 using System.Data.SqlClient;
+using System.IO;
+using System.Web;
 using System.Web.Http;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
 using WebAPI.Models;
 namespace WebAPI.Controllers
 {
@@ -22,10 +26,18 @@
         #region[鐢ㄦ埛鍒楄〃鏌ヨ]
         [Route("Xt_User/list")]
         [HttpGet]
-        public object list(string sWhere)
+        public object list(string sWhere,string user)
         {
             try
             {
+                if (!DBUtility.ClsPub.Security_Log_second("Xt_User_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
                 if (sWhere == null || sWhere.Equals(""))
                 {
                     ds = oCN.RunProcReturn("select * from h_v_IF_UserList " + sWhere, "h_v_IF_UserList");
@@ -96,6 +108,26 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
+
+                //鑾峰彇褰撳墠鐢ㄦ埛韬唤鍒楄〃
+                string sql = "select HLev from System_UserGroupInfo u " +
+                        " left join System_UserGroup r " +
+                        "on u.GroupId = r.GroupID where u.UserId = '" + HCzybm + "'";
+
+                //鐢ㄦ埛韬唤鍒ゆ柇
+                DataSet hLev = oCN.RunProcReturn(sql, "System_UserGroupInfo");
+                foreach(DataRow dr in hLev.Tables[0].Rows)
+                {
+                    if (!dr["HLev"].Equals(RoleConstant.EMPLOYEE))
+                    {
+                        objJsonResult.code = CodeConstant.FAIL;
+                        objJsonResult.count = CountConstant.FAIL;
+                        objJsonResult.Message = "绠$悊鍛樿韩浠戒笉鍏佽鍒犻櫎锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }      
+
                 oCN.BeginTran();
                 //鍒犻櫎鐢ㄦ埛淇℃伅
                 oCN.RunProc("delete from  Gy_Czygl where Czybm='" + HCzybm + "'");
@@ -154,6 +186,7 @@
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
             string msg3 = sArray[1].ToString();
+            string msg4 = sArray[2].ToString();
 
             ListModels oListModels = new ListModels();
             try
@@ -162,6 +195,8 @@
                 msg2 = msg2.Replace("\\", "");
                 msg2 = msg2.Replace("\n", "");  //\n
                 lsmain = oListModels.getObjectByJson_Gy_Gy_User(msg2);
+
+                var num = msg4.Split(',');
 
                 //淇濆瓨
                 if (msg3=="Add") //鏂板
@@ -191,13 +226,37 @@
                     ",HSellManID,HSellMan,HDeptID,HDept " +
                     ",HWhID,HWHName,HSupID,HSupName " +
                     ",HSCWHID,HSCWHName " +
-                    ",HCloudUserName,HCloudUserPsd,HUSEORGID) " +
+                    ",HCloudUserName,HCloudUserPsd,HUSEORGID,HProcID" +
+                    ",HGroupID,HSourceID,HCheckEmpID,HWorkCenterID,HICNumber) " +
                     "values ('" + lsmain[0].Czybm.ToString() + "','" + lsmain[0].Czymc.ToString() + "','" + ClsPub.StrToPsd(lsmain[0].Czmm.ToString()) + "','" + lsmain[0].Explain.ToString() + "','" + lsmain[0].HEmpID.ToString() + "',"+ lsmain[0].HK3UserID.ToString() + "" +
                     ","+ lsmain[0].HKeeperID.ToString() + ",'"+ lsmain[0].HKeeper.ToString() + "',"+ lsmain[0].HSecManagerID.ToString() + ",'"+ lsmain[0].HSecManager.ToString() + "'" +
                     "," + lsmain[0].HSellManID.ToString() + ",'" + lsmain[0].HSellMan.ToString() + "'," + lsmain[0].HDeptID.ToString() + ",'" + lsmain[0].HDept.ToString() + "'" +
                     "," + lsmain[0].HWhID.ToString() + ",'" + lsmain[0].HWHName.ToString() + "'," + lsmain[0].HSupID.ToString() + ",'" + lsmain[0].HSupName.ToString() + "'" +
                     "," + lsmain[0].HSCWHID.ToString() + ",'" + lsmain[0].HSCWHName.ToString() + "'" + 
-                    ",'" + lsmain[0].HCloudUserName.ToString() + "','" + lsmain[0].HCloudUserPsd.ToString() + "',"+ lsmain[0].HOrgID.ToString() + ")");
+                    ",'" + lsmain[0].HCloudUserName.ToString() + "','" + lsmain[0].HCloudUserPsd.ToString() + "',"+ lsmain[0].HOrgID.ToString() + "," + lsmain[0].HProcID.ToString() + "" +
+                    ","+ lsmain[0].HGroupID.ToString() + ","+ lsmain[0].HSourceID.ToString() + "," + lsmain[0].HCheckEmpID.ToString() + "," + lsmain[0].HWorkCenterID.ToString() + ",'" + lsmain[0].HICNumber + "'" + ")");
+
+                    //鏂板鍚庢煡璇�  纭繚鏁版嵁娣诲姞鎴愬姛
+                    ds = oCN.RunProcReturn("Select * from  Gy_Czygl where Czybm='" + lsmain[0].Czybm.ToString() + "'", "Gy_Czygl");
+
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瑙掕壊鏂板澶辫触锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                 
+                    oCN.RunProc("delete from  System_UserGroupInfo where UserId='" + lsmain[0].Czybm.ToString() + "'");
+
+                    if (num[0] != "-1")
+                    {
+                        for (int i = 0; i < num.Length; i++)
+                        {
+                            oCN.RunProc("insert into  System_UserGroupInfo (GroupId,UserId) values (" + num[i] + ",'" + lsmain[0].Czybm.ToString() + "')");
+                        }
+                    }
                 }
                 else //淇敼
                 {
@@ -218,14 +277,20 @@
                         ",HDeptID=" + lsmain[0].HDeptID.ToString() +
                         ",HDept='" + lsmain[0].HDept.ToString() + "'" +
                         ",HWhID=" + lsmain[0].HWhID.ToString() +
+                        ",HCheckEmpID=" + lsmain[0].HCheckEmpID.ToString() +
                         ",HWHName='" + lsmain[0].HWHName.ToString() + "'" +
                         ",HSCWHID=" + lsmain[0].HSCWHID.ToString() +
                         ",HSCWHName='" + lsmain[0].HSCWHName.ToString() + "'" +
                         ",HSupID=" + lsmain[0].HSupID.ToString() +
+                        ",HProcID=" + lsmain[0].HProcID.ToString() +
+                        ",HSourceID=" + lsmain[0].HSourceID.ToString() +
+                        ",HGroupID=" + lsmain[0].HGroupID.ToString() +
+                        ",HWorkCenterID=" + lsmain[0].HWorkCenterID.ToString() +
                         ",HSupName='" + lsmain[0].HSupName.ToString() + "'" +
                         ",HCloudUserName='" + lsmain[0].HCloudUserName.ToString() + "'" +
                         ",HCloudUserPsd='" + lsmain[0].HCloudUserPsd.ToString() + "'" +
                         ",HUSEORGID=" + lsmain[0].HOrgID.ToString() +
+                        ",HICNumber='" + lsmain[0].HICNumber + "'" +
                         "  where  Czybm='" + lsmain[0].Czybm.ToString() + "'");
                     }
                     else
@@ -242,16 +307,32 @@
                            ",HSellMan='" + lsmain[0].HSellMan.ToString() + "'" +
                            ",HDeptID=" + lsmain[0].HDeptID.ToString() +
                            ",HDept='" + lsmain[0].HDept.ToString() + "'" +
+                           ",HCheckEmpID=" + lsmain[0].HCheckEmpID.ToString() +
                            ",HWhID=" + lsmain[0].HWhID.ToString() +
                            ",HWHName='" + lsmain[0].HWHName.ToString() + "'" +
                            ",HSCWHID=" + lsmain[0].HSCWHID.ToString() +
                            ",HSCWHName='" + lsmain[0].HSCWHName.ToString() + "'" +
                            ",HSupID=" + lsmain[0].HSupID.ToString() +
+                            ",HProcID=" + lsmain[0].HProcID.ToString() +
+                           ",HSourceID=" + lsmain[0].HSourceID.ToString() +
+                           ",HGroupID=" + lsmain[0].HGroupID.ToString() +
+                           ",HWorkCenterID=" + lsmain[0].HWorkCenterID.ToString() +
                            ",HSupName='" + lsmain[0].HSupName.ToString() + "'" +
                            ",HCloudUserName='" + lsmain[0].HCloudUserName.ToString() + "'" +
                            ",HCloudUserPsd='" + lsmain[0].HCloudUserPsd.ToString() + "'" +
                            ",HUSEORGID=" + lsmain[0].HOrgID.ToString() +
+                            ",HICNumber='" + lsmain[0].HICNumber + "'" +
                            "  where  Czybm='" + lsmain[0].Czybm.ToString() + "'");
+                    }
+
+                    oCN.RunProc("delete from  System_UserGroupInfo where UserId='" + lsmain[0].Czybm.ToString()+"'");
+
+                    if (num[0] != "-1")
+                    {
+                        for (int i = 0; i < num.Length; i++)
+                        {
+                            oCN.RunProc("insert into  System_UserGroupInfo (GroupId,UserId) values (" + num[i] + ",'" + lsmain[0].Czybm.ToString() + "')");
+                        }
                     }
 
                 }
@@ -315,7 +396,7 @@
         }
         #endregion
 
-        #region 鐢ㄦ埛鍏宠仈渚涘簲鍟嗕繚瀛�
+        #region 鐢ㄦ埛鍏宠仈渚涘簲鍟嗕繚瀛� Excel瀵煎叆
         [Route("Xt_User/SaveUserSupper")]
         [HttpPost]
         public object SaveUserSupper([FromBody] JObject msg)
@@ -359,6 +440,237 @@
                 return objJsonResult;
             }
         }
+
+        /// 鏂囦欢涓婁紶 Gy_Supplier
+        [Route("Xt_User/UserSupperBill_Excel")]
+        [HttpPost]
+        public object UserSupperBill_Excel()
+        {
+            try
+            {
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                ////Excel妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("HSupID", typeof(Int32));//渚涘簲鍟咺D
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    tb2.Rows.Add(row);
+                }
+
+
+                var error = "";
+
+                ////鏌ヨ鐢ㄦ埛鍏宠仈渚涘簲鍟嗘病鏈夌殑鍒�
+                if (!tb2.Columns.Contains("鐢ㄦ埛浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮敤鎴蜂唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鐢ㄦ埛鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愮敤鎴峰悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("渚涘簲鍟嗕唬鐮�"))
+                    error += "娌℃湁鎵惧埌銆愪緵搴斿晢浠g爜銆戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("渚涘簲鍟嗗悕绉�"))
+                    error += "娌℃湁鎵惧埌銆愪緵搴斿晢鍚嶇О銆戠殑鏍囬,";
+
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+                {
+                    string czybm = "";
+                    string czymc = "";
+                    string HNumber = "";
+                    string HName = "";
+
+                    //HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐缂栫爜"].ToString());
+                    //HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐"].ToString());
+                    czybm = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛浠g爜"].ToString());
+                    czymc = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛鍚嶇О"].ToString());
+                    HNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString());
+                    HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗗悕绉�"].ToString());
+                   
+                    int index = i + 1;
+                    //妫�鏌ョ敤鎴蜂笌渚涘簲鍟嗕唬鐮佹槸鍚﹂兘涓虹┖
+                    if (czybm != "" || HNumber != "")
+                    {
+                        //鏌ヨ渚涘簲鍟�
+                        ds = oCN.RunProcReturn("select * from Gy_Supplier where  HNumber='" + HNumber + "'", "Gy_Supplier");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,渚涘簲鍟�:" + HName + ",涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); //渚涘簲鍟咺D
+                        }
+                        //鏌ヨ鐢ㄦ埛
+                        ds = oCN.RunProcReturn("select * from Gy_Czygl where  czybm='" + czybm + "'", "Gy_Czygl");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,璇�" + czymc + "鐢ㄦ埛,涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            //tb2.Rows[i]["czybm"] = ds.Tables[0].Rows[0]["czybm"].ToString();
+                        }
+
+                        //瀹℃牳浠g爜鏄惁鍚堢悊
+                        if (!DBUtility.ClsPub.AllowNumber(czybm))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鐢ㄦ埛浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "绗�" + index + "琛�,鐢ㄦ埛浠g爜涓虹┖";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = error;
+                objJsonResult.data = tb2;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+  
+
+        #region  瀵煎叆(淇濆瓨)
+        [Route("Xt_User/UserSupperBill_btnSave")]
+        [HttpPost]
+        public object UserSupperBill_btnSave([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            try
+            {
+               
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                oCN.BeginTran();
+                int i = 1;
+                foreach (Dictionary<string, string> item in list)
+                {
+                    string HSupID = item["HSupID"].ToString();//渚涘簲鍟咺D
+                    string HUserID = item["鐢ㄦ埛浠g爜"].ToString();//鐢ㄦ埛浠g爜
+                    string czymc = item["鐢ㄦ埛鍚嶇О"].ToString();//鐢ㄦ埛鍚嶇О
+                    string HNumber = item["渚涘簲鍟嗕唬鐮�"].ToString();//渚涘簲鍟嗕唬鐮�
+                    string HName = item["渚涘簲鍟嗗悕绉�"].ToString();//渚涘簲鍟嗗悕绉�
+
+                    var ds = oCN.RunProcReturn("select * from Gy_UserSupplierRelation where  HSupID='" + HSupID + "'and HUserID='" + HUserID + "'", "Gy_UserSupplierRelation");
+
+
+                    if (ds.Tables[0].Rows.Count >0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绗�" + i + "琛�, 鐢ㄦ埛: " + czymc + " 涓� 渚涘簲鍟�: "+ HName + ",宸插瓨鍦�,鎴�,鎻掑叆琛ㄦ牸鏈夐噸澶嶄俊鎭�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        oCN.RunProc("insert into Gy_UserSupplierRelation (HSupID,HUserID) values ('" + HSupID + "','" + HUserID + "')");
+                    }
+
+                    i++;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "瀵煎叆鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
         #endregion
 
         #region  鏍规嵁鐢ㄦ埛缂栫爜鏌ユ壘宸插垎閰嶇粍缁囧垪琛�
@@ -396,7 +708,7 @@
                 return objJsonResult;
             }
         }
-        #endregion
+        #endregion       
 
         #region 鐢ㄦ埛鍏宠仈缁勭粐淇濆瓨
         [Route("Xt_User/SaveUserByOrg")]
@@ -443,6 +755,316 @@
         }
         #endregion
 
+        #region 鐢ㄦ埛鍏宠仈缁勭粐缁存姢鍒楄〃
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationOrganizationList")]
+        [HttpGet]
+        public object UserRelationOrganizationList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                string sql = "";
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    sql = "select * from h_v_Gy_UserOrganizationRelationList_Query order by 鐢ㄦ埛浠g爜 asc,缁勭粐浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserOrganizationRelationList_Query");
+                }
+                else
+                {
+                    sql = "select * from h_v_Gy_UserOrganizationRelationList_Query where 1=1 ";
+                    sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,缁勭粐浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserOrganizationRelationList_Query");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈缁勭粐缁存姢 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationOrganizationlist_Drop")]
+        [HttpGet]
+        public object UserRelationOrganizationlist_Drop(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+
+                //鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_Drop", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserORGRelation where HItemID = " + HInterID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈缁勭粐缁存姢 缂栬緫鍒濆鍖�
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationOrganizationList_EditInit")]
+        [HttpGet]
+        public object UserRelationOrganizationList_EditInit(int HItemID, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                string sql = "select * from h_v_Gy_UserOrganizationRelationList_Query where HItemID = " + HItemID;
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserOrganizationRelationList_Query");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                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/UserRelationOrganizationList_Save")]
+        [HttpPost]
+        public object UserRelationOrganizationList_Save([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string saveType = sArray[2].ToString();
+            try
+            {
+                //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationOrganization_Edit", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                if (saveType == "1")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HItemID = item["HItemID"].ToString();        //
+                        string HUserID = item["HUserID"].ToString();        //鐢ㄦ埛浠g爜
+                        string HUserName = item["HUserName"].ToString();    //鐢ㄦ埛鍚嶇О
+                        string HOrgID = item["HOrgID"].ToString();          //缁勭粐鍐呯爜
+                        string HOrgNumber = item["HOrgNumber"].ToString();  //缁勭粐浠g爜
+                        string HOrgName = item["HOrgName"].ToString();      //缁勭粐鍚嶇О
+
+
+                        sql = "select * from Gy_UserORGRelation where HUserID = '" + HUserID + "' and HOrgID = " + HOrgID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserORGRelation");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            sql = "insert into Gy_UserORGRelation(HUserID,HOrgID)" +
+                                "values(" +
+                                "'" + HUserID + "'" +
+                                "," + HOrgID + "" +
+                                ")";
+                            oCN.RunProc(sql);
+                        }
+                        else
+                        {
+                            err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱旂粍缁囥��" + HOrgName + "銆�";
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else if (saveType == "3")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HItemID = item["HItemID"].ToString();        //
+                        string HUserID = item["HUserID"].ToString();        //鐢ㄦ埛浠g爜
+                        string HUserName = item["HUserName"].ToString();    //鐢ㄦ埛鍚嶇О
+                        string HOrgID = item["HOrgID"].ToString();          //缁勭粐鍐呯爜
+                        string HOrgNumber = item["HOrgNumber"].ToString();  //缁勭粐浠g爜
+                        string HOrgName = item["HOrgName"].ToString();      //缁勭粐鍚嶇О
+
+                        sql = "select * from Gy_UserORGRelation where HItemID = " + HItemID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserORGRelation");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            sql = "select * from Gy_UserORGRelation where HUserID = '" + HUserID + "' and HOrgID = " + HOrgID + " and HItemID <> " + HItemID;
+                            ds = oCN.RunProcReturn(sql, "Gy_UserORGRelation");
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                sql = "update Gy_UserORGRelation set " +
+                                      "HUserID = '" + HUserID + "' " +
+                                      ",HOrgID = " + HOrgID + " " +
+                                      "where HItemID = " + HItemID;
+                                oCN.RunProc(sql);
+                            }
+                            else
+                            {
+                                err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱旂粍缁囥��" + HOrgName + "銆�";
+                            }
+                        }
+                        else
+                        {
+                            err += "绗�" + i + "琛岋細璁板綍涓嶅瓨鍦�!";
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
         #region  鏍规嵁鐢ㄦ埛缂栫爜鏌ユ壘宸插垎閰嶄粨搴撳垪琛�
         [Route("Xt_User/UserStocklistPlaylist")]
         [HttpGet]
@@ -468,6 +1090,110 @@
                     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/Gy_UserStockRelationList")]
+        [HttpGet]
+        public object Gy_UserStockRelationList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserStockRelation_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql1 = "select * from h_v_Gy_UserStockRelation where 1 = 1";
+                string sql = sql1 + sWhere + " order by 鐢ㄦ埛浠g爜 ";
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserStockRelation");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈浠撳簱鍒楄〃 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/Gy_UserStockRelationDrop")]
+        [HttpGet]
+        public object Gy_UserStockRelationDrop(string HItemID, string user)
+        {
+            try
+            {
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserStockRelation_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HItemID == null || HItemID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HItemID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserStockRelation where HItemID = " + HItemID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
             }
             catch (Exception e)
             {
@@ -525,6 +1251,45 @@
         }
         #endregion
 
+        #region  鐢ㄦ埛鍏宠仈鐢ㄦ埛鍒楄〃鏌ヨ
+        [Route("Xt_User/Gy_UserByUserList")]
+        [HttpGet]
+        public object Gy_UserByUserList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                string sql1 = "select * from h_v_Gy_UserByUserRelationList where 1 = 1";
+                string sql = sql1 + sWhere + " order by 鐢ㄦ埛浠g爜 ";
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserStockRelation");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                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/UserGrouplistPlaylist")]
         [HttpGet]
@@ -550,6 +1315,69 @@
                     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 鐢ㄦ埛鍏宠仈鐝粍缁存姢鍒楄〃
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/Gy_UserGroupRelationList")]
+        [HttpGet]
+        public object Gy_UserGroupRelationList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_Group_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "";
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    sql = "select * from h_v_Gy_UserGroupRelationList_Query order by 鐢ㄦ埛浠g爜 asc,鐝粍浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserGroupRelationList_Query");
+                }
+                else
+                {
+                    sql = "select * from h_v_Gy_UserGroupRelationList_Query where 1=1 ";
+                    sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,鐝粍浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserGroupRelationList_Query");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
             }
             catch (Exception e)
             {
@@ -602,6 +1430,62 @@
                 objJsonResult.count = 0;
                 objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
                 objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈鐝粍缁存姢 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserGroupRelationList_Drop")]
+        [HttpGet]
+        public object UserGroupRelationList_Drop(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_Group_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserGroupRelation where HItemID = " + HInterID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
                 return objJsonResult;
             }
         }
@@ -689,6 +1573,250 @@
         }
         #endregion
 
+        #region 鐢ㄦ埛鍏宠仈閮ㄩ棬鏌ヨ
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationDeptlist")]
+        [HttpGet]
+        public object UserRelationDeptlist(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationDept_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "";
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    sql = "select * from h_v_Gy_UserDeptRelationList_Query order by 鐢ㄦ埛浠g爜 asc,閮ㄩ棬浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserDeptRelationList_Query");
+                }
+                else
+                {
+                    sql = "select * from h_v_Gy_UserDeptRelationList_Query where 1=1 ";
+                    sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,閮ㄩ棬浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserDeptRelationList_Query");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈閮ㄩ棬 鏍规嵁鐢ㄦ埛ID鏌ユ壘
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationDeptlist_EditInit")]
+        [HttpGet]
+        public object UserRelationDeptlist_EditInit(int HItemID, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationDept_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "select * from h_v_Gy_UserDeptRelationList_Query where HItemID = " + HItemID;
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserDeptRelationList_Query");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈閮ㄩ棬 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationDeptlist_Drop")]
+        [HttpGet]
+        public object UserRelationDeptlist_Drop(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationDept_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserDeptRelation where HItemID = " + HInterID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                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/UserWorkCenterlistPlaylist")]
+        [HttpGet]
+        public object UserWorkCenterlistPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HWorkCenterID HItemID,宸ヤ綔涓績浠g爜 HNumber,宸ヤ綔涓績鍚嶇О HName from h_v_Gy_UserWorkCenterRelationList where HUserID='" + HUserID + "' ", "h_v_Gy_UserWorkCenterRelationList");
+                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/SaveUserWorkCenter")]
+        [HttpPost]
+        public object SaveUserWorkCenter([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.WorkCenter> lsmain = new List<Models.WorkCenter>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_WorkCenter(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserWorkCenterRelation  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.WorkCenter oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserWorkCenterRelation (HWorkCenterID,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]
@@ -714,6 +1842,69 @@
                     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 鐢ㄦ埛鍏宠仈宸ヤ綅缁存姢鍒楄〃
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserByWorkStationRelationList")]
+        [HttpGet]
+        public object UserByWorkStationRelationList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserWorkStationList_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "";
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    sql = "select * from h_v_Gy_UserByWorkStationRelationList_Query order by 鐢ㄦ埛浠g爜 asc,宸ヤ綅浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserByWorkStationRelationList_Query");
+                }
+                else
+                {
+                    sql = "select * from h_v_Gy_UserByWorkStationRelationList_Query where 1=1 ";
+                    sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,宸ヤ綅浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserByWorkStationRelationList_Query");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
             }
             catch (Exception e)
             {
@@ -770,5 +1961,2530 @@
             }
         }
         #endregion
+
+        #region 鐢ㄦ埛鍏宠仈宸ヤ綅缁存姢 缂栬緫鍒濆鍖�
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserByWorkStationRelationList_EditInit")]
+        [HttpGet]
+        public object UserByWorkStationRelationList_EditInit(int HItemID, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserWorkStationList_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "select * from h_v_Gy_UserByWorkStationRelationList_Query where 鐢ㄦ埛浠g爜 = '" + HItemID + "'";
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserByWorkStationRelationList_Query");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈宸ヤ綅缁存姢 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserByWorkStationRelationList_Drop")]
+        [HttpGet]
+        public object UserByWorkStationRelationList_Drop(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserWorkStationList_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserByWorkStationRelation where HItemID = " + HInterID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                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/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 鐢ㄦ埛鍏宠仈鑱屽憳淇濆瓨 Excel瀵煎叆
+        [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;
+            }
+        }
+
+        /// <summary>
+        /// 鏂囦欢涓婁紶瑙f瀽鍥炴樉
+        /// </summary>
+        /// <returns></returns>
+        [Route("Xt_User/UserEmployeeBill_Excel")]
+        [HttpPost]
+        public object UserEmployeeBill_Excel()
+        {
+            try
+            {
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                ////Excel妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("HEmployeeID", typeof(Int32));//宸ュ簭ID
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    tb2.Rows.Add(row);
+                }
+
+
+                var error = "";
+
+                ////鏌ヨ鐢ㄦ埛鍏宠仈渚涘簲鍟嗘病鏈夌殑鍒�
+                if (!tb2.Columns.Contains("鐢ㄦ埛浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮敤鎴蜂唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鐢ㄦ埛鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愮敤鎴峰悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鑱屽憳浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愯亴鍛樹唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鑱屽憳鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愯亴鍛樺悕绉般�戠殑鏍囬,";
+
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+                {
+                    string czybm = "";
+                    string czymc = "";
+                    string HNumber = "";
+                    string HName = "";
+
+                    //HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐缂栫爜"].ToString());
+                    //HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐"].ToString());
+                    czybm = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛浠g爜"].ToString());
+                    czymc = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛鍚嶇О"].ToString());
+                    HNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鑱屽憳浠g爜"].ToString());
+                    HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鑱屽憳鍚嶇О"].ToString());
+
+                    int index = i + 1;
+                    //妫�鏌ョ敤鎴蜂笌宸ュ簭浠g爜鏄惁閮戒负绌�
+                    if (czybm != "" || HNumber != "")
+                    {
+                        //鏌ヨ宸ュ簭
+                        ds = oCN.RunProcReturn("select * from Gy_Employee where  HNumber='" + HNumber + "'", "Gy_Employee");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鑱屽憳鍚嶇О:" + HName + ",涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HEmployeeID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); //鑱屽憳ID
+                        }
+                        //鏌ヨ鐢ㄦ埛
+                        ds = oCN.RunProcReturn("select * from Gy_Czygl where  czybm='" + czybm + "'", "Gy_Czygl");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鐢ㄦ埛: " + czymc + ",涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            //tb2.Rows[i]["czybm"] = ds.Tables[0].Rows[0]["czybm"].ToString();
+                        }
+
+                        //瀹℃牳浠g爜鏄惁鍚堢悊
+                        if (!DBUtility.ClsPub.AllowNumber(czybm))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鐢ㄦ埛浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "绗�" + index + "琛�,鐢ㄦ埛浠g爜涓虹┖";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = error;
+                objJsonResult.data = tb2;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+        /// <summary>
+        /// 瀵煎叆淇濆瓨
+        /// </summary>
+        /// <param name="sMainSub"></param>
+        /// <returns></returns>
+        [Route("Xt_User/UserEmployeeBill_btnSave")]
+        [HttpPost]
+        public object UserEmployeeBill_btnSave([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            try
+            {
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                oCN.BeginTran();
+                int i = 1;
+                foreach (Dictionary<string, string> item in list)
+                {
+                    string HEmployeeID = item["HEmployeeID"].ToString();//鑱屽憳ID
+                    string HUserID = item["鐢ㄦ埛浠g爜"].ToString();//鐢ㄦ埛浠g爜
+                    string czymc = item["鐢ㄦ埛鍚嶇О"].ToString();//鐢ㄦ埛鍚嶇О
+                    string HNumber = item["鑱屽憳浠g爜"].ToString();//鑱屽憳浠g爜
+                    string HName = item["鑱屽憳鍚嶇О"].ToString();//鑱屽憳鍚嶇О
+
+                    var ds = oCN.RunProcReturn("select * from Gy_UserEmployeeRelation where  HEmployeeID='" + HEmployeeID + "'and HUserID='" + HUserID + "'", "Gy_UserEmployeeRelation");
+
+
+                    if (ds.Tables[0].Rows.Count > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绗�" + i + "琛�, 鐢ㄦ埛: " + czymc + " 涓� 宸ュ簭鍚�: " + HName + ",宸插瓨鍦�,鎴�,鎻掑叆琛ㄦ牸鏈夐噸澶嶄俊鎭�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        oCN.RunProc("insert into Gy_UserEmployeeRelation (HEmployeeID,HUserID) values ('" + HEmployeeID + "','" + HUserID + "')");
+                    }
+
+                    i++;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "瀵煎叆鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈鑱屽憳缁存姢鍒楄〃
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationEmployeelist")]
+        [HttpGet]
+        public object UserRelationEmployeelist(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                string sql = "";
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    sql = "select * from h_v_Gy_UserEmployeeRelationList_Query order by 鐢ㄦ埛浠g爜 asc,鑱屽憳浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserEmployeeRelationList_Query");
+                }
+                else
+                {
+                    sql = "select * from h_v_Gy_UserEmployeeRelationList_Query where 1=1 ";
+                    sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,鑱屽憳浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserEmployeeRelationList_Query");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈鑱屽憳缁存姢 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationEmployeelist_Drop")]
+        [HttpGet]
+        public object UserRelationEmployeelist_Drop(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+
+                //鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_Drop", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserEmployeeRelation where HItemID = " + HInterID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈鑱屽憳缁存姢 缂栬緫鍒濆鍖�
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationEmployeelist_EditInit")]
+        [HttpGet]
+        public object UserRelationEmployeelist_EditInit(int HItemID, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_Query", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                string sql = "select * from h_v_Gy_UserEmployeeRelationList_Query where HItemID = " + HItemID;
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserEmployeeRelationList_Query");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                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/UserRelationEmployeelist_Save")]
+        [HttpPost]
+        public object UserRelationEmployeelist_Save([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string saveType = sArray[2].ToString();
+            try
+            {
+                //if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationEmployee_Edit", 1, false, user))
+                //{
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                //    objJsonResult.data = null;
+                //    return objJsonResult;
+                //}
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                if (saveType == "1")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HItemID = item["HItemID"].ToString();        //
+                        string HUserID = item["HUserID"].ToString();        //鐢ㄦ埛浠g爜
+                        string HUserName = item["HUserName"].ToString();    //鐢ㄦ埛鍚嶇О
+                        string HEmpID = item["HEmpID"].ToString();          //瀹㈡埛鍐呯爜
+                        string HEmpNumber = item["HEmpNumber"].ToString();  //瀹㈡埛浠g爜
+                        string HEmpName = item["HEmpName"].ToString();      //瀹㈡埛鍚嶇О
+
+
+                        sql = "select * from Gy_UserEmployeeRelation where HUserID = '" + HUserID + "' and HEmployeeID = " + HEmpID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserEmployeeRelation");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            sql = "insert into Gy_UserEmployeeRelation(HUserID,HEmployeeID)" +
+                                "values(" +
+                                "'" + HUserID + "'" +
+                                "," + HEmpID + "" +
+                                ")";
+                            oCN.RunProc(sql);
+                        }
+                        else
+                        {
+                            err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱旇亴鍛樸��" + HEmpName + "銆�";
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else if (saveType == "3")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HItemID = item["HItemID"].ToString();        //
+                        string HUserID = item["HUserID"].ToString();        //鐢ㄦ埛浠g爜
+                        string HUserName = item["HUserName"].ToString();    //鐢ㄦ埛鍚嶇О
+                        string HEmpID = item["HEmpID"].ToString();          //鑱屽憳鍐呯爜
+                        string HEmpNumber = item["HEmpNumber"].ToString();  //鑱屽憳浠g爜
+                        string HEmpName = item["HEmpName"].ToString();      //鑱屽憳鍚嶇О
+
+                        sql = "select * from Gy_UserEmployeeRelation where HItemID = " + HItemID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserEmployeeRelation");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            sql = "select * from Gy_UserEmployeeRelation where HUserID = '" + HUserID + "' and HEmployeeID = " + HEmpID + " and HItemID <> " + HItemID;
+                            ds = oCN.RunProcReturn(sql, "Gy_UserEmployeeRelation");
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                sql = "update Gy_UserEmployeeRelation set " +
+                                      "HUserID = '" + HUserID + "' " +
+                                      ",HEmployeeID = " + HEmpID + " " +
+                                      "where HItemID = " + HItemID;
+                                oCN.RunProc(sql);
+                            }
+                            else
+                            {
+                                err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + HUserName + "銆戝凡缁忓叧鑱旇亴鍛樸��" + HEmpName + "銆�";
+                            }
+                        }
+                        else
+                        {
+                            err += "绗�" + i + "琛岋細璁板綍涓嶅瓨鍦�!";
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #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/Gy_UserMaterList")]
+        [HttpGet]
+        public object Gy_UserMaterList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserMaterList_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql1 = "select * from h_v_Gy_UserMater where 1 = 1";
+                string sql = sql1 + sWhere + " order by 鐢ㄦ埛浠g爜 ";
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserMater");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈鐗╂枡鍒楄〃 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/Gy_UserMaterRelationDrop")]
+        [HttpGet]
+        public object Gy_UserMaterRelationDrop(string HItemID, string user)
+        {
+            try
+            {
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserMaterList_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HItemID == null || HItemID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HItemID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserMaterRelation where HItemID = " + HItemID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                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, string CurUserName)
+        {
+            try
+            {
+                //鏌ヨ鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_UserRelationCustomer_Query", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                ds = oCN.RunProcReturn("select HCusID,瀹㈡埛浠g爜 HCustomerNumber,瀹㈡埛鍚嶇О HCustomerName from h_v_Gy_UserCustomerList where HUserID='" + HUserID + "' order by HCusID", "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/CustomerPlaylistFromUserCustomerList")]
+        [HttpGet]
+        public object CustomerPlaylistFromUserCustomerList(string HUserID, string HCusNumber, string HCusName, string CurUserName)
+        {
+            try
+            {
+                //鏌ヨ鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_UserRelationCustomer_Query", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡璇㈡潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "select HCusID,瀹㈡埛浠g爜 HCustomerNumber,瀹㈡埛鍚嶇О HCustomerName " +
+                    "from h_v_Gy_UserCustomerList " +
+                    "where HUserID='" + HUserID + "' " +
+                    "and 瀹㈡埛浠g爜 like '%" + HCusNumber + "%' " +
+                    "and 瀹㈡埛鍚嶇О like '%" + HCusName + "%' " +
+                    " order by 瀹㈡埛浠g爜";
+
+
+                ds = oCN.RunProcReturn(sql, "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();
+            string msg4 = sArray[2].ToString();
+
+            //鏌ヨ鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log_second("Gy_UserRelationCustomer_Edit", 1, false, msg4))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犵紪杈戞潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+            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
+
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛 鏂囦欢涓婁紶
+        [Route("Xt_User/Gy_UserCustomer_ImportByExcel")]
+        [HttpPost]
+        public object Gy_UserCustomer_ImportByExcel()
+        {
+            try
+            {
+                //var WorkBookName = HttpContext.Current.Request["WorkBookName"];
+                //DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]);
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("瀹㈡埛鍐呯爜", typeof(string));//瀹㈡埛鍐呯爜
+                tb2.Columns.Add("鍒ゅ畾缁撴灉", typeof(string));//鍒ゅ畾缁撴灉
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    tb2.Rows.Add(row);
+                }
+
+                //鏌ヨExcel鏂囦欢涓病鏈夌殑鍒�
+                var error = "";
+                if (!tb2.Columns.Contains("鐢ㄦ埛浠g爜"))
+                {
+                    error += "娌℃湁鎵惧埌銆愮敤鎴蜂唬鐮併�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("鐢ㄦ埛鍚嶇О"))
+                {
+                    error += "娌℃湁鎵惧埌銆愮敤鎴峰悕绉般�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("瀹㈡埛浠g爜"))
+                {
+                    error += "娌℃湁鎵惧埌銆愬鎴蜂唬鐮併�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("瀹㈡埛鍚嶇О"))
+                {
+                    error += "娌℃湁鎵惧埌銆愬鎴峰悕绉般�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("缁勭粐浠g爜"))
+                {
+                    error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+                }
+                if (!tb2.Columns.Contains("缁勭粐鍚嶇О"))
+                {
+                    error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,";
+                }
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                //鏌ヨ鏁版嵁璧嬬粰鏁版嵁琛�
+                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+                {
+                    string HUserID = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛浠g爜"].ToString());
+                    string HUserName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛鍚嶇О"].ToString());
+                    string HCusNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀹㈡埛浠g爜"].ToString());
+                    string HCusName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀹㈡埛鍚嶇О"].ToString());
+                    string HOrgNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString());
+                    string HOrgName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString());
+                    int index = i + 1;
+                    //string sql = "";
+
+                    ////鍒ゅ畾鐢ㄦ埛鏄惁瀛樺湪骞惰缃暟鎹�
+                    //sql = "select * from Gy_Czygl where Czybm = '" + HUserID + "'";
+                    //ds = oCN.RunProcReturn(sql, "Gy_Czygl");
+                    //if (ds.Tables[0].Rows.Count > 0)
+                    //{
+                    //    tb2.Rows[i]["鐢ㄦ埛鍚嶇О"] = ds.Tables[0].Rows[0]["Czymc"];
+                    //}
+                    //else
+                    //{
+                    //    sql = "select * from Gy_Czygl where Czymc = '" + HUserName + "'";
+                    //    ds = oCN.RunProcReturn(sql, "Gy_Czygl");
+                    //    if (ds.Tables[0].Rows.Count > 0)
+                    //    {
+                    //        tb2.Rows[i]["鐢ㄦ埛浠g爜"] = ds.Tables[0].Rows[0]["Czybm"];
+                    //    }
+                    //}
+
+                    ////鍒ゅ畾瀹㈡埛鏄惁瀛樺湪骞惰缃暟鎹�
+                    //sql = "select c.HItemID 瀹㈡埛鍐呯爜,c.HNumber 瀹㈡埛浠g爜,c.HName 瀹㈡埛鍚嶇О,isnull(c.HUSEORGID,0) 缁勭粐鍐呯爜,isnull(o.HNumber,'') 缁勭粐浠g爜,isnull(o.Hname,'') 缁勭粐鍚嶇О from " +
+                    //    "Gy_Customer as c " +
+                    //    "left join Xt_ORGANIZATIONS o on c.HUSEORGID = o.HItemID " +
+                    //    "where " +
+                    //        "c.HNumber = '" + HCusNumber + "' " +
+                    //        "and isnull(o.HNumber,'')<>'' and isnull(o.HNumber,'') = '" + HOrgNumber + "'";
+                    //ds = oCN.RunProcReturn(sql, "Gy_Customer");
+                    //if(ds.Tables[0].Rows.Count > 0)
+                    //{
+                    //    tb2.Rows[i]["瀹㈡埛鍐呯爜"] = ds.Tables[0].Rows[0]["瀹㈡埛鍐呯爜"];
+                    //    tb2.Rows[i]["瀹㈡埛鍚嶇О"] = ds.Tables[0].Rows[0]["瀹㈡埛鍚嶇О"];
+                    //    tb2.Rows[i]["缁勭粐鍚嶇О"] = ds.Tables[0].Rows[0]["缁勭粐鍚嶇О"];
+                    //}
+                    //else
+                    //{
+                    //    sql = "select c.HItemID 瀹㈡埛鍐呯爜,c.HNumber 瀹㈡埛浠g爜,c.HName 瀹㈡埛鍚嶇О,isnull(c.HUSEORGID,0) 缁勭粐鍐呯爜,isnull(o.HNumber,'') 缁勭粐浠g爜,isnull(o.Hname,'') 缁勭粐鍚嶇О from " +
+                    //    "Gy_Customer as c " +
+                    //    "left join Xt_ORGANIZATIONS o on c.HUSEORGID = o.HItemID " +
+                    //    "where " +
+                    //        "c.HNumber = '" + HCusNumber + "' " +
+                    //        "and isnull(o.HName,'')<>'' and isnull(o.HName,'') = '" + HOrgName + "'";
+                    //    ds = oCN.RunProcReturn(sql, "Gy_Customer");
+                    //    if (ds.Tables[0].Rows.Count > 0)
+                    //    {
+                    //        tb2.Rows[i]["瀹㈡埛鍐呯爜"] = ds.Tables[0].Rows[0]["瀹㈡埛鍐呯爜"];
+                    //        tb2.Rows[i]["瀹㈡埛鍚嶇О"] = ds.Tables[0].Rows[0]["瀹㈡埛鍚嶇О"];
+                    //        tb2.Rows[i]["缁勭粐浠g爜"] = ds.Tables[0].Rows[0]["缁勭粐浠g爜"];
+                    //    }
+                    //}
+
+                    tb2.Rows[i]["鍒ゅ畾缁撴灉"] = "";
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = error;
+                objJsonResult.data = tb2;
+                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/Gy_UserCustomer_ImportByExcel_Confirm")]
+        [HttpPost]
+        public object Gy_UserCustomer_ImportByExcel_Confirm([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string[] importFieldList = sArray[2].ToString().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            try
+            {
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                //鍒涘缓涓存椂琛ㄥ苟璁剧疆鍒楀悕
+                DataTable tb2 = new DataTable("dt2");
+                tb2.Columns.Add("鐢ㄦ埛浠g爜", typeof(string));
+                tb2.Columns.Add("鐢ㄦ埛鍚嶇О", typeof(string));
+                tb2.Columns.Add("瀹㈡埛鍐呯爜", typeof(string));
+                tb2.Columns.Add("瀹㈡埛浠g爜", typeof(string));
+                tb2.Columns.Add("瀹㈡埛鍚嶇О", typeof(string));
+                tb2.Columns.Add("缁勭粐浠g爜", typeof(string));
+                tb2.Columns.Add("缁勭粐鍚嶇О", typeof(string));
+                tb2.Columns.Add("鍒ゅ畾缁撴灉", typeof(string));
+
+                string error = "";
+                int i = 1;
+                string sql = "";
+                foreach (Dictionary<string, string> item in list)
+                {
+                    //璁板綍鍒ゅ畾缁撴灉
+                    string err = "";
+
+                    DataRow row = tb2.NewRow();
+                    tb2.Rows.Add(row);
+                    string HUserID = item["鐢ㄦ埛浠g爜"].ToString();
+                    string HUserName = item["鐢ㄦ埛鍚嶇О"].ToString();
+                    string HCusID = item["瀹㈡埛鍐呯爜"].ToString();
+                    string HCusNumber = item["瀹㈡埛浠g爜"].ToString();
+                    string HCusName = item["瀹㈡埛鍚嶇О"].ToString();
+                    string HOrgNumber = item["缁勭粐浠g爜"].ToString();
+                    string HOrgName = item["缁勭粐鍚嶇О"].ToString();
+
+                    tb2.Rows[i - 1]["鐢ㄦ埛浠g爜"] = HUserID;
+                    tb2.Rows[i - 1]["鐢ㄦ埛鍚嶇О"] = HUserName;
+                    tb2.Rows[i - 1]["瀹㈡埛鍐呯爜"] = HCusID;
+                    tb2.Rows[i - 1]["瀹㈡埛浠g爜"] = HCusNumber;
+                    tb2.Rows[i - 1]["瀹㈡埛鍚嶇О"] = HCusName;
+                    tb2.Rows[i - 1]["缁勭粐浠g爜"] = HOrgNumber;
+                    tb2.Rows[i - 1]["缁勭粐鍚嶇О"] = HOrgName;
+                    tb2.Rows[i - 1]["鍒ゅ畾缁撴灉"] = "";
+
+                    //鏍规嵁瀵煎叆瀛楁鑾峰彇鐢ㄦ埛鐩稿叧鏁版嵁锛屽苟杩涜鏍¢獙
+                    sql = "";
+                    if (importFieldList[0] == "HUserID")
+                    {
+                        sql = "select * from Gy_Czygl where Czybm = '" + HUserID + "'";
+                    }
+                    else if(importFieldList[0] == "HUserName")
+                    {
+                        sql = "select * from Gy_Czygl where Czymc = '" + HUserName + "'";
+                    }
+                    ds = oCN.RunProcReturn(sql, "Gy_Czygl");
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        err += "鐢ㄦ埛涓嶅瓨鍦紱";
+                    }
+                    else
+                    {
+                        tb2.Rows[i - 1]["鐢ㄦ埛浠g爜"] = ds.Tables[0].Rows[0]["Czybm"];
+                        tb2.Rows[i - 1]["鐢ㄦ埛鍚嶇О"] = ds.Tables[0].Rows[0]["Czymc"];
+
+                        HUserID = ds.Tables[0].Rows[0]["Czybm"].ToString();
+                        HUserName = ds.Tables[0].Rows[0]["Czymc"].ToString();
+                    }
+
+                    //鏍规嵁瀵煎叆瀛楁鑾峰彇瀹㈡埛鐩稿叧鏁版嵁锛屽苟杩涜鏍¢獙
+                    sql = "";
+                    if (importFieldList[1] == "HOrgNumber")
+                    {
+                        sql = "select * from Xt_ORGANIZATIONS where HNumber = '" + HOrgNumber + "'";
+                    }
+                    else if (importFieldList[1] == "HOrgName")
+                    {
+                        sql = "select * from Xt_ORGANIZATIONS where HName = '" + HOrgName + "'";
+                    }
+                    ds = oCN.RunProcReturn(sql, "Xt_ORGANIZATIONS");
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        err += "缁勭粐涓嶅瓨鍦紱";
+
+                        HCusID = "0";
+                        tb2.Rows[i - 1]["瀹㈡埛鍐呯爜"] = "0";
+                    }
+                    else
+                    {
+                        tb2.Rows[i - 1]["缁勭粐浠g爜"] = ds.Tables[0].Rows[0]["HNumber"];
+                        tb2.Rows[i - 1]["缁勭粐鍚嶇О"] = ds.Tables[0].Rows[0]["HName"];
+
+                        sql = "select c.* from " +
+                        "Gy_Customer as c " +
+                        "left join Xt_ORGANIZATIONS o on c.HUSEORGID = o.HItemID " +
+                        "where c.HNumber = '" + HCusNumber + "' " +
+                        "and o.HNumber = '" + ds.Tables[0].Rows[0]["HNumber"] + "' " +
+                        "and o.HName = '" + ds.Tables[0].Rows[0]["HName"] + "'";
+                        ds = oCN.RunProcReturn(sql, "Gy_Customer");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            err += "璇ョ粍缁囦笅瀹㈡埛涓嶅瓨鍦紱";
+                            HCusID = "0";
+                            tb2.Rows[i - 1]["瀹㈡埛鍐呯爜"] = "0";
+                        }
+                        else
+                        {
+                            tb2.Rows[i - 1]["瀹㈡埛鍐呯爜"] = ds.Tables[0].Rows[0]["HItemID"];
+                            tb2.Rows[i - 1]["瀹㈡埛浠g爜"] = ds.Tables[0].Rows[0]["HNumber"];
+                            tb2.Rows[i - 1]["瀹㈡埛鍚嶇О"] = ds.Tables[0].Rows[0]["HName"];
+
+                            HCusID = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+                    }
+
+                    //鍒ゅ畾瀹㈡埛鏄惁宸茬粡鍏宠仈鐢ㄦ埛
+                    sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " +
+                            " from Gy_UserCustomerRelation as a" +
+                            " left join Gy_Czygl as b on a.HUserID = b.Czybm " +
+                            " left join Gy_Customer as c on a.HCusID = c.HItemID " +
+                            " where a.HCusID = " + HCusID;
+                    ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                    if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HUserID"].ToString()!= HUserID)
+                    {
+                        err += "鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆戯紱";
+                    }
+                    else
+                    {
+                        //鍒ゅ畾璇ョ敤鎴蜂笌瀹㈡埛鏄惁宸茬粡鍏宠仈
+                        sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            err += "鐢ㄦ埛宸茬粡鍏宠仈璇ュ鎴凤紱";
+                        }
+                    }
+
+                    tb2.Rows[i - 1]["鍒ゅ畾缁撴灉"] = err;
+                    error += err;
+
+                    i++;
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = (error.Length>0?"0":"1");
+                objJsonResult.data = tb2;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛 瀵煎叆(淇濆瓨)
+        [Route("Xt_User/Gy_UserCustomer_ImportByExcel_Save")]
+        [HttpPost]
+        public object Gy_UserCustomer_ImportByExcel_Save([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string saveType = sArray[2].ToString();
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲鍏ユ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                if(saveType == "1")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HUserID = item["鐢ㄦ埛浠g爜"].ToString();//渚涘簲鍟�
+                        string HUserName = item["鐢ㄦ埛鍚嶇О"].ToString();//鐗╂枡ID
+                        string HCusID = item["瀹㈡埛鍐呯爜"].ToString();//缁勭粐ID
+                        string HCusNumber = item["瀹㈡埛浠g爜"].ToString();
+                        string HCusName = item["瀹㈡埛鍚嶇О"].ToString();
+                        string HOrgNumber = item["缁勭粐浠g爜"].ToString();
+                        string HOrgName = item["缁勭粐鍚嶇О"].ToString();
+
+                        sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " +
+                            " from Gy_UserCustomerRelation as a" +
+                            " left join Gy_Czygl as b on a.HUserID = b.Czybm " +
+                            " left join Gy_Customer as c on a.HCusID = c.HItemID " +
+                            " where a.HCusID = " + HCusID;
+                            ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" +
+                                "values(" +
+                                "'" + HUserID + "'" +
+                                "," + HCusID + "" +
+                                ")";
+                                oCN.RunProc(sql);
+                            }
+                            else
+                            {
+                                err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆�,瀹㈡埛涓嶅彲琚涓敤鎴峰叧鑱旓紒";
+                            }
+                            i++;
+                        }
+                        else
+                        {
+                            
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀵煎叆閿欒锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else if(saveType == "2")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HUserID = item["鐢ㄦ埛浠g爜"].ToString();//渚涘簲鍟�
+                        string HUserName = item["鐢ㄦ埛鍚嶇О"].ToString();//鐗╂枡ID
+                        string HCusID = item["瀹㈡埛鍐呯爜"].ToString();//缁勭粐ID
+                        string HCusNumber = item["瀹㈡埛浠g爜"].ToString();
+                        string HCusName = item["瀹㈡埛鍚嶇О"].ToString();
+                        string HOrgNumber = item["缁勭粐浠g爜"].ToString();
+                        string HOrgName = item["缁勭粐鍚嶇О"].ToString();
+
+
+                        sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " +
+                            " from Gy_UserCustomerRelation as a" +
+                            " left join Gy_Czygl as b on a.HUserID = b.Czybm " +
+                            " left join Gy_Customer as c on a.HCusID = c.HItemID " +
+                            " where a.HCusID = " + HCusID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                        if (ds.Tables[0].Rows.Count > 0 && ds.Tables[0].Rows[0]["HUserID"].ToString()!=HUserID)
+                        {
+                            err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆�,瀹㈡埛涓嶅彲琚涓敤鎴峰叧鑱旓紒";
+                        }
+                        else
+                        {
+                            sql = "select * from Gy_UserCustomerRelation where HUserID = '" + HUserID + "' and HCusID = " + HCusID;
+                            ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                            if (ds.Tables[0].Rows.Count == 0)
+                            {
+                                sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" +
+                                    "values(" +
+                                    "'" + HUserID + "'" +
+                                    "," + HCusID + "" +
+                                    ")";
+                                oCN.RunProc(sql);
+                            }
+                            else
+                            {
+                                err += "绗�" + i + "琛岋細鐢ㄦ埛宸茬粡鍏宠仈璇ュ鎴�!";
+                            }
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀵煎叆閿欒锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "瀵煎叆鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛缁存姢鍒楄〃
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationCustomerlist")]
+        [HttpGet]
+        public object UserRelationCustomerlist(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "";
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    sql = "select * from h_v_Gy_UserCustomerRelationList_Query order by 鐢ㄦ埛浠g爜 asc,瀹㈡埛浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                }
+                else
+                {
+                    sql = "select * from h_v_Gy_UserCustomerRelationList_Query where 1=1 ";
+                    sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,瀹㈡埛浠g爜 asc";
+                    ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛缁存姢 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationCustomerlist_Drop")]
+        [HttpGet]
+        public object UserRelationCustomerlist_Drop(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserCustomerRelation where HItemID = " + HInterID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+        #region 鐢ㄦ埛鍏宠仈瀹㈡埛缁存姢 缂栬緫鍒濆鍖�
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserRelationCustomerlist_EditInit")]
+        [HttpGet]
+        public object UserRelationCustomerlist_EditInit(int HItemID, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "select * from h_v_Gy_UserCustomerRelationList_Query where HItemID = " + HItemID;
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserCustomerRelationList_Query");
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                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/UserRelationCustomerlist_Save")]
+        [HttpPost]
+        public object UserRelationCustomerlist_Save([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            string saveType = sArray[2].ToString();
+            try
+            {
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserRelationCustomer_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                if (saveType == "1")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HItemID = item["HItemID"].ToString();        //
+                        string HUserID = item["HUserID"].ToString();        //鐢ㄦ埛浠g爜
+                        string HUserName = item["HUserName"].ToString();    //鐢ㄦ埛鍚嶇О
+                        string HCusID = item["HCusID"].ToString();          //瀹㈡埛鍐呯爜
+                        string HCusNumber = item["HCusNumber"].ToString();  //瀹㈡埛浠g爜
+                        string HCusName = item["HCusName"].ToString();      //瀹㈡埛鍚嶇О
+
+
+                        sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " +
+                            " from Gy_UserCustomerRelation as a" +
+                            " left join Gy_Czygl as b on a.HUserID = b.Czybm " +
+                            " left join Gy_Customer as c on a.HCusID = c.HItemID " +
+                            " where a.HCusID = " + HCusID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            sql = "insert into Gy_UserCustomerRelation(HUserID,HCusID)" +
+                                "values(" +
+                                "'" + HUserID + "'" +
+                                "," + HCusID + "" +
+                                ")";
+                            oCN.RunProc(sql);
+                        }
+                        else
+                        {
+                            err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆�,瀹㈡埛涓嶅彲琚涓敤鎴峰叧鑱旓紒";
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+                else if (saveType == "3")
+                {
+                    oCN.BeginTran();
+                    string err = "";
+                    int i = 1;
+                    string sql = "";
+                    foreach (Dictionary<string, string> item in list)
+                    {
+                        string HItemID = item["HItemID"].ToString();        //
+                        string HUserID = item["HUserID"].ToString();        //鐢ㄦ埛浠g爜
+                        string HUserName = item["HUserName"].ToString();    //鐢ㄦ埛鍚嶇О
+                        string HCusID = item["HCusID"].ToString();          //瀹㈡埛鍐呯爜
+                        string HCusNumber = item["HCusNumber"].ToString();  //瀹㈡埛浠g爜
+                        string HCusName = item["HCusName"].ToString();      //瀹㈡埛鍚嶇О
+
+                        sql = "select * from Gy_UserCustomerRelation where HItemID = " + HItemID;
+                        ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            sql = "select a.HItemID,a.HCusID,c.HName HCusName,a.HUserID,b.Czymc " +
+                            " from Gy_UserCustomerRelation as a" +
+                            " left join Gy_Czygl as b on a.HUserID = b.Czybm " +
+                            " left join Gy_Customer as c on a.HCusID = c.HItemID " +
+                            " where a.HCusID = " + HCusID + " and a.HItemID <> " + HItemID;
+                            ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
+                            if(ds.Tables[0].Rows.Count == 0)
+                            {
+                                sql = "update Gy_UserCustomerRelation set " +
+                                      "HUserID = '" + HUserID + "' " +
+                                      ",HCusID = " + HCusID + " " +
+                                      "where HItemID = " + HItemID;
+                                oCN.RunProc(sql);
+                            }
+                            else
+                            {
+                                err += "绗�" + i + "琛岋細鐢ㄦ埛銆�" + ds.Tables[0].Rows[0]["Czymc"].ToString() + "銆戝凡缁忓叧鑱斿鎴枫��" + ds.Tables[0].Rows[0]["HCusName"].ToString() + "銆�,瀹㈡埛涓嶅彲琚涓敤鎴峰叧鑱旓紒";
+                            }
+                        }
+                        else
+                        {
+                            err += "绗�" + i + "琛岋細璁板綍涓嶅瓨鍦�!";
+                        }
+                        i++;
+                    }
+                    //鍒ゆ柇鏄惁瀛樺湪閿欒
+                    if (err.Length > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛�" + err;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region  鏍规嵁鐢ㄦ埛缂栫爜鏌ユ壘宸插垎閰嶅伐搴忓垪琛�
+        [Route("Xt_User/ProcessPlaylist")]
+        [HttpGet]
+        public object ProcessPlaylist(string HUserID)
+        {
+            try
+            {
+
+                ds = oCN.RunProcReturn("select HProcID,宸ュ簭浠g爜 HProcNumber,宸ュ簭鍚嶇О HProcName from h_v_Gy_UserProcessList where HUserID='" + HUserID + "' ", "h_v_Gy_UserProcessList");
+                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 鐢ㄦ埛鍏宠仈宸ュ簭淇濆瓨  Excel瀵煎叆
+        [Route("Xt_User/SaveUserProcess")]
+        [HttpPost]
+        public object SaveUserProcess([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_UserProcess> lsmain = new List<Models.Gy_UserProcess>();
+                msg2 = msg2.Substring(1, msg2.Length - 2);
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                lsmain = oListModels.getObjectByJson_Gy_UserProcess(msg2);
+                oCN.BeginTran();
+                //鍒犻櫎宸茬粡鍏宠仈鐨勬暟鎹�
+                oCN.RunProc("Delete From Gy_UserByProcess  where HUserID='" + msg3.ToString() + "'");
+                foreach (Models.Gy_UserProcess oItem in lsmain)
+                {
+                    //閲嶆柊鍐欏叆鍏宠仈鏁版嵁
+                    oCN.RunProc("insert into Gy_UserByProcess (HProcID,HUserID) values ('" + oItem.HProcID + "','" + 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;
+            }
+        }
+
+        /// <summary>
+        /// 鏂囦欢涓婁紶瑙f瀽鍥炴樉
+        /// </summary>
+        /// <returns></returns>
+        [Route("Xt_User/UserProcessBill_Excel")]
+        [HttpPost]
+        public object UserProcessBill_Excel()
+        {
+            try
+            {
+                //鑾峰彇鏂囦欢鍚嶇О
+                var file = HttpContext.Current.Request.Files[0];
+                //鑾峰彇鏂囦欢鐗╃悊璺緞
+                string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName);
+                //淇濆瓨鏂囦欢
+                file.SaveAs(ExcelPath);
+
+                NpoiHelper np = new NpoiHelper();
+                DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0");
+
+                //鍒犻櫎鏂囦欢
+                File.Delete(ExcelPath);
+
+                //鍒涘缓涓存椂琛�
+                DataTable tb2 = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                ////Excel妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                tb2.Columns.Add("HProcID", typeof(Int32));//宸ュ簭ID
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = tb2.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    tb2.Rows.Add(row);
+                }
+
+
+                var error = "";
+
+                ////鏌ヨ鐢ㄦ埛鍏宠仈渚涘簲鍟嗘病鏈夌殑鍒�
+                if (!tb2.Columns.Contains("鐢ㄦ埛浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愮敤鎴蜂唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鐢ㄦ埛鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愮敤鎴峰悕绉般�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("宸ュ簭浠g爜"))
+                    error += "娌℃湁鎵惧埌銆愬伐搴忎唬鐮併�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("宸ュ簭鍚嶇О"))
+                    error += "娌℃湁鎵惧埌銆愬伐搴忓悕绉般�戠殑鏍囬,";
+
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+                {
+                    string czybm = "";
+                    string czymc = "";
+                    string HNumber = "";
+                    string HName = "";
+
+                    //HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐缂栫爜"].ToString());
+                    //HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐"].ToString());
+                    czybm = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛浠g爜"].ToString());
+                    czymc = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐢ㄦ埛鍚嶇О"].ToString());
+                    HNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ュ簭浠g爜"].ToString());
+                    HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["宸ュ簭鍚嶇О"].ToString());
+
+                    int index = i + 1;
+                    //妫�鏌ョ敤鎴蜂笌宸ュ簭浠g爜鏄惁閮戒负绌�
+                    if (czybm != "" || HNumber != "")
+                    {
+                        //鏌ヨ宸ュ簭
+                        ds = oCN.RunProcReturn("select * from Gy_Process where  HNumber='" + HNumber + "'", "Gy_Process");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,宸ュ簭鍚嶇О:" + HName + ",涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HProcID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); //宸ュ簭ID
+                        }
+                        //鏌ヨ鐢ㄦ埛
+                        ds = oCN.RunProcReturn("select * from Gy_Czygl where  czybm='" + czybm + "'", "Gy_Czygl");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鐢ㄦ埛: " + czymc + ",涓嶅瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            //tb2.Rows[i]["czybm"] = ds.Tables[0].Rows[0]["czybm"].ToString();
+                        }
+
+                        //瀹℃牳浠g爜鏄惁鍚堢悊
+                        if (!DBUtility.ClsPub.AllowNumber(czybm))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鐢ㄦ埛浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                    }
+                    else
+                    {
+                        objJsonResult.code = "1";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "绗�" + index + "琛�,鐢ㄦ埛浠g爜涓虹┖";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = error;
+                objJsonResult.data = tb2;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+
+
+        /// <summary>
+        /// 瀵煎叆淇濆瓨
+        /// </summary>
+        /// <param name="sMainSub"></param>
+        /// <returns></returns>
+        [Route("Xt_User/UserProcessBill_btnSave")]
+        [HttpPost]
+        public object UserProcessBill_btnSave([FromBody] JObject sMainSub)
+        {
+            var _value = sMainSub["sMainSub"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { "&鍜�" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string user = sArray[1].ToString();
+            try
+            {
+
+                List<object> Excel = Newtonsoft.Json.JsonConvert.DeserializeObject<List<object>>(msg2);
+                List<Dictionary<string, string>> list = new List<Dictionary<string, string>>();
+
+                foreach (JObject item in Excel)
+                {
+                    Dictionary<string, string> dic = new Dictionary<string, string>();
+                    foreach (var itm in item.Properties())
+                    {
+                        dic.Add(itm.Name, itm.Value.ToString());
+                    }
+                    list.Add(dic);
+                }
+
+                oCN.BeginTran();
+                int i = 1;
+                foreach (Dictionary<string, string> item in list)
+                {
+                    string HProcID = item["HProcID"].ToString();//宸ュ簭ID
+                    string HUserID = item["鐢ㄦ埛浠g爜"].ToString();//鐢ㄦ埛浠g爜
+                    string czymc = item["鐢ㄦ埛鍚嶇О"].ToString();//鐢ㄦ埛鍚嶇О
+                    string HNumber = item["宸ュ簭浠g爜"].ToString();//宸ュ簭浠g爜
+                    string HName = item["宸ュ簭鍚嶇О"].ToString();//宸ュ簭鍚嶇О
+
+                    var ds = oCN.RunProcReturn("select * from Gy_UserByProcess where  HProcID='" + HProcID + "'and HUserID='" + HUserID + "'", "Gy_UserByProcess");
+
+
+                    if (ds.Tables[0].Rows.Count > 0)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绗�" + i + "琛�, 鐢ㄦ埛: " + czymc + " 涓� 宸ュ簭鍚�: " + HName + ",宸插瓨鍦�,鎴�,鎻掑叆琛ㄦ牸鏈夐噸澶嶄俊鎭�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        oCN.RunProc("insert into Gy_UserByProcess (HProcID,HUserID) values ('" + HProcID + "','" + HUserID + "')");
+                    }
+
+                    i++;
+                }
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "瀵煎叆鎴愬姛!";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write(e);
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region  鐢ㄦ埛鍏宠仈宸ュ簭鍒楄〃鏌ヨ
+        [Route("Xt_User/UserProcesslist")]
+        [HttpGet]
+        public object UserProcesslist(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserProcessList_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql1 = "select * from h_v_Gy_UserProcess where 1 = 1";
+                string sql = sql1 + sWhere + " order by 鐢ㄦ埛浠g爜 ";
+                ds = oCN.RunProcReturn(sql, "h_v_Gy_UserProcess");
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈宸ュ簭鍒楄〃 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/Gy_UserProcessDrop")]
+        [HttpGet]
+        public object Gy_UserProcessDrop(string HItemID, string user)
+        {
+            try
+            {
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserProcessList_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+                if (HItemID == null || HItemID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserByProcess where HItemID = " + HItemID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍒犻櫎鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈渚涘簲鍟嗙淮鎶ゅ垪琛�
+        /// <summary>
+        ///鍙傛暟锛歴tring sql銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/Gy_UserSupplierRelationList")]
+        [HttpGet]
+        public object Gy_UserSupplierRelationList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserSupplierRelationList", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = "";
+
+
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    sql = "select * from h_v_Gy_UserSupplierRelationList_Query order by 鐢ㄦ埛浠g爜 asc,渚涘簲鍟嗕唬鐮� asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserSupplierRelationList_Query");
+                }
+                else
+                {
+                    sql = "select * from h_v_Gy_UserSupplierRelationList_Query where 1=1 ";
+                    sql = sql + sWhere + " order by 鐢ㄦ埛浠g爜 asc,渚涘簲鍟嗕唬鐮� asc";
+                    ds = oCN.RunProcReturn(sql, "h_v_Gy_UserSupplierRelationList_Query");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鐢ㄦ埛鍏宠仈渚涘簲鍟嗙淮鎶� 鍒犻櫎
+        /// <summary>
+        ///鍙傛暟锛歴tring HInterID銆�
+        ///杩斿洖鍊硷細object銆�
+        /// </summary>
+        [Route("Xt_User/UserSupplierRelationList_Drop")]
+        [HttpGet]
+        public object UserSupplierRelationList_Drop(string HInterID, string user)
+        {
+            try
+            {
+                string s = "";
+
+                //鏌ョ湅鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_UserSupplierRelation_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                if (HInterID == null || HInterID.Equals(""))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "HInterID涓嶈兘涓虹┖锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                string sql = "delete from Gy_UserSupplierRelation where HItemID = " + HInterID;
+                oCN.RunProc(sql);
+
+                oCN.Commit();
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1