From 9124a9b2e9f4a041da4509039c65a70cc81dd033 Mon Sep 17 00:00:00 2001 From: wtt <1985833171@qq.com> Date: 星期五, 16 五月 2025 15:49:58 +0800 Subject: [PATCH] 组织物料启动检查项目防错装置优化 --- WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs | 395 ++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 355 insertions(+), 40 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs b/WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs index 7b7181a..63a59f7 100644 --- a/WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs +++ b/WebAPI/Controllers/BaseSet/Xt_ORGANIZATIONSController.cs @@ -1,4 +1,5 @@ -锘縰sing Newtonsoft.Json.Linq; +锘縰sing Newtonsoft.Json; +using Newtonsoft.Json.Linq; using Pub_Class; using System; using System.Collections; @@ -25,26 +26,75 @@ /// </summary> [Route("Xt_ORGANIZATIONS/list")] [HttpGet] - public object list(string sWhere) + public object list(string sWhere,string user, string Organization) { try - { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_WorkCenter_Query", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + //string sql1 = string.Format(@"select * from h_v_IF_ORGANIZATIONSList where 缁勭粐鍚嶇О='" + Organization + "'"); + string sql1 = string.Format(@"select * from h_v_IF_ORGANIZATIONSList where 1=1 "); if (sWhere == null || sWhere.Equals("")) { - ds = oCN.RunProcReturn("select * from h_v_IF_ORGANIZATIONSList " + sWhere, "h_v_IF_ORGANIZATIONSList"); + ds = oCN.RunProcReturn(sql1 + sWhere + " order by 缁勭粐浠g爜 ", "h_v_IF_ORGANIZATIONSList"); } else { - string sql1 = "select * from h_v_IF_ORGANIZATIONSList where 1 = 1 "; - string sql = sql1 + sWhere; + string sql = sql1 + sWhere + " order by 缁勭粐浠g爜 "; ds = oCN.RunProcReturn(sql, "h_v_IF_ORGANIZATIONSList"); } + + //娣诲姞鍒楀悕 + 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; + } + } + + /// <summary> + /// 鏍规嵁鍩虹璧勬枡ID 鏌ユ壘璁板綍 + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_ORGANIZATIONS/cx")] + [HttpGet] + public object cx(long HInterID) + { + try + { + + ds = oCN.RunProcReturn("select * from h_v_IF_ORGANIZATIONSList where HitemID=" + HInterID, "h_v_IF_ORGANIZATIONSList"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�"; + objJsonResult.Message = "false锛�"; objJsonResult.data = null; return objJsonResult; } @@ -66,6 +116,8 @@ return objJsonResult; } } + + /// <summary> /// 鏂板鍗曟嵁-淇濆瓨鎸夐挳 ///鍙傛暟锛歴tring sql銆� @@ -86,12 +138,12 @@ long HItemID = list[0].HItemID; string HNumber = list[0].HNumber; string HName = list[0].HName; - + long HParentID = list[0].HParentID; - + string HRemark = list[0].HRemark; bool HStopflag = list[0].HStopflag; - + if (!DBUtility.ClsPub.AllowNumber(HNumber)) { objJsonResult.code = "0"; @@ -103,12 +155,12 @@ //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙� oCN.BeginTran(); //涓昏〃 - string sql = "Insert into Xt_ORGANIZATIONS " + - " (HNumber,HName,HParentID" + - ",HStopflag" + + string sql = "Insert into Xt_ORGANIZATIONS " + + " (HNumber,HName,HParentID" + + ",HStopflag,HMakeTime" + ",HRemark) " + " Values('" + HNumber + "','" + HName + "'," + HParentID.ToString() + - "," + HStopflag + + "," + HStopflag + "getdate()" + ",'" + HRemark + "')"; oCN.RunProc(sql, ref DBUtility.ClsPub.sExeReturnInfo); //淇敼涓婄骇涓洪潪鏈骇浠g爜 @@ -151,7 +203,9 @@ string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); - //string msg3 = sArray[1].ToString(); + string msg3 = sArray[1].ToString(); + string AddOrEdit = sArray[2].ToString(); //1鏂板3缂栬緫 + //int ItemID = Convert.ToInt32(sArray[2]); //string msg4 = sArray[2].ToString(); //string msg5 = sArray[3].ToString(); //鍙嶅簭鍒楀寲 @@ -161,21 +215,26 @@ long HItemID = list[0].HItemID; string HNumber = list[0].HNumber; string HName = list[0].HName; - + DateTime HMakeTime = list[0].HMakeTime; long HParentID = list[0].HParentID; string HRemark = list[0].HRemark; bool HStopflag = list[0].HStopflag; + int ChangeHStopflag = 0; - ////鍒ゆ柇鏉冮檺 - //if (!ClsPub.Security_Log(msg5, 1, true, msg4)) - //{ - // objJsonResult.code = "0"; - // objJsonResult.count = 0; - // objJsonResult.Message = "娌℃湁鎵惧埌璇ュ姛鑳芥ā鍧楋紒"; - // objJsonResult.data = null; - // return objJsonResult; - //} + if (HStopflag) + { + ChangeHStopflag = 1; + } + //鍒ゆ柇鏉冮檺 + if (!ClsPub.Security_Log("Gy_WorkCenter_Edit", 1, false, msg3)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁鎵惧埌璇ュ姛鑳芥ā鍧楋紒"; + objJsonResult.data = null; + return objJsonResult; + } //if (!DBUtility.ClsPub.AllowNumber(HNumber)) //{ @@ -194,32 +253,68 @@ // objJsonResult.data = null; // return objJsonResult; //} + //鏌ヨ鏁版嵁涓槸鍚﹀瓨鍦ㄩ噸澶嶄唬鐮� + ds = oCN.RunProcReturn("Select HItemID from Xt_ORGANIZATIONS Where HItemID<>" + HItemID + " and HNumber='" + HNumber.Trim()+"'", "Xt_ORGANIZATIONS"); + + if (ds.Tables[0].Rows.Count > 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒"; + objJsonResult.data = 1; + return objJsonResult; + } //淇濆瓨 //淇濆瓨瀹屾瘯鍚庡鐞� - if (HItemID == 0) + if (AddOrEdit == "1") { oCN.BeginTran(); oCN.RunProc("Insert into Xt_ORGANIZATIONS " + " (HNumber,HName,HParentID" + - ",HStopflag" + - ",HRemark) " + - " Values('" + HNumber + "','" + HName + "'," + HParentID.ToString() + - "," + HStopflag + - ",'" + HRemark + "')", ref DBUtility.ClsPub.sExeReturnInfo); + ",HStopflag,HMakeTime,HItemID" + + ",HRemark,HMakeEmp) " + + " Values('" + HNumber + "','" + HName + "','" + HParentID.ToString() + + "','" + ChangeHStopflag + "'," + "getdate()" + ",'" + HItemID + "'" + + ",'" + HRemark + "','"+ msg3 + "')", ref DBUtility.ClsPub.sExeReturnInfo); //淇敼涓婄骇涓洪潪鏈骇浠g爜 oCN.RunProc("Update Xt_ORGANIZATIONS set HStopflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); oCN.Commit(); } - else + else if(AddOrEdit == "3") { + //宸插鏍镐笉鍏佽淇敼 + DataSet dss; + dss = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HItemID=" + HItemID, "Xt_ORGANIZATIONS"); + //鍒ゆ柇鏄惁鍙紪杈� + if (dss.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") + { + + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "姝ゅ崟鎹姸鎬佸凡缁忓鏍革紝涓嶅厑璁镐慨鏀癸紒"; + objJsonResult.data = null; + return objJsonResult; + } + int Stopflag; + if (HStopflag) + { + Stopflag = 1; + } + else + { + Stopflag = 0; + } //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙� oCN.BeginTran(); oCN.RunProc("Update Xt_ORGANIZATIONS set " + " HNumber='" + HNumber + "'" + ",HName='" + HName + "'" + - ",HParentID=" + HParentID + - ",HStopflag='" + HStopflag + "'" + + ",HParentID='" + HParentID + "'" + + //",HMakeTime='" + HMakeTime + "'" + + ",HModifyEmp='" + msg3 + "'" + + ",HModifyTime=getdate()" + + ",HStopflag='" + Stopflag + "'" + ",HRemark= '" + HRemark + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo); oCN.RunProc("Update Xt_ORGANIZATIONS set HStopflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); oCN.Commit(); @@ -233,7 +328,7 @@ } catch (Exception e) { - oCN.RollBack(); + //oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception锛�" + e.Message; @@ -242,11 +337,42 @@ } } /// <summary> - /// 鑱屽憳璁剧疆鍒犻櫎鍔熻兘 + /// 鑾峰彇鏈�澶ItemID + ///鍙傛暟锛歴tring sql銆� + ///杩斿洖鍊硷細object銆� + /// </summary> + [Route("Xt_ORGANIZATIONS/GetMaxHItemID")] + [HttpGet] + public object GetMaxHItemID() + { + try + { + + ds = oCN.RunProcReturn("select MAX(HItemID) from Xt_ORGANIZATIONS ", "Xt_ORGANIZATIONS"); + + + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Sucess锛�"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + /// <summary> + /// 缁勭粐璁剧疆鍒犻櫎鍔熻兘 /// </summary> /// <returns></returns> [Route("DeltetXt_ORGANIZATIONSList")] - + [HttpGet] public object DeltetXt_ORGANIZATIONSList(string HItemID) { @@ -255,7 +381,7 @@ try { //鍒犻櫎鏉冮檺 - //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, true, CurUserName)) + //if (!DBUtility.ClsPub.Security_Log(ModRightNameCheck, 1, false, CurUserName)) //{ // objJsonResult.code = "0"; // objJsonResult.count = 0; @@ -274,7 +400,7 @@ return objJsonResult; } oCN.BeginTran();//寮�濮嬩簨鍔� - ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONSList where HItemID=" + HItemID, "Xt_ORGANIZATIONSList"); + ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HItemID=" + HItemID, "Xt_ORGANIZATIONS"); if (ds == null || ds.Tables[0].Rows.Count == 0) { objJsonResult.code = "0"; @@ -294,7 +420,7 @@ return objJsonResult; } - oCN.RunProc("update Xt_ORGANIZATIONSList set HStopflag=1 where HItemID=" + HItemID); + oCN.RunProc("delete from Xt_ORGANIZATIONS where HItemID=" + HItemID); oCN.Commit();//鎻愪氦浜嬪姟 objJsonResult.code = "0"; objJsonResult.count = 1; @@ -313,6 +439,195 @@ } } + #region 缁勭粐瀹℃牳銆佸弽瀹℃牳 + /// <summary> + /// + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Xt_ORGANIZATIONS/AuditXt_ORGANIZATIONS")] + [HttpGet] + public object AuditXt_ORGANIZATIONS(int HInterID, int IsAudit, string CurUserName) + { + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Xt_ORGANIZATIONS_Check", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + var ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HItemID=" + HInterID, "Xt_ORGANIZATIONS"); + 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) //瀹℃牳鍒ゆ柇 + { + oCN.RunProc("update Xt_ORGANIZATIONS set HCheckEmp='" + CurUserName + "',HCheckTime=getdate() where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀹℃牳鎴愬姛"; + objJsonResult.data = null; + } + if (IsAudit == 1) //鍙嶅鏍稿垽鏂� + { + oCN.RunProc("update Xt_ORGANIZATIONS set HCheckEmp='',HCheckTime=null where HItemID=" + HInterID); + + 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("Xt_ORGANIZATIONS/StopXt_ORGANIZATIONS")] + [HttpGet] + public object StopXt_ORGANIZATIONS(int HInterID, int IsStop, string CurUserName) + { + try + { + //瀹℃牳鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Xt_ORGANIZATIONS_Stop", 1, false, CurUserName)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绂佺敤澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + var ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HItemID=" + HInterID, "Xt_ORGANIZATIONS"); + 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) //绂佺敤鍒ゆ柇 + { + oCN.RunProc("update Xt_ORGANIZATIONS set HStopEmp='" + CurUserName + "',HStopTime=getdate(),HStopflag=1 where HItemID=" + HInterID); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "绂佺敤鎴愬姛"; + objJsonResult.data = null; + } + if (IsStop == 1) //鍙嶇鐢ㄥ垽鏂� + { + oCN.RunProc("update Xt_ORGANIZATIONS set HStopEmp='',HStopTime=null,HStopflag=0 where HItemID=" + HInterID); + + 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 // } -- Gitblit v1.9.1