From 9a75f7db9431032c0f1ecc64be4966a25c74bafa Mon Sep 17 00:00:00 2001 From: duhe <226547893@qq.com> Date: 星期二, 05 十一月 2024 16:48:12 +0800 Subject: [PATCH] 1 --- WebAPI/Controllers/SCGL/日计划管理/Sc_JIT_ComplementGoodBillController.cs | 485 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 466 insertions(+), 19 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 1ae15f5..142d610 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" @@ -1,11 +1,14 @@ 锘縰sing DBUtility; +using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Data; +using System.IO; using System.Linq; using System.Web; using System.Web.Http; +using WebAPI.Controllers.SCGL.鏃ヨ鍒掔鐞�; using WebAPI.Models; namespace WebAPI.Controllers.SCGL @@ -19,6 +22,7 @@ private json objJsonResult = new json(); SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); DataSet ds; + Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); #region 鏃ヨ鍒掑钩鍙板熀纭�璧勬枡 杞﹂棿浠撳簱瀵圭収 @@ -29,6 +33,7 @@ { try { + List<object> a = new List<object>(); //鏌ヨ鏉冮檺 if (!DBUtility.ClsPub.Security_Log_second("JIT_ComplementGoodBill_Query", 1, false, user)) { @@ -40,11 +45,17 @@ } ds = oCN.RunProcReturn("select * from h_v_JIT_Gy_WorkWarehouseBillList where 1=1 " + sWhere + " order by hmainid desc ", "h_v_JIT_Gy_WorkWarehouseBillList"); - + foreach (DataColumn col in ds.Tables[0].Columns)//閬嶅巻ds涓涓�涓〃锛圱ables[0]锛夌殑鎵�鏈夊垪锛圕olumns锛夋瘡娆″惊鐜腑锛宑ol鍙橀噺浼氭寔鏈夊綋鍓嶅垪鐨勫紩鐢� + { + Type dataType = col.DataType; //鑾峰彇褰撳墠鏁版嵁绫诲瀷浼犲叆 鑷畾涔夊彉閲廳atadataType + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //瀛楃涓叉嫾鎺� // 灏嗗垪鍚嶅拰鏁版嵁绫诲瀷淇℃伅鎷兼帴鎴愪竴涓狫SON鏍煎紡鐨勫瓧绗︿覆 + a.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess锛�"; objJsonResult.data = ds.Tables[0]; + objJsonResult.list = a; return objJsonResult; } catch (Exception e) @@ -289,6 +300,7 @@ { try { + List<object> A = new List<object>(); //鏌ヨ鏉冮檺 if (!DBUtility.ClsPub.Security_Log_second("Cg_PODemandPlanConfigBill_Query", 1, false, user)) { @@ -300,11 +312,18 @@ } ds = oCN.RunProcReturn("select * from h_v_JIT_Cg_PODemandPlanConfigBillList where 1=1 " + sWhere + " order by hmainid desc ", "h_v_JIT_Cg_PODemandPlanConfigBillList"); - + foreach (DataColumn col in ds.Tables[0].Columns)//閬嶅巻ds涓涓�涓〃锛圱ables[0]锛夌殑鎵�鏈夊垪锛圕olumns锛夋瘡娆″惊鐜腑锛宑ol鍙橀噺浼氭寔鏈夊綋鍓嶅垪鐨勫紩鐢� + { + Type dataType = col.DataType; //鑾峰彇褰撳墠鏁版嵁绫诲瀷浼犲叆 鑷畾涔夊彉閲廳atadataType + string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}"; //瀛楃涓叉嫾鎺� // 灏嗗垪鍚嶅拰鏁版嵁绫诲瀷淇℃伅鎷兼帴鎴愪竴涓狫SON鏍煎紡鐨勫瓧绗︿覆 + A.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕 + } objJsonResult.code = "1"; objJsonResult.count = 1; objJsonResult.Message = "Sucess锛�"; objJsonResult.data = ds.Tables[0]; + objJsonResult.list = A; + return objJsonResult; } catch (Exception e) @@ -417,6 +436,8 @@ public json AddPODBillSub(string msg3) { + string Ret = ""; + oSystemParameter.ShowBill(ref Ret); omodelPODsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Cg_PODemandPlanConfigBillSub>>(msg3); foreach (Models.Cg_PODemandPlanConfigBillSub oSub in omodelPODsub) @@ -445,21 +466,25 @@ objJsonResult.data = null; return objJsonResult; } - if (oSub.HLeadTime_Sec == 0 || oSub.HLeadTime_Sec == null) + + if (oSystemParameter.omodel.WMS_CampanyName != "甯呭▉") { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = " JIT鍒拌揣鍓嶇疆鏈熶笉鑳戒负绌�"; - objJsonResult.data = null; - return objJsonResult; - } - if (oSub.HDeliveryDaysCtrl == 0 || oSub.HDeliveryDaysCtrl == null) - { - objJsonResult.code = "0"; - objJsonResult.count = 0; - objJsonResult.Message = " JIT閫佽揣鎺у埗澶╂暟涓嶈兘涓虹┖"; - objJsonResult.data = null; - return objJsonResult; + if (oSub.HLeadTime_Sec == 0 || oSub.HLeadTime_Sec == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = " JIT鍒拌揣鍓嶇疆鏈熶笉鑳戒负绌�"; + objJsonResult.data = null; + return objJsonResult; + } + if (oSub.HDeliveryDaysCtrl == 0 || oSub.HDeliveryDaysCtrl == null) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = " JIT閫佽揣鎺у埗澶╂暟涓嶈兘涓虹┖"; + objJsonResult.data = null; + return objJsonResult; + } } } @@ -548,6 +573,428 @@ objJsonResult.code = "0"; objJsonResult.count = 0; objJsonResult.Message = e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + #endregion + + #region 鎻愭枡璁″垝淇℃伅 鏂囦欢涓婁紶 + [Route("Cg_PODemandPlanConfigBill/Cg_PODemandPlanConfigBill_Excel")] + [HttpPost] + public object Cg_PODemandPlanConfigBill_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("HSupID", typeof(Int32));//渚涘簲鍟� + tb2.Columns.Add("HMaterID", typeof(Int32));//鐗╂枡ID + tb2.Columns.Add("HUnitID", typeof(Int32));//璁¢噺鍗曚綅 + + //娣诲姞鏁版嵁 + 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("渚涘簲鍟嗕唬鐮�")) + error += "娌℃湁鎵惧埌銆愪緵搴斿晢浠g爜銆戠殑鏍囬,"; + + 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("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 HSupNumer = ""; + string HSupName = ""; + 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()); + HORGName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["缁勭粐"].ToString()); + HSupNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟嗕唬鐮�"].ToString()); + HSupName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["渚涘簲鍟�"].ToString()); + HMaterNumer = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡浠g爜"].ToString()); + HMaterName = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["鐗╂枡鍚嶇О"].ToString()); + HMaterModel = DBUtility.ClsPub.isStrNull(tb2.Rows[i]["瑙勬牸鍨嬪彿"].ToString()); + HUntilName = 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_Supplier where HNumber='" + HSupNumer + "' 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_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(); + } + + //鏌ヨ璁¢噺鍗曚綅 + ds = oCN.RunProcReturn("select * from Gy_Unit where HName='" + HUntilName + "' ", "Gy_Unit"); //and HUSEORGID=" + HORGid + " + + if (ds.Tables[0].Rows.Count == 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "绗�" + index + "琛�,璇�" + HORGName + "缁勭粐,璁¢噺鍗曚綅:"+ HUntilName + ",涓嶅瓨鍦紒"; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + + //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("Cg_PODemandPlanConfigBill/Cg_PODemandPlanConfigBill_btnSave")] + [HttpPost] + public object Cg_PODemandPlanConfigBill_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("Cg_PODemandPlanConfigBill_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 HSupID = item["HSupID"].ToString();//渚涘簲鍟� + string HMaterID = item["HMaterID"].ToString();//鐗╂枡ID + string HOrgID = item["HOrgID"].ToString();//缁勭粐ID + string HSupplierName = item["渚涘簲鍟�"].ToString(); + string HMaterName = item["鐗╂枡鍚嶇О"].ToString(); + string HMaterModel = item["瑙勬牸鍨嬪彿"].ToString(); + string HUnitID = item["HUnitID"].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 Cg_PODemandPlanConfigBillSub where HMaterID=" + HMaterID + " and HSupplierID=" + HSupID, "Cg_PODemandPlanConfigBillSub"); + + if (ds.Tables[0].Rows.Count == 0) + { + + long HInterID = DBUtility.ClsPub.CreateBillID_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d + string HBillNo = DBUtility.ClsPub.CreateBillCode_Prod("4611", ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿 + + + string sql = "insert into Cg_PODemandPlanConfigBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType,HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HOrgId)" + + $"values({HInterID}, '{HBillNo}',{DateTime.Now.Year}, {DateTime.Now.Month}, '4611', '4611', GETDATE(), 1, '{user}', GETDATE(), {HOrgID})"; + string sql1 = "insert into Cg_PODemandPlanConfigBillSub(HInterID,HEntryID,HRemark,HSupplierID,HSupplierName,HMaterID," + + "HMaterName, HMaterModel, HJITMaterGroup, HJITSafeStock, HJITMaterDemand, HJITBatchQty, HDeliveryPeriod, " + + "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})"; + //涓昏〃 + oCN.RunProc(sql); + //瀛愯〃 + oCN.RunProc(sql1); + } + else + { + oCN.RunProc(" update Cg_PODemandPlanConfigBillSub set HLeadTime=" + JISLT + " where HMaterID=" + HMaterID + " and HSupplierID=" + HSupID); + } + + 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; } @@ -697,13 +1144,13 @@ { omodelNeedsub = Newtonsoft.Json.JsonConvert.DeserializeObject<List<JIT_NeedMaterPlanConfigBillSub>>(msg3); - foreach (Models.Cg_PODemandPlanConfigBillSub oSub in omodelPODsub) + foreach (Models.JIT_NeedMaterPlanConfigBillSub oSub in omodelNeedsub) { - if (oSub.HSupplierID == 0 || oSub.HSupplierID == null) + if (oSub.HWorkShopID == 0 || oSub.HWorkShopID == null) { objJsonResult.code = "0"; objJsonResult.count = 0; - objJsonResult.Message = "渚涘簲鍟嗕笉鑳戒负绌�"; + objJsonResult.Message = "鐢熶骇杞﹂棿涓嶈兘涓虹┖"; objJsonResult.data = null; return objJsonResult; } -- Gitblit v1.9.1