From f02c7cbe27d7da079f057b464e2b179f1dc17b08 Mon Sep 17 00:00:00 2001 From: yxj <yxj@hz-kingdee.com> Date: 星期二, 18 三月 2025 09:26:16 +0800 Subject: [PATCH] 新增提料运算(根据欠料单进行计算)调用方法 --- WebAPI/Controllers/BaseSet/Gy_GroupController.cs | 729 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 712 insertions(+), 17 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Gy_GroupController.cs b/WebAPI/Controllers/BaseSet/Gy_GroupController.cs index f141bbc..154c737 100644 --- a/WebAPI/Controllers/BaseSet/Gy_GroupController.cs +++ b/WebAPI/Controllers/BaseSet/Gy_GroupController.cs @@ -1,12 +1,17 @@ 锘縰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 { @@ -22,8 +27,6 @@ /// <summary> /// 杩斿洖鐝粍鍒楄〃 - ///鍙傛暟锛歴tring sql銆� - ///杩斿洖鍊硷細object銆� /// </summary> [Route("Gy_Group/list")] [HttpGet] @@ -41,6 +44,11 @@ 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+ " order by 鐝粍浠g爜 ", "h_v_GroupList"); @@ -266,8 +274,6 @@ string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); string user = sArray[1].ToString();//鐢ㄦ埛鍚� - //string msg4 = sArray[2].ToString(); - //string msg5 = sArray[3].ToString(); //鍒ゆ柇鏄惁鏈夌紪杈戞潈闄� if (!DBUtility.ClsPub.Security_Log("Gy_Group_Edit", 1, false, user)) @@ -299,10 +305,17 @@ 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, false, msg4)) @@ -336,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,HUSEORGID,HCompName) " + - " 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 + "',"+ HUSEORGID + ",'" + HCompName + "')", 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 + "'" + @@ -359,18 +451,50 @@ ",HParentID=" + HParentID + ",HStopflag='" + HStopflag + "'" + ",HRemark= '" + HRemark + "'" + + ",HUseFlag= " + HUseFlag + + ",HUSEORGID='" + HUSEORGID + "'" + + ",HCREATEORGID='" + HCREATEORGID + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime= getdate()" + ",HDeptID=" + HDeptID + ",HEmpQty=" + HEmpQty + - ",HCompName='"+ HCompName+ + ",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; } @@ -384,6 +508,8 @@ return objJsonResult; } } + + #region ///// <summary> ///// 淇敼鍗曟嵁-淇濆瓨鎸夐挳 /////鍙傛暟锛歴tring sql銆� @@ -478,6 +604,9 @@ // return objJsonResult; // } //} + #endregion + + /// <summary> /// 鐝粍鍒犻櫎鍔熻兘 /// </summary> @@ -488,7 +617,6 @@ { DataSet ds; DataSet ds1; - string ModRightNameCheck = "Gy_Group_Delete"; try { //鍒犻櫎鏉冮檺 @@ -517,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; ; } @@ -550,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; @@ -568,8 +756,6 @@ return objJsonResult; } } - - #region 鐢熶骇鐝粍瀹℃牳銆佸弽瀹℃牳 /// <summary> @@ -634,7 +820,57 @@ 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; @@ -643,7 +879,58 @@ } 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; @@ -729,7 +1016,55 @@ 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; @@ -738,7 +1073,56 @@ } 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; @@ -761,8 +1145,319 @@ } #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> /// 缁翠慨鍒楄〃淇敼鎸夐挳鏂规硶 -- Gitblit v1.9.1