From 56d942189299cdca314ce391b427728ef47f3fe9 Mon Sep 17 00:00:00 2001 From: ray Date: Sat, 15 Jan 2022 00:34:37 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=AD=A3PCS021=E9=81=8E=E7=AB=99?= =?UTF-8?q?=20NG=E6=96=B0=E5=A2=9ETable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 84 +++++++++++++------ AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 7 ++ .../AMES/NgComponentsController.cs | 4 +- .../Controllers/AMES/NgInfoController.cs | 3 + .../Models/AMES/NgComponent.cs | 36 ++++---- 5 files changed, 88 insertions(+), 46 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index aacef80c..4646f4be 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -2252,9 +2252,9 @@ namespace AMESCoreStudio.Web.Controllers StatusID = NextStopCloseStation.Success ? -1 : 1, CreateUserID = 1 }; - var resutPost = await _pcsApi.PostBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); - if (resutPost.Success) - model.BarCodeID = (int)resutPost.Data.Select(s => s.BarcodeID).FirstOrDefault(); + var resultBarCodeInfo = await _pcsApi.PostBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); + if (resultBarCodeInfo.Success) + model.BarCodeID = (int)resultBarCodeInfo.Data.Select(s => s.BarcodeID).FirstOrDefault(); } // 新增 BarCodeStation @@ -2309,23 +2309,37 @@ namespace AMESCoreStudio.Web.Controllers } - // 新增 NgInfo 不良時新增 判斷有不良代碼 + // 判斷有不良代碼 新增 NgInfo NgComponent if (model.BarcodeNG) { - var FixtureNo = string.Join(",", model.MaterialOutfits.Select(s => s.Inputs).ToArray()); - NgInfo ngInfo = new NgInfo + foreach (var NGNo in model.Inputs.Where(w => w.Contains("$"))) { + var FixtureNo = string.Join(",", model.MaterialOutfits.Select(s => s.Inputs).ToArray()); + NgInfo ngInfo = new NgInfo + { - TypeNo = model.StationTestType, - OperatorID = 0, - FixtureNo = string.IsNullOrWhiteSpace(FixtureNo) ? "-1" : FixtureNo, - BarcodeID = model.BarCodeID, - ProgramNo = "N/A", - MachineNo = "N/A", - RuleStationId = model.RuleStation, - WipId = model.WipID - }; - await _pcsApi.PostNgInfo(JsonConvert.SerializeObject(ngInfo)); + TypeNo = model.StationTestType, + OperatorID = 0, + FixtureNo = string.IsNullOrWhiteSpace(FixtureNo) ? "-1" : FixtureNo, + BarcodeID = model.BarCodeID, + ReasonNo = NGNo, + ProgramNo = "N/A", + MachineNo = "N/A", + RuleStationId = model.RuleStation, + WipId = model.WipID + }; + var resultNgInfo = await _pcsApi.PostNgInfo(JsonConvert.SerializeObject(ngInfo)); + if (resultNgInfo.Success) + { + NgComponent ngComponent = new NgComponent + { + NgID = resultNgInfo.Data.FirstOrDefault().NgID, + LocationNo = "N/A", + NgNo = NGNo + }; + await _pcsApi.PostNgComponent(JsonConvert.SerializeObject(ngComponent)); + } + } } #region 當生產單位為SMT或DIP時,確認是否有綁Group,有綁連片一起過站 @@ -2392,18 +2406,34 @@ namespace AMESCoreStudio.Web.Controllers // 新增 NgInfo 不良時新增 判斷有不良代碼 if (model.BarcodeNG) { - NgInfo ngInfo = new NgInfo + foreach (var NGNo in model.Inputs.Where(w => w.Contains("$"))) { - TypeNo = model.StationTestType, - OperatorID = 0, - FixtureNo = string.Join(",", model.MaterialOutfits.Select(s => s.Inputs).ToArray()), - BarcodeID = id, - ProgramNo = "N/A", - MachineNo = "N/A", - RuleStationId = model.RuleStation, - WipId = model.WipID - }; - await _pcsApi.PostNgInfo(JsonConvert.SerializeObject(ngInfo)); + var FixtureNo = string.Join(",", model.MaterialOutfits.Select(s => s.Inputs).ToArray()); + NgInfo ngInfo = new NgInfo + { + + TypeNo = model.StationTestType, + OperatorID = 0, + FixtureNo = string.IsNullOrWhiteSpace(FixtureNo) ? "-1" : FixtureNo, + BarcodeID = model.BarCodeID, + ReasonNo = NGNo, + ProgramNo = "N/A", + MachineNo = "N/A", + RuleStationId = model.RuleStation, + WipId = model.WipID + }; + var resultNgInfo = await _pcsApi.PostNgInfo(JsonConvert.SerializeObject(ngInfo)); + if (resultNgInfo.Success) + { + NgComponent ngComponent = new NgComponent + { + NgID = resultNgInfo.Data.FirstOrDefault().NgID, + LocationNo = "N/A", + NgNo = NGNo + }; + await _pcsApi.PostNgComponent(JsonConvert.SerializeObject(ngComponent)); + } + } } } } diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 66049199..7f4e5c14 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -243,6 +243,13 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpPut("api/NgInfo")] ITask> PutNgInfo([FromBody, RawJsonContent] string model); + + /// + /// 更新不良零件資料 + /// + /// + [WebApiClient.Attributes.HttpPost("api/NgComponents")] + ITask> PostNgComponent([FromBody, RawJsonContent] string model); #endregion #region BarcodeType 條碼類別資料檔 PCS001 diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgComponentsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgComponentsController.cs index 67b20a80..3a0fa741 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgComponentsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgComponentsController.cs @@ -150,7 +150,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> PostNgComponent(NgComponent ngComponent) { ResultModel result = new ResultModel(); - + Helper helper = new Helper(_context); + ngComponent.ComponentID = helper.GetIDKey("COMPONENT_ID").Result; + _context.NgComponents.Add(ngComponent); try { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs index e1e8bc5b..40b01fcd 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs @@ -175,11 +175,14 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES Helper helper = new Helper(_context); ngInfo.NgID = helper.GetIDKey("NG_ID").Result; _context.NgInfos.Add(ngInfo); + + List ngInfos = new List { ngInfo }; try { await _context.SaveChangesAsync(); result.Success = true; result.Msg = "OK"; + result.Data = ngInfos; } catch (Exception ex) { diff --git a/AMESCoreStudio.WebApi/Models/AMES/NgComponent.cs b/AMESCoreStudio.WebApi/Models/AMES/NgComponent.cs index a6c05da0..8f16422e 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/NgComponent.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/NgComponent.cs @@ -17,20 +17,20 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 不良零件ID /// [Key] - [Column("COMPONENT_ID", TypeName = "NUMBER")] + [Column("COMPONENT_ID")] [DataMember] [Required] [Display(Name = "不良零件ID")] - public decimal ComponentID { get; set; } + public int ComponentID { get; set; } /// /// 測試不良ID /// - [Column("NG_ID", TypeName = "NUMBER")] + [Column("NG_ID")] [DataMember] [Required] [Display(Name = "測試不良ID")] - public decimal NgID { get; set; } + public int NgID { get; set; } /// /// 零件位置代碼 @@ -45,10 +45,10 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// /// 不良腳位數量 /// - [Column("PIN_QTY", TypeName = "NUMBER")] + [Column("PIN_QTY")] [DataMember] [Display(Name = "不良腳位數量")] - public decimal PinQty { get; set; } + public int PinQty { get; set; } /// /// 不良原因代碼 @@ -73,50 +73,50 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// /// 平均高度測試值 /// - [Column("HEIGHT_AVG", TypeName = "NUMBER")] + [Column("HEIGHT_AVG")] [DataMember] [Display(Name = "平均高度測試值")] - public decimal HeightAvg { get; set; } + public decimal HeightAvg { get; set; } = 0; /// /// 平均面積測試值 /// - [Column("AREA_AVG", TypeName = "NUMBER")] + [Column("AREA_AVG")] [DataMember] [Display(Name = "平均面積測試值")] - public decimal AreaAvg { get; set; } + public decimal AreaAvg { get; set; } = 0; /// /// 平均體積測試值 /// - [Column("VOLUME_AVG", TypeName = "NUMBER")] + [Column("VOLUME_AVG")] [DataMember] [Display(Name = "平均體積測試值")] - public decimal VolumeAvg { get; set; } + public decimal VolumeAvg { get; set; } = 0; /// /// 平均X軸偏移量測試值 /// - [Column("X_OFFSET_AVG", TypeName = "NUMBER")] + [Column("X_OFFSET_AVG")] [DataMember] [Display(Name = "平均X軸偏移量測試值")] - public decimal XOffsetAvg { get; set; } + public decimal XOffsetAvg { get; set; } = 0; /// /// 平均Y軸偏移量測試值 /// - [Column("Y_OFFSET_AVG", TypeName = "NUMBER")] + [Column("Y_OFFSET_AVG")] [DataMember] [Display(Name = "平均Y軸偏移量測試值")] - public decimal YOffsetAvg { get; set; } + public decimal YOffsetAvg { get; set; } = 0; /// /// 處理狀態(0:尚未維修處理, 1:已維修處理, 2:誤判) /// - [Column("STATUS", TypeName = "NUMBER")] + [Column("STATUS")] [DataMember] [Display(Name = "處理狀態")] - public decimal Status { get; set; } = 0; + public int Status { get; set; } = 0; /// /// 更換料號