diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs index 791a7977..7044195d 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs @@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore; using AMESCoreStudio.WebApi; using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.CommonTools.Result; +using Newtonsoft.Json.Linq; namespace AMESCoreStudio.WebApi.Controllers.AMES @@ -555,6 +556,62 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + /// + /// + /// + /// + /// + [HttpPut("WriteBarcodeItem4DataCarrier1")] + public async Task> WriteBarcodeItem4DataCarrier1([FromBody] dynamic param) + { + Helper helper = new Helper(_context); + ResultModel result = new ResultModel(); + + try + { + int barcodeID = -1, wipID = -1, stationID = 900; + string itemNo = "", partNo = "", kpItemNo = ""; + string kpDateTime = "20230101121314"; + + JObject jo = new JObject(); + jo = param; + + barcodeID = int.Parse(jo["barcodeID"].ToString()); + wipID = int.Parse(jo["wipID"].ToString()); + stationID = int.Parse(jo["stationID"].ToString()); + + itemNo = jo["itemNo"].ToString(); + partNo = jo["partNo"].ToString(); + kpItemNo = jo["kpItemNo"].ToString(); + kpDateTime = jo["kpDateTime"].ToString(); + + BarcodeItem barcode_item = new BarcodeItem(); + barcode_item.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result; + barcode_item.BarcodeID = barcodeID; + barcode_item.WipID = wipID; + barcode_item.StationID = stationID; + barcode_item.ItemNo = itemNo; + barcode_item.PartNo = partNo; + barcode_item.KpItemNo = kpItemNo; + barcode_item.SysType = "S"; + barcode_item.CreateDate = DateTime.Parse(kpDateTime.Substring(0, 4) + "-" + kpDateTime.Substring(4, 2) + "-" + kpDateTime.Substring(6, 2) + " " + kpDateTime.Substring(8, 2) + ":" + kpDateTime.Substring(10, 2) + ":" + kpDateTime.Substring(12, 2)); + + _context.BarcodeItems.Add(barcode_item); + await _context.SaveChangesAsync(); + + //紀錄筆數 + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + + return result; + } + /// /// 新增條碼资料 ///