From d00b4284626da680659b4f013e5c17d5dbe4ccf7 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期一, 01 九月 2025 17:01:19 +0800
Subject: [PATCH] 合并分支

---
 WebAPI/Controllers/华远datamapping/Gy_PNLInfoController.cs | 1384 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 1,383 insertions(+), 1 deletions(-)

diff --git "a/WebAPI/Controllers/\345\215\216\350\277\234datamapping/Gy_PNLInfoController.cs" "b/WebAPI/Controllers/\345\215\216\350\277\234datamapping/Gy_PNLInfoController.cs"
index 2591593..dc7581d 100644
--- "a/WebAPI/Controllers/\345\215\216\350\277\234datamapping/Gy_PNLInfoController.cs"
+++ "b/WebAPI/Controllers/\345\215\216\350\277\234datamapping/Gy_PNLInfoController.cs"
@@ -7,6 +7,14 @@
 using System.Net.Http;
 using System.Web.Http;
 using WebAPI.Models;
+using System.Data;
+using SyntacticSugar.constant;
+using DBUtility;
+using System.Text;
+using System.Web;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
+using System.IO;
+using System.Text.RegularExpressions;
 
 namespace WebAPI.Controllers.鍩虹璧勬枡.鍩虹璧勬枡
 {
@@ -15,6 +23,7 @@
 
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+        DataSet ds;
 
         #region 鑾峰彇PNLInfo鍒楄〃
         [Route("Gy_PNLInfoController/GetGy_PNLInfoList")]
@@ -23,7 +32,79 @@
         {
             try
             {
-                return null;
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("Gy_PNLInfo_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏌ョ湅鏉冮檺";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DataSet ds = oCN.RunProcReturn("select * from h_v_Gy_PNLInfoList where 1=1 " + sWhere + " order by HInterID", "h_v_Gy_PNLInfoList");
+
+                //娣诲姞鍒楀悕
+                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 鑾峰彇PNLInfo鍒楄〃瀛愯〃
+        [Route("Gy_PNLInfoController/GetGy_PNLInfoSubList")]
+        [HttpGet]
+        public object GetGy_PNLInfoSubList(string sWhere, string user)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("Gy_PNLInfo_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏌ョ湅鏉冮檺";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DataSet ds = oCN.RunProcReturn("select * from h_v_Gy_PNLInfoSubList where 1=1 " + sWhere + " order by HInterID", "h_v_Gy_PNLInfoSubList");
+
+                //娣诲姞鍒楀悕
+                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)
             {
@@ -37,15 +118,1316 @@
         #endregion
 
         #region 鑾峰彇PNLInfo鍒楄〃 鍒嗛〉
+        [Route("Gy_PNLInfoController/GetGy_PNLInfoListPage")]
+        [HttpGet]
+        public object GetGy_PNLInfoListPage(string sWhere, string user, string page, string size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("Gy_PNLInfo_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏌ョ湅鏉冮檺";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (string.IsNullOrWhiteSpace(sWhere) == false)
+                {
+                    sWhere = sWhere.Replace("'", "''");
+                }
+
+                string sql = "exec h_p_Gy_PNLInfo_ListPage " + page + "," + size + ",'" + sWhere + "'";
+
+                DataSet ds = oCN.RunProcReturn(sql, "h_p_Gy_PNLInfo_ListPage");
+
+                //娣诲姞鍒楀悕
+                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 = CodeConstant.SUCCEED;
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = CodeConstant.FAIL;
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 鑾峰彇PNLInfo鍒楄〃瀛愯〃 鍒嗛〉
+        [Route("Gy_PNLInfoController/GetGy_PNLInfoSubListPage")]
+        [HttpGet]
+        public object GetGy_PNLInfoSubListPage(string sWhere, string user, string page, string size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                if (!DBUtility.ClsPub.Security_Log("Gy_PNLInfo_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏌ョ湅鏉冮檺";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (string.IsNullOrWhiteSpace(sWhere) == false)
+                {
+                    sWhere = sWhere.Replace("'", "''");
+                }
+
+                string sql = "exec h_p_Gy_PNLInfoSub_ListPage " + page + "," + size + ",'" + sWhere + "'";
+
+                DataSet ds = oCN.RunProcReturn(sql, "h_p_Gy_PNLInfoSub_ListPage");
+
+                //娣诲姞鍒楀悕
+                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 = CodeConstant.SUCCEED;
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = CodeConstant.FAIL;
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
         #endregion
 
         #region 娣诲姞PNLInfo 娣诲姞瀛愯〃
+        [Route("Gy_PNLInfoController/AddBill")]
+        [HttpPost]
+        public object AddBill([FromBody] JObject oMain)
+        {
+            try
+            {
+                var _value = oMain["oMain"].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(); // 鍒跺崟浜轰俊鎭�
+                //string msg4 = sArray[2].ToString();
+
+                //鍙嶅簭鍒楀寲
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsGy_PNLInfo> list = JsonConvert.DeserializeObject<List<ClsGy_PNLInfo>>(msg2);
+                List<ClsGy_PNLInfoSub> lsmain = JsonConvert.DeserializeObject<List<ClsGy_PNLInfoSub>>(msg3);
+
+
+                //鍒ゆ柇鏉冮檺
+                if (!ClsPub.Security_Log("Gy_PNLInfo_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏂板鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+                DataSet ds_editCheck;
+                //淇濆瓨鍓嶆帶鍒�=========================================
+                ds_editCheck = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_BeforeSaveCtrl " + msg4 + ",'1'", "h_p_Gy_PNLInfo_BeforeSaveCtrl");
+                if (ds_editCheck == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨鍓嶅垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+                ds_editCheck = oCN.RunProcReturn("select top 1 HInterID from Gy_PNLInfo where HLayOutName=N'" + list[0].HLayOutName  + "'", "Gy_PNLInfo");
+                if(ds_editCheck.Tables[0].Rows.Count > 0)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "PNL甯冨眬閲嶅锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql1 = "insert into Gy_PNLInfo(HLayOutName,HIcon,HRowCount,HColCount,HMaker,HMakeDate,HPNLPosition_x,HPNLPosition_y) values(" +
+                    "N'" + list[0].HLayOutName + "'," +
+                    "N'" + list[0].HIcon + "'," +
+                    "N'" + list[0].HRowCount + "'," +
+                    "N'" + list[0].HColCount + "'," +
+                    "N'" + list[0].HMaker + "'," +
+                    "N'" + list[0].HMakeDate + "'," +
+                    "N'" + list[0].HPNLPosition_x + "'," +
+                    "N'" + list[0].HPNLPosition_y + "'" +
+                    ")";
+                //LogService.Write("鎵цsql璇彞:" + sql1);
+                DataSet ds = oCN.RunProcReturn(sql1, "Gy_PNLInfo");
+                ds = oCN.RunProcReturn("Select TOP 1 HInterID from Gy_PNLInfo where HLayOutName=N'" + list[0].HLayOutName + "'", "Gy_PNLInfo");
+                if(ds.Tables[0].Rows.Count < 1)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍐呯爜涓嶅瓨鍦紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                string currHInterID = ds.Tables[0].Rows[0]["HInterID"].ToString();
+                HashSet<string> HSetNoHashSet = new HashSet<string>();
+                HashSet<string> HPCSNoHashSet = new HashSet<string>();
+                List<string> HUpdateLangList = new List<string>();
+                string insertLangTemplet = "insert into Gy_PNLInfoSub(HInterID,HLayOutName,HSetNo,HPCSNo,HPosition_x,HPosition_y" +
+                    ",HSetPosition_y, HSetPosition_x ) values(  ";
+                int batchNum = 100;
+                StringBuilder updateLangBuilder = new StringBuilder();
+                foreach (var lsone in lsmain)
+                {
+
+                    if(HPCSNoHashSet.Contains(lsone.HPCSNo) == true)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "PCS鐮侀噸澶嶏紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    HSetNoHashSet.Add(lsone.HSetNo);
+                    HPCSNoHashSet.Add(lsone.HPCSNo);
+
+                    batchNum--;
+                    updateLangBuilder.Append(insertLangTemplet);
+                    updateLangBuilder.Append("N'" + currHInterID + "',");
+                    updateLangBuilder.Append("N'" + lsone.HLayOutName + "',");
+                    updateLangBuilder.Append("N'" + lsone.HSetNo + "',");
+                    updateLangBuilder.Append("N'" + lsone.HPCSNo + "',");
+                    updateLangBuilder.Append("N'" + lsone.HPosition_x + "',");
+                    updateLangBuilder.Append("N'" + lsone.HPosition_y + "',");
+                    updateLangBuilder.Append("N'" + lsone.HSetPosition_y + "',");
+                    updateLangBuilder.Append("N'" + lsone.HSetPosition_x + "'");
+                    updateLangBuilder.Append(");");
+
+
+                    if (batchNum == 0)
+                    {
+                        HUpdateLangList.Add(updateLangBuilder.ToString());
+                        updateLangBuilder.Clear();
+                        batchNum = 100;
+                    }
+                }
+
+                HUpdateLangList.Add(updateLangBuilder.ToString());
+                updateLangBuilder.Clear();
+
+                string HSetNoInStr = "(" + string.Join(",", HSetNoHashSet.ToArray<string>()) + ")";
+                string HPCSNoInStr = "(" + string.Join(",", HPCSNoHashSet.ToArray<string>()) + ")";
+
+                // 鍒ゆ柇鏄惁鏈塻et鐮佹垨鑰匬CS鐮侀噸澶嶇殑閮ㄥ垎
+                ds = oCN.RunProcReturn("select top 1 HEntryID from Gy_PNLInfoSub where HSetNo in " + HSetNoInStr
+                    + "AND HPCSNo in " + HPCSNoInStr  + "AND HInterID = " + currHInterID, "Gy_PNLInfoSub");
+                //LogService.Write("鎵ц SQL 璇彞: select top 1 HEntryID from Gy_PNLInfoSub where HSetNo in " + HSetNoInStr
+                //    + "AND HPCSNo in " + HPCSNoInStr);
+                
+                if(ds.Tables[0].Rows.Count > 0)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "Set鐮佹垨鑰匬CS鐮佹湁閲嶅锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                HUpdateLangList.ForEach(HUpdateLang =>
+                {
+                    //LogService.Write("鎵ц SQL 璇彞: " + HUpdateLang);
+                    ds = oCN.RunProcReturn(HUpdateLang, "Gy_PNLInfoSub");
+                });
+
+
+                //淇濆瓨鍚庢帶鍒�=========================================
+                ds_editCheck = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_AfterSaveCtrl " + msg4 + ",'1'", "h_p_Gy_PNLInfo_AfterSaveCtrl");
+                if (ds_editCheck == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨鍚庡垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                }
+                if (DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "" + DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                //objJsonResult.data = null;
+                return objJsonResult;
+
+
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
         #endregion
 
         #region 鍒犻櫎PNLInfo 鍒犻櫎瀛愯〃
+        [Route("Gy_PNLInfoController/DeleteBill")]
+        [HttpGet]
+        public object DeleteBill(string HInterID, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏉冮檺
+                if (!ClsPub.Security_Log("Gy_PNLInfo_Drop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鍒犻櫎鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                DataSet ds_editCheck;
+                oCN.BeginTran();
+                //鍒犻櫎鍓嶆帶鍒�=========================================
+                ds_editCheck = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_BeforeDelCtrl " + HInterID + "," + user, "h_p_Gy_PNLInfo_BeforeDelCtrl");
+                if (ds_editCheck == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍓嶅垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+              
+                ds = oCN.RunProcReturn("delete from Gy_PNLInfo where HInterID = " + HInterID, "Gy_PNLInfo");
+       
+                ds = oCN.RunProcReturn("delete from Gy_PNLInfoSub where HInterID = " + HInterID, "Gy_PNLInfoSub"); // 鍒犻櫎瀛愯〃
+
+                //鍒犻櫎鍚庢帶鍒�=========================================
+                ds_editCheck = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_AfterDelCtrl " + HInterID + "," + user, "h_p_Gy_PNLInfo_AfterDelCtrl");
+                if (ds_editCheck == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎鍚庡垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                }
+                if (DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍒犻櫎澶辫触" + DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBackRemark"]);
+                    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.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
         #endregion
 
         #region 鏇存柊PNLInfo 鏇存柊瀛愯〃
+        [Route("Gy_PNLInfoController/EditBill")]
+        [HttpPost]
+        public object EditBill([FromBody] JObject oMain)
+        {
+            try
+            {
+                var _value = oMain["oMain"].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(); // 鍒跺崟浜轰俊鎭�
+                string msg5 = sArray[3].ToString(); // 鍒犻櫎琛ㄥ崟淇℃伅(HEntryID 鍒楄〃)
+
+                //鍙嶅簭鍒楀寲
+                msg2 = "[" + msg2.ToString() + "]";
+                List<ClsGy_PNLInfo> list = JsonConvert.DeserializeObject<List<ClsGy_PNLInfo>>(msg2);
+                List<ClsGy_PNLInfoSub> lsmain = JsonConvert.DeserializeObject<List<ClsGy_PNLInfoSub>>(msg3);
+                List<int> delEntryIDList = JsonConvert.DeserializeObject<List<int>>(msg5);
+
+
+                //鍒ゆ柇鏉冮檺
+                if (!ClsPub.Security_Log("Gy_PNLInfo_Edit", 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "娌℃湁鏂板鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+                DataSet ds_editCheck;
+                //淇濆瓨鍓嶆帶鍒�=========================================
+                ds_editCheck = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_BeforeSaveCtrl " + msg4 + ",'2'", "h_p_Gy_PNLInfo_BeforeSaveCtrl");
+                if (ds_editCheck == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨鍓嶅垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if (DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+                ds_editCheck = oCN.RunProcReturn("select top 1 HInterID from Gy_PNLInfo where HLayOutName=N'" + list[0].HLayOutName + "'"
+                    + "AND HInterID != N'" + list[0].HInterID + "'", "Gy_PNLInfo");
+                if (ds_editCheck.Tables[0].Rows.Count > 0)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "PNL甯冨眬閲嶅锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                // 涓昏〃 鏇存柊
+                StringBuilder sb = new StringBuilder();
+                sb.Append("Update Gy_PNLInfo set ");
+                sb.Append("HLayOutName=N'"+ list[0].HLayOutName + "',");
+                sb.Append("HIcon=N'" + list[0].HIcon + "',");
+                sb.Append("HRowCount=N'" + list[0].HRowCount + "',");
+                sb.Append("HColCount=N'" + list[0].HColCount + "',");
+                sb.Append("HPNLPosition_x=N'" + list[0].HPNLPosition_x + "',");
+                sb.Append("HPNLPosition_y=N'" + list[0].HPNLPosition_y + "',");
+                sb.Append("HModifyMan=N'" + msg4 + "',");
+                sb.Append("HModifyDate=getdate()");
+                sb.Append(" where HInterID=N'" + list[0].HInterID + "'");
+                string sql1 = sb.ToString();
+                oCN.RunProcReturn(sql1, "Gy_PNLInfo");
+                
+                oCN.RunProcReturn("Update Gy_PNLInfoSub set HLayOutName = N'" + list[0].HLayOutName + "'" + 
+                    " where HInterID=N'" + list[0].HInterID + "'", "Gy_PNLInfoSub"); 
+                sb.Clear();
+                // 鏋勫缓鍒犻櫎 鏇存柊璇彞
+                List<string> HUpdateLangList = new List<string>();
+                int batchNum = 100;
+
+                HashSet<string> HSetNoHashSet = new HashSet<string>();
+                HashSet<string> HPCSNoHashSet = new HashSet<string>();
+
+                foreach( var lsone in lsmain)
+                {
+
+                    batchNum--;
+
+                    if (HPCSNoHashSet.Contains(lsone.HPCSNo) == true)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "PCS鐮侀噸澶嶏紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    HSetNoHashSet.Add(lsone.HSetNo);
+                    HPCSNoHashSet.Add(lsone.HPCSNo);
+                    if (lsone.HEntryID != 0)
+                    {
+                        delEntryIDList.Add(lsone.HEntryID);
+                    }
+                    sb.Append("insert into Gy_PNLInfoSub(HInterID,");
+                    sb.Append("HLayOutName, HSetNo, HPCSNo, HPosition_x, HPosition_y" +
+                    ",HSetPosition_y, HSetPosition_x ) values(  ");
+                    sb.Append("N'" + lsone.HInterID + "',");
+                    sb.Append("N'" + lsone.HLayOutName + "',");
+                    sb.Append("N'" + lsone.HSetNo + "',");
+                    sb.Append("N'" + lsone.HPCSNo + "',");
+                    sb.Append("N'" + lsone.HPosition_x + "',");
+                    sb.Append("N'" + lsone.HPosition_y + "',");
+                    sb.Append("N'" + lsone.HSetPosition_y + "',");
+                    sb.Append("N'" + lsone.HSetPosition_x + "'");
+                    sb.Append(");");
+
+
+                    if (batchNum == 0)
+                    {
+                        HUpdateLangList.Add(sb.ToString());
+                        sb.Clear();
+                        batchNum = 100;
+                    }
+                }
+
+                HUpdateLangList.Add(sb.ToString());
+                sb.Clear();
+
+
+                // 瀛愯〃鍒犻櫎
+                string delWhereStr = "(" + string.Join(",", delEntryIDList.ToArray()) + ")";
+                string sql2 = "Delete from Gy_PNLInfoSub where HEntryID in " + delWhereStr;
+                LogService.Write("鎵цSQL璇彞锛�" + sql2);
+                oCN.RunProcReturn(sql2, "Gy_PNLInfoSub");
+
+
+                // 澧炲姞鍓嶅垽鏂� 褰撳墠闇�瑕佹柊澧炵殑鏁版嵁涓槸鍚︽湁PCS鐮佸拰SET鐮侀噸澶嶇殑閮ㄥ垎
+                string HSetNoInStr = "(" + string.Join(",", HSetNoHashSet.ToArray<string>()) + ")";
+                string HPCSNoInStr = "(" + string.Join(",", HPCSNoHashSet.ToArray<string>()) + ")";
+
+                // 鍒ゆ柇鏄惁鏈塻et鐮佹垨鑰匬CS鐮侀噸澶嶇殑閮ㄥ垎
+                ds = oCN.RunProcReturn("select top 1 HEntryID from Gy_PNLInfoSub where HSetNo in " + HSetNoInStr
+                    + " AND HPCSNo in " + HPCSNoInStr + "and HInterID = " + list[0].HInterID , "Gy_PNLInfoSub");
+                LogService.Write("鎵ц SQL 璇彞: select top 1 HEntryID from Gy_PNLInfoSub where HSetNo in " + HSetNoInStr
+                    + " AND HPCSNo in " + HPCSNoInStr + "and HInterID = " + list[0].HInterID);
+
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "set鐮佸拰PCS鐮佹湁閲嶅锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                // 瀛愯〃 鏂板
+                HUpdateLangList.ForEach(HUpdateLang =>
+                    {
+                        ds = oCN.RunProcReturn(HUpdateLang, "Gy_PNLInfoSub");
+                    }
+                );
+
+
+                //淇濆瓨鍚庢帶鍒�=========================================
+                ds_editCheck = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_AfterSaveCtrl " + msg4 + ",'2'", "h_p_Gy_PNLInfo_AfterSaveCtrl");
+                if (ds_editCheck == null)
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨鍚庡垽鏂け璐ワ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+
+                }
+                if (DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBack"]) != "0")
+                {
+                    oCN.RollBack();
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "" + DBUtility.ClsPub.isStrNull(ds_editCheck.Tables[0].Rows[0]["HBackRemark"]);
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                //=========================================================
+
+                oCN.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                //objJsonResult.data = null;
+                return objJsonResult;
+
+
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.Message;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 瀹℃牳PNL甯冨眬
+        [Route("Gy_PNLInfoController/CheckBill")]
+        [HttpGet]
+        public object CheckBill(int HInterID, string user, int IsAudit)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_PNLInfo_Check", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select top 1 HCheckMan from Gy_PNLInfo  where HInterID=" + HInterID, "Gy_PNLInfo");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["HCheckMan"].ToString()) != true)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (string.IsNullOrEmpty(ds.Tables[0].Rows[0]["HCheckMan"].ToString()) == true)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鏍�!涓嶉渶瑕佸弽瀹℃牳!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+
+
+                oCN.BeginTran();
+
+                if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                {
+                    //瀹℃牳鍓嶆帶鍒�=========================================
+                    ds = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_BeforeCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_PNLInfo_BeforeCheckCtrl");
+                    if (ds == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    oCN.RunProc("update Gy_PNLInfo set HCheckMan='" + user + "',HCheckDate=getdate() where HInterID=" + HInterID);
+
+                    //瀹℃牳鍚庢帶鍒�=========================================
+                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_AfterCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_PNLInfo_AfterCheckCtrl");
+                    if (ds2 == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳鍚庡垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                {
+                    //鍙嶅鏍稿墠鎺у埗=========================================
+                    ds = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_BeforeUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_PNLInfo_BeforeUnCheckCtrl");
+                    if (ds == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    oCN.RunProc("update Gy_PNLInfo set HCheckMan='',HCheckDate=null where HInterID=" + HInterID);
+
+
+                    //鍙嶅鏍稿悗鎺у埗=========================================
+                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_AfterUnCheckCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_PNLInfo_AfterUnCheckCtrl");
+                    if (ds2 == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳鍚庡垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶅鏍告垚鍔�";
+                    objJsonResult.data = null;
+                }
+
+
+
+                oCN.Commit();
+
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+
+        }
+        #endregion
+
+        #region 绂佺敤PNL甯冨眬
+        [Route("Gy_PNLInfoController/StopBill")]
+        [HttpGet]
+        public object StopBill(int HInterID, string user, int IsStop)
+        {
+            try
+            {
+                //绂佺敤鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_PNLInfo_Stop", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select top 1 HStopMan from Gy_PNLInfo where HInterID=" + HInterID, "Gy_PNLInfo");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsStop == 0)  //绂佺敤鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopMan"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸茬鐢�!涓嶈兘鍐嶆绂佺敤锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopMan"].ToString() == "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鏈鐢�!涓嶉渶瑕佸弽绂佺敤!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鍗曟嵁涓嶅瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                oCN.BeginTran();
+
+                if (IsStop == 0)  //绂佺敤鍒ゆ柇
+                {
+                    //绂佺敤鍓嶆帶鍒�=========================================
+                    ds = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_BeforeStopCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_PNLInfo_BeforeStopCtrl");
+                    if (ds == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    oCN.RunProc("update Gy_PNLInfo set HStopMan='" + user + "',HStopDate=getdate() where HInterID=" + HInterID);
+
+                    //绂佺敤鍚庢帶鍒�=========================================
+                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_AfterStopCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_PNLInfo_AfterStopCtrl");
+                    if (ds2 == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤鍚庡垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "绂佺敤鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                {
+                    //鍙嶇鐢ㄥ墠鎺у埗=========================================
+                    ds = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_BeforeUnStopCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_PNLInfo_BeforeUnStopCtrl");
+                    if (ds == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤鍓嶅垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    oCN.RunProc("update Gy_PNLInfo set HStopMan='',HStopDate=null where HInterID=" + HInterID);
+
+
+                    //鍙嶇鐢ㄥ悗鎺у埗=========================================
+                    DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_PNLInfo_AfterUnStopCtrl " + HInterID + ",'" + user + "'", "h_p_Gy_PNLInfo_AfterUnStopCtrl");
+                    if (ds2 == null)
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤鍚庡垽鏂け璐ワ紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0")
+                    {
+                        oCN.RollBack();
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绂佺敤澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]);
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    //=========================================================
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍙嶇鐢ㄦ垚鍔�";
+                    objJsonResult.data = null;
+                }
+                oCN.Commit();
+
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "绂佺敤澶辫触鎴栬�呭弽绂佺敤澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region PNL甯冨眬淇℃伅 鏂囦欢涓婁紶
+        [Route("Gy_PNLInfo/Gy_PNLInfo_Excel")]
+        [HttpPost]
+        public object Gy_PNLInfo_Excel()
+        {
+            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("Set鍙�", typeof(string));
+                tb2.Columns.Add("琛岀储寮�", typeof(Int32));
+                tb2.Columns.Add("鍒楃储寮�", typeof(Int32));
+                tb2.Columns.Add("HPNLInfoTypeID", typeof(Int32));
+
+                //娣诲姞鏁版嵁
+                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
+                    if (ExcelDs.Tables[0].Rows[i][0].ToString() == "")
+                    {
+                        continue;
+                    }
+                    else
+                    {
+                        tb2.Rows.Add(row);
+                    }
+                }
+
+
+                var error = "";
+
+                //鏌ヨ瀵煎叆妯℃澘娌℃湁鐨勫垪
+                if (!tb2.Columns.Contains("鏂欏彿"))
+                    error += "涓婁紶鏂囦欢涓病鏈夋壘鍒般�愭枡鍙枫�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("鍒嗙被"))
+                    error += "涓婁紶鏂囦欢涓病鏈夋壘鍒般�愬垎绫汇�戠殑鏍囬,";
+
+                if (!tb2.Columns.Contains("PCS鍙�"))
+                    error += "涓婁紶鏂囦欢涓病鏈夋壘鍒般�怭CS鍙枫�戠殑鏍囬,";
+
+
+                if (error.Length > 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string HLayOutName_temp = "";
+                string HPNLInfoTypeName_temp = "";
+                List<string> HPCSNo_Array = new List<string>();
+                if (tb2.Rows.Count > 0)
+                {
+                    HLayOutName_temp = DBUtility.ClsPub.isStrNull(tb2.Rows[0]["鏂欏彿"].ToString());
+                    HPNLInfoTypeName_temp = DBUtility.ClsPub.isStrNull(tb2.Rows[0]["鍒嗙被"].ToString());
+                }
+
+                for (int i = 0; i <= tb2.Rows.Count - 1; i++)
+                {
+                    string HLayOutName = "";                //鏂欏彿
+                    string HPNLInfoTypeName = "";           //鍒嗙被
+                    string HPCSNo = "";                     //PCS鍙�
+
+                    HLayOutName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鏂欏彿"].ToString());
+                    HPNLInfoTypeName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍒嗙被"].ToString());
+                    HPCSNo = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["PCS鍙�"].ToString());
+                    
+                    //妫�鏌ユ暟鎹槸鍚﹀畬鏁�
+                    int index = i + 2;
+
+                    if (HLayOutName != "")
+                    {
+                        if (HLayOutName != HLayOutName_temp)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,銆愭枡鍙枫�戜笌棣栬鏁版嵁涓�愭枡鍙枫�戜笉涓�鑷达紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (HPNLInfoTypeName != HPNLInfoTypeName_temp)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,銆愬垎绫汇�戜笌棣栬鏁版嵁涓�愬垎绫汇�戜笉涓�鑷达紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        if (HPCSNo_Array.Contains(HPCSNo))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,銆怭CS鍙枫�戝瓨鍦ㄩ噸澶嶏紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            HPCSNo_Array.Add(HPCSNo);
+                        }
+
+
+                        //鏌ヨ鏂欏彿璧勬枡鏄惁宸茬粡瀛樺湪
+                        ds = oCN.RunProcReturn("select * from Gy_PNLInfo where HLayOutName = '" + HLayOutName + "' ", "Gy_PNLInfo");
+
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鏂欏彿銆�" + HLayOutName + "銆戣祫鏂欏凡缁忓瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        //鏌ヨ 鍒嗙被
+                        ds = oCN.RunProcReturn("select * from Gy_PNLInfoType where HName = '" + HPNLInfoTypeName + "' ", "Gy_PNLInfoType");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鍒嗙被銆�" + HPNLInfoTypeName + "銆戜笉瀛樺湪锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["HPNLInfoTypeID"] = ds.Tables[0].Rows[0]["HInterID"];
+                        }
+
+                        //鍒ゆ柇PCS鍙锋牸寮忔槸鍚︽纭�
+                        if (!Regex.IsMatch(HPCSNo, @"^\d{6}$"))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,PCS鍙枫��" + HPCSNo + "銆戞牸寮忛敊璇紝搴旇缃负鐢�6浣嶆暟瀛楃粍鎴愶紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else
+                        {
+                            tb2.Rows[i]["Set鍙�"] = HPCSNo.Substring(0, 2);
+                            tb2.Rows[i]["琛岀储寮�"] = int.Parse(HPCSNo.Substring(2, 2));
+                            tb2.Rows[i]["鍒楃储寮�"] = int.Parse(HPCSNo.Substring(4, 2));
+                        }
+                    }
+                }
+
+                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 PNL甯冨眬淇℃伅 瀵煎叆(淇濆瓨)
+        [Route("Gy_PNLInfo/Gy_PNLInfo_btnSave")]
+        [HttpPost]
+        public object Gy_PNLInfo_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
+            {
+                if (!DBUtility.ClsPub.Security_Log("Gy_PNLInfo_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);
+                }
+
+                oCN.BeginTran();
+                int i = 1;
+                foreach (Dictionary<string, string> item in list)
+                {
+                    string HInterID = "0";
+                    string HLayOutName = item["鏂欏彿"].ToString();                //鏂欏彿
+                    string HPNLInfoTypeID = item["HPNLInfoTypeID"].ToString();   //鍒嗙被ID
+                    string HPNLInfoTypeName = item["鍒嗙被"].ToString();           //鍒嗙被
+                    string HSetNo = item["Set鍙�"].ToString();                    //Set鍙�
+                    string HPCSNo = item["PCS鍙�"].ToString();                    //PCS鍙�
+                    string HPosition_x = item["琛岀储寮�"].ToString();              //琛岀储寮�
+                    string HPosition_y = item["鍒楃储寮�"].ToString();              //鍒楃储寮�
+
+                    //妫�鏌ユ暟鎹槸鍚﹀畬鏁�
+                    int index = i;
+
+                    if (i == 1)
+                    {
+                        //鏌ヨ鏂欏彿璧勬枡鏄惁宸茬粡瀛樺湪
+                        ds = oCN.RunProcReturn("select * from Gy_PNLInfo where HLayOutName = '" + HLayOutName + "' ", "Gy_PNLInfo");
+                        if (ds.Tables[0].Rows.Count > 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "绗�" + index + "琛�,鏂欏彿銆�+ " + HLayOutName + "銆戣祫鏂欏凡缁忓瓨鍦紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+
+                        string HIcon = "/img/鏅鸿兘鑺墖锛�.png";
+                        string HMaker = user;
+
+                        string sql_main = "insert into Gy_PNLInfo(HLayOutName,HIcon,HMaker,HMakeDate,HPNLInfoTypeID) " +
+                            "values(" +
+                            "'" + HLayOutName + "'" +
+                            ",'" + HIcon + "'" +
+                            ",'" + HMaker + "'" +
+                            ",getdate()" +
+                            "," + HPNLInfoTypeID + "" +
+                            ")";
+                        oCN.RunProc(sql_main);
+                    }
+
+                    string sql_getInterID = "select * from Gy_PNLInfo where HLayOutName = '" + HLayOutName + "'";
+                    ds = oCN.RunProcReturn(sql_getInterID, "Gy_PNLInfo");
+                    if (ds == null || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "PNL甯冨眬淇℃伅瀵煎叆澶辫触锛侊紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+                    else
+                    {
+                        HInterID = DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HInterID"]);
+                    }
+
+                    //鏌ヨ 鍒嗙被
+                    ds = oCN.RunProcReturn("select * from Gy_PNLInfoType where HName = '" + HPNLInfoTypeName + "' ", "Gy_PNLInfoType");
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绗�" + index + "琛�,鍒嗙被銆�+ " + HPNLInfoTypeName + "銆戜笉瀛樺湪锛�";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //鍒ゆ柇PCS鍙锋牸寮忔槸鍚︽纭�
+                    if (!Regex.IsMatch(HPCSNo, @"^\d{6}$"))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "绗�" + index + "琛�,PCS鍙枫��" + HPCSNo + "銆戞牸寮忛敊璇紝搴旇缃负鐢�6浣嶆暟瀛楃粍鎴愶紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    string sql_sub = "insert into Gy_PNLInfoSub(HInterID,HLayOutName,HSetNo,HPCSNo,HPosition_x,HPosition_y) " +
+                        "values(" +
+                        "" + HInterID + "" +
+                        ",'" + HLayOutName + "'" +
+                        ",'" + HSetNo + "'" +
+                        ",'" + HPCSNo + "'" +
+                        "," + HPosition_x + "" +
+                        "," + HPosition_y + "" +
+                        ")";
+                    oCN.RunProc(sql_sub);
+                    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
     }
 }

--
Gitblit v1.9.1