From 23dbc5b616dfa1a2bcb1fa4302637b8df701f43c Mon Sep 17 00:00:00 2001 From: yxj <yxj@hz-kingdee.com> Date: 星期四, 24 四月 2025 13:27:12 +0800 Subject: [PATCH] 1 --- WebAPI/Controllers/SCGL/日计划管理/Sc_JIT_ComplementGoodBillController.cs | 555 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 499 insertions(+), 56 deletions(-) diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs" index fe4355d..5630795 100644 --- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs" +++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/Sc_JIT_ComplementGoodBillController.cs" @@ -719,11 +719,11 @@ string JIDLT = ""; //JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級 string JIMLC = ""; //JIT鏈�灏忚捣閫侀噺 - HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐缂栫爜"].ToString()); + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐缂栫爜"].ToString()).Replace("'", ""); HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐"].ToString()); - HSupNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString()); + HSupNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString()).Replace("'", ""); HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟�"].ToString()); - HMaterNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString()); + HMaterNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString()).Replace("'", ""); HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString()); HMaterModel = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瑙勬牸鍨嬪彿"].ToString()); HUntilName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["璁¢噺鍗曚綅"].ToString()); @@ -807,66 +807,82 @@ tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); } - //JIT鐗╂枡鍒嗙被 - if (JITType == "") + string msg = ""; + oSystemParameter.ShowBill(ref msg); + if (oSystemParameter.omodel.WMS_CampanyName == "瀹濆伐"|| oSystemParameter.omodel.WMS_CampanyName == "涓夊崌") { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "绗�" + index + "琛�,JIT鐗╂枡鍒嗙被涓虹┖锛�"; - objJsonResult.data = null; - return objJsonResult; + //JIT渚涜揣鎻愬墠鏈燂紙澶╋級 + if (JISLT == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT渚涜揣鎻愬墠鏈燂紙澶╋級涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } } - - //JIT鎻愯揣缁忔祹鎵归噺 - if (JIPEB == "") + else { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "绗�" + index + "琛�,JIT鎻愯揣缁忔祹鎵归噺涓虹┖锛�"; - objJsonResult.data = null; - return objJsonResult; - } + //JIT鐗╂枡鍒嗙被 + if (JITType == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT鐗╂枡鍒嗙被涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } - //JIT渚涜揣鎻愬墠鏈燂紙澶╋級 - if (JISLT == "") - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "绗�" + index + "琛�,JIT渚涜揣鎻愬墠鏈燂紙澶╋級涓虹┖锛�"; - objJsonResult.data = null; - return objJsonResult; - } + //JIT鎻愯揣缁忔祹鎵归噺 + if (JIPEB == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT鎻愯揣缁忔祹鎵归噺涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } - //JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級 - if (JIDLT == "") - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "绗�" + index + "琛�,JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級涓虹┖锛�"; - objJsonResult.data = null; - return objJsonResult; - } + //JIT渚涜揣鎻愬墠鏈燂紙澶╋級 + if (JISLT == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT渚涜揣鎻愬墠鏈燂紙澶╋級涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } - //JIT鏈�灏忚捣閫侀噺 - if (JIMLC == "") - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "绗�" + index + "琛�,JIT鏈�灏忚捣閫侀噺涓虹┖锛�"; - objJsonResult.data = null; - return objJsonResult; - } + //JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級 + if (JIDLT == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } - //瀹℃牳浠g爜鏄惁鍚堢悊 - if (!DBUtility.ClsPub.AllowNumber(HMaterNumer)) - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; - objJsonResult.data = null; - return objJsonResult; - } + //JIT鏈�灏忚捣閫侀噺 + if (JIMLC == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT鏈�灏忚捣閫侀噺涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + //瀹℃牳浠g爜鏄惁鍚堢悊 + if (!DBUtility.ClsPub.AllowNumber(HMaterNumer)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = null; + return objJsonResult; + } + } } else { @@ -967,7 +983,7 @@ "HLeadTime, HLeadTime_Sec, HDeliveryMode, HDeliveryDaysCtrl,HUnitID,HJITMinDeliveryQty)values" + $"({HInterID}, 1, '{HRemark}', {(HSupID == "" ? "0" : HSupID)}, '{HSupplierName}', {(HMaterID == "" ? "0" : HMaterID)}," + $" '{HMaterName}', '{HMaterModel}', '{JITType}', {(JITPSL == "" ? "0" : JITPSL)}, {(JITMDSC == "" ? "0" : JITMDSC)},{(JIPEB == "" ? "0" : JIPEB)},{(JITPBCC == "" ? "0" : JITPBCC)}," + - $" {(JISLT == "" ? "0" : JISLT)}, {(JIDLT == "" ? "0" : JIDLT)}, '', {(JITDCD == "" ? "0" : JITDCD)} ,{HUnitID},{JIMLC})"; + $" {(JISLT == "" ? "0" : JISLT)}, {(JIDLT == "" ? "0" : JIDLT)}, '', {(JITDCD == "" ? "0" : JITDCD)} ,{HUnitID},{(JIMLC==""?"0": JIMLC)})"; //涓昏〃 oCN.RunProc(sql); //瀛愯〃 @@ -1283,6 +1299,433 @@ } #endregion + #region 鎻愭枡璁″垝淇℃伅 鏂囦欢涓婁紶 + [Route("Sc_JIT_ComplementGoodBill/Sc_JIT_ComplementGoodBill_Excel")] + [HttpPost] + public object Sc_JIT_ComplementGoodBill_Excel() + { + try + { + //var WorkBookName = HttpContext.Current.Request["WorkBookName"]; + //DBUtility.ClsPub.HOrgID = long.Parse(HttpContext.Current.Request["HOrgID"]); + //鑾峰彇鏂囦欢鍚嶇О + 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("HWorkShopID", typeof(Int32));//渚涘簲鍟� + tb2.Columns.Add("HMaterID", 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 + if (ExcelDs.Tables[0].Rows[i][0].ToString() == "") + { + continue; + } + else + { + tb2.Rows.Add(row); + } + } + + + var 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("鐗╂枡浠g爜")) + error += "娌℃湁鎵惧埌銆愮墿鏂欎唬鐮併�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("鐗╂枡鍚嶇О")) + error += "娌℃湁鎵惧埌銆愮墿鏂欏悕绉般�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("瑙勬牸鍨嬪彿")) + error += "娌℃湁鎵惧埌銆愯鏍煎瀷鍙枫�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("JIT鐗╂枡鍒嗙被")) + error += "娌℃湁鎵惧埌銆怞IT鐗╂枡鍒嗙被銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("JIT鎷夊姩瀹夊叏搴撳瓨閲�")) + error += "娌℃湁鎵惧埌銆怞IT鎷夊姩瀹夊叏搴撳瓨閲忋�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("JIT鐗╂枡闇�姹備緵璐у懆鏈�")) + error += "娌℃湁鎵惧埌銆怞IT鐗╂枡闇�姹備緵璐у懆鏈熴�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("JIT鎻愯揣鎵归噺")) + error += "娌℃湁鎵惧埌銆怞IT鎻愯揣鎵归噺銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("JIT鎻愯揣鎵归噺瀵瑰簲鍛ㄦ湡锛堝ぉ锛�")) + error += "娌℃湁鎵惧埌銆怞IT鎻愯揣鎵归噺瀵瑰簲鍛ㄦ湡锛堝ぉ锛夈�戠殑鏍囬,"; + + if (!tb2.Columns.Contains("JIT渚涜揣鎻愬墠鏈燂紙澶╋級")) + error += "娌℃湁鎵惧埌銆怞IT渚涜揣鎻愬墠鏈燂紙澶╋級銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級")) + error += "娌℃湁鎵惧埌銆怞IT鍒拌揣鍓嶇疆鏈燂紙澶╋級銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("JIT閫佽揣鎺у埗澶╂暟")) + error += "娌℃湁鎵惧埌銆怞IT閫佽揣鎺у埗澶╂暟銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("JIT閫佽揣鏂瑰紡")) + error += "娌℃湁鎵惧埌銆怞IT閫佽揣鏂瑰紡銆戠殑鏍囬,"; + + if (!tb2.Columns.Contains("澶囨敞")) + error += "娌℃湁鎵惧埌銆愬娉ㄣ�戠殑鏍囬,"; + + if (error.Length > 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"Excel妯℃澘瀛樺湪閿欒,{error}\r\n"; + objJsonResult.data = null; + return objJsonResult; + } + + for (int i = 0; i <= tb2.Rows.Count - 1; i++) + { + string HORGNumber = ""; + string HORGName = ""; + string HWorkShopNumer = ""; + string HWorkShopName = ""; + string HMaterNumer = ""; + string HMaterName = ""; + string HMaterModel = ""; + string HUntilName = ""; + + string JITType = "";//JIT鐗╂枡鍒嗙被 + string JIPEB = ""; //JIT鎻愯揣缁忔祹鎵归噺 + string JISLT = ""; //JIT渚涜揣鎻愬墠鏈燂紙澶╋級 + string JIDLT = ""; //JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級 + string JIMLC = ""; //JIT鏈�灏忚捣閫侀噺 + + HORGNumber = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐缂栫爜"].ToString()).Replace("'",""); + HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐"].ToString()); + HWorkShopNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["杞﹂棿浠g爜"].ToString()).Replace("'", ""); + HWorkShopName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["杞﹂棿"].ToString()); + HMaterNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString()).Replace("'", ""); + HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString()); + HMaterModel = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瑙勬牸鍨嬪彿"].ToString()); + + JITType = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT鐗╂枡鍒嗙被"].ToString()); + JIPEB = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT鎻愯揣鎵归噺"].ToString()); + JISLT = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT渚涜揣鎻愬墠鏈燂紙澶╋級"].ToString()); + JIDLT = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級"].ToString()); + JIMLC = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["JIT閫佽揣鏂瑰紡"].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 = "0"; + objJsonResult.count = 0; + 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_Department where HNumber='" + HWorkShopNumer + "' and HUSEORGID=" + HORGid + "", "Gy_Department"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,杞﹂棿:" + HWorkShopName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HWorkShopID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + + //鏌ヨ鐗╂枡 + ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterNumer + "' and HUSEORGID=" + HORGid + "", "Gy_Material"); + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,鐗╂枡:" + HMaterName + ",鐗╂枡浠g爜:" + HMaterNumer + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + + string msg = ""; + oSystemParameter.ShowBill(ref msg); + if (oSystemParameter.omodel.WMS_CampanyName == "瀹濆伐") + { + //JIT渚涜揣鎻愬墠鏈燂紙澶╋級 + if (JISLT == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT渚涜揣鎻愬墠鏈燂紙澶╋級涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級 + if (JIDLT == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + } + else + { + //JIT鐗╂枡鍒嗙被 + if (JITType == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT鐗╂枡鍒嗙被涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //JIT鎻愯揣鎵归噺 + if (JIPEB == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT鎻愯揣鎵归噺涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //JIT渚涜揣鎻愬墠鏈燂紙澶╋級 + if (JISLT == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT渚涜揣鎻愬墠鏈燂紙澶╋級涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級 + if (JIDLT == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //JIT鏈�灏忚捣閫侀噺 + if (JIMLC == "") + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,JIT閫佽揣鏂瑰紡涓虹┖锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + //瀹℃牳浠g爜鏄惁鍚堢悊 + if (!DBUtility.ClsPub.AllowNumber(HMaterNumer)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,鐗╂枡浠g爜涓笉鑳藉嚭鐜拌繛缁��.鈥欏苟涓旈浣嶆湯浣嶄笉鑳戒负鈥�.鈥欙紒"; + objJsonResult.data = null; + return objJsonResult; + } + } + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,缁勭粐浠g爜涓虹┖"; + objJsonResult.data = null; + return objJsonResult; + } + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = error; + objJsonResult.data = tb2; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 瑕佹枡璁″垝淇℃伅 瀵煎叆(淇濆瓨) + [Route("Sc_JIT_ComplementGoodBill/Sc_JIT_ComplementGoodBill_btnSave")] + [HttpPost] + public object Sc_JIT_ComplementGoodBill_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("JIT_NeedMaterPlanConfigBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + 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 HWorkShopID = item["HWorkShopID"].ToString();//杞﹂棿 + string HMaterID = item["HMaterID"].ToString();//鐗╂枡ID + string HOrgID = item["HOrgID"].ToString();//缁勭粐ID + string HWorkShopName = item["杞﹂棿"].ToString(); + string HMaterName = item["鐗╂枡鍚嶇О"].ToString(); + string HMaterModel = item["瑙勬牸鍨嬪彿"].ToString(); + string JITType = item["JIT鐗╂枡鍒嗙被"].ToString(); + string JITPSL = item["JIT鎷夊姩瀹夊叏搴撳瓨閲�"].ToString(); + string JITMDSC = item["JIT鐗╂枡闇�姹備緵璐у懆鏈�"].ToString(); + string JIPEB = item["JIT鎻愯揣鎵归噺"].ToString(); + string JITPBCC = item["JIT鎻愯揣鎵归噺瀵瑰簲鍛ㄦ湡锛堝ぉ锛�"].ToString(); + string JISLT = item["JIT渚涜揣鎻愬墠鏈燂紙澶╋級"].ToString(); + string JIDLT = item["JIT鍒拌揣鍓嶇疆鏈燂紙澶╋級"].ToString(); + string JITDCD = item["JIT閫佽揣鎺у埗澶╂暟"].ToString(); + string JIMLC = item["JIT閫佽揣鏂瑰紡"].ToString(); + string HRemark = item["澶囨敞"].ToString(); + + ds = oCN.RunProcReturn("select * from JIT_NeedMaterPlanConfigBillSub where HMaterID=" + HMaterID + " and HWorkShopID=" + HWorkShopID, "JIT_NeedMaterPlanConfigBillSub"); + + if (ds.Tables[0].Rows.Count == 0) + { + + long HInterID = DBUtility.ClsPub.CreateBillID_Prod("4615", ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d + string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("4615", ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿 + + + string sql = "insert into JIT_NeedMaterPlanConfigBillMain" + + "(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" + + $"values({HInterID}, '{HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '4615', '4615', GETDATE(), 1, '{user}', GETDATE(), {HOrgID})"; + string sql1 = "insert into JIT_NeedMaterPlanConfigBillSub(HInterID,HEntryID,HRemark,HWorkShopID,HWorkShopName,HMaterID," + + "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " + + "HLeadTime, HLeadTime_Sec, HDeliveryDaysCtrl, HDeliveryMode) values" + + $"({HInterID}, 1, '{HRemark}', {(HWorkShopID == "" ? "0" : HWorkShopID)}, '{HWorkShopName}', {(HMaterID == "" ? "0" : HMaterID)}," + + $" '{HMaterName}', '{HMaterModel}', '{JITType}', {(JITPSL == "" ? "0" : JITPSL)}, {(JITMDSC == "" ? "0" : JITMDSC)},{(JIPEB == "" ? "0" : JIPEB)},{(JITPBCC == "" ? "0" : JITPBCC)}," + + $" {(JISLT == "" ? "0" : JISLT)}, {(JIDLT == "" ? "0" : JIDLT)}, {(JITDCD == "" ? "0" : JITDCD)}, '{(JIMLC == "" ? "" : JIMLC)}')"; + + //涓昏〃 + oCN.RunProc(sql); + //瀛愯〃 + oCN.RunProc(sql1); + } + else + { + oCN.RunProc(" update JIT_NeedMaterPlanConfigBillMain set HLeadTime=" + JISLT + ",HLeadTime_Sec=" + JIDLT + " where HMaterID=" + HMaterID + " and HWorkShopID = " + HWorkShopID); + } + + i++; + } + + oCN.Commit(); + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "瀵煎叆鎴愬姛!"; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + LogService.Write(e); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion #endregion -- Gitblit v1.9.1