| | |
| | | using System.Web.Http; |
| | | using System.Web.Script.Serialization; |
| | | using WebAPI.Models; |
| | | |
| | | using System.Globalization; |
| | | namespace WebAPI.Controllers.SCGL.æ¥è®¡å管ç |
| | | { |
| | | public class JIT_DayPlanPlatFormImportController : ApiController |
| | |
| | | SQLHelper.ClsCN oCN = new SQLHelper.ClsCN(); |
| | | public static string BillType = "4610"; |
| | | Sc_WorkBillSortBillMain omdelMian = new Sc_WorkBillSortBillMain(); |
| | | Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter(); |
| | | |
| | | |
| | | #region ç产æ¥è®¡å æä»¶ä¸ä¼ |
| | | [Route("JIT_DayPlanPlatFormImport/JIT_DayPlanPlatFormImport_DR")] |
| | |
| | | tb2.Columns.Add("ICMOBillHInterID", typeof(Int32));//ç产订å主id |
| | | tb2.Columns.Add("ICMOBillHEntryID", typeof(Int32));//ç产订ååid |
| | | tb2.Columns.Add("HProdORGID", typeof(Int32));//ç»ç»id |
| | | tb2.Columns.Add("HSeOrderBillNo", typeof(string));//éå®è®¢åå· |
| | | tb2.Columns.Add("HSeOrderBillNo", 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.Rows.Add(row); |
| | | //å¦æè¡¨æ ¼ç¬¬iè¡ç第ä¸å为空ï¼åå¤æä¸ºè¿ä¸è¡çæ°æ®ä¸ºç©ºï¼è·³åºå¾ªç¯å¹¶ä¸ä¸ææ°æ®åå
¥ tb2 |
| | | if (ExcelDs.Tables[0].Rows[i][0].ToString() == "" && ExcelDs.Tables[0].Rows[i][1].ToString() == "") |
| | | { |
| | | continue; |
| | | } |
| | | //else if (oSystemParameter.omodel.JIT_DayPlan_TimeFrame != "0" && oSystemParameter.omodel.JIT_DayPlan_TimeFrame != "") |
| | | //{ |
| | | // Int32 HDays = Convert.ToInt32(oSystemParameter.omodel.JIT_DayPlan_TimeFrame) * 7; |
| | | |
| | | |
| | | |
| | | |
| | | // for (int j = 0; j < ExcelDs.Tables[0].Columns.Count; j++) |
| | | // { |
| | | // if (Convert.ToInt32(ExcelDs.Tables[0].Rows[i][j].ToString()) > 0 ) |
| | | // { |
| | | // continue; |
| | | // } |
| | | // } |
| | | //} |
| | | else |
| | | { |
| | | tb2.Rows.Add(row); |
| | | } |
| | | } |
| | | |
| | | var error = ""; |
| | |
| | | return objJsonResult; |
| | | } |
| | | |
| | | string sql1 = string.Format("select * from h_v_IF_ICMOBillList where åæ®å·='{0}' and ç产车é´ä»£ç ='{1}' and 产å代ç ='{2}' and æç»è¡å·={3} ", |
| | | string sql1 = string.Format("select * from h_v_JIT_ICMOBillList_DR where åæ®å·='{0}' and ç产车é´ä»£ç ='{1}' and 产å代ç ='{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_IF_ICMOBillList"); |
| | | ds = oCN.RunProcReturn(sql1, "h_v_JIT_ICMOBillList_DR"); |
| | | |
| | | if (ds.Tables[0].Rows.Count == 0) |
| | | { |
| | |
| | | tb2.Rows[i]["HWorkShopID"] = ds.Tables[0].Rows[0]["HDeptID"].ToString(); |
| | | tb2.Rows[i]["ICMOBillHInterID"] = ds.Tables[0].Rows[0]["hmainid"].ToString();//ç产订å主id |
| | | tb2.Rows[i]["ICMOBillHEntryID"] = ds.Tables[0].Rows[0]["HEntryID"].ToString();//ç产订ååid |
| | | tb2.Rows[i]["çäº§è®¢åæ°é"] = ds.Tables[0].Rows[0]["ç产任å¡åæ°é"].ToString();//çäº§è®¢åæ°é |
| | | string sErr = ""; |
| | | if (oSystemParameter.ShowBill(ref sErr)) |
| | | { |
| | | if (oSystemParameter.omodel.WMS_CampanyName != "å®å·¥") |
| | | { |
| | | tb2.Rows[i]["çäº§è®¢åæ°é"] = ds.Tables[0].Rows[0]["ç产任å¡åæ°é"].ToString();//çäº§è®¢åæ°é |
| | | } |
| | | } |
| | | //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_Sc_WorkBillSortBillList " + |
| | | 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 ç©æä»£ç ='{tb2.Rows[i]["ç©æç¼ç *"].ToString()}' " + |
| | | $"and çäº§èµæºç¼ç ='{tb2.Rows[i]["çäº§èµæºç¼ç *"].ToString()}' ", "h_v_JIT_Sc_WorkBillSortBillList"); |
| | | $"and çäº§èµæºç¼ç ='{tb2.Rows[i]["çäº§èµæºç¼ç *"].ToString()}' ", "h_v_JIT_WorkBillSortBillList_DR"); |
| | | //ç»ç»ç¼ç ='{tb2.Rows[i]["ç»ç»ç¼ç *"].ToString()}' and |
| | | //and çäº§èµæºç¼ç ='{tb2.Rows[i]["çäº§èµæºç¼ç *"].ToString()}' |
| | | |
| | |
| | | else |
| | | { |
| | | //åå·¥ |
| | | ds = oCN.RunProcReturn($"select * from Gy_Employee where HNumber='{tb2.Rows[i]["åå·¥ç¼ç "].ToString()}'", "Gy_Employee"); |
| | | ds = oCN.RunProcReturn($"select * from Gy_Employee with(nolock) where HNumber='{tb2.Rows[i]["åå·¥ç¼ç "].ToString()}'", "Gy_Employee"); |
| | | if (ds.Tables[0].Rows.Count > 0) { |
| | | tb2.Rows[i]["HEmpID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | | tb2.Rows[i]["åå·¥"] = ds.Tables[0].Rows[0]["HName"].ToString(); |
| | |
| | | } |
| | | |
| | | //计éåä½ |
| | | ds = oCN.RunProcReturn($"select * from Gy_Unit where HNumber='{tb2.Rows[i]["计éåä½"].ToString()}'", "Gy_Unit"); |
| | | ds = oCN.RunProcReturn($"select * from Gy_Unit with(nolock) where HNumber='{tb2.Rows[i]["计éåä½"].ToString()}'", "Gy_Unit"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | tb2.Rows[i]["HUnitID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | |
| | | } |
| | | |
| | | //çäº§èµæº |
| | | ds = oCN.RunProcReturn($"select * from Gy_Source where HNumber='{tb2.Rows[i]["çäº§èµæºç¼ç *"].ToString()}'", "Gy_Source"); |
| | | ds = oCN.RunProcReturn($"select * from Gy_Source with(nolock) where HNumber='{tb2.Rows[i]["çäº§èµæºç¼ç *"].ToString()}'", "Gy_Source"); |
| | | if (ds.Tables[0].Rows.Count > 0) |
| | | { |
| | | tb2.Rows[i]["HSourceID"] = ds.Tables[0].Rows[0]["HItemID"].ToString(); |
| | |
| | | } |
| | | } |
| | | //ç»ç» |
| | | ds = oCN.RunProcReturn($"select * from Xt_ORGANIZATIONS where HNumber='{tb2.Rows[i]["ç»ç»ç¼ç *"].ToString()}'", "Xt_ORGANIZATIONS"); |
| | | 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(); |
| | |
| | | var HProdORGID = list[i]["HProdORGID"].ToString(); |
| | | var HWorkShopID = list[i]["HWorkShopID"].ToString(); |
| | | var HSourceID = list[i]["HSourceID"].ToString(); |
| | | 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 HSeOrderBillNo = list[i]["HSeOrderBillNo"].ToString(); |
| | | |
| | | string sql = $"select * from Sc_WorkBillSortBillMain where HMainSourceInterID={HMainSourceInterID}" + |
| | | $" and HMainSourceEntryID={HMainSourceEntryID} and HICMOBillNo='{HICMOBillNo}' and HICMOEntrySEQ={HICMOEntrySEQ} and HSourceID={HSourceID}"; |
| | | $" 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) |
| | |
| | | //主表 |
| | | oCN.RunProc("insert into Sc_WorkBillSortBillMain(HInterID,HBillNo,HYear,HPeriod,HBillType," + |
| | | "HBillSubType,HDate,HBillStatus,HMaker,HMakeDate,HICMOBillNo,HOrderType," + |
| | | "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX, HEmpID," + |
| | | "HICMOEntrySEQ,HWorkShopID,HSourceID, HYX,HWorkQty, HEmpID," + |
| | | " HMaterID, HMaterName, HMaterModel, HUnitID, HBatchNo," + |
| | | " HSeOrderBillQty, HPlanQty, HCompleteQty,HPreparatDate," + |
| | | "HMainSourceInterID,HMainSourceEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec" + |
| | | "HMainSourceInterID,HMainSourceEntryID,HICMOInterID,HICMOEntryID,HProdORGID,HICMOInterID_Sec,HICMOEntryID_Sec" + |
| | | ",HSeOrderBillNo)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)}, {(HEmpID == "" ? 0.ToString() : HEmpID)}," + |
| | | $"{(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},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID}" + |
| | | $" {HMainSourceInterID},{HMainSourceEntryID},{HMainSourceInterID},{HMainSourceEntryID},{HProdORGID}, {HMainSourceInterID},{HMainSourceEntryID}" + |
| | | $",'{HSeOrderBillNo}')"); |
| | | } |
| | | |
| | | 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++) |
| | | { |
| | |
| | | } |
| | | } |
| | | //ä¸»è¡¨ææ°æ® åè¡¨æ æ°æ® |
| | | if (j == 30 && SumCount == 0 && HInterID != 0 && HBillNo != "") |
| | | if (j == SumDay - 1 && SumCount == 0 && HInterID != 0 && HBillNo != "") |
| | | { |
| | | objJsonResult = AddBillSub(HInterID.ToString(), HBillNo, DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd").ToString()), 0); |
| | | } |