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 | 2461 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 2,455 insertions(+), 6 deletions(-) diff --git a/WebAPI/Controllers/WebAPIController.cs b/WebAPI/Controllers/WebAPIController.cs index ce68293..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 @@ -36,6 +33,9 @@ Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); //public static string sUrl = "http://183.129.128.86:9090/WEBS-WMSTest/WebService1.asmx"; // private POInStockBillServices oclscg_poinstockbillmain = new POInStockBillServices(); + + string fileip = System.Configuration.ConfigurationManager.AppSettings["FileIP"]; + /// <summary> /// 閫佽揣鍗曡〃澶翠俊鎭� /// </summary> @@ -384,6 +384,51 @@ return objjson; ; } } + /// <summary> + /// 鐧诲綍鏍规嵁ic鍗¤幏鍙栦俊鎭� + /// </summary> + /// <param name="HBarCode"></param> + /// <returns></returns> + [Route("Web/GetUserByICCard")] + [HttpGet] + public object GetUserByICCard(string HBarCode) + { + try + { + DataSet ds = null; + ClsCN oCnLoc = new ClsCN(); + DAL.ClsUser oUser = new DAL.ClsUser(); + string sql = string.Format(@" select a.* from h_v_Gy_Czygl_Login a + where a.HICNumber = '{0}'", HBarCode); + ds = oCnLoc.RunProcReturn(sql, "h_v_Gy_Czygl_Login"); + + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鏃犳ic鍗″搴斿憳宸ヤ俊鎭紒"; + objjson.data = null; + return objjson; + } + + objjson.code = "1"; + objjson.count = 1; + objjson.Message = "淇℃伅鑾峰彇鎴愬姛锛�"; + objjson.data = ds.Tables[0]; + return objjson; + + } + catch (Exception e) + { + + objjson.code = "0"; + objjson.count = 0; + objjson.Message = "鐧诲綍寮傚父锛�" + e.Message; + objjson.data = null; + return objjson; ; + } + } + /// <summary> /// 鑿滃崟鏍� /// </summary> @@ -1493,6 +1538,106 @@ return objjson; } } + + + /// <summary> + /// 鑾峰彇鐝鍒楄〃 + /// </summary> + /// <returns></returns> + [Route("Web/GetGy_ShiftsList_Json")] + [HttpGet] + public object GetGy_ShiftsList_Json(string Shifts) + { + sWhere = " 绂佺敤鏍囪!='Y'"; + if (Shifts != "") + { + sWhere = " Where 绂佺敤鏍囪!='Y' and ( 鐝浠g爜 like '%" + Shifts + "%' or 鐝鍚嶇О like '%" + Shifts + "%' ) "; + } + else + { + sWhere = " Where 绂佺敤鏍囪!='Y' "; + } + try + { + string sql = $"Select * from h_v_Gy_ShiftsList {sWhere} Order by 鐝浠g爜"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_ShiftsList"); + 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 = "0"; + 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; + } + } + + /// <summary> + /// 鑾峰彇寮傚父鍙嶉绫诲瀷鍒楄〃 + /// </summary> + /// <returns></returns> + [Route("Web/GetGy_ErrMsgBackTypeList_Json")] + [HttpGet] + public object GetGy_ErrMsgBackTypeList_Json(string ErrMsg) + { + sWhere = " 绂佺敤鏍囧織 ='鍚�'"; + if (ErrMsg != "") + { + sWhere = " Where 绂佺敤鏍囧織 ='鍚�' and ( 寮傚父鍙嶉绫诲瀷浠g爜 like '%" + ErrMsg + "%' or 寮傚父鍙嶉绫诲瀷鍚嶇О like '%" + ErrMsg + "%' ) "; + } + else + { + sWhere = " Where 绂佺敤鏍囧織 ='鍚�' "; + } + try + { + string sql = $"Select * from h_v_Gy_ErrMsgBackType {sWhere} Order by 寮傚父鍙嶉绫诲瀷浠g爜"; + ds = oCN.RunProcReturn(sql, "h_v_Gy_ErrMsgBackType"); + 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 = "0"; + 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; + } + } + /// <summary> /// 鑾峰彇鐝粍鍒楄〃 @@ -2630,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> /// 淇濆瓨涓嶈壇绫诲瀷 @@ -2833,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> @@ -3933,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 @@ -5288,6 +6346,188 @@ objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + /// <summary> + /// 鏂囦欢涓婁紶 + /// </summary> + /// <returns></returns> + [Route("Gy_InspectInstruMent_UploadFile")] + [HttpPost] + public object Gy_InspectInstruMent_UploadFile() + { + + string HBillNo = HttpContext.Current.Request.Params["HBillNo"]; //鍗曟嵁鍙� + string HRemark = HttpContext.Current.Request.Params["HRemark"]; //澶囨敞 + string HUserName = HttpContext.Current.Request.Params["HUserName"]; //鍒涘缓浜� + HttpPostedFile files = HttpContext.Current.Request.Files["file"]; + string path = HttpContext.Current.Server.MapPath("~/../Files/Gy_InspectInstruMent/" + HBillNo); + //string path = @"D:\\Files\\"+ HBillNo; + dynamic dyResult = UpLoadFile(files, path, HBillNo, HRemark, HUserName); + if (dyResult != null && dyResult.result == 1) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "涓婁紶鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = dyResult.returnval; + objJsonResult.data = null; + return objJsonResult; + } + + } + + public dynamic UpLoadFile(HttpPostedFile files, string path, string HBillNo, string HRemark, string HUserName) + { + dynamic Result_Ob = new { result = 1, returnval = "涓婁紶鎴愬姛锛�" }; + string filePath = Path.GetFullPath(files.FileName);//鏂囦欢涓婁紶璺緞 + string fileExtension = Path.GetExtension(files.FileName);// 鏂囦欢鎵╁睍鍚� + string filename = files.FileName;//鏂囦欢鍚� + string fileSavePath = path;// 涓婁紶淇濆瓨璺緞 + int filesize = files.ContentLength;//鑾峰彇涓婁紶鏂囦欢鐨勫ぇ灏忓崟浣嶄负瀛楄妭byte + int Maxsize = 40000 * 1024;//瀹氫箟涓婁紶鏂囦欢鐨勬渶澶х┖闂村ぇ灏忎负40M + try + { + if (files == null || files.ContentLength <= 0) + { + Result_Ob = new { result = 0, returnval = "鏂囦欢涓嶈兘涓虹┖!" }; + return Result_Ob; + } + if (filesize >= Maxsize) + { + Result_Ob = new { result = 0, returnval = "涓婁紶鏂囦欢瓒呰繃40M锛屼笉鑳戒笂浼狅紒" }; + return Result_Ob; + } + + string fileurl = Path.Combine(fileSavePath, filename); + if (Directory.Exists(fileurl) == true) //濡傛灉瀛樺湪閲嶅悕鏂囦欢灏辨彁绀� + { + Result_Ob = new { result = 0, returnval = "瀛樺湪鍚屽悕鏂囦欢锛�" }; + return Result_Ob; + } + //鍒犻櫎鏁版嵁琛ㄦ暟鎹� + ds = oCN.RunProcReturn("delete from MES_AccessoriesList where HSourceBillNo ='" + HBillNo + "' and HFileName='" + filename + "'", "MES_AccessoriesList"); + if (Directory.Exists(path)) + { + File.Delete(fileurl); //鍒犻櫎鎸囧畾鏂囦欢 + files.SaveAs(fileurl); + string StrPath = "/files/Gy_InspectInstruMent/" + HBillNo + "/" + filename; + if (File.Exists(fileurl)) + { + //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱 + //鍐欏叆鏁版嵁琛� + oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + + ",HFileClsID,HSourceBillNo" + + ") values('" + + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + + "','" + 0 + "','" + HBillNo + + "') "); + } + else + { + Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" }; + } + } + else + { + Directory.CreateDirectory(fileSavePath); //娣诲姞鏂囦欢澶� + files.SaveAs(fileurl); + string StrPath = "/files/Gy_InspectInstruMent/" + HBillNo + "/" + filename; + if (File.Exists(fileurl)) + { + //杩欓噷鍙互鎵ц涓�浜涘叾瀹冪殑鎿嶄綔锛屾瘮濡傛洿鏂版暟鎹簱 + //鍐欏叆鏁版嵁琛� + oCN.RunProc("Insert into MES_AccessoriesList (HFileName,HFilePath,HFilePath_Cus,HFileType" + + ",HLoadMan,HLoadDate,HRemark,HVerNum,HFileSize" + + ",HFileClsID,HSourceBillNo" + + ") values('" + + filename.ToString() + "','" + StrPath.ToString() + "','" + filePath.ToString() + "','" + fileExtension.ToString() + "'" + + ",'" + HUserName + "',getdate(),'" + HRemark + "','V1','" + filesize + + "','" + 0 + "','" + HBillNo + + "') "); + } + else + { + Result_Ob = new { result = 0, returnval = "涓婁紶澶辫触锛佹鏂囦欢涓烘伓鎰忔枃浠�" }; + } + } + + } + catch (Exception e) + { + Result_Ob = new { result = 0, returnval = e.Message }; + } + return Result_Ob; + } + + /// <summary> + /// 鏍规嵁鍗曟嵁鍙锋煡鎵句笂浼犳枃浠跺垪琛� + /// </summary> + /// <param name="sWhere"></param> + /// <returns></returns> + [Route("Gy_InspectInstruMent_Filelist")] + [HttpGet] + public object Gy_InspectInstruMent_Filelist(string HBillNo) + { + var url = fileip + "/files/Gy_InspectInstruMent/" + HBillNo + "/"; + //@"C:\\files\\" + try + { + ds = oCN.RunProcReturn("select *,'" + url + "'+CAST(HFileName as varchar(200))as url from MES_AccessoriesList where HSourceBillNo='" + HBillNo + "'", "MES_AccessoriesList"); + 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> + /// 鏍规嵁ID,鍗曟嵁鍙�,鏂囦欢鍚� 鍒犻櫎鏂囦欢 + /// </summary> + /// <param name="sWhere"></param> + /// <returns></returns> + [Route("Gy_InspectInstruMent_DeleteFilelist")] + [HttpGet] + public object Gy_InspectInstruMent_DeleteFilelist(string HItemID, string HSourceBillNo, string HFileName) + { + try + { + + oCN.RunProc("delete from MES_AccessoriesList where HItemID =" + HItemID); + string fileurl = Path.Combine(HttpContext.Current.Server.MapPath("~/../Files/EquipTechParamFolder/" + HSourceBillNo), HFileName); + File.Delete(fileurl); //鍒犻櫎鎸囧畾鏂囦欢 + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍒犻櫎鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); objJsonResult.data = null; return objJsonResult; } @@ -8679,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 宸ヨ壓鍙傛暟鍒嗙被 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 @@ -9241,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 鐩樼偣鏂规 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 @@ -10680,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 椤圭洰绫诲埆 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 @@ -12999,6 +15056,284 @@ } #endregion + + #region 鐜妫�娴嬪崟 璁剧疆鍒楄〃/淇濆瓨/缂栬緫/鍒犻櫎鏂规硶 + /// <summary> + /// 淇濆瓨鐜妫�娴嬪崟 + /// </summary> + /// <param name="msg"></param> + /// <returns></returns> + [Route("SaveGy_EnvironmentTestItem")] + [HttpPost] + public object SaveGy_EnvironmentTestItem([FromBody] JObject msg) + { + DataSet ds; + var _value = msg["msg"].ToString(); + string msg3 = _value.ToString(); + string[] sArray = msg3.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); + string msg1 = sArray[0].ToString(); + string msg2 = sArray[1].ToString(); + + //鏌ョ湅鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Gy_EnvironmentTestItem_Edit", 1, false, msg2)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + Int64 HItemID = 0; + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + //鑾峰彇鏈�澶D鍊艰祴鍊� + DataSet Maxds = oCN.RunProcReturn("select MAX(HItemID) HItemID from Gy_EnvironmentTestItem ", "Gy_EnvironmentTestItem"); + if (Maxds != null || Maxds.Tables[0].Rows.Count > 0) + { + //HItemID= Maxds.Tables[0].Rows[0]["HItemID"] + var maxid = Convert.ToInt32(Maxds.Tables[0].Rows[0]["HItemID"]); + maxid += 1; + HItemID = maxid; + } + ListModels oListModels = new ListModels(); + try + { + WebAPI.DLL.ClsGy_EnvironmentTestItem_Ctl oBill = new WebAPI.DLL.ClsGy_EnvironmentTestItem_Ctl(); + List<Model.ClsGy_EnvironmentTestItem_Model> lsmain = new List<Model.ClsGy_EnvironmentTestItem_Model>(); + msg1 = msg1.Replace("\\", ""); + msg1 = msg1.Replace("\n", ""); //\n + lsmain = oListModels.getObjectByJson_Gy_EnvironmentTestItem(msg1); + foreach (Model.ClsGy_EnvironmentTestItem_Model oItem in lsmain) + { + if (oItem.HNumber.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷笉鑳戒负绌猴紒"; + objJsonResult.data = 1; + return objJsonResult; + } + if (oItem.HName.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佸悕绉颁笉鑳戒负绌猴紒"; + objJsonResult.data = 1; + return objJsonResult; + } + if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim())) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鏌ヨ鏁版嵁涓槸鍚﹀瓨鍦ㄩ噸澶嶄唬鐮� + + ds = oCN.RunProcReturn("select * from Gy_EnvironmentTestItem where HStopflag=0 and HNumber='" + oItem.HNumber.Trim() + "'", "Gy_EnvironmentTestItem"); + if (oItem.HNumber.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷负绌猴紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //鏂板鏃跺垽鏂� + if (oItem.HItemID == 0) + { + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮侀噸澶嶏紒"; + objJsonResult.data = 1; + return objJsonResult; + } + //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦� + string sParent; + sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim()); + if (sParent.Trim() == "") + { + oBill.oModel.HParentID = 0; + } + else + { + if (oBill.HavParentCode(sParent.Trim(), HItemID)) + { + oBill.oModel.HParentID = oBill.oModel.HItemID; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + } + } + else//缂栬緫鏃跺垽鏂� + { + //妫�鏌ョ埗绾ф槸鍚﹀瓨鍦� + string sParent; + sParent = DBUtility.ClsPub.GetParentCode(oItem.HNumber.Trim()); + if (sParent.Trim() == "") + { + oBill.oModel.HParentID = 0; + } + else + { + if (oBill.HavParentCode(sParent.Trim(), oItem.HItemID)) + { + oBill.oModel.HParentID = oBill.oModel.HItemID; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佷笂绾т唬鐮佷笉瀛樺湪鎴栬绂佺敤锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + } + } + //寰楀埌鐭唬鐮� + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim()); + if (sShortNumber.Trim() == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + oItem.HShortNumber = sShortNumber;//鐭唬鐮� + oItem.HEndFlag = true;//鏈骇鏍囧織 + oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇 + oItem.HMakeEmp = msg2; //鍒涘缓浜� + + oBill.oModel = oItem; + } + + //淇濆瓨 + //淇濆瓨瀹屾瘯鍚庡鐞� + bool bResult; + if (oBill.oModel.HItemID == 0) + { + bResult = oBill.AddNew(); + } + else + { + bResult = oBill.ModifyByID(oBill.oModel.HItemID); + } + if (bResult) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨鎴愬姛锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.data = 1; + return objJsonResult; + } + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString(); + objJsonResult.data = 1; + return objJsonResult; + } + } + + /// <summary> + /// 鐜妫�娴嬪崟鍙栦俊鎭� + /// </summary> + /// <returns></returns> + [Route("GetGy_EnvironmentTestItem_Edit")] + [HttpGet] + public ApiResult<DataSet> GetGy_EnvironmentTestItem_Edit(string HID) + { + var model = LuBaoSevice.GetGy_EnvironmentTestItemEdit(HID); + return model; + } + + /// <summary> + /// 鐜妫�娴嬪崟鍒犻櫎鍔熻兘 + /// </summary> + /// <returns></returns> + [Route("DeltetGy_EnvironmentTestItem")] + [HttpGet] + public object DeltetGy_EnvironmentTestItem(string HItemID, string user) + { + DataSet ds; + try + { + //鍒犻櫎鏉冮檺 + if (!DBUtility.ClsPub.Security_Log("Gy_EnvironmentTestItem_Delete", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + if (string.IsNullOrWhiteSpace(HItemID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HItemID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + oCN.BeginTran();//寮�濮嬩簨鍔� + ds = oCN.RunProcReturn("select * from Gy_EnvironmentTestItem where HItemID=" + HItemID, "Gy_EnvironmentTestItem"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁鏁版嵁锛屾棤娉曞垹闄わ紒"; + objJsonResult.data = null; + return objJsonResult; ; + } + + oCN.RunProc("delete Gy_EnvironmentTestItem where HItemID=" + HItemID); + oCN.Commit();//鎻愪氦浜嬪姟 + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鏁版嵁鍒犻櫎鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; ; + + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + /// <summary> /// 鐢ㄥ叧鑱斿伐搴忚幏鍙栦俊鎭� /// </summary> @@ -14516,6 +16851,46 @@ } /// <summary> + /// 鏍规嵁鐗╂枡+宸ュ簭鑾峰彇妫�楠屾柟妗� + /// </summary> + /// <returns></returns> + [Route("Web/GetCheckItemID")] + [HttpGet] + public object GetCheckItemID(string HName,string HProName) + { + try + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_QCCheckProjectList_Main where 鐗╂枡鍚嶇О='"+HName+ "' and 宸ュ簭鍚嶇О='" + HProName + "' order by 鏃ユ湡 desc ", "h_v_Gy_QCCheckProjectList_Main"); + 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; + } + } + + + /// <summary> /// 鏍规嵁妫�楠屾柟妗堜富鍐呯爜鑾峰彇妫�楠岄」鐩� /// </summary> /// <returns></returns> @@ -14983,7 +17358,7 @@ if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") { objjson.code = "0"; - objjson.count = 1; + objjson.count = 0; objjson.Message = "璇ヨ澶囨湁澶氫釜璁″垝鍗曟垨鐐规瑙勭▼,鎵嬪姩閫夌潃" ; objjson.data = null; return objjson; @@ -15636,8 +18011,15 @@ ds = oCn.RunProcReturn(sql, "Gy_MenuDefineSet"); //鏌ヨ褰撳墠鐢ㄦ埛鐨勮嚜瀹氫箟鑿滃崟鏁版嵁 if (ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0) //鍒ゆ柇褰撳墠鐢ㄦ埛鏄惁鏈夎缃繃鑷畾涔変俊鎭紝鑻ヨ褰曟暟涓�0锛屽垯娌℃湁璁剧疆杩囷紝鍔犺浇鎵�鏈夌殑鑿滃崟淇℃伅 { - sql = "Select * from Gy_Menu_1 where HType = '" + HType + "' Order by HPosition,len(HitemID),HitemID "; - ds = oCn.RunProcReturn(sql, "Gy_Menu"); + string sql1 = "select HItemID,HPartentID,HNumber,HName,HLevel,Hurl,HType,HPicNum from Gy_MenuDefineSet where HMakeName=" + + "(select top 1 c.GroupName from Gy_Czygl a left join System_UserGroupInfo b on a.Czybm = b.UserId " + + "left join System_UserGroup c on b.GroupId = c.GroupID where a.Czymc ='"+HMakeName+"' order by len(c.GroupName ))"; + ds = oCn.RunProcReturn(sql1, "Gy_MenuDefineSet"); //鏌ヨ鐢ㄦ埛缁戝畾鐨勮鑹� 鏄惁璁剧疆鑿滃崟淇℃伅 鍙栬鑹插悕绉版渶鐭殑涓�涓� + if ((ds.Tables[0] == null || ds.Tables[0].Rows.Count == 0)) + { + sql = "Select * from Gy_Menu_1 where HType = '" + HType + "' Order by HPosition,len(HitemID),HitemID "; + ds = oCn.RunProcReturn(sql, "Gy_Menu"); + } } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) //灏嗚彍鍗曠殑鏍硅妭鐐逛繚瀛樺埌鍒楄〃menu涓� @@ -16081,6 +18463,12 @@ string sql = "select a.HSubFuncID, a.HCaption,a.HPicNum,b.Hurl from Xt_UserFastMenu as a join Gy_Menu_1 as b on a.HSubFuncID = b.HItemID where a.HUserID = '" + HMakeName + "' and b.HType = '" + HType + "' Order by a.HItemID"; ds = oCn.RunProcReturn(sql, "Xt_UserFastMenu"); //鑾峰彇Xt_UserFastMenu涓鐢ㄦ埛璁剧疆鐨勮嚜瀹氫箟鑿滃崟淇℃伅锛岀敤浜庡湪鍓嶇鍔犺浇 + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + sql = "select a.HSubFuncID, a.HCaption,a.HPicNum,b.Hurl from Xt_UserFastMenu as a join Gy_Menu_1 as b on a.HSubFuncID = b.HItemID where a.HUserID = 'admin' and b.HType = '" + HType + "' Order by a.HItemID"; + ds = oCn.RunProcReturn(sql, "Xt_UserFastMenu"); //鑾峰彇Xt_UserFastMenu涓鐢ㄦ埛璁剧疆鐨勮嚜瀹氫箟鑿滃崟淇℃伅锛岀敤浜庡湪鍓嶇鍔犺浇 + } + objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "鏌ヨ鎴愬姛锛�"; @@ -16551,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