diff --git a/AMESCoreStudio.Web/Controllers/REPController.cs b/AMESCoreStudio.Web/Controllers/REPController.cs index 6b167c91..efd6de62 100644 --- a/AMESCoreStudio.Web/Controllers/REPController.cs +++ b/AMESCoreStudio.Web/Controllers/REPController.cs @@ -12,6 +12,7 @@ using System.ComponentModel.DataAnnotations; using System.IO; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Hosting; +using AMESCoreStudio.WebApi.DTO.AMES; namespace AMESCoreStudio.Web.Controllers { @@ -21,14 +22,16 @@ namespace AMESCoreStudio.Web.Controllers public readonly IREP _repApi; public readonly IPPS _ppsApi; public readonly IBAS _basApi; + public readonly IPCS _pcsApi; private readonly IWebHostEnvironment _env; - public REPController(ILogger logger, IREP repApi, IPPS ppsApi,IBAS basApi, IWebHostEnvironment env) + public REPController(ILogger logger, IREP repApi, IPPS ppsApi,IBAS basApi,IPCS pcsApi, IWebHostEnvironment env) { _logger = logger; _repApi = repApi; _ppsApi = ppsApi; _basApi = basApi; + _pcsApi = pcsApi; _env = env; } @@ -300,6 +303,12 @@ namespace AMESCoreStudio.Web.Controllers ModelState.AddModelError("error", "請選擇要上傳檔案"); } + if (model.ngRepair.Missing == "Y") + { + model.ngRepair.RepairNo = "N/A"; + model.ngComponent.Status = 2; + } + result = await _repApi.PutNgComponent((int)model.ngComponent.ComponentID, JsonConvert.SerializeObject(model.ngComponent)); if (model.repairRecord.ComponentID > 0) @@ -313,11 +322,6 @@ namespace AMESCoreStudio.Web.Controllers result = await _repApi.PostRepairRecord(JsonConvert.SerializeObject(model.repairRecord)); } - if (model.ngRepair.Missing == "Y") - { - model.ngRepair.RepairNo = "N/A"; - } - if (model.ngRepair.RepairID > 0) { result = await _repApi.PutNgRepair((int)model.ngRepair.RepairID, JsonConvert.SerializeObject(model.ngRepair)); @@ -374,6 +378,81 @@ namespace AMESCoreStudio.Web.Controllers // ModelState.AddModelError("error", result.Msg); //} + bool repairComplete = true; + + var ng_component = await _repApi.GetNgComponentByNGID(model.ngInfo.NgID); + for (int i = 0; i < ng_component.Count; i++) + { + if (ng_component[i].Status == 0) + { + repairComplete = false; + break; + } + } + + List items = new List(); + //判斷組件是否更換 + for (int i = 0; i < ng_component.Count; i++) + { + if (ng_component[i].NewPartNo!="") + { + items.Add(new BarCodeCheckDto.inputItem + { + inputType="KP", + inputData = ng_component[i].NewPartNo, + oldInputData = ng_component[i].OldPartNo + }); + } + } + + if (repairComplete) + { + //判断全部维修完成过站 + int repairStationID = -1; + var rules = await _basApi.GetRules(model.ngInfo.Barcode.RuleStationID); + if (rules.Count > 0) + { + for (int i = 0; i < rules.Count; i++) + { + if (rules[i].RuleStatus == model.ngInfo.Barcode.RuleStatus) + { + repairStationID = rules[i].NextStationID; + break; + } + } + } + + int lineID = -1; + if (model.ngInfo.Wip.LineID != null) + { + lineID = model.ngInfo.Wip.LineID.Value; + } + + //准备资料 + var barCode = new BarCodeCheckDto + { + wipNo = model.ngInfo.Wip.WipNO, + barcode = model.ngInfo.Barcode.BarcodeNo, + barcodeType = "S", + station = repairStationID, + line = lineID, + unitNo = model.ngInfo.Wip.UnitNO, + inputItems = items + }; + + try + { + var barcode_result = await _pcsApi.PassIngByCheck(JsonConvert.SerializeObject(barCode)); + } + catch { } + + //更新NG_INFO + //var ng_info = await _repApi.GetNgInfo((int)model.ngInfo.NgID); + //ng_info[0].Status = 1; + model.ngInfo.Status = 1; + result = await _repApi.PutNgInfo(JsonConvert.SerializeObject(model.ngInfo)); + } + if (result.Success) { var _msg = "保存成功!"; diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs b/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs index d70a4755..940813af 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IREP.cs @@ -93,6 +93,13 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/NgRepairBlobs/{id}")] ITask> GetNgRepairBlob(decimal id); + /// + /// 更新不良資料 + /// + /// + [WebApiClient.Attributes.HttpPut("api/NgInfo")] + ITask> PutNgInfo([FromBody, RawJsonContent] string model); + /// /// 新增不良維修資料 /// diff --git a/AMESCoreStudio.Web/Views/REP/REP001R.cshtml b/AMESCoreStudio.Web/Views/REP/REP001R.cshtml index b8f30721..64ec9af1 100644 --- a/AMESCoreStudio.Web/Views/REP/REP001R.cshtml +++ b/AMESCoreStudio.Web/Views/REP/REP001R.cshtml @@ -39,6 +39,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +