From 1ce73b98043f2fd3f0262c8f85471e5888f486eb Mon Sep 17 00:00:00 2001 From: yusijie <ysj@hz-kingdee.com> Date: 星期四, 31 七月 2025 12:22:20 +0800 Subject: [PATCH] 排产计划查询中生产车间过滤字段改成字符串类型;凯贝添加excel导入日计划方法;凯贝提料运算改成和宝工一个方法;返修码生成模块添加机型码字段 --- WebAPI/Controllers/SCGL/日计划管理/JIT_DayPlanPlatFormBillController.cs | 6 WebAPI/Controllers/SCGL/日计划管理/JIT_DayPlanPlatFormImportController.cs | 406 ++++++++++++++++++++++++++++++++++++++++++++++++++ WarM/条码打印/Gy_BarCodeBill_Rework.cs | 7 WebAPI/Models/Sc_WorkBillSortBillMain.cs | 2 4 files changed, 415 insertions(+), 6 deletions(-) diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_Rework.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_Rework.cs" index 081fe4b..51987b0 100644 --- "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_Rework.cs" +++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_Rework.cs" @@ -27,7 +27,7 @@ public const Int16 HMaterIDCol = 6; public const Int16 HMaterNumberCol = 7; public const Int16 HMaterNameCol = 8; - public const Int16 HPinfanCol = 9; + public const Int16 HSubjoin2Col = 9; public const Int16 HMaterModelCol = 10; public const Int16 HAuxPropIDCol = 11; public const Int16 HAuxPropNumberCol = 12; @@ -77,6 +77,8 @@ public const Int16 HInnerBillNoCol = 56; public const Int16 HEndDateCol = 57; public const Int16 HSourceBillQtyCol = 58; + public const Int16 HPinfanCol = 59; + // public string ModName = "85"; public string ModCaption = "鏉$爜鐢熸垚"; @@ -803,7 +805,7 @@ private void initGrid() { grdMain.RowCount = 0; - grdMain.ColumnCount = 59; //鎬诲垪鏁� + grdMain.ColumnCount = 60; //鎬诲垪鏁� DBUtility.Xt_BaseBillFun.initGridFst(grdMain, this.Name); grdMain.Columns[HSnoCol].HeaderText = "搴忓彿"; grdMain.Columns[HMainIDCol].HeaderText = "婧愬崟涓籌D"; @@ -814,6 +816,7 @@ grdMain.Columns[HMaterNumberCol].HeaderText = "鐗╂枡浠g爜"; grdMain.Columns[HMaterNameCol].HeaderText = "鐗╂枡鍚嶇О"; grdMain.Columns[HMaterModelCol].HeaderText = "瑙勬牸鍨嬪彿"; + grdMain.Columns[HSubjoin2Col].HeaderText = "鏈哄瀷鐮�"; grdMain.Columns[HPinfanCol].HeaderText = "鍝佺暘"; grdMain.Columns[HUnitIDCol].HeaderText = "璁¢噺鍗曚綅ID"; grdMain.Columns[HUnitNumberCol].HeaderText = "璁¢噺鍗曚綅浠g爜"; diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs" index 219e637..4d7e1f7 100644 --- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs" +++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormBillController.cs" @@ -43,7 +43,7 @@ omdelMian = JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(sWhere); ds = oCN.RunProcReturn($"exec h_p_JIT_Sc_WorkBillSortBill_Query '{omdelMian.HPlanBeginDate}',{(omdelMian.HProdORGID == null ? 0 : omdelMian.HProdORGID)},'{omdelMian.HSeOrderBillNo}'" + - $",'{omdelMian.HPlanEndDate.AddDays(1)}',{omdelMian.HMaterID},'{omdelMian.HICMOBillNo}',{omdelMian.HWorkShopID}" + + $",'{omdelMian.HPlanEndDate.AddDays(1)}',{omdelMian.HMaterID},'{omdelMian.HICMOBillNo}','{omdelMian.HWorkShopID}'" + $",'{omdelMian.HMastersDate}','{omdelMian.sWheres}'", "h_p_JIT_Sc_WorkBillSortBill_Query"); objJsonResult.code = "1"; @@ -1981,13 +1981,13 @@ sqlName = "AIS20210811135644"; } - if (WMS_CampanyName == "瀹濆伐" || WMS_CampanyName == "娣诲悍绉戞妧") + if (WMS_CampanyName == "瀹濆伐" || WMS_CampanyName == "娣诲悍绉戞妧" || WMS_CampanyName == "鍑礉濂堢壒") { objJsonResult = (json)JIT_MOMaterLack(fProWorkShopId, fPrdOrgId, user); } else if (HTLType == "缂烘枡") { - if (WMS_CampanyName == "甯呭▉" || WMS_CampanyName == "鍑礉濂堢壒" /*|| WMS_CampanyName == "娣诲悍绉戞妧"*/) + if (WMS_CampanyName == "甯呭▉" /*|| WMS_CampanyName == "鍑礉濂堢壒" || WMS_CampanyName == "娣诲悍绉戞妧"*/) { objJsonResult = (json)JIT_QL(fProWorkShopId, fPrdOrgId, user, sqlName); } diff --git "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs" "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs" index b5249f2..1c6923f 100644 --- "a/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs" +++ "b/WebAPI/Controllers/SCGL/\346\227\245\350\256\241\345\210\222\347\256\241\347\220\206/JIT_DayPlanPlatFormImportController.cs" @@ -1240,5 +1240,411 @@ #endregion + #region 鐢熶骇鏃ヨ鍒� 鏂囦欢涓婁紶(鍑礉) + [Route("JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_KB")] + [HttpPost] + public object JIT_DayPlanPlatFormImport_KB() + { + 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("hmainid", typeof(Int32)); + tb2.Columns.Add("HMaterID", typeof(Int32));//鐗╂枡ID + tb2.Columns.Add("鍗曟嵁鍙�", typeof(string)); + tb2.Columns.Add("HWorkShopID", typeof(Int32));//鐢熶骇杞﹂棿 + tb2.Columns.Add("HEmpID", typeof(Int32));//鑱屽憳 + tb2.Columns.Add("鍛樺伐", typeof(string));//鑱屽憳 + tb2.Columns.Add("HUnitID", typeof(Int32));//璁¢噺鍗曚綅 + tb2.Columns.Add("HSourceID", typeof(Int32));//鐢熶骇璧勬簮id + tb2.Columns.Add("ICMOBillHInterID", typeof(Int32));//鐢熶骇璁㈠崟涓籭d + tb2.Columns.Add("ICMOBillHEntryID", typeof(Int32));//鐢熶骇璁㈠崟瀛恑d + tb2.Columns.Add("HProdORGID", typeof(Int32));//缁勭粐id + tb2.Columns.Add("HSeOrderBillNo", typeof(string));//閿�鍞鍗曞彿 + tb2.Columns.Add("HVersion_Import", typeof(string));//瀵煎叆搴忓垪鍙� + + //鑾峰彇绯荤粺鍙傛暟 + string Ret = ""; + oSystemParameter.ShowBill(ref Ret); + + LogService.Write("excel鍊硷細" + ExcelDs.Tables[0].Rows[1][15].ToString());//2024-11-26 + //娣诲姞鏁版嵁 + 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() == "" && ExcelDs.Tables[0].Rows[i][1].ToString() == "") + { + continue; + } + else + { + tb2.Rows.Add(row); + } + } + + var error = ""; + var ErrorResult = ""; + + //鏌ヨ鐢熶骇璁㈠崟琛ㄥ垽鏂湁娌℃湁鐢熶骇璁㈠崟淇℃伅 + for (int i = 0; i < tb2.Rows.Count; i++) + { + tb2.Rows[i]["HVersion_Import"] = DateTime.Now.ToString("yyyy-MM-dd HH"); + + if (tb2.Rows[i]["缁勭粐缂栫爜*"].ToString() == "") + error += "缁勭粐缂栫爜涓嶈兘涓虹┖;"; + if (tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString() == "") + error += "鐢熶骇璁㈠崟鍙蜂笉鑳戒负绌�;\n"; + if (tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString() == "") + error += "鐢熶骇璁㈠崟鏄庣粏琛屽彿涓嶈兘涓虹┖;"; + if (tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString() == "") + error += "鐢熶骇杞﹂棿缂栫爜涓嶈兘涓虹┖;"; + if (tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString() == "") + error += "鐗╂枡缂栫爜涓嶈兘涓虹┖;"; + + if (error.Length > 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = ErrorResult += $"Excel妯℃澘瀛樺湪閿欒锛岃鏁皗i + 1}:{error}\r\n"; ; + objJsonResult.data = null; + return objJsonResult; + } + + string sql1 = ""; + + sql1 = string.Format("select * from h_v_JIT_ICMOBillList_DR where 鍗曟嵁鍙�='{0}' and 鐢熶骇杞﹂棿浠g爜='{1}' and 浜у搧浠g爜='{2}' and 鏄庣粏琛屽彿={3} ", + tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString(), tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString(), tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString(), tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString()); + + ds = oCN.RunProcReturn(sql1, "h_v_JIT_ICMOBillList_DR"); + + if (ds.Tables[0].Rows.Count == 0) + { + error += $"娌℃湁鐢熶骇璁㈠崟淇℃伅锛岀敓浜ц鍗曞彿:{ tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString()},鐢熶骇杞﹂棿缂栫爜:{tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString()}" + + $",鐢熶骇璁㈠崟鏄庣粏琛屽彿:{ tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString()},鐗╂枡缂栫爜:{ tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString()}"; + } + + if (error.Length > 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = ErrorResult += $"Excel妯℃澘瀛樺湪閿欒锛岃鏁皗i + 1}:{error}\r\n"; ; + objJsonResult.data = null; + return objJsonResult; + } + else + { + tb2.Rows[i]["HMaterID"] = ds.Tables[0].Rows[0]["HMaterID"].ToString(); + tb2.Rows[i]["鐗╂枡鍚嶇О"] = ds.Tables[0].Rows[0]["浜у搧鍚嶇О"].ToString(); + tb2.Rows[i]["瑙勬牸鍨嬪彿"] = ds.Tables[0].Rows[0]["瑙勬牸鍨嬪彿"].ToString(); + tb2.Rows[i]["HWorkShopID"] = ds.Tables[0].Rows[0]["HDeptID"].ToString(); + tb2.Rows[i]["ICMOBillHInterID"] = ds.Tables[0].Rows[0]["hmainid"].ToString();//鐢熶骇璁㈠崟涓籭d + tb2.Rows[i]["ICMOBillHEntryID"] = ds.Tables[0].Rows[0]["HEntryID"].ToString();//鐢熶骇璁㈠崟瀛恑d + tb2.Rows[i]["鐢熶骇璁㈠崟鏁伴噺"] = ds.Tables[0].Rows[0]["鐢熶骇浠诲姟鍗曟暟閲�"].ToString();//鐢熶骇璁㈠崟鏁伴噺 + tb2.Rows[i]["HSeOrderBillNo"] = ds.Tables[0].Rows[0]["閿�鍞鍗曞彿"].ToString();//閿�鍞鍗曞彿 + } + + ds = oCN.RunProcReturn("select * from h_v_JIT_WorkBillSortBillList_DR " + + $"where 鐢熶骇璁㈠崟鍙�='{tb2.Rows[i]["鐢熶骇璁㈠崟鍙�*"].ToString()}' and 鐢熶骇璁㈠崟鏄庣粏琛屽彿='{tb2.Rows[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString()}' " + + $"and 鐢熶骇杞﹂棿缂栫爜='{tb2.Rows[i]["鐢熶骇杞﹂棿缂栫爜*"].ToString()}' and 鐗╂枡浠g爜='{tb2.Rows[i]["鐗╂枡缂栫爜*"].ToString()}' " + , "h_v_JIT_WorkBillSortBillList_DR"); + + if (ds.Tables[0].Rows.Count > 0) + { + tb2.Rows[i]["hmainid"] = ds.Tables[0].Rows[0]["hmainid"].ToString(); + tb2.Rows[i]["鍗曟嵁鍙�"] = ds.Tables[0].Rows[0]["鍗曟嵁鍙�"].ToString(); + tb2.Rows[i]["浼樺厛绾�"] = ds.Tables[0].Rows[0]["浼樺厛绾�"].ToString(); + tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HSourceID"].ToString(); + tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HEmpID"].ToString(); + tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HUnitID"].ToString(); + tb2.Rows[i]["閿�鍞鍗曟暟閲�"] = ds.Tables[0].Rows[0]["閿�鍞鍗曟暟閲�"].ToString(); + } + else + { + + } + //缁勭粐 + ds = oCN.RunProcReturn($"select * from Xt_ORGANIZATIONS with(nolock) where HNumber='{tb2.Rows[i]["缁勭粐缂栫爜*"].ToString()}'", "Xt_ORGANIZATIONS"); + if (ds.Tables[0].Rows.Count > 0) + { + tb2.Rows[i]["HProdORGID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); + } + else + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"绗瑊i + 1}琛�,缁勭粐鏌ユ棤鏁版嵁!"; + objJsonResult.data = tb2; + return objJsonResult; + } + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = ErrorResult; + 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("JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_btnSave_KB")] + [HttpPost] + public object JIT_DayPlanPlatFormImport_btnSave_KB([FromBody] JObject sMainSub) + { + var _value = sMainSub["sMainSub"].ToString(); + string msg1 = _value.ToString(); + oCN.BeginTran(); + //淇濆瓨涓昏〃 + objJsonResult = AddBillMain_KB(msg1); + if (objJsonResult.code == "0") + { + oCN.RollBack(); + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + oCN.Commit(); + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�"; + objJsonResult.data = null; + return objJsonResult; + } + + public json AddBillMain_KB(string msg1) + { + string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); + string msg2 = sArray[0].ToString(); + string msg3 = sArray[1].ToString(); + string user = sArray[2].ToString(); + + try + { + if (!DBUtility.ClsPub.Security_Log("Sc_WorkBillSortBill_Edit", 1, false, user)) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒"; + objJsonResult.data = null; + return objJsonResult; + } + + //琛ㄥご瀛楁 + omdelMian = Newtonsoft.Json.JsonConvert.DeserializeObject<Sc_WorkBillSortBillMain>(msg2); + + //JSON搴忓垪鍖栬浆鎹㈠瓧鍏搁泦鍚� + List<Dictionary<string, string>> list = new List<Dictionary<string, string>>(); + List<object> jb = JsonConvert.DeserializeObject<List<object>>(msg3); + foreach (JObject item in jb) + { + Dictionary<string, string> dic = new Dictionary<string, string>(); + foreach (var itm in item.Properties()) + { + dic.Add(itm.Name, itm.Value.ToString()); + } + list.Add(dic); + } + + for (int i = 0; i < list.Count; i++) + { + int TrueCount = 0, SumCount = 0; + long HInterID = 0; + var HBillNo = ""; + if (list[i]["鍗曟嵁鍙�"].ToString() == "" && list[i]["hmainid"].ToString() == "") + { + HBillNo = DBUtility.ClsPub.CreateBillCode_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo, true);//鑾峰緱涓�涓柊鐨勫崟鎹彿 + HInterID = DBUtility.ClsPub.CreateBillID_Prod(BillType, ref DBUtility.ClsPub.sExeReturnInfo);//鑾峰緱涓�涓柊鐨刬d + var HICMOBillNo = list[i]["鐢熶骇璁㈠崟鍙�*"].ToString(); + var HICMOEntrySEQ = list[i]["鐢熶骇璁㈠崟鏄庣粏琛屽彿*"].ToString(); + var HProdORGID = list[i]["HProdORGID"].ToString(); + var HWorkShopID = list[i]["HWorkShopID"].ToString(); + var HSourceID = "0"; + var HWorkQty = DBUtility.ClsPub.isDoule(list[i]["浜ц兘"]); + var HYX = list[i]["浼樺厛绾�"].ToString(); + var HEmpID = list[i]["HEmpID"].ToString(); + var HMaterID = list[i]["HMaterID"].ToString(); + var HMaterName = list[i]["鐗╂枡鍚嶇О"].ToString(); + var HMaterModel = list[i]["瑙勬牸鍨嬪彿"].ToString(); + var HUnitID = list[i]["HUnitID"].ToString(); + var HBatchNo = ""; + var HSeOrderBillQty = list[i]["閿�鍞鍗曟暟閲�"].ToString(); + var HPlanQty = list[i]["鐢熶骇璁㈠崟鏁伴噺"].ToString(); + var HCompleteQty = "0"; + var HOrderType = omdelMian.HOrderType; + var HDate = omdelMian.HDate; + var HMainSourceInterID = list[i]["ICMOBillHInterID"].ToString(); + var HMainSourceEntryID = list[i]["ICMOBillHEntryID"].ToString(); + var HSeOrderBillNo = list[i]["HSeOrderBillNo"].ToString(); + var HVersion_Import = list[i]["HVersion_Import"].ToString(); + + string sql = $"select * from Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" + + $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID} and ISNULL(HDeleteMan,'') = ''"; + LogService.Write("sql:" + sql); + ds = oCN.RunProcReturn(sql, "Sc_WorkBillSortBillMain"); + if (ds.Tables[0].Rows.Count > 0) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = $"绗瑊i + 1}琛岀敓浜ц祫婧愭湁閲嶅,璇蜂慨鏀�!"; + objJsonResult.data = null; + return objJsonResult; + } + + //涓昏〃 + oCN.RunProc("insert into Sc_WorkBillSortBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType," + + "HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HICMOBillNo,HOrderType," + + "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX,HWorkQty, HEmpID," + + " HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," + + " HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," + + "HMainSourceInterID,HMainSourceEntryID,HICMOInterID,HICMOEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec" + + ",HSeOrderBillNo,HVersion_Import)values" + + $"({HInterID},'{HBillNo}',{DateTime.Now.Year},{DateTime.Now.Month},'{BillType}'," + + $"'{BillType}',GETDATE(),1,'{user}','{HDate}','{HICMOBillNo}','{HOrderType}'," + + $"{(HICMOEntrySEQ == "" ? 0.ToString() : HICMOEntrySEQ)},{(HWorkShopID == "" ? 0.ToString() : HWorkShopID)},{(HSourceID == "" ? 0.ToString() : HSourceID)}, {(HYX == "" ? 0.ToString() : HYX)},{(HWorkQty)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," + + $" {(HMaterID == "" ? 0.ToString() : HMaterID)}, '{HMaterName}', '{HMaterModel}', {(HUnitID == "" ? 0.ToString() : HUnitID)}, '{HBatchNo}'," + + $" {(HSeOrderBillQty == "" ? 0.ToString() : HSeOrderBillQty)}, {(HPlanQty == "" ? 0.ToString() : HPlanQty)}, {(HCompleteQty == "" ? 0.ToString() : HCompleteQty)},getdate()," + + $" {HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID}" + + $",'{HSeOrderBillNo}','{HVersion_Import}')"); + } + + int SumDay = 31; //鍔ㄦ�佷袱鏈堜箣宸� DateTime.Now.AddMonths(1).AddDays(-1).Subtract(DateTime.Now).Days; + + // 缁熻鎬诲ぉ鏁� + HashSet<DateTime> uniqueDates = new HashSet<DateTime>(); + + foreach (var key in list[i].Keys) + { + if (DateTime.TryParseExact(key, "yyyy-M-d", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime date)) + { + uniqueDates.Add(date); + } + } + + SumDay = uniqueDates.Count; + + for (int j = 0; j < SumDay; j++) + { + LogService.Write("0:" + DateTime.Now.AddDays(j).ToString("yyyy-MM-dd").ToString()); + LogService.Write("1:" + list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString()); + LogService.Write("2:" + DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")); + //涓昏〃瀛愯〃閮芥湁鏁版嵁 + if (list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString() != "") + { + SumCount += 1; + ////淇濆瓨瀛愯〃 + objJsonResult = AddBillSub_KB(HInterID == 0 ? list[i]["hmainid"].ToString() : HInterID.ToString() + , HBillNo == "" ? list[i]["鍗曟嵁鍙�"].ToString() : HBillNo + , DateTime.Parse(DateTime.Now.AddDays(j).ToString("yyyy-MM-dd").ToString()) + , int.Parse(list[i][DateTime.Now.AddDays(j).ToString("yyyy-MM-dd")].ToString())); + + if (objJsonResult.count == 1) + { + TrueCount += 1; + } + } + //涓昏〃鏈夋暟鎹� 瀛愯〃鏃犳暟鎹� + if (j == SumDay - 1 && SumCount == 0 && HInterID != 0 && HBillNo != "") + { + objJsonResult = AddBillSub_KB(HInterID.ToString(), HBillNo, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0); + } + } + if (TrueCount != SumCount) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = objJsonResult.Message; + objJsonResult.data = null; + return objJsonResult; + } + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = null; + objJsonResult.data = null; + return objJsonResult; + } + catch (Exception e) + { + objJsonResult.code = "0"; + objJsonResult.count = 0; + objJsonResult.Message = "Exception锛�" + e.ToString(); + objJsonResult.data = null; + return objJsonResult; + } + } + + public json AddBillSub_KB(string HInterID, string HBillNo, DateTime date, int HQTY) + { + //鑾峰彇琛ㄦ牸鏁版嵁 + ds = oCN.RunProcReturn($"select * from h_v_JIT_Sc_WorkBillSortBillList where 鍗曟嵁鍙�='{HBillNo}'", "h_v_JIT_Sc_WorkBillSortBillList"); + int count = 0; + if (ds.Tables[0].Rows.Count > 0) + { + //鍒ゆ柇瀛愯〃鏄惁鏈夊綋鏃ョ殑鏃ユ湡浠ュ強鏃ユ湡鎵�瀵瑰簲鐨勬暟閲� + for (int i = 0; i < ds.Tables[0].Rows.Count; i++) + { + if (DateTime.Parse(ds.Tables[0].Rows[i]["鏃ヨ鍒掔敓浜ф棩鏈�"].ToString()) == date) + { + oCN.RunProc($"update Sc_WorkBillSortBillSub set HMasterDate='{date}',HQty={HQTY}" + + $" where HInterID={HInterID} and HEntryID={ds.Tables[0].Rows[i]["hsubid"].ToString()}"); + count += 1; + } + } + } + + if (count != 1) + { + //鎻掑叆瀛愯〃 + oCN.RunProc("insert into Sc_WorkBillSortBillSub(HInterID,HSEQ," + + "HMasterDate,HQty)" + + $"values({HInterID}, {(ds.Tables[0].Rows.Count + 1)}," + + $" '{date}', {HQTY})"); + } + + objJsonResult.code = "1"; + objJsonResult.count = 1; + objJsonResult.Message = null; + objJsonResult.data = null; + return objJsonResult; + } + #endregion + } } \ No newline at end of file diff --git a/WebAPI/Models/Sc_WorkBillSortBillMain.cs b/WebAPI/Models/Sc_WorkBillSortBillMain.cs index d10e7bc..595fd5e 100644 --- a/WebAPI/Models/Sc_WorkBillSortBillMain.cs +++ b/WebAPI/Models/Sc_WorkBillSortBillMain.cs @@ -40,7 +40,7 @@ public string HSeOrderBillNo { get; set; } public int? HGroupID; public int? HWorkerID; - public int? HWorkShopID; + public string HWorkShopID; public int? HProdORGID; public int? HEntrustORGID; public int? HStockInORGID; -- Gitblit v1.9.1