From 9b4915b7b3669ffe80774740bd06c547ece49494 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期一, 31 三月 2025 12:47:27 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/BaseSet/Gy_GroupController.cs | 1045 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 994 insertions(+), 51 deletions(-)

diff --git a/WebAPI/Controllers/BaseSet/Gy_GroupController.cs b/WebAPI/Controllers/BaseSet/Gy_GroupController.cs
index 12eeffb..952f761 100644
--- a/WebAPI/Controllers/BaseSet/Gy_GroupController.cs
+++ b/WebAPI/Controllers/BaseSet/Gy_GroupController.cs
@@ -1,11 +1,17 @@
-锘縰sing Newtonsoft.Json.Linq;
+锘縰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.Threading.Tasks;
+using System.Web;
 using System.Web.Http;
+using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�;
 using WebAPI.Models;
 namespace WebAPI.Controllers
 {
@@ -21,41 +27,65 @@
 
         /// <summary>
         /// 杩斿洖鐝粍鍒楄〃
-        ///鍙傛暟锛歴tring sql銆�
-        ///杩斿洖鍊硷細object銆�
         /// </summary>
         [Route("Gy_Group/list")]
         [HttpGet]
-        public object list(string sWhere)
+        public object list(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;
+                }
+
+                //鏍规嵁鐢ㄦ埛瀵瑰簲鐝粍鐨勫叧绯伙紝杩囨护鏉′欢涓鍔犲彧鏄剧ず瀵瑰簲鐨勭彮缁�
+                DataSet dsHitemID = oCN.RunProcReturn("exec h_p_Gy_GetSQLGroupByUser '" + user + "'", "h_p_Gy_GetSQLGroupByUser");
+                sWhere = sWhere + DBUtility.ClsPub.isStrNull(dsHitemID.Tables[0].Rows[0]["HBack"]);
+
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_GroupList " + sWhere, "h_v_GroupList");
+                    ds = oCN.RunProcReturn("select * from h_v_GroupList " + sWhere+ " order by 鐝粍浠g爜 ", "h_v_GroupList");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_GroupList where 1 = 1 ";
-                    string sql = sql1 + sWhere;
+                    string sql = sql1 + sWhere+ " order by 鐝粍浠g爜 ";
                     ds = oCN.RunProcReturn(sql, "h_v_GroupList");
                 }
-                if (ds == null || ds.Tables[0].Rows.Count == 0)
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
                 {
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "false锛�";
-                    objJsonResult.data = null;
-                    return objJsonResult;
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
                 }
