diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 45fa807a..ab6637af 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -1666,10 +1666,10 @@ namespace AMESCoreStudio.Web.Controllers Msg += "請刷入治具編號\r\n"; - if (string.IsNullOrWhiteSpace(model.Input)) + if (string.IsNullOrWhiteSpace(model.Input)) { Msg += "請刷讀條碼\r\n"; - } + } else { if (model.Input.ToUpper() != "OK") @@ -1679,30 +1679,78 @@ namespace AMESCoreStudio.Web.Controllers if (!string.IsNullOrWhiteSpace(Msg)) Success = false; - //// 新增or更新 BarCode_Info - //BarcodeInfo barcodeInfo = new BarcodeInfo - //{ - // BarcodeNo = model.Input, - // StatusNo = "SMT", - // RuleStationID = model.Station, - // RuleStatus = "P", //F 不良 - // WipID = model.WipID, - // StatusID = 1, - // CreateUserID = 1 - //}; - //await _pcsApi.PostBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); - - //// 新增or更新 BarCodeStation - //BarcodeStation barcodeStation = new BarcodeStation - //{ - // BarcodeID = 1, - // WipID = model.WipID, - // RuleStationID = model.Station, - // RuleStatus = "S", - // InputDate = DateTime.Now, - // LineId = (decimal)model.LineID - //}; - //await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStation)); + + #region 內部序號輸入後新增 or 更新 + string BarStatusNo = _basApi.GetFactoryUnit(model.UnitNO).InvokeAsync().Result.FirstOrDefault().UnitCode; + string RuleStationID = ""; + + // 新增or更新 BarCode_Info + BarcodeInfo barcodeInfo = new BarcodeInfo + { + BarcodeNo = model.Input, + StatusNo = BarStatusNo, + RuleStationID = model.Station, + RuleStatus = "P", //F 不良 + WipID = model.WipID, + StatusID = 1, + CreateUserID = 1 + }; + await _pcsApi.PostBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); + + // 新增 BarCodeStation + BarcodeStation barcodeStation = new BarcodeStation + { + BarcodeID = 1, + WipID = model.WipID, + RuleStationID = model.Station, + RuleStatus = "P", //F 不良 + InputDate = DateTime.Now, + LineId = (decimal)model.LineID + }; + await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStation)); + + // 新增 BarCodeItem + List barcodeItems = new List(); + foreach (string str in model.Inputs) + { + barcodeItems.Add(new BarcodeItem + { + BarcodeID = 1001, + WipID = model.WipID, + RuleStationID = model.Station, + ItemNo = "01", + PartNo = str, + SysType = "S", + CreateUserID = 0, + CreateDate = DateTime.Now, + UpdateDate = DateTime.Now + }); ; + await _pcsApi.PostBarcodeItem(JsonConvert.SerializeObject(barcodeItems)); + } + #endregion + + // 新增 BarCodeWip 投入站新增 + BarcodeWip barcodeWip = new BarcodeWip + { + BarcodeID = 1001, + WipID = model.WipID + }; + + // 刪除 BarCodeGroup DIP完工後刪除 + + // 新增 NgInfo 不良時新增 + NgInfo ngInfo = new NgInfo + { + TypeNo = "", + OperatorID = 0, + FixtureNo = string.Join(",", model.MaterialOutfits.Select(s => s.Inputs).ToArray()), + BarcodeId = 1001, + ProgramNo = "N/A", + MachineNo = "N/A", + RuleStationId =1001, + WipId = model.WipID + }; + await _pcsApi.PostNgInfo(JsonConvert.SerializeObject(ngInfo)); return Json(new Result() { success = Success, msg = Msg, data = Data }); } diff --git a/AMESCoreStudio.Web/ViewModels/PCS/PCS021ViewModel.cs b/AMESCoreStudio.Web/ViewModels/PCS/PCS021ViewModel.cs index ca5da58d..1e2c1d40 100644 --- a/AMESCoreStudio.Web/ViewModels/PCS/PCS021ViewModel.cs +++ b/AMESCoreStudio.Web/ViewModels/PCS/PCS021ViewModel.cs @@ -40,6 +40,7 @@ namespace AMESCoreStudio.Web.ViewModels.PCS /// public int Station { get; set; } + /// /// SOP路徑 /// diff --git a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml index c2f2c56e..0aef8ccb 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml @@ -73,13 +73,11 @@ -
-
@@ -93,7 +91,7 @@
- +
@@ -297,11 +295,11 @@ // Jquery 將兩邊DIV設定同高度 jQuery(function ($) { $('.element').responsiveEqualHeightGrid(); - getFlowRuleList($("#unit").val()); - getStationsList($("#unit").val()); + getUnitLineList($("#unit").val()); + getRuleStationList($("#unit").val()); }); - function getFlowRuleList(data) + function getUnitLineList(data) { $.ajax( { @@ -325,7 +323,7 @@ }); }; - function getStationsList(data) + function getRuleStationList(data) { $.ajax( { @@ -390,15 +388,10 @@ form = layui.form; form.on('select(unit)', function (data) { - $("#unitNo").val(data.value); - - getFlowRuleList(data.value); - getStationsList(data.value); + getUnitLineList(data.value); + getRuleStationList(data.value); }); - form.on('select(line)', function (data) { - $("#lineId").val(data.value); - }); }); // 新增trRow diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs index d1f3799a..1e5c942c 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs @@ -79,6 +79,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> PostNgInfo([FromBody] NgInfo ngInfo) { ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + ngInfo.NgID = helper.GetIDKey("NG_ID").Result; _context.NgInfos.Add(ngInfo); try { diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs index 7f759b07..036ec3ba 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs @@ -47,13 +47,12 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } /// - /// 判斷內部序號 + /// 內部序號查詢工單號碼 /// - /// - /// - /// + /// 內部序號 + /// Success:true or false [HttpGet("BarCodeFromWip")] - public IActionResult CheckBarCodeFromWip(string barcode, string wipno) + public IActionResult CheckBarCodeFromWip(string barcode) { ResultModel resultModel = new ResultModel { Success = false }; if (barcode.Length <= 4) @@ -63,14 +62,57 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } WipInfosController wipInfosController = new WipInfosController(_context); + // 內部序號扣除流水號 查詢 IQueryable q = _context.WipBarcodes.Where(w => w.StartNO.Contains(barcode.Substring(0, (barcode.Length - 4)))); if (!q.Any()) { resultModel.Msg = "找不到內部序號:" + barcode + " 對應相關工單號碼"; return Ok(resultModel); } + else + { + try + { + var No = int.Parse(barcode.Substring(barcode.Length - 4, 4)); + foreach (var item in q) + { + int StartNo = int.Parse(item.StartNO.Substring(item.StartNO.Length - 4, 4)); + int EndNo = int.Parse(item.EndNO.Substring(item.EndNO.Length - 4, 4)); + if (StartNo <= No && No <= EndNo) + { + resultModel.Success = true; + resultModel.Msg = q.Select(s => s.WipNO).FirstOrDefault(); + return Ok(resultModel); + } + } + resultModel.Msg = "工單號碼:" + q.Select(s => s.WipNO).FirstOrDefault() + " 找不到範圍內的內部序號"; + } + catch (Exception ex) + { + resultModel.Msg = ex.Message; + } + } + return Ok(resultModel); + } + /// + /// 內部序號是否報廢 + /// + /// 內部序號 + /// Success:true or false + [HttpGet("BarCodeLock")] + public IActionResult CheckBarCodeLock(string barcode) + { + ResultModel resultModel = new ResultModel { Success = false }; + if (barcode.Length <= 4) + { + resultModel.Msg = "內部序號小於4個字數"; + return Ok(resultModel); + } + + //BarcodeLock barcodeLock = new BarcodeLock(_context); + //IQueryable q = _context.WipBarcodes.Where(w => w.StartNO.Contains(barcode.Substring(0, (barcode.Length - 4)))); return Ok(resultModel); } @@ -166,17 +208,17 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return ""; } - /// - /// 判斷內部序號對應工單號買 - /// - /// 內部序號 - /// - private async Task CheckBarCodeFromWip(string BarCode) - { - //if (BarCode.Length <= 4) - return "NG, 找不到相關工單號碼"; + ///// + ///// 判斷內部序號對應工單號買 + ///// + ///// 內部序號 + ///// + //private async Task CheckBarCodeFromWip(string BarCode) + //{ + // //if (BarCode.Length <= 4) + // return "NG, 找不到相關工單號碼"; - } + //} } } diff --git a/AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs b/AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs index f0bb1dde..72268548 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/BarcodeWip.cs @@ -38,7 +38,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES [DataMember] [Required(ErrorMessage = "{0},不能空白")] [Display(Name = "建立者")] - public decimal CreateUserID { get; set; } = -1; + public decimal CreateUserID { get; set; } = 0; /// /// 建立時間 diff --git a/AMESCoreStudio.WebApi/Models/AMES/NgInfo.cs b/AMESCoreStudio.WebApi/Models/AMES/NgInfo.cs index 89bfff0a..cbce8dde 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/NgInfo.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/NgInfo.cs @@ -70,14 +70,14 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// [Column("TEST_QTY", TypeName = "NUMBER")] [DataMember] - public decimal TestQty { get; set; } + public decimal TestQty { get; set; } = 0; /// /// 不良總點數 /// [Column("NG_QTY", TypeName = "NUMBER")] [DataMember] - public decimal NgQty { get; set; } + public decimal NgQty { get; set; } = 0; /// /// 開始測試時間