From 5b6d9876d89219f34a2fda2820b1de752d28d77e Mon Sep 17 00:00:00 2001 From: duhe <226547893@qq.com> Date: 星期二, 08 四月 2025 11:05:24 +0800 Subject: [PATCH] 物料:增加 制单人 --- WebAPI/Controllers/BaseSet/Gy_MaterialController.cs | 1786 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 1,759 insertions(+), 27 deletions(-) diff --git a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs index 596820f..caeec5c 100644 --- a/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs +++ b/WebAPI/Controllers/BaseSet/Gy_MaterialController.cs @@ -14,6 +14,8 @@ using WebAPI.Models; using WebAPI.Service; using System.Text.RegularExpressions; +using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; +using SyntacticSugar.constant; namespace WebAPI.Controllers { @@ -22,7 +24,7 @@ //鑾峰彇绯荤粺鍙傛暟 Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); public DBUtility.ClsPub.Enum_BillStatus BillStatus; - + public string sWhere = ""; private json objJsonResult = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; @@ -79,7 +81,7 @@ objJsonResult.data = null; return objJsonResult; } - string sql1 = string.Format(@"select * from h_v_Gy_MaterialList where 缁勭粐鍚嶇О='" + Organization + "'"); + string sql1 = string.Format(@"select top(500) * from h_v_Gy_MaterialList where 缁勭粐鍚嶇О='" + Organization + "'"); if (sWhere == null || sWhere.Equals("")) { ds = oCN.RunProcReturn(sql1 + sWhere + " order by 鐗╂枡浠g爜 desc", "h_v_Gy_MaterialList"); @@ -114,6 +116,60 @@ return objJsonResult; } } + + #region 鐗╂枡鍒嗛〉鍒楄〃 + [Route("Gy_Material/page")] + [HttpGet] + public object page(string sWhere, string user, string Organization,int page,int size) + { + try + { + List<object> columnNameList = new List<object>(); + //缂栬緫鏉冮檺 + if (!DBUtility.ClsPub.Security_Log_second("Gy_Material", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + if (sWhere == null || sWhere.Equals("")) + { + ds = oCN.RunProcReturn("exec h_p_Gy_MaterialList " + page + "," + size + ",'" + Organization +"'," + "''", "h_p_Gy_MaterialList"); + } + else + { + sWhere = sWhere.Replace("'", "''"); + ds = oCN.RunProcReturn("exec h_p_Gy_MaterialList " + page + "," + size + ",'" + Organization + "','" + sWhere + "'", "h_p_Gy_MaterialList"); + } + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + objJsonResult.code = "1"; + objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + objJsonResult.Message = "Sucess锛�"; + objJsonResult.list = columnNameList; + 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; + } + } + #endregion #region 鐗╂枡鏍规嵁鍒嗙被鑾峰彇鏈�澶х墿鏂欑紪鐮� [Route("Gy_Material/getMaxNum")] @@ -186,6 +242,155 @@ objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 鑾峰彇鐗╂枡绮惧害閫氳繃id + [Route("Gy_Material/getDecByID")] + [HttpGet] + public object getDecByID(int HMaterID) + { + try + { + if(HMaterID == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁閫夋嫨鐗╂枡"; + objJsonResult.data = null; + return objJsonResult; + } + ds = oCN.RunProcReturn(@"select HQtyDec,HPriceDec,HMoneyDec from Gy_Material where HitemID=" + HMaterID , "Gy_Material"); + if (ds == null || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "娌℃湁鎵惧埌璇ョ墿鏂欑紪鐮�"; + objJsonResult.data = null; + return objJsonResult; + } + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "Success"; + 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; + } + } + #endregion + + #region 鑾峰彇椤圭洰鍙� + [Route("Gy_Material/Get_HProject")] + [HttpGet] + public object Get_HProject() + { + try + { + DataSet oDs = new DataSet(); + //========== + oDs = oCN.RunProcReturn("select top(20) HInterID as HItemID,HProName HName from PM_ProjectBillMain", "PM_ProjectBillMain"); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鑾峰彇鎴愬姛锛�"; + objJsonResult.data = oDs.Tables[0]; + return objJsonResult; ; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + /// <summary> + /// 鑾峰彇椤圭洰鍒楄〃 + /// </summary> + /// <returns></returns> + [Route("Gy_Material/GetProjectGroupList_Json")] + [HttpGet] + public object GetProjectGroupList_Json(string Unit) + { + if (Unit != "" && Unit != null) + { + sWhere = sWhere + " and ( HBillNo like '%" + Unit + "%' or HProName like '%" + Unit + "%' ) "; + } + + try + { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + if (sWhere == null || sWhere.Equals("")) + { + ds = oCN.RunProcReturn("Select HInterID,HBillNo 椤圭洰浠g爜,HProName 椤圭洰缁� from PM_ProjectBillMain where HCloseType = 0 Order by HInterID ", "PM_ProjectBillMain"); + } + else + { + string sql1 = "Select HInterID,HBillNo 椤圭洰浠g爜,HProName 椤圭洰缁� from PM_ProjectBillMain where HCloseType = 0 "; + string sql = sql1 + sWhere; + ds = oCN.RunProcReturn(sql, "PM_ProjectBillMain"); + } + + if (ds == null || ds.Tables[0].Rows.Count <= 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鑾峰彇澶辫触" + DBUtility.ClsPub.sErrInfo; + objJsonResult.data = null; + return objJsonResult; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鑾峰彇鎴愬姛!"; + objJsonResult.data = ds.Tables[0]; + return objJsonResult; + } + } + catch (Exception ex) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鑾峰彇澶辫触" + ex.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #region 鑾峰彇浜嬩笟閮� + [Route("Gy_Material/Get_Gy_Division")] + [HttpGet] + public object Get_Gy_Division(string HOrgID) + { + try + { + DataSet oDs = new DataSet(); + //========== + oDs = oCN.RunProcReturn(" select HItemID,HName from Gy_Division", "Gy_Division"); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鑾峰彇鎴愬姛锛�"; + objJsonResult.data = oDs.Tables[0]; + return objJsonResult; ; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触锛�" + e.ToString(); objJsonResult.data = null; return objJsonResult; } @@ -365,6 +570,7 @@ oItem.HShortNumber = sShortNumber;//鐭唬鐮� oItem.HEndFlag = true;//鏈骇鏍囧織 oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇 + oItem.HMakeEmp = msg2; oBill.oModel = oItem; } //淇濆瓨 @@ -455,6 +661,458 @@ } } + #region 鐗╂枡 鏂囦欢瀵煎叆淇濆瓨 + #region 鐗╂枡 鏂囦欢涓婁紶 + [Route("Gy_Material/Gy_Material_Excel")] + [HttpPost] + public object Gy_Material_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("HMaterClsID", typeof(Int32));//鐗╂枡灞炴�D + tb2.Columns.Add("HUnitGroupID", typeof(Int32));//璁¢噺鍗曚綅缁処D + tb2.Columns.Add("HUnitID", typeof(Int32));//鍗曚綅ID + tb2.Columns.Add("HSecUnitID", typeof(Int32));//杈呭姪璁¢噺鍗曚綅ID + tb2.Columns.Add("HWhID", typeof(Int32));//榛樿浠撳簱ID + //娣诲姞鏁版嵁 + for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) + { + DataRow row = tb2.NewRow(); + for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) + { + row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); + } + tb2.Rows.Add(row); + } + + + var error = ""; + + //鍒ゆ柇瀵煎叆鏂囦欢鍒楁槸鍚﹀畬鏁� + if (!tb2.Columns.Contains("缁勭粐浠g爜")) + error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("缁勭粐鍚嶇О")) + error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鐗╂枡鍚嶇О")) + error += "娌℃湁鎵惧埌銆愮墿鏂欏悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鐗╂枡浠g爜")) + error += "娌℃湁鎵惧埌銆愮墿鏂欎唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("瑙勬牸鍨嬪彿")) + error += "娌℃湁鎵惧埌銆愯鏍煎瀷鍙枫�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鍔╄鐮�")) + error += "娌℃湁鎵惧埌銆愬姪璁扮爜銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鐗堟湰鍙�")) + error += "娌℃湁鎵惧埌銆愮増鏈彿銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鐗╂枡灞炴��")) + error += "娌℃湁鎵惧埌銆愮墿鏂欏睘鎬с�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("璁¢噺鍗曚綅缁�")) + error += "娌℃湁鎵惧埌銆愯閲忓崟浣嶇粍銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("璁¢噺鍗曚綅浠g爜")) + error += "娌℃湁鎵惧埌銆愯閲忓崟浣嶄唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("璁¢噺鍗曚綅")) + error += "娌℃湁鎵惧埌銆愯閲忓崟浣嶃�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("杈呭姪璁¢噺鍗曚綅")) + error += "娌℃湁鎵惧埌銆愯緟鍔╄閲忓崟浣嶃�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鎹㈢畻鐜�")) + error += "娌℃湁鎵惧埌銆愭崲绠楃巼銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("榛樿浠撳簱")) + error += "娌℃湁鎵惧埌銆愰粯璁や粨搴撱�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鏈�楂樺簱瀛�")) + error += "娌℃湁鎵惧埌銆愭渶楂樺簱瀛樸�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鏈�浣庡簱瀛�")) + error += "娌℃湁鎵惧埌銆愭渶浣庡簱瀛樸�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("瀹夊叏搴撳瓨")) + error += "娌℃湁鎵惧埌銆愬畨鍏ㄥ簱瀛樸�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("閲囪喘鍗曚环")) + error += "娌℃湁鎵惧埌銆愰噰璐崟浠枫�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("閿�鍞崟浠�")) + error += "娌℃湁鎵惧埌銆愰攢鍞崟浠枫�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("璁″垝鍗曚环")) + error += "娌℃湁鎵惧埌銆愯鍒掑崟浠枫�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鏍囧噯鎴愭湰")) + error += "娌℃湁鎵惧埌銆愭爣鍑嗘垚鏈�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("淇濊川鏈�")) + error += "娌℃湁鎵惧埌銆愪繚璐ㄦ湡銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鏈�灏忚璐ч噺")) + 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 HMaterName = ""; + string HMaterNumber = ""; + string HORGNumber = ""; + string HORGName = ""; + string HMaterClsName = ""; + string HUnitGroupName = ""; + string HUnitNumber = ""; + string HUnitName = ""; + string HSecUnitName = ""; + string HWhName = ""; + + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString()); + HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString()); + HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString()); + HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString()); + HMaterClsName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡灞炴��"].ToString()); + HUnitGroupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅缁�"].ToString()); + HUnitNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅浠g爜"].ToString()); + HUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅"].ToString()); + HSecUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["杈呭姪璁¢噺鍗曚綅"].ToString()); + HWhName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撳簱"].ToString()); + //妫�鏌ョ墿鏂� + int index = i + 1; + + if (HORGNumber != "") + { + + //鏌ヨ缁勭粐 + ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,缁勭粐涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); + //鏌ヨ灞炴�� + if (HMaterClsName == "澶栬喘") + { + tb2.Rows[i]["HMaterClsID"] = 1; + } + else if(HMaterClsName == "鑷埗") + { + tb2.Rows[i]["HMaterClsID"] = 2; + } + else if (HMaterClsName == "濮斿") + { + tb2.Rows[i]["HMaterClsID"] = 3; + } + else + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡灞炴�т笉瀛樺湪锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //鏌ヨ璁¢噺鍗曚綅缁� + ds = oCN.RunProcReturn("select * from Gy_UnitGroup where HName='" + HUnitGroupName + "'", "Gy_UnitGroup"); + + if (ds.Tables[0].Rows.Count == 0 && HUnitGroupName != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + "璁¢噺鍗曚綅缁�:" + HUnitGroupName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else if (HMaterNumber == "") + { + tb2.Rows[i]["HUnitGroupID"] = 0; + } + else + { + tb2.Rows[i]["HUnitGroupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鏌ヨ鍗曚綅 + ds = oCN.RunProcReturn("select * from Gy_Unit where HNumber='" + HUnitNumber + "' and HUSEORGID=" + HORGid + "", "Gy_Unit"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍗曚綅:" + HUnitName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鏌ヨ杈呭姪鍗曚綅 + ds = oCN.RunProcReturn("select * from Gy_Unit where HName='" + HSecUnitName + "' and HUSEORGID=" + HORGid + "", "Gy_Unit"); + + if (ds.Tables[0].Rows.Count == 0 && HSecUnitName != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍗曚綅:" + HSecUnitName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + }else if (HSecUnitName == "") + { + tb2.Rows[i]["HSecUnitID"] = 0; + } + else + { + tb2.Rows[i]["HSecUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鏌ヨ浠撳簱 + ds = oCN.RunProcReturn("select * from Gy_Warehouse where HName='" + HWhName + "' and HUSEORGID=" + HORGid + "", "Gy_Warehouse"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撳簱:" + HWhName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HWHID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鐗╂枡鍚嶇О + if (HMaterName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //鐗╂枡浠g爜 + if (HMaterNumber == "") + { + 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_Material/Gy_Material_btnSave")] + [HttpPost] + public object Gy_Material_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_Material_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) + { + DLL.ClsGy_Material_Ctl oBill = new DLL.ClsGy_Material_Ctl(); + ClsGy_Material_Model oItem = new ClsGy_Material_Model(); + //璧嬪�煎墠绔紶鍏ョ殑 + oItem.HUSEORGID = int.Parse(item["HOrgID"].ToString()); + oItem.HNumber = item["鐗╂枡浠g爜"].ToString(); + oItem.HName = item["鐗╂枡鍚嶇О"].ToString(); + oItem.HModel = item["瑙勬牸鍨嬪彿"].ToString(); + oItem.HHelpCode = item["鍔╄鐮�"].ToString(); + oItem.HVersion = item["鐗堟湰鍙�"].ToString(); + oItem.HMaterClsID = int.Parse(item["HMaterClsID"].ToString()); + oItem.HUnitGroupID = int.Parse(item["HUnitGroupID"].ToString()); + oItem.HUnitID = int.Parse(item["HUnitID"].ToString()); + oItem.HSecUnitID = int.Parse(item["HSecUnitID"].ToString()); + oItem.HSecUnitRate = double.Parse(item["鎹㈢畻鐜�"].ToString()==""?"0": item["鎹㈢畻鐜�"].ToString()); + oItem.HWhID = int.Parse(item["HWhID"].ToString()); + oItem.HHighStock = int.Parse(item["鏈�楂樺簱瀛�"].ToString() == "" ? "0" : item["鏈�楂樺簱瀛�"].ToString()); + oItem.HLowStock = int.Parse(item["鏈�浣庡簱瀛�"].ToString() == "" ? "0" : item["鏈�浣庡簱瀛�"].ToString()); + oItem.HSafeStock = int.Parse(item["瀹夊叏搴撳瓨"].ToString() == "" ? "0" : item["瀹夊叏搴撳瓨"].ToString()); + oItem.HOrderPrice = int.Parse(item["閲囪喘鍗曚环"].ToString() == "" ? "0" : item["閲囪喘鍗曚环"].ToString()); + oItem.HSalePrice = int.Parse(item["閿�鍞崟浠�"].ToString() == "" ? "0" : item["閿�鍞崟浠�"].ToString()); + oItem.HPlanPrice = int.Parse(item["璁″垝鍗曚环"].ToString() == "" ? "0" : item["璁″垝鍗曚环"].ToString()); + oItem.HstdPrice = int.Parse(item["鏍囧噯鎴愭湰"].ToString() == "" ? "0" : item["鏍囧噯鎴愭湰"].ToString()); + oItem.HKeepDays = int.Parse(item["淇濊川鏈�"].ToString() == "" ? "0" : item["淇濊川鏈�"].ToString()); + oItem.HQtyMin = int.Parse(item["鏈�灏忚璐ч噺"].ToString() == "" ? "0" : item["鏈�灏忚璐ч噺"].ToString()); + oItem.HQtyMin = int.Parse(item["鏈�澶ц璐ч噺"].ToString() == "" ? "0" : item["鏈�澶ц璐ч噺"].ToString()); + oItem.HEngName = item["鑻辨枃鍚嶇О"].ToString(); + oItem.HEngModel = item["鑻辨枃瑙勬牸"].ToString(); + //甯歌璧嬪�艰祴绌哄�奸槻姝㈡姤閿� + oItem.HMaterTypeID = 0; + oItem.HColorRemark = ""; + oItem.HColorNo = ""; + oItem.HMaterRuleType = ""; + string sShortNumber; + sShortNumber = DBUtility.ClsPub.GetShortNumber(oItem.HNumber.Trim()); + if (sShortNumber.Trim() == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佺煭浠g爜涓虹┖锛�"; + objJsonResult.data = 1; + return objJsonResult; + } + oItem.HShortNumber = sShortNumber;//鐭唬鐮� + oItem.HEndFlag = true;//鏈骇鏍囧織 + oItem.HLevel = DBUtility.ClsPub.GetLevel(oItem.HNumber.Trim()); //绛夌骇 + oBill.oModel = oItem; + if (!DBUtility.ClsPub.AllowNumber(oItem.HNumber.Trim())) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + oItem.HNumber.Trim() + "'", "Gy_Material"); + + if (ds.Tables[0].Rows.Count == 0) + { + + oBill.AddNew(); + } + else + { + + int HItemID = int.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString()); + oBill.oModel.HItemID = HItemID; + oBill.ModifyByID(oBill.oModel.HItemID); + + } + + 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> /// 鐗╂枡璁剧疆鍒犻櫎鍔熻兘 /// </summary> @@ -463,11 +1121,11 @@ [HttpGet] public object DeltetGy_Material(string HItemID, string user) { + SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); + oCN.BeginTran();//寮�濮嬩簨鍔� DataSet ds; try { - SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); - if (user == "10000")//api鍚屾鏂瑰紡 { oCN.RunProc("delete from Gy_Material where HERPItemID=" + HItemID); @@ -495,7 +1153,7 @@ objJsonResult.data = null; return objJsonResult; } - oCN.BeginTran();//寮�濮嬩簨鍔� + ds = oCN.RunProcReturn("select * from Gy_Material where HItemID=" + HItemID, "Gy_Material"); if (ds == null || ds.Tables[0].Rows.Count == 0) { @@ -729,7 +1387,49 @@ } #endregion + #region 鑾峰彇褰撳墠鍏徃鍚� + /// <summary> + /// + /// </summary> + /// <param name="HInterID">鍗曟嵁ID</param> + /// <param name="IsAudit">瀹℃牳(0),鍙嶅鏍�(1)</param> + /// <param name="CurUserName">瀹℃牳浜�</param> + /// <returns></returns> + [Route("Xt_getInfo/getCompanyName")] + [HttpGet] + public object getCompanyName() + { + try + { + string sErr = ""; + if(oSystemParameter.ShowBill(ref sErr)) + { + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = oSystemParameter.omodel.WMS_CampanyName; + objJsonResult.data = oSystemParameter.omodel.WMS_CampanyName; + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "褰撳墠鍏徃鍚嶈幏鍙栧け璐ワ紒" ; + objJsonResult.data = null; + } + return objJsonResult; + } + catch (Exception e) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion /// <summary> @@ -777,6 +1477,63 @@ return objJsonResult; } } + + #region 妯″叿鍒楄〃鍒嗛〉鍒楄〃 + [Route("Gy_Mould/page")] + [HttpGet] + public object Gy_MouldPage(string sWhere,string ModRightNameSelect,string user, int page, int size) + { + DataSet ds; + json res = new json(); + try + { + List<object> columnNameList = new List<object>(); + if (!DBUtility.ClsPub.Security_Log(ModRightNameSelect, 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "娌℃湁鏌ョ湅鏉冮檺"; + objJsonResult.data = null; + return objJsonResult; + } + + if (sWhere == null || sWhere.Equals("")) + { + ds = oCN.RunProcReturn("exec h_p_Gy_MouldFileList " + page + "," + size + ",''", "h_p_Gy_MouldFileList"); + } + else + { + sWhere = sWhere.Replace("'", "''"); + ds = oCN.RunProcReturn("exec h_p_Gy_MouldFileList " + page + "," + size + ",'" + sWhere + "'", "h_p_Gy_MouldFileList"); + } + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } + + res.code = CodeConstant.SUCCEED; + res.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString()); + res.Message = "Sucess锛�"; + res.list = columnNameList; + res.data = ds.Tables[0]; + return res; + } + catch (Exception e) + { + res.code = CodeConstant.FAIL; + res.count = CountConstant.FAIL; + res.Message = "Exception锛�" + e.ToString(); + res.data = null; + return res; + } + } + #endregion + + #region 鍣ㄥ叿妗f鍒楄〃 鏍戠姸鍥� 璁惧鍒嗙被鏌ヨ @@ -921,6 +1678,7 @@ { try { + List<object> columnNameList = new List<object>(); //鍒ゆ柇鏄惁鏈夋煡璇㈡潈闄� if (!DBUtility.ClsPub.Security_Log("Gy_BarCodeBill_Query", 1, false, user)) { @@ -931,14 +1689,23 @@ return objJsonResult; } - string sql1 = "select top 5000 * from h_v_IF_BarCodeBillList where 1 = 1 "; + string sql1 = "select top 15000 * from h_v_IF_BarCodeBillList where 1 = 1 "; string sql = sql1 + sWhere + " order by hmainid desc"; ds = oCN.RunProcReturn(sql, "h_v_IF_BarCodeBillList"); + + //娣诲姞鍒楀悕 + foreach (DataColumn col in ds.Tables[0].Columns) + { + Type dataType = col.DataType; + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; + columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess锛�"; objJsonResult.data = ds.Tables[0]; + objJsonResult.list = columnNameList; return objJsonResult; } catch (Exception e) @@ -981,7 +1748,7 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒"; + objJsonResult.Message = "[0000-1-058]鏃犲垹闄ゆ潈闄愶紒"; objJsonResult.data = null; return objJsonResult; } @@ -992,7 +1759,7 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍒犻櫎鏉$爜鍓嶅垽鏂彂鐢熼敊璇紒"; + objJsonResult.Message = "[3899-1-001]鍒犻櫎鏉$爜鍓嶅垽鏂彂鐢熼敊璇紒"; objJsonResult.data = null; return objJsonResult; } @@ -1002,9 +1769,9 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]); + objJsonResult.Message = "[0000-1-007]" + DBUtility.ClsPub.isStrNull(Ds.Tables[0].Rows[0]["HRemark"]); objJsonResult.data = null; - return objJsonResult; + return objJsonResult; } } //Int64 lngBillKey = 0; @@ -1013,7 +1780,7 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁ID涓虹┖锛�"; + objJsonResult.Message = "[0000-1-009]鍗曟嵁ID涓虹┖锛�"; objJsonResult.data = null; return objJsonResult; } @@ -1058,7 +1825,7 @@ oCN.Commit(); objJsonResult.code = "1"; objJsonResult.count = 1; - objJsonResult.Message = "鍒犻櫎鎴愬姛"; + objJsonResult.Message = "[0000-1-008]鍒犻櫎鎴愬姛"; objJsonResult.data = null; return objJsonResult; } @@ -1066,7 +1833,7 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍗曟嵁鏈壘鍒�"; + objJsonResult.Message = "[0000-1-045]鍗曟嵁鏈壘鍒�"; objJsonResult.data = null; return objJsonResult; } @@ -1076,7 +1843,7 @@ oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = e.Message; + objJsonResult.Message = "[0000-1-007]" + e.Message; objJsonResult.data = null; return objJsonResult; } @@ -1103,7 +1870,7 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "浣滃簾澶辫触锛佹棤鏉冮檺锛�"; + objJsonResult.Message = "[0000-1-063]浣滃簾澶辫触锛佹棤鏉冮檺锛�"; objJsonResult.data = null; return objJsonResult; } @@ -1112,7 +1879,7 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "HInterID灏忎簬0锛�"; + objJsonResult.Message = "[0000-1-009]HInterID灏忎簬0锛�"; objJsonResult.data = null; return objJsonResult; } @@ -1140,7 +1907,7 @@ objJsonResult.code = "1"; objJsonResult.count = 1; - objJsonResult.Message = "浣滃簾鎴愬姛"; + objJsonResult.Message = "[0000-1-040]浣滃簾鎴愬姛"; objJsonResult.data = null; oCN.Commit(); @@ -1149,7 +1916,7 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "浣滃簾澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.Message = "[0000-1-042]浣滃簾澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; oCN.RollBack(); @@ -1172,7 +1939,7 @@ objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍙嶄綔搴熷け璐ワ紝鍘熷洜锛氬弽浣滃簾鏉$爜鍓嶅垽鏂彂鐢熼敊璇紒"; + objJsonResult.Message = "[0000-1-042]鍙嶄綔搴熷け璐ワ紝鍘熷洜锛氬弽浣滃簾鏉$爜鍓嶅垽鏂彂鐢熼敊璇紒"; objJsonResult.data = null; return objJsonResult; } @@ -1184,7 +1951,7 @@ objJsonResult.code = "1"; objJsonResult.count = 1; - objJsonResult.Message = "鍙嶄綔搴熷け璐ワ紝鍘熷洜锛�" + DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HRemark"]); + objJsonResult.Message = "[0000-1-042]鍙嶄綔搴熷け璐ワ紝鍘熷洜锛�" + DBUtility.ClsPub.isStrNull(DS.Tables[0].Rows[0]["HRemark"]); objJsonResult.data = null; return objJsonResult; } @@ -1206,7 +1973,7 @@ objJsonResult.code = "1"; objJsonResult.count = 1; - objJsonResult.Message = "鍙嶄綔搴熸垚鍔�"; + objJsonResult.Message = "[0000-1-043]鍙嶄綔搴熸垚鍔�"; objJsonResult.data = null; oCN.Commit(); return objJsonResult; @@ -1215,7 +1982,7 @@ { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "鍙嶄綔搴熷け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; + objJsonResult.Message = "[0000-1-042]鍙嶄綔搴熷け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo; objJsonResult.data = null; oCN.RollBack(); return objJsonResult; @@ -1228,7 +1995,7 @@ oCN.RollBack(); objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "浣滃簾澶辫触鎴栬�呭弽浣滃簾澶辫触锛�" + e.ToString(); + objJsonResult.Message = "[0000-1-044]浣滃簾澶辫触鎴栬�呭弽浣滃簾澶辫触锛�" + e.ToString(); objJsonResult.data = null; return objJsonResult; } @@ -1351,6 +2118,7 @@ long HSPID = mainList[0].HSPID; Double HDesignLife = mainList[0].HDesignLife; Double HUseLife = mainList[0].HUseLife; + Double HInitLife = mainList[0].HInitLife;//涓婄嚎鍒濆鍖栧鍛� Double HLeaveLife = mainList[0].HLeaveLife; Double HProdQty = mainList[0].HProdQty; Double HProdWeight = mainList[0].HProdWeight; @@ -1370,6 +2138,32 @@ string HMouldClass = mainList[0].HMouldClass; int HNowWHID = mainList[0].HNowWHID; int HNowSPID = mainList[0].HNowSPID; + string HMouldUseStatus = mainList[0].HMouldUseStatus; + int HCREATEORGID = mainList[0].HCREATEORGID; + int HUSEORGID = mainList[0].HUSEORGID; + + //淇濆瓨鍓嶆帶鍒�========================================= + string HBillNote = ""; + ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFileMain_BeforeSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',1 ", "h_p_Gy_MouldFileMain_BeforeSaveCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:淇濆瓨鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= + //涓昏〃 oCN.RunProc("Insert Into Gy_MouldFileMain " + @@ -1382,7 +2176,7 @@ ",HPrintQty,HMouldStatus,HWhID,HRoutingID,HCaveQty" + ",HBomID,HVersion,HSPGroupID,HSPID,HDesignLife,HNowSupID,HNowSupTypeID" + ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode,HMadeSupID" + - ",HMouldClass,HNowWHID,HNowSPID) " + + ",HMouldClass,HNowWHID,HNowSPID,HInitLife,HMouldUseStatus,HCREATEORGID,HUSEORGID) " + " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" + ",'" + HMouldNo + "','" + HName + "','" + HModel + "','" + HModel2 + "','" + HDiameter + "'" + @@ -1392,7 +2186,7 @@ "," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty + "," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" + ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID + - ",'"+ HMouldClass + "'," + HNowWHID + "," + HNowSPID + ") "); + ",'"+ HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "','" + HMouldUseStatus + "',"+ HCREATEORGID + ","+ HUSEORGID + ") "); //瀛愯〃 oCN.RunProc("Insert into Gy_MouldFileSub " + @@ -1404,6 +2198,29 @@ ") "); objJsonResult = AddBillSub(msg5,msg6,msg7,HInterID, HBillNo); + + //淇濆瓨鍚庢帶鍒�========================================= + ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFileMain_AfterSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',1 ", "h_p_Gy_MouldFileMain_AfterSaveCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:淇濆瓨鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //========================================================= + if (objJsonResult.code == "0") { @@ -1499,6 +2316,7 @@ long HSPID = mainList[0].HSPID; Double HDesignLife = mainList[0].HDesignLife; Double HUseLife = mainList[0].HUseLife; + Double HInitLife = mainList[0].HInitLife; Double HLeaveLife = mainList[0].HLeaveLife; Double HProdQty = mainList[0].HProdQty; Double HProdWeight = mainList[0].HProdWeight; @@ -1518,9 +2336,33 @@ string HMouldClass = mainList[0].HMouldClass; int HNowWHID = mainList[0].HNowWHID; int HNowSPID = mainList[0].HNowSPID; - + string HMouldUseStatus = mainList[0].HMouldUseStatus; + int HUSEORGID = mainList[0].HUSEORGID; //鑻AINDI閲嶅鍒欓噸鏂拌幏鍙� oCN.BeginTran(); + + //淇濆瓨鍓嶆帶鍒�========================================= + string HBillNote = ""; + ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFileMain_BeforeSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',1 ", "h_p_Gy_MouldFileMain_BeforeSaveCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:淇濆瓨鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ; + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= + //涓昏〃 oCN.RunProc("UpDate Gy_MouldFileMain set " + " HBillNo='" + HBillNo + "'" + //鍥哄畾璧嬪��=============== @@ -1541,6 +2383,7 @@ ",HPICNo='" + HPICNo + "'" + ",HWorkMaterModel='" + HWorkMaterModel + "'" + ",HMaterID=" + HMaterID.ToString() + + ",HUSEORGID=" + HUSEORGID.ToString() + ",HMaterNumber='" + HMaterNumber + "'" + ",HMouldClass='" + HMouldClass + "'" + ",HMouldType=" + HMouleTypeID.ToString() + @@ -1574,7 +2417,9 @@ ",HMadeSupID=" + HMadeSupID + ",HNowWHID=" + HNowWHID + ",HNowSPID=" + HNowSPID + - " where HInterID=" + HInterID.ToString()); + ",HInitLife='" + HInitLife + + "',HMouldUseStatus='" + HMouldUseStatus + + "' where HInterID=" + HInterID.ToString()); //淇敼瀛愰」鐩唬鐮� //oCN.RunProc("exec h_p_Gy_UpdateNumber Gy_Department,'" + HNumber + ".','" + this.HOldNumber + ".'", ref DBUtility.ClsPub.sExeReturnInfo); @@ -1585,6 +2430,29 @@ oCN.RunProc("delete from Gy_MouldFileSub_MaintainRule where HInterID='" + HInterID + "'"); oCN.RunProc("delete from Gy_MouldFileSub_DotCheckRule where HInterID='" + HInterID + "'"); objJsonResult = AddBillSub(msg5, msg6, msg7, HInterID, HBillNo); + + + //淇濆瓨鍚庢帶鍒�========================================= + ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFileMain_AfterSaveCtrl " + HInterID.ToString() + ", '" + HBillNo + "','" + HBillNote + "',1 ", "h_p_Gy_MouldFileMain_AfterSaveCtrl"); + if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:淇濆瓨鍓嶅垽鏂け璐ワ紝璇蜂笌缃戠粶绠$悊浜哄憳鑱旂郴"; + objJsonResult.data = null; + return objJsonResult; + } + + if (ds.Tables[0].Rows[0]["HBack"].ToString() != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "淇濆瓨澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HBackRemark"].ToString(); ; + objJsonResult.data = null; + oCN.RollBack(); + return objJsonResult; + } + //========================================================= oCN.Commit(); objJsonResult.code = "1"; @@ -1771,8 +2639,56 @@ } if (oBill.DeleteBill(hmainid, ref DBUtility.ClsPub.sExeReturnInfo)) { + oCN.BeginTran(); + //鍒犻櫎鍓嶆帶鍒�========================================= + ds = oCN.RunProcReturn("Exec h_p_Gy_MouldFile_BeforeDelCtrl " + hmainid + ",'" + User + "'", "h_p_Gy_MouldFile_BeforeDelCtrl"); + + if (ds == null) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎鍓嶅垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= + oCN.RunProc("Delete From Gy_MouldFileSub_MaintainRule where HInterID=" + hmainid); oCN.RunProc("Delete From Gy_MouldFileSub_DotCheckRule where HInterID=" + hmainid); + + //鍒犻櫎鍚庢帶鍒�========================================= + DataSet ds2 = oCN.RunProcReturn("Exec h_p_Gy_MouldFile_AfterDelCtrl " + hmainid + ",'" + User + "'", "h_p_Gy_MouldFile_AfterDelCtrl"); + if (ds2 == null) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎鍚庡垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鍒犻櫎澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= + + oCN.Commit(); //鍐欏叆鏃ュ織 ClsPub.Add_Log("", "鍒犻櫎椤圭洰锛屼唬鐮侊細" + oBill.omodel.HMouldNo + ",鍚嶇О锛�" + oBill.omodel.HName, ClsPub.CurUserName); //鏇存柊涓婄骇涓� 鏈骇 @@ -2146,6 +3062,26 @@ } if (IsAudit == 0) //瀹℃牳鎻愪氦 { + //瀹℃牳鍓嶆帶鍒�========================================= + ds = oCN.RunProcReturn("Exec h_p_Sc_MouldStockBill_BeforeCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Sc_MouldStockBill_BeforeCheckCtrl"); + if (ds == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳鍓嶅垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= + //瀹℃牳鎻愪氦 if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) { @@ -2163,9 +3099,50 @@ objJsonResult.data = null; return objJsonResult; } + + //瀹℃牳鍚庢帶鍒�========================================= + DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_MouldStockBill_AfterCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Sc_MouldStockBill_AfterCheckCtrl"); + + if (ds2 == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳鍚庡垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= } if (IsAudit == 1) //鍙嶅鏍告彁浜� { + //鍙嶅鏍稿墠鎺у埗========================================= + ds = oCN.RunProcReturn("Exec h_p_Sc_MouldStockBill_BeforeUnCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Sc_MouldStockBill_BeforeUnCheckCtrl"); + if (ds == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳鍓嶅垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBack"]) != "0") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= + //鍙嶅鏍告彁浜bandonCheck if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true) { @@ -2183,6 +3160,29 @@ objJsonResult.data = null; return objJsonResult; } + + //鍙嶅鏍稿悗鎺у埗========================================= + DataSet ds2 = oCN.RunProcReturn("Exec h_p_Sc_MouldStockBill_AfterUnCheckCtrl " + HInterID + ",'" + CurUserName + "'", "h_p_Sc_MouldStockBill_AfterUnCheckCtrl"); + if (ds2 == null) + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳鍚庡垽鏂け璐ワ紒"; + objJsonResult.data = null; + return objJsonResult; + } + if (DBUtility.ClsPub.isStrNull(ds2.Tables[0].Rows[0]["HBack"]) != "0") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "瀹℃牳澶辫触锛�" + DBUtility.ClsPub.isStrNull(ds.Tables[0].Rows[0]["HBackRemark"]); + objJsonResult.data = null; + return objJsonResult; + } + //========================================================= + } return objJsonResult; } @@ -2191,6 +3191,154 @@ objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 妯″叿妗堝叧闂�/鍙嶅叧闂姛鑳� + [Route("Gy_Mould/CloseGy_Mould")] + [HttpGet] + public object CloseGy_Mould(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄� + if (!DBUtility.ClsPub.Security_Log("Gy_MouldFile_Close", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + ClsPub.CurUserName = user; + DAL.ClsGy_MouldFile oBill = new DAL.ClsGy_MouldFile(); + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 鍏抽棴 2 鍙嶅叧闂� + if (Type == 1) + { + if (!oBill.CloseBill(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + if (!oBill.CancelClose(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + + 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 + + #region 妯″叿妗f浣滃簾/鍙嶄綔搴熷姛鑳� + [Route("Gy_Mould/DeleteGy_Mould")] + [HttpGet] + public object DeleteGy_Mould(string HInterID, int Type, string user) + { + try + { + //鍒ゆ柇鏄惁鏈夊垹闄ゆ潈闄� + if (!DBUtility.ClsPub.Security_Log("Gy_MouldFile_Drop", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犳潈闄愬叧闂�!"; + objJsonResult.data = null; + return objJsonResult; + } + + if (string.IsNullOrWhiteSpace(HInterID)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "HInterID涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + DAL.ClsGy_MouldFile oBill = new DAL.ClsGy_MouldFile(); + ClsPub.CurUserName = user; + + oCN.BeginTran();//寮�濮嬩簨鍔� + + //Type 1 浣滃簾 2 鍙嶄綔搴� + if (Type == 1) + { + if (!oBill.Cancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍏抽棴澶辫触!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + if (!oBill.AbandonCancelltion(int.Parse(HInterID), ref ClsPub.sExeReturnInfo)) + { + objJsonResult.code = "0"; + objJsonResult.count = 1; + objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + ClsPub.sExeReturnInfo; + objJsonResult.data = null; + return objJsonResult; + } + } + + 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; } @@ -2496,5 +3644,589 @@ } #endregion + #region 鍣ㄥ叿妗f 鏂囦欢瀵煎叆淇濆瓨 + #region 鍣ㄥ叿妗f 鏂囦欢涓婁紶 + [Route("Gy_MouldFile/Gy_MouldFile_Excel")] + [HttpPost] + public object Gy_Mould_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("HMaterID", typeof(Int32));//鐗╂枡ID + tb2.Columns.Add("HMouldTypeID", typeof(Int32));//鍒嗙被ID + tb2.Columns.Add("HUnitID", typeof(Int32));//鍗曚綅ID + tb2.Columns.Add("HDeptID", typeof(Int32));//閮ㄩ棬ID + tb2.Columns.Add("HWHID", typeof(Int32));//浠撳簱ID + tb2.Columns.Add("HSupID", typeof(Int32));//渚涘簲鍟咺D + tb2.Columns.Add("HSPID", typeof(Int32));//浠撲綅ID + tb2.Columns.Add("HMadeSupID", typeof(Int32));//鍒堕�犲晢ID + //娣诲姞鏁版嵁 + for (int i = 1; i < ExcelDs.Tables[0].Rows.Count; i++) + { + DataRow row = tb2.NewRow(); + for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) + { + row[j] = ExcelDs.Tables[0].Rows[i][j].ToString(); + } + tb2.Rows.Add(row); + } + + + var error = ""; + + //鍒ゆ柇瀵煎叆鏂囦欢鍒楁槸鍚﹀畬鏁� + if (!tb2.Columns.Contains("缁勭粐浠g爜")) + error += "娌℃湁鎵惧埌銆愮粍缁囦唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("缁勭粐鍚嶇О")) + error += "娌℃湁鎵惧埌銆愮粍缁囧悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鍣ㄥ叿鍚嶇О")) + error += "娌℃湁鎵惧埌銆愬櫒鍏峰悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鍣ㄥ叿缂栧彿")) + error += "娌℃湁鎵惧埌銆愬櫒鍏风紪鍙枫�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鍣ㄥ叿鍒嗙被")) + error += "娌℃湁鎵惧埌銆愬櫒鍏峰垎绫汇�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鍣ㄥ叿瑙勬牸")) + error += "娌℃湁鎵惧埌銆愬櫒鍏疯鏍笺�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鍣ㄥ叿鍨嬪彿")) + error += "娌℃湁鎵惧埌銆愬櫒鍏峰瀷鍙枫�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("绌存暟")) + error += "娌℃湁鎵惧埌銆愮┐鏁般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("杈呭姪灞炴��1")) + error += "娌℃湁鎵惧埌銆愯緟鍔╁睘鎬�1銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("杈呭姪灞炴��2")) + error += "娌℃湁鎵惧埌銆愯緟鍔╁睘鎬�2銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鍥惧彿")) + error += "娌℃湁鎵惧埌銆愬浘鍙枫�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("瀵瑰簲ERP鐗╂枡浠g爜")) + error += "娌℃湁鎵惧埌銆愬搴擡RP鐗╂枡浠g爜銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("瀵瑰簲ERP鐗╂枡")) + error += "娌℃湁鎵惧埌銆愬搴擡RP鐗╂枡銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("璁¢噺鍗曚綅")) + error += "娌℃湁鎵惧埌銆愯閲忓崟浣嶃�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鍣ㄥ叿鍑哄巶缂栧彿")) + error += "娌℃湁鎵惧埌銆愬櫒鍏峰嚭鍘傜紪鍙枫�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("浣跨敤閮ㄩ棬")) + error += "娌℃湁鎵惧埌銆愪娇鐢ㄩ儴闂ㄣ�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鐘舵��")) + error += "娌℃湁鎵惧埌銆愮姸鎬併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("榛樿浠撳簱")) + error += "娌℃湁鎵惧埌銆愰粯璁や粨搴撱�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("榛樿浠撲綅")) + error += "娌℃湁鎵惧埌銆愰粯璁や粨浣嶃�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鐗堟湰鍙�")) + error += "娌℃湁鎵惧埌銆愮増鏈彿銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("璁捐瀵垮懡")) + error += "娌℃湁鎵惧埌銆愯璁″鍛姐�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("浣跨敤瀵垮懡")) + 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 HMouldName = ""; + string HMouldNum = ""; + string HORGNumber = ""; + string HORGName = ""; + string HMaterNumber = ""; + string HMaterName = ""; + string HUnitName = ""; + string HDeptName = ""; + string HWHName = ""; + string HSPName = ""; + string HSupName = ""; + string HSupNumber = ""; + string HMadeSupName = ""; + string HMouldTypeName = ""; + + HMouldName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍣ㄥ叿鍚嶇О"].ToString()); + HMouldNum = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍣ㄥ叿缂栧彿"].ToString()); + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐浠g爜"].ToString()); + HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐鍚嶇О"].ToString()); + HMaterNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀵瑰簲ERP鐗╂枡浠g爜"].ToString()); + HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瀵瑰簲ERP鐗╂枡"].ToString()); + HUnitName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅"].ToString()); + HDeptName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["浣跨敤閮ㄩ棬"].ToString()); + HWHName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撳簱"].ToString()); + HSPName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["榛樿浠撲綅"].ToString()); + HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟�"].ToString()); + HSupNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString()); + HMadeSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍒堕�犲晢"].ToString()); + HMouldTypeName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鍣ㄥ叿鍒嗙被"].ToString()); + //妫�鏌ョ墿鏂� + int index = i + 1; + + if (HORGNumber != "") + { + + //鏌ヨ缁勭粐 + ds = oCN.RunProcReturn("select * from Xt_ORGANIZATIONS where HNumber='" + HORGNumber + "' and Hname='" + HORGName + "'", "Xt_ORGANIZATIONS"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,缁勭粐涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HOrgID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + string HORGid = ds.Tables[0].Rows[0]["HItemID"].ToString(); + //鏌ヨ鍒嗙被 + ds = oCN.RunProcReturn("select * from Gy_MouldType where HName='" + HMouldTypeName + "' ", "Gy_MouldType"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,鍒嗙被:" + HMouldTypeName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HMouldTypeID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鏌ヨ鐗╂枡 + ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterNumber + "' and HUSEORGID=" + HORGid + "", "Gy_Department"); + + if (ds.Tables[0].Rows.Count == 0 && HMaterNumber != "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鐗╂枡:" + HMaterName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else if (HMaterNumber == "") + { + tb2.Rows[i]["HMaterID"] = 0; + } + else + { + tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鏌ヨ鍗曚綅 + ds = oCN.RunProcReturn("select * from Gy_Unit where HName='" + HUnitName + "' and HUSEORGID=" + HORGid + "", "Gy_Unit"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍗曚綅:" + HUnitName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鏌ヨ閮ㄩ棬 + ds = oCN.RunProcReturn("select * from Gy_Department where HName='" + HDeptName + "' and HUSEORGID=" + HORGid + "", "Gy_Department"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,閮ㄩ棬:" + HDeptName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HDeptID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鏌ヨ浠撳簱 + ds = oCN.RunProcReturn("select * from Gy_Warehouse where HName='" + HWHName + "' and HUSEORGID=" + HORGid + "", "Gy_Warehouse"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撳簱:" + HWHName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HWHID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + string HWHID = tb2.Rows[i]["HWHID"].ToString(); + //鏌ヨ浠撲綅 + ds = oCN.RunProcReturn("select * from Gy_StockPlace where HName='" + HSPName + "'and HSPGroupID=" + HWHID+ " and HUSEORGID=" + HORGid + "", "Gy_Warehouse"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,浠撲綅:" + HSPName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HSPID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鏌ヨ渚涘簲鍟� + ds = oCN.RunProcReturn("select * from Gy_Supplier where HNumber='" + HSupNumber + "' and HUSEORGID=" + HORGid + "", "Gy_Supplier"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,渚涘簲鍟�:" + HSupName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + //鏌ヨ鍒堕�犲晢 + ds = oCN.RunProcReturn("select * from Gy_Supplier where HName='" + HMadeSupName + "' and HUSEORGID=" + HORGid + "", "Gy_Supplier"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鍒堕�犲晢:" + HMadeSupName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HMadeSupID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + + //鍣ㄥ叿妗f鍚嶇О + if (HMouldName == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,鍣ㄥ叿妗f鍚嶇О涓嶈兘涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //鍣ㄥ叿妗f浠g爜 + if (HMouldNum == "") + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "绗�" + index + "琛�,鍣ㄥ叿妗f浠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 鍣ㄥ叿妗f椤圭洰 瀵煎叆(淇濆瓨) + [Route("Gy_MouldFile/Gy_MouldFile_btnSave")] + [HttpPost] + public object Gy_Mould_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_MouldFile_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 BillType = "3899"; + //寰楀埌mainid + long HInterID = DBUtility.ClsPub.CreateBillID(BillType, ref DBUtility.ClsPub.sExeReturnInfo); + string HBillNo = DBUtility.ClsPub.CreateBillCode(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true); ;//閫掑叆type寰楀埌鐨勫崟鎹彿 + DateTime HDate = DateTime.Now;//鏃ユ湡 + int HYear = DBUtility.ClsPub.isInt(DateTime.Now.Year); + double HPeriod = DBUtility.ClsPub.isLong(DateTime.Now.Month); + string HMouldNo = item["鍣ㄥ叿缂栧彿"].ToString(); + string HBarCode = item["鏉″舰鐮�"].ToString(); + string HName = item["鍣ㄥ叿鍚嶇О"].ToString(); + string HModel = item["鍣ㄥ叿瑙勬牸"].ToString(); + string HModel2 = item["鍣ㄥ叿鍨嬪彿"].ToString(); + string HDiameter = "";//鐩村緞 + string HSubjoin = item["杈呭姪灞炴��1"].ToString(); + string HSubjoin2 = item["杈呭姪灞炴��2"].ToString(); + string HPICNo = item["鍥惧彿"].ToString(); + string HWorkMaterModel = "";//鐢熶骇浜у搧鍨嬪彿 + long HMaterID = int.Parse(item["HMaterID"].ToString()); + long HMouleTypeID = int.Parse(item["HMouldTypeID"].ToString()); + long HUnitID = int.Parse(item["HUnitID"].ToString()); + DateTime HOutComDate = DateTime.Now; + string HOutComNo = item["鍣ㄥ叿鍑哄巶缂栧彿"].ToString(); + long HDeptID = int.Parse(item["HDeptID"].ToString()); + long HSupID = int.Parse(item["HSupID"].ToString()); + string HMouldStatus = item["鐘舵��"].ToString(); + long HWHID = int.Parse(item["HWHID"].ToString()); + long HRoutingID = 0;//宸ヨ壓璺嚎id + long HBOMID = 0; + string HVersion = "";//鐗堟湰 + long HSPGroupID = 0;//榛樿浠撲綅缁� + long HSPID = int.Parse(item["HSPID"].ToString());//浠撲綅id + Double HDesignLife = item["璁捐瀵垮懡"].ToString()=="" ? 0: double.Parse(item["璁捐瀵垮懡"].ToString()); + Double HUseLife = item["浣跨敤瀵垮懡"].ToString() == "" ? 0 : double.Parse(item["浣跨敤瀵垮懡"].ToString()); + Double HInitLife = 0;//涓婄嚎鍒濆鍖栧鍛� + Double HLeaveLife = 0;//鍓╀綑瀵垮懡 + Double HProdQty = 0;//宸茬敓浜ф暟閲� + Double HProdWeight = 0;//宸茬敓浜ч噸閲� + string HRemark = item["澶囨敞"].ToString(); + string HMaker = user; + string HMaterNumber = item["瀵瑰簲ERP鐗╂枡浠g爜"].ToString(); + string HSupNumber = item["渚涘簲鍟嗕唬鐮�"].ToString(); + long HPrintQty = 0;//宸茬敓浜ф暟閲� + string HMouldOWNER = "鑷垂";//璐т富绫诲瀷 + string HSaveLife = "";//瀹夊叏瀵垮懡 + int HCaveQty = item["绌存暟"].ToString() == "" ? 0 : int.Parse(item["绌存暟"].ToString()); + int HMouldDotCheckRuleInterID = 0; + int HMouldMaintainRuleInterID = 0; + int HNowSupID = 0;//铏氭嫙浠� + int HNowSupTypeID = 0; + int HMadeSupID = 0; + string HMouldClass = "妯″叿";//鍣ㄥ叿绫诲瀷 + int HNowWHID = 0; + int HNowSPID = 0; + + + if (!DBUtility.ClsPub.AllowNumber(HMouldNo.Trim())) + { + objJsonResult.code = CodeConstant.FAIL; + objJsonResult.count = CountConstant.FAIL; + objJsonResult.Message = "淇濆瓨澶辫触锛佷唬鐮佷腑涓嶈兘鍑虹幇杩炵画鈥�.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = 1; + return objJsonResult; + } + + ds = oCN.RunProcReturn("select * from Gy_MouldFileMain where HMouldNo='" + HMouldNo + "'", "Gy_MouldFileMain"); + + if (ds.Tables[0].Rows.Count == 0) + { + + oCN.RunProc("Insert Into Gy_MouldFileMain " + + "(HBillType,HBillSubType,HInterID,HBillNo,HDate" + + ",HYear,HPeriod,HRemark,HMaker,HMakeDate" + + ",HMouldNo,HName,HModel,HModel2,HDiameter" + + ",HSubjoin,HSubjoin2,HPICNo,HWorkMaterModel" + + ",HMaterID,HMaterNumber,HMouldType,HUnitID" + + ",HOutComDate,HOutComNo,HDeptID,HSupID,HSupNumber" + + ",HPrintQty,HMouldStatus,HWhID,HRoutingID,HCaveQty" + + ",HBomID,HVersion,HSPGroupID,HSPID,HDesignLife,HNowSupID,HNowSupTypeID" + + ",HUseLife,HLeaveLife,HProdQty,HProdWeight,HMouldOWNER,HSaveLife,HMouldDotCheckRuleInterID,HMouldMaintainRuleInterID,HBarCode,HMadeSupID" + + ",HMouldClass,HNowWHID,HNowSPID,HInitLife) " + + " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "','" + HDate + "'" + + "," + HYear + "," + HPeriod + ",'" + HRemark + "','" + HMaker + "',getdate()" + + ",'" + HMouldNo + "','" + HName + "','" + HModel + "','" + HModel2 + "','" + HDiameter + "'" + + ",'" + HSubjoin + "','" + HSubjoin2 + "','" + HPICNo + "','" + HWorkMaterModel + "'" + + "," + HMaterID + ",'" + HMaterNumber + "'," + HMouleTypeID + "," + HUnitID + + ",'" + HOutComDate + "','" + HOutComNo + "'," + HDeptID + "," + HSupID + ",'" + HSupNumber + "'" + + "," + HPrintQty + ",'" + HMouldStatus + "'," + HWHID + "," + HRoutingID + "," + HCaveQty + + "," + HBOMID + ",'" + HVersion + "'," + HSPGroupID + "," + HSPID + ",'" + HDesignLife + "','" + HNowSupID + "','" + HNowSupTypeID + "'" + + ",'" + HUseLife + "','" + HLeaveLife + "','" + HProdQty + "','" + HProdWeight + "','" + HMouldOWNER + "','" + HSaveLife + "','" + HMouldDotCheckRuleInterID + "','" + HMouldMaintainRuleInterID + "','" + HBarCode + "'," + HMadeSupID + + ",'" + HMouldClass + "'," + HNowWHID + "," + HNowSPID + ",'" + HInitLife + "') "); + } + else + { + oCN.RunProc("UpDate Gy_MouldFileMain set " + + //" HBillNo='" + HBillNo + "'" + //鍥哄畾璧嬪��=============== + //",HDate='" + HDate + "'" + + //",HYear='" + HYear.ToString() + "'" + + //",HPeriod='" + HPeriod.ToString() + "'" + + "HRemark='" + HRemark + "'" + + ",HUpDater='" + user + "'" + + ",HUpDateDate=getdate()" + + //======================================== + //",HMouldNo='" + HMouldNo + "'" + + ",HName='" + HName + "'" + + ",HModel='" + HModel + "'" + + ",HModel2='" + HModel2 + "'" + + ",HDiameter='" + HDiameter + "'" + + ",HSubjoin='" + HSubjoin + "'" + + ",HSubjoin2='" + HSubjoin2 + "'" + + ",HPICNo='" + HPICNo + "'" + + ",HWorkMaterModel='" + HWorkMaterModel + "'" + + ",HMaterID=" + HMaterID.ToString() + + ",HMaterNumber='" + HMaterNumber + "'" + + ",HMouldClass='" + HMouldClass + "'" + + ",HMouldType=" + HMouleTypeID.ToString() + + ",HUnitID=" + HUnitID.ToString() + + ",HOutComDate='" + HOutComDate + "'" + + ",HOutComNo='" + HOutComNo + "'" + + ",HDeptID=" + HDeptID.ToString() + + ",HSupID=" + HSupID.ToString() + + ",HSupNumber='" + HSupNumber + "'" + + ",HPrintQty=" + HPrintQty.ToString() + + ",HMouldStatus='" + HMouldStatus + "'" + + ",HSaveLife='" + HSaveLife + "'" + + ",HWhID=" + HWHID.ToString() + + ",HRoutingID=" + HRoutingID.ToString() + + ",HBomID=" + HBOMID.ToString() + + ",HVersion='" + HVersion + "'" + + ",HSPGroupID=" + HSPGroupID.ToString() + + ",HSPID=" + HSPID.ToString() + + ",HDesignLife=" + HDesignLife.ToString() + + ",HCaveQty=" + HCaveQty.ToString() + + ",HUseLife=" + HUseLife.ToString() + + ",HLeaveLife=" + HLeaveLife.ToString() + + ",HProdQty=" + HProdQty.ToString() + + ",HMouldDotCheckRuleInterID=" + HMouldDotCheckRuleInterID.ToString() + + ",HMouldMaintainRuleInterID=" + HMouldMaintainRuleInterID.ToString() + + ",HMouldOWNER='" + HMouldOWNER + "'" + + ",HNowSupID=" + HNowSupID.ToString() + + ",HNowSupTypeID=" + HNowSupTypeID.ToString() + + ",HProdWeight=" + HProdWeight.ToString() + + ",HBarCode='" + HBarCode.ToString() + "'" + + ",HMadeSupID=" + HMadeSupID + + ",HNowWHID=" + HNowWHID + + ",HNowSPID=" + HNowSPID + + ",HInitLife='" + HInitLife + + "' where HMouldNo='" + HMouldNo.ToString()+"'"); + } + + 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 + } } \ No newline at end of file -- Gitblit v1.9.1