From c34e85eda515636993b37a752b52c0f43ae6e17b Mon Sep 17 00:00:00 2001 From: yusijie <ysj@hz-kingdee.com> Date: 星期四, 09 一月 2025 09:17:18 +0800 Subject: [PATCH] Merge branch 'master' of http://101.37.171.70:10101/r/MES-WEB-API --- WebAPI/Controllers/WebAPIController.cs | 1794 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1,791 insertions(+), 3 deletions(-) diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs index c49d34c..0674f47 100644 --- a/WebAPI/Controllers/WebAPIController.cs +++ b/WebAPI/Controllers/WebAPIController.cs @@ -18,9 +18,6 @@ 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 @@ -2778,6 +2775,342 @@ } } + #region 涓嶈壇鍘熷洜 鏂囦欢瀵煎叆淇濆瓨 + #region 涓嶈壇鍘熷洜 鏂囦欢涓婁紶 + [Route("Gy_BadReason/Gy_BadReason_Excel")] + [HttpPost] + public object Gy_BadReason_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 + tb2.Columns.Add("HDeptID", typeof(Int32));//閮ㄩ棬ID + tb2.Columns.Add("HProcID", 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("涓嶈壇鍘熷洜浠g爜")) + error += "娌℃湁鎵惧埌銆愪笉鑹師鍥犱唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("涓嶈壇鍘熷洜")) + error += "娌℃湁鎵惧埌銆愪笉鑹師鍥犮�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("榛樿閮ㄩ棬浠g爜")) + error += "娌℃湁鎵惧埌銆愰粯璁ら儴闂ㄤ唬鐮併�戠殑鏍囬,"; + if (!tb2.Columns.Contains("榛樿閮ㄩ棬")) + error += "娌℃湁鎵惧埌銆愰粯璁ら儴闂ㄣ�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("榛樿宸ュ簭浠g爜")) + error += "娌℃湁鎵惧埌銆愰粯璁ゅ伐搴忎唬鐮併�戠殑鏍囬,"; + if (!tb2.Columns.Contains("榛樿宸ュ簭")) + 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 HName = ""; + string HNum = ""; + string HORGNumber = ""; + string HORGName = ""; + string HDeptNumber = ""; + string HDeptName = ""; + string HProcNumber = ""; + string HProcName = ""; + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇鍘熷洜"].ToString()); + HNum = 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()); + HDeptNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿閮ㄩ棬浠g爜"].ToString()); + HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿閮ㄩ棬"].ToString()); + HProcNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿宸ュ簭浠g爜"].ToString()); + HProcName = 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(); + } + if (HDeptNumber != "") + { + //鏌ヨ閮ㄩ棬 + ds = oCN.RunProcReturn("select * from Gy_Department where HNumber='" + HDeptNumber + "' and Hname='" + HDeptName + "'", "Gy_Department"); + + 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]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + } + else + { + tb2.Rows[i]["HDeptID"] = 0; + } + if (HProcNumber != "") + { + //鏌ヨ閮ㄩ棬 + ds = oCN.RunProcReturn("select * from Gy_Process where HNumber='" + HProcNumber + "' and Hname='" + HProcName + "'", "Gy_Process"); + + 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]["HProcID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + } + else + { + tb2.Rows[i]["HProcID"] = 0; + } + + //涓嶈壇鍘熷洜鍚嶇О + if (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇鍘熷洜鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //涓嶈壇鍘熷洜浠g爜 + if (HNum == "") + { + 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_BadReason/Gy_BadReason_btnSave")] + [HttpPost] + public object Gy_BadReason_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_BadReason_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 HDeptID = item["HDeptID"].ToString();//閮ㄩ棬ID + string HProcID = item["HProcID"].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_BadReason where HNumber='" + HNumber + "'", "Gy_BadReason"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into " + "Gy_BadReason " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HDeptID,HProcID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HBadTypeID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HDeptID.ToString() + "," + HProcID.ToString() + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "'," + 0 + ")", ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + oCN.RunProc("Update Gy_BadReason"+ " set " + + "HName='" + HName + "'" + + ",HShortNumber='" + sShortNumber + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HLevel=" + HLevel.ToString() + + ",HDeptID=" + HDeptID.ToString() + + ",HProcID=" + HProcID.ToString() + + ",HRemark= '" + HRemark + "' Where HNumber='" + HNumber + "'", ref DBUtility.ClsPub.sExeReturnInfo); + } + + 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> /// 淇濆瓨涓嶈壇绫诲瀷 @@ -2981,6 +3314,312 @@ return objJsonResult; } } + + #region 涓嶈壇绫诲瀷 鏂囦欢瀵煎叆淇濆瓨 + #region 涓嶈壇绫诲瀷 鏂囦欢涓婁紶 + [Route("Gy_BadType/Gy_BadType_Excel")] + [HttpPost] + public object Gy_BadType_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 + tb2.Columns.Add("HGroupID", 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("涓嶈壇绫诲瀷浠g爜")) + error += "娌℃湁鎵惧埌銆愪笉鑹被鍨嬩唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("涓嶈壇绫诲瀷")) + error += "娌℃湁鎵惧埌銆愪笉鑹被鍨嬨�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("榛樿鐝粍浠g爜")) + error += "娌℃湁鎵惧埌銆愰粯璁ょ彮缁勪唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("榛樿鐝粍鍚嶇О")) + 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 HName = ""; + string HNum = ""; + string HORGNumber = ""; + string HORGName = ""; + string HGroupNumber = ""; + string HGroupName = ""; + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇绫诲瀷"].ToString()); + HNum = 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()); + HGroupNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿鐝粍浠g爜"].ToString()); + HGroupName = 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(); + } + if(HGroupNumber != "") + { + //鏌ヨ鐝粍 + ds = oCN.RunProcReturn("select * from Gy_Group where HNumber='" + HGroupNumber + "' and Hname='" + HGroupName + "'", "Gy_Group"); + + 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]["HGroupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + } + else + { + tb2.Rows[i]["HGroupID"] = 0; + } + + + //涓嶈壇绫诲瀷鍚嶇О + if (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇绫诲瀷鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //涓嶈壇绫诲瀷浠g爜 + if (HNum == "") + { + 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_BadType/Gy_BadType_btnSave")] + [HttpPost] + public object Gy_BadType_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_BadType_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 HGroupID = item["HGroupID"].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_BadType where HNumber='" + HNumber + "'", "Gy_BadType"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into Gy_BadType" + " " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HGroupID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HUSEORGID,HCREATEORGID,HUseFlag,HMakeEmp,HMakeTime) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HGroupID.ToString() + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "'," + HOrgID + "," + HOrgID + ",'" + "鏈娴�" + "','" + user + "',getdate())", ref DBUtility.ClsPub.sExeReturnInfo); + + } + else + { + oCN.RunProc("Update " + "Gy_BadType " + " set " + + "HName='" + HName + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HGroupID= '" + HGroupID + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " 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 /// <summary> @@ -4081,6 +4720,277 @@ return objJsonResult; } } + + #region 涓嶈壇鍚庢灉 鏂囦欢瀵煎叆淇濆瓨 + #region 涓嶈壇鍚庢灉 鏂囦欢涓婁紶 + [Route("Gy_BadResult/Gy_BadResult_Excel")] + [HttpPost] + public object Gy_BadResult_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("涓嶈壇鍚庢灉浠g爜")) + error += "娌℃湁鎵惧埌銆愪笉鑹悗鏋滀唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("涓嶈壇鍚庢灉")) + 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 HName = ""; + string HNum = ""; + string HORGNumber = ""; + string HORGName = ""; + + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇鍚庢灉"].ToString()); + HNum = 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(); + } + + //涓嶈壇鍚庢灉鍚嶇О + if (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇鍚庢灉鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //涓嶈壇鍚庢灉浠g爜 + if (HNum == "") + { + 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_BadResult/Gy_BadResult_btnSave")] + [HttpPost] + public object Gy_BadResult_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_BadResult_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_BadResult where HNumber='" + HNumber + "'", "Gy_BadResult"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into Gy_BadResult" + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HISsystemSet,HCREATEORGID,HERPItemID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + 0 + "','" + HOrgID + "','" + 0 + "')", ref DBUtility.ClsPub.sExeReturnInfo); + + } + else + { + oCN.RunProc("Update " + "Gy_BadResult " + " set " + + "HName='" + HName + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " 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 + #endregion @@ -9009,6 +9919,278 @@ return objJsonResult; } } + + #region 渚涘簲鍟嗗垎绫� 鏂囦欢瀵煎叆淇濆瓨 + #region 渚涘簲鍟嗗垎绫� 鏂囦欢涓婁紶 + [Route("Gy_SupType/Gy_SupType_Excel")] + [HttpPost] + public object Gy_SupType_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 += "娌℃湁鎵惧埌銆愪緵搴斿晢鍒嗙被浠g爜銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("渚涘簲鍟嗗垎绫�")) + 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 HName = ""; + string HNum = ""; + string HORGNumber = ""; + string HORGName = ""; + + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗗垎绫�"].ToString()); + HNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗗垎绫讳唬鐮�"].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(); + } + + //渚涘簲鍟嗗垎绫诲悕绉� + if (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,渚涘簲鍟嗗垎绫诲悕绉颁笉鑳戒负绌猴紒"; + objJsonResult.data = null; + return objJsonResult; + } + + //渚涘簲鍟嗗垎绫讳唬鐮� + if (HNum == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,渚涘簲鍟嗗垎绫讳唬鐮佷笉鑳戒负绌猴紒"; + 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_SupType/Gy_SupType_btnSave")] + [HttpPost] + public object Gy_SupType_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_SupType_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["渚涘簲鍟嗗垎绫讳唬鐮�"].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_SupType where HNumber='" + HNumber + "'", "Gy_SupType"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into " + "Gy_SupType " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + oCN.RunProc("Update " + "Gy_SupType " + " set " + + "HName='" + HName + "'" + + ",HShortNumber='" + sShortNumber + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " 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 + + #endregion #region 宸ヨ壓鍙傛暟鍒嗙被 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 @@ -9571,6 +10753,278 @@ return objJsonResult; } } + + + #region 瀹㈡埛鍒嗙被 鏂囦欢瀵煎叆淇濆瓨 + #region 瀹㈡埛鍒嗙被 鏂囦欢涓婁紶 + [Route("Gy_CusType/Gy_CusType_Excel")] + [HttpPost] + public object Gy_CusType_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("瀹㈡埛鍒嗙被浠g爜")) + error += "娌℃湁鎵惧埌銆愬鎴峰垎绫讳唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("瀹㈡埛鍒嗙被")) + 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 HName = ""; + string HNum = ""; + string HORGNumber = ""; + string HORGName = ""; + + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀹㈡埛鍒嗙被"].ToString()); + HNum = 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(); + } + + //瀹㈡埛鍒嗙被鍚嶇О + if (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,瀹㈡埛鍒嗙被鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //瀹㈡埛鍒嗙被浠g爜 + if (HNum == "") + { + 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_CusType/Gy_CusType_btnSave")] + [HttpPost] + public object Gy_CusType_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_CusType_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_CusType where HNumber='" + HNumber + "'", "Gy_CusType"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into " + " Gy_CusType" + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); + } + else + { + oCN.RunProc("Update " + "Gy_CusType " + " set " + + "HName='" + HName + "'" + + ",HShortNumber='" + sShortNumber + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " 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 + #endregion #region 鐩樼偣鏂规 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 @@ -11010,6 +12464,279 @@ return objJsonResult; } } + + #region 涓嶈壇鐜拌薄 鏂囦欢瀵煎叆淇濆瓨 + #region 涓嶈壇鐜拌薄 鏂囦欢涓婁紶 + [Route("Gy_BadPhenomena/Gy_BadPhenomena_Excel")] + [HttpPost] + public object Gy_BadPhenomena_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("涓嶈壇鐜拌薄浠g爜")) + error += "娌℃湁鎵惧埌銆愪笉鑹幇璞′唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("涓嶈壇鐜拌薄")) + 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 HName = ""; + string HNum = ""; + string HORGNumber = ""; + string HORGName = ""; + + + HName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["涓嶈壇鐜拌薄"].ToString()); + HNum = 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(); + } + + //涓嶈壇鐜拌薄鍚嶇О + if (HName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,涓嶈壇鐜拌薄鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //涓嶈壇鐜拌薄浠g爜 + if (HNum == "") + { + 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_BadPhenomena/Gy_BadPhenomena_btnSave")] + [HttpPost] + public object Gy_BadPhenomena_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_BadPhenomena_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_BadPhenomena where HNumber='" + HNumber + "'", "Gy_BadPhenomena"); + + if (ds.Tables[0].Rows.Count == 0) + { + oCN.RunProc("Insert into " + "Gy_BadPhenomena " + + " (HNumber,HName,HHelpCode,HShortNumber,HParentID" + + ",HLevel,HEndFlag,HStopflag,HRemark,HMakeTime,HUSEORGID,HUseFlag,HMakeEmp,HCREATEORGID) " + + " Values('" + HNumber + "','" + HName + "','" + HHelpCode + "','" + sShortNumber + "'," + 0 + + "," + HLevel.ToString() + "," + HEndFlag + "," + 0 + ",'" + HRemark + "','" + DateTime.Now + "','" + HOrgID + "','" + "鏈娴�" + "','" + user + "','" + HOrgID + "')", ref DBUtility.ClsPub.sExeReturnInfo); + + } + else + { + oCN.RunProc("Update " + "Gy_BadPhenomena " + " set " + + "HName='" + HName + "'" + + ",HShortNumber='" + sShortNumber + "'" + + ",HHelpCode='" + HHelpCode + "'" + + ",HRemark= '" + HRemark + "'" + + ",HModifyEmp= '" + user + "'" + + ",HModifyTime=getdate()" + + ",HUSEORGID=" + HOrgID + + " 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 + + #endregion #region 椤圭洰绫诲埆 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 @@ -17212,6 +18939,67 @@ } } + + /// <summary> + /// 閲戝竻WMS鎺ュ彛 + /// </summary> + /// <returns></returns> + [Route("Web/WMSBarcodeQuery")] + [HttpGet] + public object WMSBarcodeQuery(DateTime dateTime, string UserName, string PassWord) + { + try + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + //鏉冮檺鍒ゅ畾 + DAL.ClsUser oUser = new DAL.ClsUser(); + DataSet DS; + DS = oCN.RunProcReturn("select * from Gy_Czygl where Czymc='" + UserName.Trim() + "' and Czmm='" + DBUtility.ClsPub.StrToPsd(PassWord.Trim()) + "' ", "Gy_Czygl"); + if (UserName == "" || UserName != "鍞悗鏉$爜鏌ヨ") + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鐢ㄦ埛涓嶅锛�"; + objjson.data = null; + return objjson; + } + if (DS == null || DS.Tables[0].Rows.Count == 0) + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "瀵嗙爜閿欒锛�"; + objjson.data = null; + return objjson; + } + ds = oCN.RunProcReturn("exec h_p_WMSBarcodeQuery '" + dateTime + "'", "h_p_WMSBarcodeQuery"); + + if (ds == null || ds.Tables[0].Rows.Count <= 0) + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鑾峰彇澶辫触" + DBUtility.ClsPub.sErrInfo; + objjson.data = null; + return objjson; + } + else + { + objjson.code = "1"; + objjson.count = 1; + objjson.Message = "鑾峰彇鎴愬姛!"; + objjson.data = ds.Tables[0]; + return objjson; + } + } + catch (Exception ex) + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鑾峰彇澶辫触" + ex.ToString(); + objjson.data = null; + return objjson; + } + } + } } -- Gitblit v1.9.1