diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs index 37035243..69ed0b1e 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeInfoesController.cs @@ -329,6 +329,67 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } } + /// + /// 結轉寫入條碼資料 + /// + /// + /// + /// + /// + /// + /// + [HttpPut("WriteBarcodeInfo4DataCarrier/{barcodeNo}/{wipID}/{stationID}/{extraBarcodeNo}/{boxNo}")] + public async Task> WriteBarcodeInfo4DataCarrier(string barcodeNo, int wipID, int stationID, string extraBarcodeNo, string boxNo) + { + Helper helper = new Helper(_context); + ResultModel result = new ResultModel(); + + try + { + IQueryable b = _context.BarcodeInfoes; + b = b.Where(p => p.BarcodeNo.Equals(barcodeNo)); + var barcodeInfo = await b.ToListAsync(); + + if (barcodeInfo == null) + { + BarcodeInfo barcode_info = new BarcodeInfo(); + barcode_info.BarcodeID = helper.GetIDKey("BARCODE_ID").Result; + barcode_info.BarcodeNo = barcodeNo; + barcode_info.WipID = wipID; + barcode_info.StationID = stationID; + barcode_info.ExtraBarcodeNo = extraBarcodeNo; + barcode_info.BoxNo = boxNo; + barcode_info.CreateDate = DateTime.Now; + + _context.BarcodeInfoes.Add(barcode_info); + await _context.SaveChangesAsync(); + } + + var q = from q1 in _context.BarcodeInfoes + select new + { + q1.BarcodeID, + q1.BarcodeNo + }; + + q = q.Where(w => w.BarcodeNo.Equals(barcodeNo)); + + + //紀錄筆數 + result.DataTotal = q.Count(); + result.Success = true; + result.Data = await q.ToListAsync(); + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + + return result; + } + /// /// 更新條碼资料 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs index afa8a975..47b74888 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs @@ -509,6 +509,49 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } } + /// + /// 結轉寫入條碼資料 + /// + /// + /// + /// + /// + /// + /// + /// + [HttpPut("WriteBarcodeItem4DataCarrier/{barcodeID}/{wipID}/{stationID}/{itemNo}/{partNo}/{kpItemNo}")] + public async Task> WriteBarcodeItem4DataCarrier(int barcodeID, int wipID, int stationID,string itemNo, string partNo, string kpItemNo) + { + Helper helper = new Helper(_context); + ResultModel result = new ResultModel(); + + try + { + BarcodeItem barcode_item = new BarcodeItem(); + barcode_item.BarcodeItemID = helper.GetIDKey("BARCODEITEM_ID").Result; + barcode_item.WipID = wipID; + barcode_item.StationID = stationID; + barcode_item.ItemNo = itemNo; + barcode_item.PartNo = partNo; + barcode_item.KpItemNo = kpItemNo; + barcode_item.CreateDate = DateTime.Now; + + _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; + } + /// /// 新增條碼资料 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs index 3e1b2b17..9b57ad9b 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs @@ -291,6 +291,47 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + /// + /// 結轉寫入條碼過站 + /// + /// + /// + /// + /// + [HttpPut("WriteBarcodeStation4DataCarrier/{barcodeID}/{wipID}/{stationID}")] + public async Task> WriteBarcodeStation4DataCarrier(int barcodeID,int wipID, int stationID) + { + Helper helper = new Helper(_context); + ResultModel result = new ResultModel(); + + try + { + BarcodeStation barcode_station = new BarcodeStation(); + barcode_station.BarcodeID = barcodeID; + barcode_station.WipID = wipID; + barcode_station.StationID = stationID; + barcode_station.FlowRuleID = -1; + barcode_station.RuleStatus = "P"; + barcode_station.Systype = "S"; + barcode_station.CreateDate = DateTime.Now; + + _context.BarcodeStation.Add(barcode_station); + await _context.SaveChangesAsync(); + + //紀錄筆數 + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + + return result; + } + + // PUT: api/BarcodeStation/5 // To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://go.microsoft.com/fwlink/?linkid=2123754.