From 0cb11a633b8450f55c4fc2d7e92d1199ca016c02 Mon Sep 17 00:00:00 2001 From: "vick_wang419@hotmail.com.tw" Date: Wed, 20 Dec 2023 22:33:20 +0800 Subject: [PATCH] =?UTF-8?q?PTD=E8=A6=8F=E6=A0=BC=E6=9B=B8-2023=E7=B3=BB?= =?UTF-8?q?=E7=B5=B1=E9=9C=80=E6=B1=82=20-Fix=20DN=E5=96=AE=E6=9F=A5?= =?UTF-8?q?=E8=A9=A2=20&=20=E6=89=A3=E5=B8=B3=E4=BD=9C=E6=A5=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PTDController.cs | 108 +++- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 14 +- AMESCoreStudio.Web/Views/PTD/PTD002.cshtml | 10 +- AMESCoreStudio.Web/Views/PTD/PTD006.cshtml | 573 ++++++++++++++++++ AMESCoreStudio.Web/Views/PTD/PTD007.cshtml | 215 +++++++ .../Controllers/AMES/WipInfosController.cs | 338 ++++++++++- .../Models/AMES/PTD101AMESModel.cs | 24 + 7 files changed, 1256 insertions(+), 26 deletions(-) create mode 100644 AMESCoreStudio.Web/Views/PTD/PTD006.cshtml create mode 100644 AMESCoreStudio.Web/Views/PTD/PTD007.cshtml diff --git a/AMESCoreStudio.Web/Controllers/PTDController.cs b/AMESCoreStudio.Web/Controllers/PTDController.cs index 69efa219..6fab7693 100644 --- a/AMESCoreStudio.Web/Controllers/PTDController.cs +++ b/AMESCoreStudio.Web/Controllers/PTDController.cs @@ -274,6 +274,7 @@ namespace AMESCoreStudio.Web.Controllers ViewBag.RecordTypeInfo = RecordTypes; ViewBag.RecordType = SelectListItem; ViewBag.Location = "9000"; + ViewBag.WorkCenter = "TWM0"; ViewBag.RecordDate = System.DateTime.Now.ToString("yyyy/MM/dd"); return View(); } @@ -290,7 +291,7 @@ namespace AMESCoreStudio.Web.Controllers [HttpPost] public async Task PTD002_Commit(string data) { - var result = await _pcsApi.PostPostPTD002Commit(data); + var result = await _pcsApi.PostPTD002Commit(data); //将数据Json化并传到前台视图 return Json(new { data = result }); } @@ -325,7 +326,6 @@ namespace AMESCoreStudio.Web.Controllers ViewBag.EndDate = System.DateTime.Now.ToString("yyyy/MM/dd"); ViewBag.WorkCenter = "TWM0"; - return View(); } public async Task PTD003QueryAsync(string recordType, string recordNumber, string lineNo, string materialNo, string shippingSN, string dateStart, string dateEnd) @@ -442,6 +442,110 @@ namespace AMESCoreStudio.Web.Controllers #endregion + #region "PTD005 設定 ERP 客戶代號和客戶收件人名單" + public async Task PTD005() + { + return View(); + } + #endregion + + #region "PTD006 備貨作業" + public async Task PTD006() + { + if (Request.Cookies["_AMESCookie"] != null) + { + var userID = ""; + HttpContext.Request.Cookies.TryGetValue("UserID", out userID); + if (userID != null) + { + var user_info = await _sysApi.GetUserInfo(int.Parse(userID)); + var factory_info = await _basApi.GetFactoryInfo(user_info[0].FactoryID); + ViewData["RBU"] = factory_info[0].Address; + } + + } + + List RecordTypes = await _pcsApi.GetRecordTypeInfo(); + + var SelectListItem = new List(); + + foreach (WebApi.Models.AMES.RecordTypeInfo RecordType in RecordTypes) + { + SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); + } + ViewBag.RecordTypeInfo = RecordTypes; + ViewBag.RecordType = SelectListItem; + ViewBag.Location = "9000"; + ViewBag.WorkCenter = "TWM0"; + ViewBag.RecordDate = System.DateTime.Now.ToString("yyyy/MM/dd"); + return View(); + } + public async Task PTD006QueryAsync(string recordNumber, string? LineNO) + { + if (recordNumber == null || recordNumber == "") + return Json(new Table() { count = 0, data = null }); + + var result = await _pcsApi.GetZWHPickListDetail(recordNumber, LineNO); + if (result.DataTotal > 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + return Json(new Table() { count = 0, data = null, msg = result.Msg }); + } + #endregion + + #region "PTD007 扣帳作業" + public async Task PTD007() + { + if (Request.Cookies["_AMESCookie"] != null) + { + var userID = ""; + HttpContext.Request.Cookies.TryGetValue("UserID", out userID); + if (userID != "") + { + var user_info = await _sysApi.GetUserInfo(int.Parse(userID)); + List factory_info = await _basApi.GetFactoryInfo(user_info[0].FactoryID); + ViewData["RBU"] = factory_info[0].Address; + } + } + + List RecordTypes = await _pcsApi.GetRecordTypeInfo(); + + var SelectListItem = new List(); + + foreach (WebApi.Models.AMES.RecordTypeInfo RecordType in RecordTypes) + { + SelectListItem.Add(new SelectListItem(RecordType.ID.ToString() + "-" + RecordType.TypeName, RecordType.ID.ToString())); + } + + ViewBag.RecordType = SelectListItem; + ViewBag.WorkCenter = "TWM0"; + ViewBag.RecordDate = System.DateTime.Now.ToString("yyyy/MM/dd"); + return View(); + } + + public async Task PTD007QueryAsync(string recordType, string recordNumber) + { + if (recordNumber == null || recordNumber == "") + return Json(new Table() { count = 0, data = null }); + + var result = await _pcsApi.GetZDNDetailJoinZWHPickListDetail(recordType, recordNumber); + if (result.DataTotal > 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + return Json(new Table() { count = 0, data = null, msg = result.Msg }); + } + + [HttpPost] + public async Task PTD007_Commit(string data) + { + var result = await _pcsApi.PostPTD007Commit(data); + //将数据Json化并传到前台视图 + return Json(new { data = result }); + } + + #endregion } } diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 9de00dfd..5502d35d 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -1999,8 +1999,20 @@ namespace AMESCoreStudio.Web #region "PTD002 PTD002 一段式入出庫作業" [WebApiClient.Attributes.HttpPost("api/WipInfos/PostPTD002Commit")] - ITask> PostPostPTD002Commit([FromBody, RawJsonContent] string model); + ITask> PostPTD002Commit([FromBody, RawJsonContent] string model); #endregion + + #region "PTD006 備貨作業" + [WebApiClient.Attributes.HttpGet("api/WipInfos/GetZWHPickListDetail")] + ITask> GetZWHPickListDetail(string recordNumber, string LineNO); + #endregion + + #region "PTD007 扣帳作業" + [WebApiClient.Attributes.HttpGet("api/WipInfos/GetZDNDetailJoinZWHPickListDetail")] + ITask> GetZDNDetailJoinZWHPickListDetail(string recordType, string recordNumber); + [WebApiClient.Attributes.HttpPost("api/WipInfos/PostPTD007Commit")] + ITask> PostPTD007Commit([FromBody, RawJsonContent] string model); + #endregion } } diff --git a/AMESCoreStudio.Web/Views/PTD/PTD002.cshtml b/AMESCoreStudio.Web/Views/PTD/PTD002.cshtml index a5482409..92bae685 100644 --- a/AMESCoreStudio.Web/Views/PTD/PTD002.cshtml +++ b/AMESCoreStudio.Web/Views/PTD/PTD002.cshtml @@ -163,12 +163,12 @@ -
- -
+ +
+
-
+
@@ -567,7 +567,7 @@ } ]]; //基本数据表格 - var table = hg.table.datatable('query', '扣帳資訊', '', {}, tableCols, toolbar, false, '360', ['filter', 'print', 'exports']); + var table = hg.table.datatable('query', '扣帳資訊', '', {}, tableCols, toolbar, false, 'full-100'); } diff --git a/AMESCoreStudio.Web/Views/PTD/PTD006.cshtml b/AMESCoreStudio.Web/Views/PTD/PTD006.cshtml new file mode 100644 index 00000000..53d4b78e --- /dev/null +++ b/AMESCoreStudio.Web/Views/PTD/PTD006.cshtml @@ -0,0 +1,573 @@ +@{ + ViewData["Title"] = "備貨作業"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + + + + + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+ +
+
+
+
+
+
+ +
+ + + +
+ +
+
+ +
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+ +
+
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+ +
+ + +
+
+ +
+ +
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +@section Scripts{ + + + +} diff --git a/AMESCoreStudio.Web/Views/PTD/PTD007.cshtml b/AMESCoreStudio.Web/Views/PTD/PTD007.cshtml new file mode 100644 index 00000000..7c250bcf --- /dev/null +++ b/AMESCoreStudio.Web/Views/PTD/PTD007.cshtml @@ -0,0 +1,215 @@ +@{ + ViewData["Title"] = "扣帳作業"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + + + +
+
+
+
+
@ViewBag.Title
+
+
+
+ +
+
+
+
+
+ +
+ +
+
+ +
+
+ +
+
+
+
+
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+ +
+ + +
+ +
+
+ +
+
+ +
+
+
+
+
+
+ + +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs index c929388d..48aeb92d 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs @@ -2585,7 +2585,9 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S { await connPTD.OpenAsync(); } - string strSQL = $@"select SerialNumber from SFIS_PTD.dbo.ZProductTrans where RecordNumber ='{dnNo}' and RCLineNO ='{lineNo}' + string strSQL = $@"select RecordNumber as DN單號,MOID as WipNo,ProductID as ItemNO,SerialNumber as ExtraBarcodeNo,SalesOrderNumber as BarcodeNo, + RecordDate as StartDate + from SFIS_PTD.dbo.ZProductTrans where RecordNumber ='{dnNo}' and RCLineNO ='{lineNo}' order by SerialNumber"; DataTable dtZProductTrans = new DataTable(); using (var cmd = connPTD.CreateCommand()) @@ -2609,38 +2611,59 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S } DataTable dtBarcode = new DataTable(); - foreach (DataRow dr in dtZProductTrans.Rows) + + try { - string wip_sql = $@"SELECT '{dnNo}' as DN單號,WI.WIP_NO as WipNo,WA.ITEM_NO as ItemNO, BI.EXTRA_BARCODE_NO as ExtraBarcodeNo, BI.BARCODE_NO as BarcodeNo, BI.WIP_ID, + foreach (DataRow dr in dtZProductTrans.Rows) + { + string wip_sql = $@"SELECT '{dnNo}' as DN單號,WI.WIP_NO as WipNo,WA.ITEM_NO as ItemNO, BI.EXTRA_BARCODE_NO as ExtraBarcodeNo, BI.BARCODE_NO as BarcodeNo, BI.WIP_ID, BI.BARCODE_ID,TO_CHAR((select min(create_date) from jhames.wip_station where wip_id = BI.WIP_ID),'YYYY-MM-DD HH24:MI:SS') StartDate FROM jhames.BARCODE_INFO BI, jhames.WIP_INFO WI, jhames.WIP_ATT WA WHERE BI.WIP_ID = WI.WIP_ID AND WI.WIP_NO = WA.WIP_NO - AND BI.EXTRA_BARCODE_NO = '{dr["SerialNumber"]}'"; - - using (var cmd = conn.CreateCommand()) - { - cmd.CommandText = wip_sql; + AND BI.EXTRA_BARCODE_NO = '{dr["ExtraBarcodeNo"]}'"; - using (var reader = await cmd.ExecuteReaderAsync()) + using (var cmd = conn.CreateCommand()) { - if (reader.HasRows) + cmd.CommandText = wip_sql; + + using (var reader = await cmd.ExecuteReaderAsync()) { - if (dtBarcode == null) - { dtBarcode = DataReaderToDataTable(reader); } + if (dtBarcode.Columns.Count == 0) + { + for (int i = 0; i < reader.FieldCount; i++) + { + dtBarcode.Columns.Add(reader.GetName(i), reader.GetFieldType(i)); + } + } + + if (reader.HasRows) + { + dtBarcode.Merge(DataReaderToDataTable(reader)); + } else - { dtBarcode.Merge(DataReaderToDataTable(reader)); } - + { + DataRow newRow = dtBarcode.NewRow(); + foreach (DataColumn col in dtZProductTrans.Columns) + { + newRow[col.ColumnName] = dr[col.ColumnName]; + } + dtBarcode.Rows.Add(newRow); + } } } } } - + catch (Exception e) + { + Console.WriteLine(e.Message); + } //開始取KP資料 string strbarcode_id = "''"; foreach (DataRow drbarcode in dtBarcode.Rows) { - strbarcode_id += $",{drbarcode["BARCODE_ID"]}"; + if (!string.IsNullOrEmpty(drbarcode["BARCODE_ID"].ToString())) + strbarcode_id += $",{drbarcode["BARCODE_ID"]}"; } DataTable dtKp = new DataTable(); @@ -3036,11 +3059,11 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); [ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete], [OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], [CreatorID],[CreateDate],[ModifierID],[ModifyDate], - [chkflag],[IsBranchCoReceived]) VALUES + [chkflag],[IsBranchCoReceived],[MOID]) VALUES ('{strLatest}','{SNData.Sn}','{strRecordType}','{SNData.DnNo}','{SNData.LineNo}','{strRecordDate}', '{SNData.Material}',0,'{strLocation}','{strCustomer}',0, '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', - 'WH00','{strCreateDate}','WH00','{strCreateDate}',0,0)"; + 'WH00','{strCreateDate}','WH00','{strCreateDate}',0,0,'{strRmaNo}')"; Console.WriteLine(strSQL); colSQL.Add(strSQL); SNList.Add(SNData.Sn); @@ -3549,5 +3572,284 @@ and b.item_no = '{0}' and a.barcode_no = '{1}'", kp_no, barcode_no); } } #endregion + + #region "PTD006 備貨作業" + [Route("[action]")] + [HttpGet] + public async Task> GetZWHPickListDetail(string recordNumber,string? LineNO) + { + ResultModel result = new ResultModel(); + + //安勤連線 + PTDContext _ptd_context = new PTDContext(); + DbConnection connPTD = _ptd_context.Database.GetDbConnection(); + if (connPTD.State != ConnectionState.Open) + { + await connPTD.OpenAsync(); + } + string strSQL = $@"select [RecordTypeID] as 'recordType', + [RecordNumber] as 'dnNo', + [RCLineNO] as 'lineNo', + [ProductID] as 'material', + [InputSN] as 'sn' + from dbo.[ZWHPickListDetail] where TaskStatus ='Picked' And RecordNumber ='{recordNumber}'"; + if (!string.IsNullOrEmpty(LineNO)) + { + strSQL += $@" And RCLineNO ='{LineNO}'"; + } + DataTable dtZDNDetail = new DataTable(); + using (var cmd = connPTD.CreateCommand()) + { + cmd.CommandText = strSQL; + + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.HasRows) + { + dtZDNDetail = DataReaderToDataTable(reader); + } + } + } + + List list = new List(); + foreach (DataRow row in dtZDNDetail.Rows) + { + dynamic dyn = new ExpandoObject(); + list.Add(dyn); + foreach (DataColumn column in dtZDNDetail.Columns) + { + var dic = (IDictionary)dyn; + dic[column.ColumnName] = row[column]; + } + } + + result.DataTotal = list.Count(); + result.Data = list; + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + #endregion + + #region "PTD007 扣帳作業" + [Route("[action]")] + [HttpGet] + public async Task> GetZDNDetailJoinZWHPickListDetail(string recordType, string recordNumber) + { + ResultModel result = new ResultModel(); + + //安勤連線 + PTDContext _ptd_context = new PTDContext(); + DbConnection connPTD = _ptd_context.Database.GetDbConnection(); + if (connPTD.State != ConnectionState.Open) + { + await connPTD.OpenAsync(); + } + string strSQL = $@"SELECT DNNO + ,DNLineNO + ,a.ProductID + ,a.SoldCustomerID + ,a.ExpectShipDate + ,a.ShipQty + ,b.Qty + FROM [dbo].ZDNDetail a left join (select sum(1) as Qty,RecordNumber,RCLineNO,RecordTypeID + from dbo.[ZWHPickListDetail] where TaskStatus ='Picked' group by RecordTypeID,RecordNumber,RCLineNO)b + on (b.RecordNumber = a.DNNO and b.RCLineNO = a.DNLineNO) + where a.DNNO = '{recordNumber}' and b.RecordTypeID = '{recordType}'"; + DataTable dtZDNDetail = new DataTable(); + using (var cmd = connPTD.CreateCommand()) + { + cmd.CommandText = strSQL; + + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.HasRows) + { + dtZDNDetail = DataReaderToDataTable(reader); + } + } + } + + List list = new List(); + foreach (DataRow row in dtZDNDetail.Rows) + { + dynamic dyn = new ExpandoObject(); + list.Add(dyn); + foreach (DataColumn column in dtZDNDetail.Columns) + { + var dic = (IDictionary)dyn; + dic[column.ColumnName] = row[column]; + } + } + + result.DataTotal = list.Count(); + result.Data = list; + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + [Route("[action]")] + [HttpPost] + public async Task> PostPTD007Commit(PTD007CommitDataModel Data) + { + ResultModel result = new ResultModel(); + List SNList = new List(); + Collection colSQL = new Collection(); + try + { + string strSQL = ""; + string strRecordType = Data.RecordType; + string strRbu = Data.Rbu; + string strWorkCenter = Data.WorkCenter; + string strRecordDate = Data.RecordDate; + string strCreateDate = DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss"); + + //安勤連線 + PTDContext _ptd_context = new PTDContext(); + DbConnection connPTD = _ptd_context.Database.GetDbConnection(); + if (connPTD.State != ConnectionState.Open) + { + await connPTD.OpenAsync(); + } + + foreach (PTD007TableDataModel SNData in Data.TableData) + { + //ZWHPickListDetail查SN資訊 + strSQL = $@"Select * FROM [SFIS_PTD].[dbo].[ZWHPickListDetail] + where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}'"; + DataTable dtSNData = new DataTable(); + using (var cmd = connPTD.CreateCommand()) + { + cmd.CommandText = strSQL; + + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.HasRows) + { + dtSNData = DataReaderToDataTable(reader); + } + } + } + foreach (DataRow row in dtSNData.Rows) + { + string strLatest; + //確認此出貨序號是否有ZHistoryKeyDefine + strSQL = $@"select Seed FROM [SFIS_PTD].[dbo].[ZHistoryKeyDefine] where serialnumber ='{row["ShipmentSN"]}'"; + using (var cmd = connPTD.CreateCommand()) + { + cmd.CommandText = strSQL; + using (var reader = await cmd.ExecuteReaderAsync()) + { + if (reader.Read()) + { + int seed = Convert.ToInt32(reader["Seed"]); + int nIdx = seed + 1; + strLatest = row["ShipmentSN"].ToString() + nIdx.ToString().PadLeft(4, '0');//組成HistoryID + //HistoryKeyDefine + strSQL = @$"UPDATE [SFIS_PTD].[dbo].[ZHistoryKeyDefine] + SET [Seed] = {nIdx} where [SerialNumber]='{row["ShipmentSN"]}'"; + colSQL.Add(strSQL); + //ZSNInfo + strSQL = @$"Update SFIS_PTD..ZSNInfo SET LatestHistoryID='{strLatest}',RecordTypeID='{strRecordType}', + CurrentProductID='{row["ProductID"]}' + where SerialNumber='{row["ShipmentSN"]}'"; + colSQL.Add(strSQL); + } + else + { + strLatest = row["ShipmentSN"].ToString() + 1.ToString().PadLeft(4, '0');//組成HistoryID + //ZHistoryKeyDefine + strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZHistoryKeyDefine] ([SerialNumber],[Seed]) + VALUES ('{row["ShipmentSN"]}',1)"; + colSQL.Add(strSQL); + //ZSNInfo + strSQL = @$"INSERT INTO [SFIS_PTD].[dbo].[ZSNInfo] ([SerialNumber],[CurrentProductID],[OriginalProductID], + [LocationID],[LatestHistoryID],[RecordTypeID], + [OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], + [ModifyDate]) VALUES + ('{row["ShipmentSN"]}','{row["ProductID"]}','{row["ProductID"]}', + '9000','{strLatest}','{strRecordType}', + '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', + '{strCreateDate}')"; + colSQL.Add(strSQL); + } + //ZProductTrans + strSQL = $@"INSERT INTO [SFIS_PTD].[dbo].[ZProductTrans] + ([HistoryID],[SerialNumber],[RecordTypeID],[RecordNumber],[RCLineNO],[RecordDate], + [ProductID],[IsChangeID],[LocationID],[EmplID],[IsDelete], + [OwnerPlantID],[OwnerCompanyID],[CreatePlantID],[CreateCompanyID], + [CreatorID],[CreateDate],[ModifierID],[ModifyDate], + [chkflag],[IsBranchCoReceived],[MOID]) VALUES + ('{strLatest}','{row["ShipmentSN"]}','{strRecordType}','{SNData.dnno}','{SNData.dnLineNO}','{strRecordDate}', + '{SNData.productID}',0,'9000','{SNData.soldCustomerID}',0, + '{strWorkCenter}','{strRbu}','{strWorkCenter}','{strRbu}', + 'WH00','{strCreateDate}','WH00','{strCreateDate}',0,0,'')"; + colSQL.Add(strSQL); + } + } + } + strSQL = $@"Update [SFIS_PTD].[dbo].[ZWHPickListDetail] set TaskStatus ='Recorded' + where RecordNumber='{SNData.dnno}' and RCLineNO='{SNData.dnLineNO}'"; + colSQL.Add(strSQL); + } + + foreach (string query in colSQL) + { + Console.WriteLine(query); + } + + using (var cmd = connPTD.CreateCommand()) + { + using (var transaction = connPTD.BeginTransaction()) + { + try + { + foreach (string query in colSQL) + { + cmd.CommandText = query; + cmd.Transaction = transaction; + cmd.ExecuteNonQuery(); + } + + // Commit the transaction + transaction.Commit(); + } + catch (Exception ex) + { + // Rollback the transaction in case of an exception + transaction.Rollback(); + throw ex; // Rethrow the exception after rollback + } + } + } + + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.Message; + } + return result; + + } + #endregion } } diff --git a/AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs b/AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs index 13540583..d70b43bc 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/PTD101AMESModel.cs @@ -95,4 +95,28 @@ namespace AMESCoreStudio.WebApi.Models.AMES public int? Length { get; set; } } + #region "PTD007 扣帳作業" + public class PTD007CommitDataModel + { + public string RecordType { get; set; } + public string WorkCenter { get; set; } + public string Rbu { get; set; } + public string RecordDate { get; set; } + public List TableData { get; set; } + } + public class PTD007TableDataModel + { + public string dnno { get; set; } + public string dnLineNO { get; set; } + public string productID { get; set; } + public string soldCustomerID { get; set; } + public string expectShipDate { get; set; } + public int shipQty { get; set; } + public int qty { get; set; } + + } + + + #endregion + }