diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 547a0f22..b6734f33 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -2192,15 +2192,15 @@ namespace AMESCoreStudio.Web.Controllers // Input為內部序號 model.Barcode = true; - // 確認內部序號是否報廢 - var BarCodeScrapped = await _pcsApi.CheckBarCodeScrapped(Data); - if (!BarCodeScrapped.Success) - return Json(new Result() { success = BarCodeScrapped.Success, msg = BarCodeScrapped.Msg, data = Data }); + //// 確認內部序號是否報廢 + //var BarCodeScrapped = await _pcsApi.CheckBarCodeScrapped(Data); + //if (!BarCodeScrapped.Success) + // return Json(new Result() { success = BarCodeScrapped.Success, msg = BarCodeScrapped.Msg, data = Data }); - // 確認內部序號是否鎖定 - var BarCodeLock = await _pcsApi.CheckBarCodeLock(Data); - if (!BarCodeLock.Success) - return Json(new Result() { success = BarCodeLock.Success, msg = BarCodeLock.Msg, data = Data }); + //// 確認內部序號是否鎖定 + //var BarCodeLock = await _pcsApi.CheckBarCodeLock(Data); + //if (!BarCodeLock.Success) + // return Json(new Result() { success = BarCodeLock.Success, msg = BarCodeLock.Msg, data = Data }); // 取RuleStationID var RuleStations = await _basApi.GetRuleStationsByFlow(model.FlowRuleID, 0); @@ -2219,14 +2219,19 @@ namespace AMESCoreStudio.Web.Controllers if (model.StationSEQ == 1) { Msg += "投入站不能刷不良代碼
"; + } + if (!string.IsNullOrWhiteSpace(Msg)) + { + Success = false; + return Json(new Result() { success = Success, msg = Msg, data = Data }); } } - // 判斷作業站與製程順序是否正確 - var BarCodeFlow = await _pcsApi.CheckBarCodeFlow(model.WipNO, model.Input, model.UnitNO, model.Station); - if (!BarCodeFlow.Success) - return Json(new Result() { success = BarCodeFlow.Success, msg = BarCodeFlow.Msg, data = Data }); + //// 判斷作業站與製程順序是否正確 + //var BarCodeFlow = await _pcsApi.CheckBarCodeFlow(model.WipNO, model.Input, model.UnitNO, model.Station); + //if (!BarCodeFlow.Success) + // return Json(new Result() { success = BarCodeFlow.Success, msg = BarCodeFlow.Msg, data = Data }); // 下一個作業站是完工站時再判斷是否都有刷組件 @@ -2240,253 +2245,298 @@ namespace AMESCoreStudio.Web.Controllers if (CheckBarCodeKP.Data != null) ExtNo = CheckBarCodeKP.Data.FirstOrDefault(); } - } - else - { - Msg += "內部序號工單號碼與過站工單不相同
"; - } - #endregion - } + var keyParts = new List(); + // 先查詢已綁定組件數量 + var BarCodeItems = await _pcsApi.GetBarcodeItemByBarCode(model.Input); + int KpItemQty = BarCodeItems.Count(); + int i = 0; + foreach (var KeyPartItem in model.Inputs) + { - if (!string.IsNullOrWhiteSpace(Msg)) - { - Success = false; - return Json(new Result() { success = Success, msg = Msg, data = Data }); - } + keyParts.Add(new BarCodeCheckDto.inputItem + { + inputType = KeyPartItem.Contains("$") ? "NG" : model.MaterialKps[i + KpItemQty].KpNo, + inputData = KeyPartItem + }); - #region 判斷下一站為完工站 - var NextStopCloseStation = await _pcsApi.CheckNextStopCloseStation(model.WipNO, model.UnitNO, model.Station); - #endregion + if (!KeyPartItem.Contains("$")) + i += 1; + } - #region 過站判斷正常 往下處理Table + var outfit = new List(); + foreach (var outfitItem in model.MaterialOutfits) + { + outfit.Add(new BarCodeCheckDto.Outfit + { + inputData = outfitItem.Inputs + }); + } - if (model.Barcode) - { - #region 內部序號輸入後新增 or 更新 - string BarStatusNo = _basApi.GetFactoryUnit(model.UnitNO).InvokeAsync().Result.FirstOrDefault().UnitCode; - // 新增or更新 BarCode_Info - var barcodeInfos = await _pcsApi.GetBarcodeInfoesByNo(model.Input); - if (barcodeInfos.Count() != 0) - { - model.BarCodeID = barcodeInfos[0].BarcodeID; + var x = new BarCodeCheckDto + { + wipNo = model.WipNO, + barcode = model.Input, + barcodeType = "M", + station = model.Station, + line = model.LineID, + unitNo = model.UnitNO, + inputItems = keyParts, + outfits = outfit + }; - barcodeInfos[0].StatusNo = BarStatusNo; - barcodeInfos[0].ExtraBarcodeNo = ExtNo; - barcodeInfos[0].RuleStationID = model.RuleStation; - barcodeInfos[0].RuleStatus = !model.BarcodeNG ? "P" : "F"; //F 不良 - barcodeInfos[0].WipID = model.WipID; - barcodeInfos[0].StatusID = NextStopCloseStation.Success ? -1 : 1; - barcodeInfos[0].UpdateDate = DateTime.Now; - await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfos[0])); + var barcode_result = await _pcsApi.PassIngByCheck(JsonConvert.SerializeObject(x)); + if (!barcode_result.Success) + return Json(new Result() { success = barcode_result.Success, msg = barcode_result.Msg, data = Data }); + else + { + Msg = "內部序號【" + Data + "】 過站完成!"; + Data = string.Empty; + } } else { - BarcodeInfo barcodeInfo = new BarcodeInfo - { - BarcodeNo = model.Input, - StatusNo = BarStatusNo, - RuleStationID = model.RuleStation, - RuleStatus = !model.BarcodeNG ? "P" : "F",//F 不良 - WipID = model.WipID, - StatusID = NextStopCloseStation.Success ? -1 : 1, - CreateUserID = 1 - }; - var resultBarCodeInfo = await _pcsApi.PostBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); - if (resultBarCodeInfo.Success) - model.BarCodeID = (int)resultBarCodeInfo.Data.Select(s => s.BarcodeID).FirstOrDefault(); + Msg += "內部序號工單號碼與過站工單不相同
"; } + #endregion + } - // 新增 BarCodeStation - BarcodeStation barcodeStation = new BarcodeStation - { - BarcodeID = model.BarCodeID, - WipID = model.WipID, - RuleStationID = model.RuleStation, - RuleStatus = !model.BarcodeNG ? "P" : "F", //F 不良 - InputDate = DateTime.Now, - LineId = model.LineID - }; - await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStation)); - - // 新增 BarCodeItem - // 先查詢已綁定組件數量 - var BarCodeItems = await _pcsApi.GetBarcodeItemByBarCodeID(model.BarCodeID); - int KpItemQty = BarCodeItems.Count(); - - for (int i = 0; i < Kp.Count(); i++) - { - // - if (ExtNo == Kp[i]) - continue; - var barcodeItem = new BarcodeItem - { - BarcodeID = model.BarCodeID, - WipID = model.WipID, - RuleStationID = model.RuleStation, - ItemNo = model.MaterialKps[i + KpItemQty].KpNo, - PartNo = Kp[i], - SysType = "S", - CreateUserID = 0, - CreateDate = DateTime.Now, - UpdateDate = DateTime.Now - }; - await _pcsApi.PostBarcodeItem(JsonConvert.SerializeObject(barcodeItem)); - } - #endregion + - // 新增 BarCodeWip 投入站新增 for 只有投入站才新增 - if (model.StationSEQ == 1) - { - BarcodeWip barcodeWip = new BarcodeWip - { - BarcodeID = model.BarCodeID, - WipID = model.WipID - }; - await _pcsApi.PostBarcodeWip(JsonConvert.SerializeObject(barcodeWip)); + #region 判斷下一站為完工站 + var NextStopCloseStation = await _pcsApi.CheckNextStopCloseStation(model.WipNO, model.UnitNO, model.Station); + #endregion - var wipInfo = await _pcsApi.GetWipInfo(model.WipID); - wipInfo[0].CompleteQTY += 1; - await _pcsApi.PutWipInfo(JsonConvert.SerializeObject(wipInfo[0])); + #region 過站判斷正常 往下處理Table 移到API執行 - } + //if (model.Barcode) + //{ + // #region 內部序號輸入後新增 or 更新 + // string BarStatusNo = _basApi.GetFactoryUnit(model.UnitNO).InvokeAsync().Result.FirstOrDefault().UnitCode; - // 判斷有不良代碼 新增 NgInfo NgComponent - if (model.BarcodeNG) - { - 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 - { + // // 新增or更新 BarCode_Info + // var barcodeInfos = await _pcsApi.GetBarcodeInfoesByNo(model.Input); + // if (barcodeInfos.Count() != 0) + // { + // model.BarCodeID = barcodeInfos[0].BarcodeID; + + // barcodeInfos[0].StatusNo = BarStatusNo; + // barcodeInfos[0].ExtraBarcodeNo = ExtNo; + // barcodeInfos[0].RuleStationID = model.RuleStation; + // barcodeInfos[0].RuleStatus = !model.BarcodeNG ? "P" : "F"; //F 不良 + // barcodeInfos[0].WipID = model.WipID; + // barcodeInfos[0].StatusID = NextStopCloseStation.Success ? -1 : 1; + // barcodeInfos[0].UpdateDate = DateTime.Now; + // await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfos[0])); + // } + // else + // { + // BarcodeInfo barcodeInfo = new BarcodeInfo + // { + // BarcodeNo = model.Input, + // StatusNo = BarStatusNo, + // RuleStationID = model.RuleStation, + // RuleStatus = !model.BarcodeNG ? "P" : "F",//F 不良 + // WipID = model.WipID, + // StatusID = NextStopCloseStation.Success ? -1 : 1, + // CreateUserID = 1 + // }; + // var resultBarCodeInfo = await _pcsApi.PostBarcodeInfoes(JsonConvert.SerializeObject(barcodeInfo)); + // if (resultBarCodeInfo.Success) + // model.BarCodeID = (int)resultBarCodeInfo.Data.Select(s => s.BarcodeID).FirstOrDefault(); + // } - TypeNo = model.StationTestType, - OperatorID = 0, - FixtureNo = string.IsNullOrWhiteSpace(FixtureNo) ? "-1" : FixtureNo, - BarcodeID = model.BarCodeID, - ReasonNo = NGNo, - ProgramNo = "N/A", - MachineNo = "N/A", - StationId = model.Station, - 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)); - } - } - } + // // 新增 BarCodeStation + // BarcodeStation barcodeStation = new BarcodeStation + // { + // BarcodeID = model.BarCodeID, + // WipID = model.WipID, + // RuleStationID = model.RuleStation, + // RuleStatus = !model.BarcodeNG ? "P" : "F", //F 不良 + // InputDate = DateTime.Now, + // LineId = model.LineID + // }; + // await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStation)); + + // // 新增 BarCodeItem + // // 先查詢已綁定組件數量 + // var BarCodeItems = await _pcsApi.GetBarcodeItemByBarCodeID(model.BarCodeID); + // int KpItemQty = BarCodeItems.Count(); + + // for (int i = 0; i < Kp.Count(); i++) + // { + // // + // if (ExtNo == Kp[i]) + // continue; + + // var barcodeItem = new BarcodeItem + // { + // BarcodeID = model.BarCodeID, + // WipID = model.WipID, + // RuleStationID = model.RuleStation, + // ItemNo = model.MaterialKps[i + KpItemQty].KpNo, + // PartNo = Kp[i], + // SysType = "S", + // CreateUserID = 0, + // CreateDate = DateTime.Now, + // UpdateDate = DateTime.Now + // }; + // await _pcsApi.PostBarcodeItem(JsonConvert.SerializeObject(barcodeItem)); + // } + // #endregion - #region 當生產單位為SMT或DIP時,確認是否有綁Group,有綁連片一起過站 - List GroupBarCodeID = new List(); - if (model.UnitNO == "S" || model.UnitNO == "D") - { - var GroupID = await _pcsApi.GetBarcodeGroupByBarCodeID(model.BarCodeID); - if (GroupID.Count != 0) - { - var BarCodeGroup = await _pcsApi.GetBarcodeGroupByGroupID(GroupID.FirstOrDefault().GroupID); - GroupBarCodeID = BarCodeGroup.Where(w => w.BarcodeID != model.BarCodeID).Select(s => s.BarcodeID).ToList(); - } + // // 新增 BarCodeWip 投入站新增 for 只有投入站才新增 + // if (model.StationSEQ == 1) + // { + // BarcodeWip barcodeWip = new BarcodeWip + // { + // BarcodeID = model.BarCodeID, + // WipID = model.WipID + // }; + // await _pcsApi.PostBarcodeWip(JsonConvert.SerializeObject(barcodeWip)); - foreach (int id in GroupBarCodeID) - { - // 更新 BarCode_Info - var barcodeGroupID = await _pcsApi.GetBarcodeInfoes(id); - if (barcodeGroupID.Count() != 0) - { - barcodeGroupID[0].StatusNo = BarStatusNo; - barcodeGroupID[0].RuleStationID = model.RuleStation; - barcodeGroupID[0].RuleStatus = !model.BarcodeNG ? "P" : "F"; //F 不良 - barcodeGroupID[0].WipID = model.WipID; - barcodeGroupID[0].StatusID = NextStopCloseStation.Success ? -1 : 1; - barcodeGroupID[0].UpdateDate = DateTime.Now; - await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeGroupID[0])); - } - // 新增 BarCodeStation - barcodeStation.BarcodeID = id; - await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStation)); - // 新增 BarCodeItem - for (int i = 0; i < model.Inputs.Where(w => !w.StartsWith("$")).Count(); i++) - { - var barcodeItem = new BarcodeItem - { - BarcodeID = id, - WipID = model.WipID, - RuleStationID = model.RuleStation, - ItemNo = model.MaterialKps[i].KpNo, - PartNo = Kp[i], - SysType = "S", - CreateUserID = 0, - CreateDate = DateTime.Now, - UpdateDate = DateTime.Now - }; - await _pcsApi.PostBarcodeItem(JsonConvert.SerializeObject(barcodeItem)); - } - // 新增 BarCodeWip 投入站新增 for 只有投入站才新增 - if (model.StationSEQ == 1) - { - BarcodeWip barcodeWip = new BarcodeWip - { - BarcodeID = id, - WipID = model.WipID - }; - await _pcsApi.PostBarcodeWip(JsonConvert.SerializeObject(barcodeWip)); + // var wipInfo = await _pcsApi.GetWipInfo(model.WipID); + // wipInfo[0].CompleteQTY += 1; + // await _pcsApi.PutWipInfo(JsonConvert.SerializeObject(wipInfo[0])); - var wipInfo = await _pcsApi.GetWipInfo(model.WipID); - wipInfo[0].CompleteQTY += 1; - await _pcsApi.PutWipInfo(JsonConvert.SerializeObject(wipInfo[0])); + // } - } + // // 判斷有不良代碼 新增 NgInfo NgComponent + // if (model.BarcodeNG) + // { + // 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, + // ReasonNo = NGNo, + // ProgramNo = "N/A", + // MachineNo = "N/A", + // StationId = model.Station, + // 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)); + // } + // } + // } - // 新增 NgInfo 不良時新增 判斷有不良代碼 - if (model.BarcodeNG) - { - 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, - ReasonNo = NGNo, - ProgramNo = "N/A", - MachineNo = "N/A", - StationId = model.Station, - 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)); - } - } - } - } - } - #endregion + // #region 當生產單位為SMT或DIP時,確認是否有綁Group,有綁連片一起過站 + // List GroupBarCodeID = new List(); + // if (model.UnitNO == "S" || model.UnitNO == "D") + // { + // var GroupID = await _pcsApi.GetBarcodeGroupByBarCodeID(model.BarCodeID); + // if (GroupID.Count != 0) + // { + // var BarCodeGroup = await _pcsApi.GetBarcodeGroupByGroupID(GroupID.FirstOrDefault().GroupID); + // GroupBarCodeID = BarCodeGroup.Where(w => w.BarcodeID != model.BarCodeID).Select(s => s.BarcodeID).ToList(); + // } + + // foreach (int id in GroupBarCodeID) + // { + // // 更新 BarCode_Info + // var barcodeGroupID = await _pcsApi.GetBarcodeInfoes(id); + // if (barcodeGroupID.Count() != 0) + // { + // barcodeGroupID[0].StatusNo = BarStatusNo; + // barcodeGroupID[0].RuleStationID = model.RuleStation; + // barcodeGroupID[0].RuleStatus = !model.BarcodeNG ? "P" : "F"; //F 不良 + // barcodeGroupID[0].WipID = model.WipID; + // barcodeGroupID[0].StatusID = NextStopCloseStation.Success ? -1 : 1; + // barcodeGroupID[0].UpdateDate = DateTime.Now; + // await _pcsApi.PutBarcodeInfoes(JsonConvert.SerializeObject(barcodeGroupID[0])); + // } + // // 新增 BarCodeStation + // barcodeStation.BarcodeID = id; + // await _pcsApi.PostBarcodeStation(JsonConvert.SerializeObject(barcodeStation)); + // // 新增 BarCodeItem + // for (int i = 0; i < model.Inputs.Where(w => !w.StartsWith("$")).Count(); i++) + // { + // var barcodeItem = new BarcodeItem + // { + // BarcodeID = id, + // WipID = model.WipID, + // RuleStationID = model.RuleStation, + // ItemNo = model.MaterialKps[i].KpNo, + // PartNo = Kp[i], + // SysType = "S", + // CreateUserID = 0, + // CreateDate = DateTime.Now, + // UpdateDate = DateTime.Now + // }; + // await _pcsApi.PostBarcodeItem(JsonConvert.SerializeObject(barcodeItem)); + // } + // // 新增 BarCodeWip 投入站新增 for 只有投入站才新增 + // if (model.StationSEQ == 1) + // { + // BarcodeWip barcodeWip = new BarcodeWip + // { + // BarcodeID = id, + // WipID = model.WipID + // }; + // await _pcsApi.PostBarcodeWip(JsonConvert.SerializeObject(barcodeWip)); + + // var wipInfo = await _pcsApi.GetWipInfo(model.WipID); + // wipInfo[0].CompleteQTY += 1; + // await _pcsApi.PutWipInfo(JsonConvert.SerializeObject(wipInfo[0])); + + // } + + // // 新增 NgInfo 不良時新增 判斷有不良代碼 + // if (model.BarcodeNG) + // { + // 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, + // ReasonNo = NGNo, + // ProgramNo = "N/A", + // MachineNo = "N/A", + // StationId = model.Station, + // 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)); + // } + // } + // } + // } + // } + // #endregion - Msg = "內部序號【" + Data + "】 過站完成!"; - Data = string.Empty; + // Msg = "內部序號【" + Data + "】 過站完成!"; + // Data = string.Empty; - } + //} #endregion if (NextStopCloseStation.Success) @@ -2504,7 +2554,7 @@ namespace AMESCoreStudio.Web.Controllers // 確認完工數是否等於工單數 await _pcsApi.CheckWipNoBarCodeAllClost(model.WipNO, model.UnitNO, model.RuleStation); } - + return Json(new Result() { success = Success, msg = Msg, data = Data }); } #endregion diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index eb9e8250..24cc5fed 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -249,6 +249,13 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/BarcodeItems/ByBarCodeID")] ITask> GetBarcodeItemByBarCodeID(int barcodeID); + + /// + /// 查詢組件序號 by BarCode + /// + /// + [WebApiClient.Attributes.HttpGet("api/BarcodeItems/ByBarCode")] + ITask> GetBarcodeItemByBarCode(string barcode); #endregion #region NgInfo 測試不良基本資料檔 PCS021 @@ -718,7 +725,6 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/BarCodeCheck/BarCodeKP")] ITask> CheckBarCodeKP(string wipno, string barcode, string unitNo, List inputKP); - #endregion diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs index b8ec6d24..c8c13801 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemsController.cs @@ -242,6 +242,33 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return barcodeItem; } + /// + /// 用barcode獲取資料 + /// + /// barcodeID + /// + [HttpGet("ByBarCode")] + public async Task>> GetBarcodeItemByBarCode(string barcode) + { + int barcodeID = 0; + BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); + var q1 = await barcodeInfoesController.GetBarcodeInfoesByNo(barcode); + if (!q1.Value.Any()) + barcodeID = 0; + else + barcodeID = q1.Value.FirstOrDefault().BarcodeID; + + IQueryable q = _context.BarcodeItems; + var barcodeItem = await q.Where(w => w.BarcodeID == barcodeID).ToListAsync(); + + if (barcodeItem == null) + { + return NotFound(); + } + + return barcodeItem; + } + /// /// 確認組件代碼是否重複 /// diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs index 1dda28ff..30e6ca5b 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs @@ -132,6 +132,23 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES // 抓RulseStationID barCodeCheckDto.ruleStationID = q_rulestation.Value.Where(w => w.StationID == barCodeCheckDto.station).FirstOrDefault().RuleStationID; + #region KeyParts 判斷 + if (barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Count() != 0) + { + var barcodeItemKPDto = new BarcodeItemKPDto + { + WipNo = barCodeCheckDto.wipNo, + barcode = barCodeCheckDto.barcode, + unitNo = barCodeCheckDto.unitNo, + inputKP = barCodeCheckDto.inputItems.Where(w => !w.inputType.Contains("NG")).Select(s => s.inputData).ToList() + }; + + var resultKeyParts = await CheckBarCodeKPAsync(barcodeItemKPDto); + if (!resultKeyParts.Success) + return (ResultModel)resultKeyParts; + } + #endregion + // 維修過站 組件需獨立判斷 if (barCodeCheckDto.barcodeType == "S") { @@ -360,6 +377,16 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } + if (!Table_BarcodeItem(barCodeCheckDto).Result.Success) + { + + } + + if (!Table_NgInfo(barCodeCheckDto).Result.Success) + { + + } + if (!Table_BarcodeWip(barCodeCheckDto).Result.Success) { @@ -461,6 +488,80 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return await barcodeStationController.PostBarcodeStation(barcodeStation); } + /// + /// NgInfo-組件资料 + /// + /// + /// + private async Task> Table_BarcodeItem(BarCodeCheckDto barCodeCheckDto) + { + BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); + var KeyPartsItem = barCodeCheckDto.inputItems.Where(w => !w.inputData.Contains("$")).ToList(); + var resut = new ResultModel(); + // 新增 BarCodeStation + for (int i = 0; i < KeyPartsItem.Count(); i++) + { + var barcodeItem = new BarcodeItem + { + BarcodeID = barCodeCheckDto.barcodeID, + WipID = barCodeCheckDto.wipID, + RuleStationID = barCodeCheckDto.ruleStationID, + ItemNo = KeyPartsItem[i].inputType, + PartNo = KeyPartsItem[i].inputData, + SysType = "S", + CreateUserID = 0, + CreateDate = DateTime.Now, + UpdateDate = DateTime.Now + }; + await barcodeItemsController.PostBarcodeItems(barcodeItem); + } + + return resut; + } + + /// + /// NgInfo-測試不良基本資料檔 + /// + /// + /// + private async Task> Table_NgInfo(BarCodeCheckDto barCodeCheckDto) + { + NgInfoController ngInfoController = new NgInfoController(_context); + NgComponentsController ngComponentsController = new NgComponentsController(_context); + var NgItem = barCodeCheckDto.inputItems.Where(w => w.inputData.Contains("$")).ToList(); + var resut = new ResultModel(); + // 新增 BarCodeStation + foreach (var NGNo in NgItem) + { + NgInfo ngInfo = new NgInfo + { + + TypeNo ="N", + OperatorID = 0, + FixtureNo = "NA", + BarcodeID = barCodeCheckDto.barcodeID, + ReasonNo = NGNo.inputData, + ProgramNo = "N/A", + MachineNo = "N/A", + StationId = barCodeCheckDto.station, + WipId = barCodeCheckDto.wipID + }; + var resultNgInfo = await ngInfoController.PostNgInfo(ngInfo); + if (resultNgInfo.Success) + { + NgComponent ngComponent = new NgComponent + { + NgID = resultNgInfo.Data.FirstOrDefault().NgID, + LocationNo = "N/A", + NgNo = NGNo.inputData, + }; + await ngComponentsController.PostNgComponent(ngComponent); + } + } + + return resut; + } + /// /// BarcodeWip-檔案用途 條碼工單資料檔 /// diff --git a/AMESCoreStudio.WebApi/DTO/BLL/BarCodeCheckDto.cs b/AMESCoreStudio.WebApi/DTO/BLL/BarCodeCheckDto.cs index 8b2d8ae5..a2830e92 100644 --- a/AMESCoreStudio.WebApi/DTO/BLL/BarCodeCheckDto.cs +++ b/AMESCoreStudio.WebApi/DTO/BLL/BarCodeCheckDto.cs @@ -100,7 +100,7 @@ namespace AMESCoreStudio.WebApi.DTO.AMES /// /// 紀錄組件或不良代碼 /// - + public class inputItem { /// @@ -125,7 +125,7 @@ namespace AMESCoreStudio.WebApi.DTO.AMES /// /// 治具條碼 /// - public class Outfit + public class Outfit { /// /// 刷入治具條碼