From ae4902061bc8e34f341d55b85f28acdf24d3b9dc Mon Sep 17 00:00:00 2001 From: chenhaozhe <cgz@hz-kingdee.com> Date: 星期四, 26 六月 2025 14:41:51 +0800 Subject: [PATCH] 合并分支 --- WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs | 377 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 359 insertions(+), 18 deletions(-) diff --git a/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs b/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs index 23b262c..b6db605 100644 --- a/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs +++ b/WebAPI/Controllers/SBGL/Gy_EquipTypeController.cs @@ -8,6 +8,11 @@ using System.Net.Http; using System.Web.Http; using WebAPI.Models; +using System.Web; +using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; +using System.IO; +using SyntacticSugar.constant; +using Newtonsoft.Json; namespace WebAPI.Controllers.SBGL { @@ -29,6 +34,7 @@ { try { + List<object> columnNameList = new List<object>(); //if (!DBUtility.ClsPub.Security_Log("Gy_EquipTypeList", 1, false, user)) //{ // objJsonResult.code = "0"; @@ -37,24 +43,23 @@ // objJsonResult.data = null; // return objJsonResult; //} - ds = oCN.RunProcReturn("select HItemID,HParentID,HNumber,HName,HLevel, case when HEndFlag<>0 then 'Y'else ' 'end HEndFlag,case when HStopFlag <> 0 then 'Y'else ' 'end HStopFlag, HRemark, HUseFlag from Gy_EquipFileType where 1=1 " + sWhere+ " order by HItemID ", "Gy_EquipFileType"); - //if (ds.Tables[0].Rows.Count != 0 || ds != null) - //{ + ds = oCN.RunProcReturn("select * from h_v_Gy_EquipFileTypeList where 1=1 " + sWhere+ " order by HItemID ", "h_v_Gy_EquipFileTypeList"); + + //娣诲姞鍒楀悕 + 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; - //} - //else - //{ - //objJsonResult.code = "0"; - //objJsonResult.count = 0; - //objJsonResult.Message = "鏃犳暟鎹�"; - //objJsonResult.data = null; - //return objJsonResult; - //} } catch (Exception ex) { @@ -94,8 +99,18 @@ return objJsonResult; } DLL.ClsGy_EquipTypeBill oBill = new DLL.ClsGy_EquipTypeBill(); - if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo)) + ds = oCN.RunProcReturn("select * from Gy_EquipFileType where HItemID=" + HItemID, "Gy_EquipFileType"); + if (ds.Tables[0].Rows.Count > 0) { + if (ds.Tables[0].Rows[0]["HCloseEmp"].ToString() != "" || ds.Tables[0].Rows[0]["HCheckEmp"].ToString() != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍗曟嵁褰撳墠澶勪簬涓嶈兘鍒犻櫎鐘舵�侊紒"; + objJsonResult.data = null; + return objJsonResult; + } + oCN.RunProc("Delete From Gy_EquipFileType where HItemID=" + lngBillKey); objJsonResult.code = "1"; objJsonResult.count = 1; @@ -131,7 +146,8 @@ string msg1 = _value.ToString(); string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); string msg2 = sArray[0].ToString(); - string msg4 = sArray[1].ToString(); + string msg4 = sArray[2].ToString(); + string HUseOrgID = sArray[3].ToString(); if (!DBUtility.ClsPub.Security_Log("Gy_EquipType_Edit", 1, false, msg4)) { @@ -156,6 +172,8 @@ bool HStopflag = list[0].HStopflag; string HUseFlag = list[0].HUseFlag; bool HEndFlag = list[0].HEndFlag; + long HUSEORGID = list[0].HUSEORGID; + long HCREATEORGID = list[0].HCREATEORGID; if (!DBUtility.ClsPub.AllowNumber(HNumber)) @@ -167,19 +185,38 @@ return objJsonResult; } - + //淇濆瓨鍓嶆帶鍒�========================================= + ds = oCN.RunProcReturn("Exec h_p_Gy_EquipType_BeforeSaveCtrl '" + HNumber.ToString() + "','" + HName + "'," + HUSEORGID + ",1,0", " h_p_Gy_EquipType_BeforeSaveCtrl "); + if (ds == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨鍓嶅垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙� oCN.BeginTran(); //涓昏〃 oCN.RunProc("Insert into Gy_EquipFileType " + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + - ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime) " + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HMakeEmp,HUSEORGID,HCREATEORGID) " + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + HShortNumber + "'," + HParentID + - "," + HLevel + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo); + "," + HLevel + "," + Convert.ToString(HEndFlag ? 1 : 0) + "," + Convert.ToString(HStopflag ? 1 : 0) + ",'" + HRemark + "',getdate(),'" + msg4 + "'," + HUSEORGID + "," + HCREATEORGID + ")", ref DBUtility.ClsPub.sExeReturnInfo); //淇敼涓婄骇涓洪潪鏈骇浠g爜 oCN.RunProc("Update Gy_EquipFileType set HEndflag=0 where HItemID=" + HParentID, ref DBUtility.ClsPub.sExeReturnInfo); oCN.Commit(); + objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "鏂板鎴愬姛锛�"; @@ -239,6 +276,7 @@ string HRemark = list[0].HRemark; bool HStopflag = list[0].HStopflag; string HUseFlag = list[0].HUseFlag; + long HUSEORGID = list[0].HUSEORGID; if (!DBUtility.ClsPub.AllowNumber(HNumber)) { @@ -259,6 +297,25 @@ return objJsonResult; } + //淇濆瓨鍓嶆帶鍒�========================================= + ds = oCN.RunProcReturn("Exec h_p_Gy_EquipType_BeforeSaveCtrl '" + HNumber.ToString() + "','" + HName + "'," + HUSEORGID + ",3," + HItemID, " h_p_Gy_EquipType_BeforeSaveCtrl "); + if (ds == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨鍓嶅垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙� oCN.BeginTran(); @@ -269,7 +326,10 @@ ",HShortNumber='" + HShortNumber + "'" + ",HHelpCode='" + HHelpCode + "'" + ",HParentID=" + HParentID + + ",HModifyTime=getdate()" + + ",HModifyEmp='" + msg4 + "'" + ",HStopflag='" + HStopflag + "'" + + ",HUSEORGID=" + HUSEORGID + ",HRemark= '" + HRemark + "' Where HItemID=" + HItemID, ref DBUtility.ClsPub.sExeReturnInfo); //淇敼瀛愰」鐩唬鐮� //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_RepairCheck,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo); @@ -302,7 +362,7 @@ { try { - ds = oCN.RunProcReturn("select * from Gy_EquipFileType where HItemID=" + HInterID, "Gy_EquipFileType"); + ds = oCN.RunProcReturn("select * from h_v_Gy_EquipFileTypeEdit with(nolock) where HItemID=" + HInterID, "h_v_Gy_EquipFileTypeEdit"); objJsonResult.code = "1"; objJsonResult.count = 1; @@ -346,6 +406,26 @@ objJsonResult.data = null; return objJsonResult; } + + //瀹℃牳鍓嶆帶鍒�========================================= + ds = oCN.RunProcReturn("Exec h_p_Gy_EquipType_BeforeAuditCtrl " + HInterID + ",'" + Type + "'", " h_p_Gy_EquipType_BeforeAuditCtrl "); + if (ds == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏍¢獙鍒ゆ柇澶辫触锛�"; + objJsonResult.data = null; + return objJsonResult; + } + if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= ClsPub.CurUserName = user; oCN.BeginTran();//寮�濮嬩簨鍔� @@ -567,5 +647,266 @@ } #endregion + #region 璁惧鍒嗙被 鏂囦欢瀵煎叆淇濆瓨 + #region 璁惧鍒嗙被 鏂囦欢涓婁紶 + [Route("Gy_EquipType/Gy_EquipType_Excel")] + [HttpPost] + public object Gy_EquipType_Excel() + { + try + { + //鑾峰彇鏂囦欢鍚嶇О + var file = HttpContext.Current.Request.Files[0]; + //鑾峰彇鏂囦欢鐗╃悊璺緞 + string ExcelPath = HttpContext.Current.Server.MapPath("~/" + file.FileName); + //淇濆瓨鏂囦欢 + file.SaveAs(ExcelPath); + + NpoiHelper np = new NpoiHelper(); + DataSet ExcelDs = np.ReadExcel(ExcelPath, 1, 1, "0"); + + //鍒犻櫎鏂囦欢 + File.Delete(ExcelPath); + + //鍒涘缓涓存椂琛� + DataTable tb2 = new DataTable("dt2"); + + //娣诲姞鍒楀悕 + for (int i = 0; i < ExcelDs.Tables[0].Columns.Count; i++) + { + tb2.Columns.Add(ExcelDs.Tables[0].Rows[0][i].ToString()); + } + + //妯℃澘缂哄皯鍒� 浣嗛渶瑕佷粠鏁版嵁搴撲腑鏌ヨ鍑烘潵鏄剧ず鍦ㄩ〉闈㈢殑瀛楁 + tb2.Columns.Add("HOrgID", typeof(Int32));//缁勭粐ID + + //娣诲姞鏁版嵁 + for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) + { + DataRow row = tb2.NewRow(); + for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) + { + row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); + } + tb2.Rows.Add(row); + } + + + var error = ""; + + //鏌ヨ娌℃湁鐨勫垪 + if (!tb2.Columns.Contains("缁勭粐浠g爜")) + error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("缁勭粐鍚嶇О")) + error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("璁惧鍒嗙被")) + error += "娌℃湁鎵惧埌銆愯澶囧垎绫诲悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("璁惧鍒嗙被浠g爜")) + error += "娌℃湁鎵惧埌銆愯澶囧垎绫讳唬鐮併�戠殑鏍囬,"; + if (!tb2.Columns.Contains("澶囨敞")) + error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,"; + if (!tb2.Columns.Contains("鍔╄鐮�")) + error += "娌℃湁鎵惧埌銆愬姪璁扮爜銆戠殑鏍囬,"; + + if (error.Length > 0) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n"; + objJsonResult.data = null; + return objJsonResult; + } + + for (int i = 0; i <= tb2.Rows.Count - 1; i++) + { + string HProcessName = ""; + string HProcessNum = ""; + string HORGNumber = ""; + string HORGName = ""; + + + HProcessName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁惧鍒嗙被"].ToString()); + HProcessNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁惧鍒嗙被浠g爜"].ToString()); + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString()); + HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString()); + + //妫�鏌ョ墿鏂� + int index = i + 1; + + if (HORGNumber != "") + { + + //鏌ヨ缁勭粐 + ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,缁勭粐涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); + + //璁惧鍒嗙被鍚嶇О + if (HProcessName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,璁惧鍒嗙被鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //璁惧鍒嗙被浠g爜 + if (HProcessNum == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,璁惧鍒嗙被浠g爜涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖"; + objJsonResult.data = null; + return objJsonResult; + } + } + + objJsonResult.code = CodeConstant.SUCCEED; + objJsonResult.count = CountConstant.SUCCEED; + objJsonResult.Message = error; + objJsonResult.data = tb2; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 璁惧鍒嗙被椤圭洰 瀵煎叆(淇濆瓨) + [Route("Gy_EquipType/Gy_EquipType_btnSave")] + [HttpPost] + public object Gy_EquipType_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_ErrType_Edit", 1, false, user)) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + 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 HOrgID = item["HOrgID"].ToString();//缁勭粐ID + string HName = item["璁惧鍒嗙被"].ToString(); + string HNumber = item["璁惧鍒嗙被浠g爜"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + string HHelpCode = item["鍔╄鐮�"].ToString(); + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(HNumber);//鐭唬鐮� + if (sShortNumber.Trim() == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + 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 = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_EquipFileType where HNumber='" + HNumber + "'", "Gy_EquipType"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into Gy_EquipFileType " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HMakeEmp) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "',getdate(),'" + user + "')"); + } + else + { + oCN.RunProc("update Gy_EquipFileType set HHelpCode='" + HHelpCode + "',HRemark='" + HRemark + "' where HNumber='" + HNumber + "'"); + } + + i++; + } + + oCN.Commit(); + + objJsonResult.code = CodeConstant.SUCCEED; + objJsonResult.count = CountConstant.SUCCEED; + objJsonResult.Message = "瀵煎叆鎴愬姛!"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + LogService.Write(e); + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + #endregion + } } -- Gitblit v1.9.1