-                else
-                {
-                    objJsonResult.code = "1";
-                    objJsonResult.count = 1;
-                    objJsonResult.Message = "Sucess锛�";
-                    objJsonResult.data = ds.Tables[0];
-                    return objJsonResult;
-                }
+
+
+                //if (ds.Tables[0].Rows.Count != 0 || ds != null)
+                //{
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                objJsonResult.list = columnNameList;
+                return objJsonResult;
+                //}
+                //else
+                //{
+                //objJsonResult.code = "0";
+                //objJsonResult.count = 0;
+                //objJsonResult.Message = "鏃犳暟鎹�";
+                //objJsonResult.data = null;
+                //return objJsonResult;
+                //}
             }
             catch (Exception e)
             {
@@ -146,10 +176,26 @@
             {
                 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();
+
+                //鍒ゆ柇鏉冮檺
+                if (!ClsPub.Security_Log(msg5, 1, false, msg4))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犱繚瀛樻潈闄�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 //鍙嶅簭鍒楀寲
-                msg1 = "[" + msg1.ToString() + "]";
+                msg2 = "[" + msg2.ToString() + "]";
                 DAL.ClsGy_Group_Ctl oDept = new DAL.ClsGy_Group_Ctl();
-                List<Gy_Group> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_Group>>(msg1);
+                List<Gy_Group> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_Group>>(msg2);
                 long HItemID = list[0].HItemID;
                 string HNumber = list[0].HNumber;
                 string HName = list[0].HName;
@@ -227,9 +273,18 @@
                 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();
+                string user = sArray[1].ToString();//鐢ㄦ埛鍚�
+
+                //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄�
+                if (!DBUtility.ClsPub.Security_Log("Gy_Group_Edit", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犵紪杈戞潈闄�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
                 //鍙嶅簭鍒楀寲
                 msg2 = "[" + msg2.ToString() + "]";
                 List<Gy_Group> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Gy_Group>>(msg2);
@@ -248,17 +303,26 @@
                 var HBarCodeForBase = list[0].HBarCodeForBase;
                 var HDeptID = list[0].HDeptID;
                 long HProcID = list[0].HProcID;
+                int HUSEORGID = list[0].HUSEORGID;
+                string HCompName = list[0].HCompName;
+                string HPayMentType = list[0].HPayMentType;
                 var HDeptNumber = "";
-                //var HEndFlag = 0;
                 long HLevel = 1;
-                //var HProcID = "";
+                string HMakeEmp = list[0].HMakeEmp;
+                string HCheckEmp = list[0].HCheckEmp;
+                string HCheckTime = list[0].HCheckTime;
+                string HModifyEmp = list[0].HModifyEmp;
+                string HModifyTime = list[0].HModifyTime;
+                string HStopEmp = list[0].HStopEmp;
+                string HStopTime = list[0].HStopTime;              
+                long HCREATEORGID = list[0].HCREATEORGID;
 
-                ////鍒ゆ柇鏉冮檺
-                //if (!ClsPub.Security_Log(msg5, 1, true, msg4))
+                //鍒ゆ柇鏉冮檺
+                //if (!ClsPub.Security_Log(msg5, 1, false, msg4))
                 //{
                 //    objJsonResult.code = "0";
                 //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "娌℃湁鎵惧埌璇ュ姛鑳芥ā鍧楋紒";
+                //    objJsonResult.Message = "鏃犱繚瀛樻潈闄�";
                 //    objJsonResult.data = null;
                 //    return objJsonResult;
                 //}
@@ -285,22 +349,101 @@
                 if (HItemID == 0)
                 {
                     oCN.BeginTran();
+
+                    //淇濆瓨鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_Group_BeforeSaveCtrl " + HMakeEmp + ",'" + 1 + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Group_BeforeSaveCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:淇濆瓨鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+
                     oCN.RunProc("Insert into Gy_Group " +
                     " (HNumber,HName,HHelpCode,HShortNumber,HParentID" +
-                    ",HEmpQty,HDeptID,HDeptNumber,HProcID" +
-                    ",HLevel,HEndFlag,HStopflag,HRemark,HBarCodeForBase) " +
-                    " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID.ToString() +
-                    "," + HEmpQty.ToString() + "," + HDeptID.ToString() + ",'" + HDeptNumber + "'," + HProcID.ToString() +
-                    "," + HLevel.ToString() + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "','" + HBarCodeForBase + "')", ref DBUtility.ClsPub.sExeReturnInfo);
+                    ",HEmpQty,HDeptID,HDeptNumber,HProcID,HUseFlag" +
+                    ",HLevel,HEndFlag,HStopflag,HRemark,HBarCodeForBase," +
+                    "HUSEORGID,HCREATEORGID,HCompName,HPayMentType,HMakeEmp,HMakeTime) " +
+                    " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "','" + HParentID.ToString() +
+                    "','" + HEmpQty.ToString() + "','" + HDeptID.ToString() + "','" + HDeptNumber + "','" + HProcID.ToString() + "','" + HUseFlag.ToString() +
+                    "','" + HLevel.ToString() + "'," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "','" + HBarCodeForBase + "'" +
+                    ",'" + HUSEORGID + "','" + HCREATEORGID + "','" + HCompName + "','" + HPayMentType + "','" + user + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo);
                     //淇敼涓婄骇涓洪潪鏈骇浠g爜
                     oCN.RunProc("Update Gy_Group set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
+
+
+                    //淇濆瓨鍚庢帶鍒�=========================================      
+                    string sql2 = "exec h_p_Gy_Group_AfterSaveCtrl " + HMakeEmp + ",'" + 1 + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Group_AfterSaveCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜锛氫繚瀛樺悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================    
+                  
                     oCN.Commit();
                 }
                 else
                 {
                     //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙�
                     oCN.BeginTran();
-                    oCN.RunProc("Update Gy_Group set " + 
+
+                    //淇濆瓨鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_Group_BeforeSaveCtrl " + HMakeEmp + ",'" + 2 + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Group_BeforeSaveCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:淇濆瓨鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+                    oCN.RunProc("Update Gy_Group set " +
                                  " HNumber='" + HNumber + "'" +
                                  ",HName='" + HName + "'" +
                                  ",HShortNumber='" + HShortNumber + "'" +
@@ -308,17 +451,50 @@
                                  ",HParentID=" + HParentID +
                                  ",HStopflag='" + HStopflag + "'" +
                                  ",HRemark= '" + HRemark + "'" +
+                                 ",HUseFlag= '" + HUseFlag + "'" +
+                                 ",HUSEORGID='" + HUSEORGID + "'" +
+                                 ",HCREATEORGID='" + HCREATEORGID + "'" +
+                                 ",HModifyEmp= '" + user + "'" +
+                                 ",HModifyTime= getdate()" +
                                  ",HDeptID=" + HDeptID +
                                  ",HEmpQty=" + HEmpQty +
-                                 ",HBarCodeForBase='" + HBarCodeForBase + "' " +
+                                 ",HCompName='" + HCompName + "'" +
+                                 ",HPayMentType='" + HPayMentType +
+                                 "',HBarCodeForBase='" + HBarCodeForBase + "' " +
                                  ", HProcID = '" + HProcID + "'  Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo);
                     oCN.RunProc("Update Gy_Group set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo);
+
+
+                    //淇濆瓨鍚庢帶鍒�=========================================      
+                    string sql2 = "exec h_p_Gy_Group_AfterSaveCtrl " + HMakeEmp + ",'" + 2 + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Group_AfterSaveCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜锛氫繚瀛樺悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================   
+
+                 
                     oCN.Commit();
                 }
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
-                //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
                 objJsonResult.data = 1;
                 return objJsonResult;
             }
@@ -332,6 +508,8 @@
                 return objJsonResult;
             }
         }
+
+        #region
         ///// <summary>
         ///// 淇敼鍗曟嵁-淇濆瓨鎸夐挳
         /////鍙傛暟锛歴tring sql銆�
@@ -365,7 +543,7 @@
         //        var HProcID = list[0].HProcID;
 
         //        //鍒ゆ柇鏉冮檺
-        //        //if (!ClsPub.Security_Log(msg5, 1, true, msg4))
+        //        //if (!ClsPub.Security_Log(msg5, 1, false, msg4))
         //        //{
         //        //    objJsonResult.code = "0";
         //        //    objJsonResult.count = 0;
@@ -426,28 +604,30 @@
         //        return objJsonResult;
         //    }
         //}
+        #endregion
+
+
         /// <summary>
         /// 鐝粍鍒犻櫎鍔熻兘
         /// </summary>
         /// <returns></returns>
-        [Route("DeltetGy_Group")]
+        [Route("Gy_Group/DeltetGy_Group")]
         [HttpGet]
-        public object DeltetGy_Group(string HItemID)
+        public object DeltetGy_Group(string HItemID,string user)
         {
             DataSet ds;
             DataSet ds1;
-            //string ModRightNameCheck = "Sc_ProcessReport_check";
             try
             {
                 //鍒犻櫎鏉冮檺
-                //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName))
-                //{
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
+                if (!DBUtility.ClsPub.Security_Log("Gy_Group_Delete", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
                 SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
                 if (string.IsNullOrWhiteSpace(HItemID))
@@ -465,6 +645,14 @@
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
                     objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒";
+                    objJsonResult.data = null;
+                    return objJsonResult; ;
+                }
+                else if (ds.Tables[0].Rows[0]["HCheckEmp"] != null && ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "宸茬粡瀹℃牳涓嶈兘鍒犻櫎锛�";
                     objJsonResult.data = null;
                     return objJsonResult; ;
                 }
@@ -498,7 +686,59 @@
                     return objJsonResult;
                 }
 
+                //鍒犻櫎鍓嶆帶鍒�=========================================      
+                string sql1 = "exec h_p_Gy_Group_BeforeDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql1, "h_p_Gy_Group_BeforeDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:鍒犻櫎鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+
                 oCN.RunProc("delete from Gy_Group  where HItemID=" + HItemID);
+
+
+                //鍒犻櫎鍚庢帶鍒�=========================================      
+                string sql2 = "exec h_p_Gy_Group_AfterDelCtrl " + HItemID + ",'" + user + "'";
+                ds = oCN.RunProcReturn(sql2, "h_p_Gy_Group_AfterDelCtrl");
+                if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜锛氬垹闄ゅ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+
+                if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "鍒犻櫎澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                    objJsonResult.data = null;
+                    oCN.RollBack();
+                    return objJsonResult;
+                }
+                //================================================================================== 
+
+              
                 oCN.Commit();//鎻愪氦浜嬪姟
                 objJsonResult.code = "0";
                 objJsonResult.count = 1;
@@ -516,6 +756,709 @@
                 return objJsonResult;
             }
         }
+
+        #region 鐢熶骇鐝粍瀹℃牳銆佸弽瀹℃牳
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_Group/AuditGy_Group")]
+        [HttpGet]
+        public object AuditGy_Group(int HInterID, int IsAudit, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Group_Check", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_Group where HItemID=" + HInterID, "Gy_Group");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸插鏍�!涓嶈兘鍐嶆瀹℃牳锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HCheckEmp"].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 (IsAudit == 0)  //瀹℃牳鍒ゆ柇
+                {
+                    //瀹℃牳鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_Group_BeforeCheckCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Group_BeforeCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+
+                    oCN.RunProc("update Gy_Group set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID);
+
+                    //瀹℃牳鍚庢帶鍒�=========================================      
+                    string sql2 = "exec h_p_Gy_Group_AfterCheckCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Group_AfterCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:瀹℃牳鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================
+                   
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "瀹℃牳鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsAudit == 1) //鍙嶅鏍稿垽鏂�
+                {
+                    //鍙嶅鏍稿墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_Gy_Group_BeforeUnCheckCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Group_BeforeCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+
+                    oCN.RunProc("update Gy_Group set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID);
+
+
+                    //鍙嶅鏍稿悗鎺у埗=========================================      
+                    string sql2 = "exec h_p_Gy_Group_AfterUnCheckCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Group_AfterCheckCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:鍙嶅鏍稿悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        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 鐢熶骇鐝粍绂佺敤銆佸弽绂佺敤
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="HInterID">鍗曟嵁ID</param>
+        /// <param name="IsStop">绂佺敤(0),鍙嶇鐢�(1)</param>
+        /// <param name="CurUserName">瀹℃牳浜�</param>
+        /// <returns></returns>
+        [Route("Gy_Group/StopGy_Group")]
+        [HttpGet]
+        public object StopGy_Group(int HInterID, int IsStop, string CurUserName)
+        {
+            try
+            {
+                //瀹℃牳鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Gy_Group_Stop", 1, false, CurUserName))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                var ds = oCN.RunProcReturn("select * from Gy_Group where HItemID=" + HInterID, "Gy_Group");
+                if (ds.Tables[0].Rows.Count > 0)
+                {
+                    if (IsStop == 0)  //绂佺敤鍒ゆ柇
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].ToString() != "")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁宸茬鐢�!涓嶈兘鍐嶆绂佺敤锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                    {
+                        if (ds.Tables[0].Rows[0]["HStopEmp"].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)  //绂佺敤鍒ゆ柇
+                {
+                    //绂佺敤鍓嶆帶鍒�=========================================      
+                    string sql1 = "exec h_p_Gy_Group_BeforeStopCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Group_BeforeStopCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "绂佺敤澶辫触!鍘熷洜:绂佺敤鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "绂佺敤澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+                    oCN.RunProc("update Gy_Group set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID);
+
+
+                    //绂佺敤鍚庢帶鍒�=========================================      
+                    string sql2 = "exec h_p_Gy_Group_AfterStopCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Group_AfterStopCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "绂佺敤澶辫触!鍘熷洜:绂佺敤鍚庡垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "绂佺敤澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //==================================================================================       
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "绂佺敤鎴愬姛";
+                    objJsonResult.data = null;
+                }
+                if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂�
+                {
+                    //鍙嶇鐢ㄥ墠鎺у埗=========================================      
+                    string sql1 = "exec h_p_Gy_Group_BeforeUnStopCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql1, "h_p_Gy_Group_BeforeUnStopCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶇鐢ㄥけ璐�!鍘熷洜:鍙嶇鐢ㄥ墠鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶇鐢ㄥけ璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+                    //================================================================================== 
+
+                    oCN.RunProc("update Gy_Group set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID);
+
+
+                    //鍙嶇鐢ㄥ悗鎺у埗=========================================      
+                    string sql2 = "exec h_p_Gy_Group_AfterUnStopCtrl " + HInterID + ",'" + CurUserName + "'";
+                    ds = oCN.RunProcReturn(sql2, "h_p_Gy_Group_AfterUnStopCtrl");
+                    if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶇鐢ㄥけ璐�!鍘熷洜:鍙嶇鐢ㄥ悗鍒ゆ柇澶辫触锛岃涓庣綉缁滅鐞嗕汉鍛樿仈绯�";
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        return objJsonResult;
+                    }
+
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 1;
+                        objJsonResult.Message = "鍙嶇鐢ㄥけ璐�!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString(); ;
+                        objJsonResult.data = null;
+                        oCN.RollBack();
+                        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 鐢熶骇鐝粍 鏂囦欢涓婁紶
+        [Route("Gy_Group/Gy_Group_Excel")]
+        [HttpPost]
+        public json Gy_Group_Excel()
+        {
+            json res = new json();
+            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 provisional = new DataTable("dt2");
+
+                //娣诲姞鍒楀悕
+                for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++)
+                {
+                    provisional.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString());
+                }
+
+                //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁
+                provisional.Columns.Add("HOrgID", typeof(Int32));//缁勭粐ID
+                provisional.Columns.Add("HDeptID", typeof(Int32));//閮ㄩ棬ID
+
+                //娣诲姞鏁版嵁
+                for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++)
+                {
+                    DataRow row = provisional.NewRow();
+                    for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++)
+                    {
+                        row[j] = ExcelDs.Tables[0].Rows[i][j].ToString();
+                    }
+                    provisional.Rows.Add(row);
+                }
+
+                //鍒ゆ柇鍒�
+                string error = JudgmentColumns(provisional);
+                if (error.Length > 0)
+                {
+                    res.code = "0";
+                    res.count = 0;
+                    res.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n";
+                    res.data = null;
+                    return res;
+                }
+
+                for (int i = 0; i <= provisional.Rows.Count - 1; i++)
+                {
+                    string HNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鐝粍浠g爜"].ToString());
+                    string HUSEORGID = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["缁勭粐浠g爜"].ToString());
+                    string HName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鐝粍"].ToString());
+                    string HORGName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["缁勭粐鍚嶇О"].ToString());
+                    string HDeptID = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["閮ㄩ棬浠g爜"].ToString());
+                    string HDeptNumber = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鎵�灞為儴闂�"].ToString());
+                    string HEmpQty = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鐝粍鎬讳汉鏁�"].ToString());
+                    string HHelpCode = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鍔╄鐮�"]);
+                    string HCompName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鍔冲姟鍗曚綅"]).ToString();
+                    string HProcID = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["宸ュ簭"].ToString());
+                    string HProcName = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["宸ュ簭鍚嶇О"].ToString());
+                    string HBarCode = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["鏉″舰鐮�"].ToString());
+                    string HRemark = DBUtility.ClsPub.isStrNull(provisional.Rows[i]["澶囨敞"].ToString());
+
+                    //鑾峰彇鐪熷疄琛屾暟
+                    int line = i + 1;
+
+                    if (HUSEORGID != "")
+                    {
+                        //鏌ヨ缁勭粐
+                        ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where  HNumber='" + HUSEORGID + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            res.code = "0";
+                            res.count = 0;
+                            res.Message = "绗�" + line + "琛�,缁勭粐涓嶅瓨鍦紒";
+                            res.data = null;
+                            return res;
+                        }
+                        else
+                        {
+                            provisional.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+                        string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString();
+
+                        if(String.IsNullOrEmpty(HProcID) || String.IsNullOrEmpty(HProcName))
+                        {
+                            res.code = "0";
+                            res.count = 0;
+                            res.Message = "绗�" + line + "琛�,宸ュ簭鍚嶇О涓嶈兘涓虹┖锛�";
+                            res.data = null;
+                            return res;
+                        }
+
+                        //閮ㄩ棬鏌ヨ
+                        //鏌ヨ閮ㄩ棬
+                        ds = oCN.RunProcReturn("select * from Gy_Department where  HNumber='" + HDeptID + "'  and HUSEORGID=" + HORGid + "", "Gy_Department");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            res.code = "0";
+                            res.count = 0;
+                            res.Message = "绗�" + line + "琛�,璇�" + HORGName + "缁勭粐,閮ㄩ棬:" + HDeptNumber + ",涓嶅瓨鍦紒";
+                            res.data = null;
+                        }
+                        else
+                        {
+                            provisional.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+
+                        //宸ュ簭鏌ヨ
+                        //鏌ヨ宸ュ簭鏄惁瀛樺湪
+                        ds = oCN.RunProcReturn("select * from Gy_Process where HNumber ='" + HProcID + "' and HUSEORGID=" + HORGid + "", "Gy_Process");
+
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            res.code = "0";
+                            res.count = 0;
+                            res.Message = "绗�" + line + "琛�,璇�" + HORGName + "缁勭粐,宸ュ簭:" + HProcName + ",涓嶅瓨鍦紒";
+                            res.data = null;
+                        }
+                        else
+                        {
+                            provisional.Rows[i]["HProcID"] = ds.Tables[0].Rows[0]["HItemID"].ToString();
+                        }
+
+                    }
+                    else
+                    {
+                        res.code = CodeConstant.FAIL;
+                        res.count = CountConstant.FAIL;
+                        res.Message = "绗�" + line + "琛�,缁勭粐浠g爜涓虹┖";
+                        res.data = null;
+                        return res;
+                    }
+                }
+
+                res.code = "1";
+                res.count = 1;
+                res.Message = error;
+                res.data = provisional;
+                return res;
+            }
+            catch (Exception e)
+            {
+                res.code = "0";
+                res.count = 0;
+                res.Message = "Exception锛�" + e.ToString();
+                res.data = null;
+                return res;
+            }
+        }
+
+        /// <summary>
+        /// 鍒ゆ柇鍒�
+        /// </summary>
+        /// <param name="provisional"></param>
+        /// <returns></returns>
+        private static string JudgmentColumns(DataTable provisional)
+        {
+            var error = "";
+
+            //鏌ヨ宸ヨ壓璺嚎娌℃湁鐨勫垪
+            if (!provisional.Columns.Contains("缁勭粐浠g爜"))
+                error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("鐝粍浠g爜"))
+                error += "娌℃湁鎵惧埌銆愮彮缁勪唬鐮併�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("鐝粍"))
+                error += "娌℃湁鎵惧埌銆愮彮缁勩�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("閮ㄩ棬浠g爜"))
+                error += "娌℃湁鎵惧埌銆愰儴闂ㄤ唬鐮併�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("鎵�灞為儴闂�"))
+                error += "娌℃湁鎵惧埌銆愭墍灞為儴闂ㄣ�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("鐝粍鎬讳汉鏁�"))
+                error += "娌℃湁鎵惧埌銆愮彮缁勬�讳汉鏁般�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("宸ュ簭"))
+                error += "娌℃湁鎵惧埌銆愬伐搴忋�戠殑鏍囬,";
+
+            if (!provisional.Columns.Contains("宸ュ簭"))
+                error += "娌℃湁鎵惧埌銆愬伐搴忋�戠殑鏍囬,";
+            
+            if (!provisional.Columns.Contains("鍔冲姟鍗曚綅"))
+                error += "娌℃湁鎵惧埌銆愬姵鍔″崟浣嶃�戠殑鏍囬,";
+            return error;
+        }
+        #endregion
+
+        #region 鐢熶骇鐝粍 瀵煎叆(淇濆瓨)
+        [Route("Gy_Group/Gy_Group_btnSave")]
+        [HttpPost]
+        public object Gy_Group_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_Group_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 HNumber = item["鐝粍浠g爜"].ToString();
+                    string HUSEORGID = item["缁勭粐浠g爜"].ToString();
+                    string HName = item["鐝粍"].ToString();
+                    string HORGName = item["缁勭粐鍚嶇О"].ToString();
+                    string HDeptID = item["閮ㄩ棬浠g爜"].ToString();
+                    string HDeptNumber = item["鎵�灞為儴闂�"].ToString();
+                    string HEmpQty = item["鐝粍鎬讳汉鏁�"].ToString();
+                    string HHelpCode = item["鍔╄鐮�"];
+                    string HCompName = item["鍔冲姟鍗曚綅"].ToString();
+                    string HProcID = item["宸ュ簭"].ToString();
+                    string HProcName = item["宸ュ簭鍚嶇О"].ToString();
+                    string HRemark = item["澶囨敞"].ToString();
+                    string HBarCodeForBase = item["鏉″舰鐮�"].ToString();
+                    
+                    string sShortNumber;
+                    sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮�
+                    if (sShortNumber.Trim() == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    int HEndFlag = 1;//鏈骇鏍囧織
+                    int HLevel = DBUtility.ClsPub.GetLevel(HNumber); //绛夌骇
+
+
+                    if (!DBUtility.ClsPub.AllowNumber(HNumber.Trim()))
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+
+                    ds = oCN.RunProcReturn("select * from Gy_Group where HNumber='" + HNumber + "'", "Gy_Group");
+
+                    if (ds.Tables[0].Rows.Count == 0)
+                    {
+
+                        string sql = "insert into Gy_Group(HName,HNumber,HDeptID,HUSEORGID,HCREATEORGID,HEmpQty,HShortNumber,HBarCodeForBase,HCompName,HProcID,HLevel,HHelpCode,HParentID,HStopflag,HRemark)" +
+                            $"values('{HName}', '{HNumber}',{HDeptID}, {HUSEORGID}, {HUSEORGID}, {HEmpQty}, '{sShortNumber}','{HBarCodeForBase}','{HCompName}',{HProcID},{HLevel},'',0,0,'{HRemark}')";
+                        oCN.RunProc(sql);
+                    }
+                    else
+                    {
+                        oCN.RunProc("update  Gy_Group set HBarCodeForBase='" + HBarCodeForBase + "',HDeptID=" + HDeptID + ",HName='" + HName + "', HHelpCode='" + HHelpCode + "'  where HNumber='" + HNumber + "'");
+                    }
+
+                    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
+
         /// <summary>
         /// 缁翠慨鍒楄〃淇敼鎸夐挳鏂规硶
         ///鍙傛暟锛歴tring sql銆�
@@ -558,7 +1501,7 @@
             DAL.ClsGy_Group_View oDeptHlp = new DAL.ClsGy_Group_View();
             try
             {
-                if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, true, User))
+                if (!DBUtility.ClsPub.Security_Log(ModRightNameDelete, 1, false, User))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;

--
Gitblit v1.9.1