From f34c6a21dc58bc0d40a011d6d7366c5eb3f15f15 Mon Sep 17 00:00:00 2001 From: yxj <yxj@hz-kingdee.com> Date: 星期五, 20 九月 2024 13:59:34 +0800 Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API --- WebAPI/Controllers/WebAPIController.cs | 519 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 518 insertions(+), 1 deletions(-) diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs index a36f008..54ea8f1 100644 --- a/WebAPI/Controllers/WebAPIController.cs +++ b/WebAPI/Controllers/WebAPIController.cs @@ -18,6 +18,10 @@ using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; using WebAPI.Models; using WebAPI.Service; +using System.Web; +using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; +using System.IO; +using SyntacticSugar.constant; namespace WebAPI.Controllers { @@ -3094,6 +3098,263 @@ return objJsonResult; } } + #endregion + + #region 寮傚父绫诲瀷 鏂囦欢瀵煎叆淇濆瓨 + #region 寮傚父绫诲瀷 鏂囦欢涓婁紶 + [Route("Gy_ErrType/Gy_ErrType_Excel")] + [HttpPost] + public object Gy_ErrType_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 (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_ErrType/Gy_ErrType_btnSave")] + [HttpPost] + public object Gy_ErrType_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 HProcessName = item["寮傚父绫诲瀷"].ToString(); + string HProcessNum = item["寮傚父绫诲瀷浠g爜"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//鐭唬鐮� + 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(HProcessNum); //绛夌骇 + + + if (!DBUtility.ClsPub.AllowNumber(HProcessNum.Trim())) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_ErrType where HNumber='" + HProcessNum + "'", "Gy_ErrType"); + + if (ds.Tables[0].Rows.Count == 0) + { + + oCN.RunProc("Insert into " + "Gy_ErrType" + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HBarCode,HUSEORGID,HCREATEORGID,HUseFlag) " + + " Values('" + HProcessNum + "','" + HProcessName + "','" + "','" + sShortNumber + "'," + 0 + + "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + "'," + HOrgID + "," + HOrgID + ",'" + "鏈娴�" + "')"); + } + else + { + oCN.RunProc("update Gy_ErrType set HUSEORGID=" + HOrgID + ",HRemark='" + HRemark + "' where HNumber='" + HProcessNum + "'"); + } + + 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 /// <summary> @@ -9170,6 +9431,262 @@ } #endregion + #region 寮傚父鍙嶉绫诲瀷 鏂囦欢瀵煎叆淇濆瓨 + #region 寮傚父鍙嶉绫诲瀷 鏂囦欢涓婁紶 + [Route("Gy_ErrMsgBackType/Gy_ErrMsgBackType_Excel")] + [HttpPost] + public object Gy_ErrMsgBackType_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 (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_ErrMsgBackType/Gy_ErrMsgBackType_btnSave")] + [HttpPost] + public object Gy_ErrMsgBackType_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 HProcessName = item["寮傚父鍙嶉绫诲瀷"].ToString(); + string HProcessNum = item["寮傚父鍙嶉绫诲瀷浠g爜"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(HProcessNum);//鐭唬鐮� + 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(HProcessNum); //绛夌骇 + + + if (!DBUtility.ClsPub.AllowNumber(HProcessNum.Trim())) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_ErrMsgBackType where HNumber='" + HProcessNum + "'", "Gy_ErrMsgBackType"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into " + "Gy_ErrMsgBackType " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + + " Values('" + HProcessNum + "','" + HProcessName + "','" + "','" + sShortNumber + "'," + 0 + + "," + HLevel + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + HOrgID + "')"); + } + else + { + oCN.RunProc("update Gy_ErrMsgBackType set HUSEORGID=" + HOrgID + ",HRemark='" + HRemark + "' where HNumber='" + HProcessNum + "'"); + } + + 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 + #region 涓嶈壇鐜拌薄 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 /// <summary> /// 涓嶈壇鐜拌薄 淇濆瓨 @@ -13177,7 +13694,7 @@ { objjson.code = "0"; objjson.count = 1; - objjson.Message = "璇ヨ澶囨湁澶氫釜璁″垝鍗�,鎵嬪姩閫夌潃" ; + objjson.Message = "璇ヨ澶囨湁澶氫釜璁″垝鍗曟垨鐐规瑙勭▼,鎵嬪姩閫夌潃" ; objjson.data = null; return objjson; } -- Gitblit v1.9.1