From 1c831c06baedf009035033e7fdca63d10d71b619 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 4 Jan 2022 18:41:58 +0800 Subject: [PATCH] 1. PCS021 --- .../Controllers/PCSController.cs | 49 +++-- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 20 +- AMESCoreStudio.Web/Views/PCS/PCS021.cshtml | 2 +- .../AMES/BarcodeStationController.cs | 23 +- .../Controllers/BLL/BarCodeCheckController.cs | 208 +++++++++++++++--- 5 files changed, 248 insertions(+), 54 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 7d68f28b..13193702 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -401,7 +401,7 @@ namespace AMESCoreStudio.Web.Controllers var RuleStations = new List(); for (int i = 0; i < result.Count; i++) { - RuleStations.Add(new SelectListItem(result[i].Sequence + "-" + result[i].StationDesc, result[i].RuleStationID.ToString())); + RuleStations.Add(new SelectListItem(result[i].Sequence + "-" + result[i].StationDesc, result[i].StationID.ToString())); } if (RuleStations.Count == 0) @@ -1829,7 +1829,7 @@ namespace AMESCoreStudio.Web.Controllers if (result.Success) { _msg += "目前內部序號【" + model.BarCodeNo + "】條碼鎖定成功!
"; - + } else { @@ -2066,6 +2066,7 @@ namespace AMESCoreStudio.Web.Controllers if (model.MaterialItem != null) { model.MaterialKps = await _pcsApi.GetMaterialKpByItemID(model.MaterialItem.ItemID); + model.MaterialKps = model.MaterialKps.Where(w => w.StationType == model.UnitNO).ToList(); model.MaterialStationsItems = await _pcsApi.GetMaterialStationsItemByItemID(model.MaterialItem.ItemID); if (model.MaterialStationsItems.Count() == 0) @@ -2104,9 +2105,7 @@ namespace AMESCoreStudio.Web.Controllers // ResultModel string Msg = string.Empty; bool Success = true; - string Data = string.Empty; - - + string Data = model.Input; #region 基本Input 輸入判斷 if (model.WipID == 0) @@ -2115,7 +2114,7 @@ namespace AMESCoreStudio.Web.Controllers if (model.MaterialOutfits.Where(w => string.IsNullOrWhiteSpace(w.Inputs)).Any()) Msg += "請刷入治具編號
"; - if (model.RuleStation == 0) + if (model.Station == 0) { Msg += "請選擇作業站
"; } @@ -2132,22 +2131,37 @@ namespace AMESCoreStudio.Web.Controllers } #endregion - Data = model.Input; var Kp = model.Inputs.Where(w => !w.Contains("$")).ToList(); // 撈非不良代碼 = 組件序號 var q = await _pcsApi.CheckBarCodeFromWip(model.Input); // 判斷是否用內部序號有對應到工單號碼,沒對應到視為組件或不良代碼 if (q.Success) { + #region 確認序號的狀態 // 比對內序號的工單號碼與過站工單號碼是否一致 if (q.Msg == model.WipNO) { // Input為內部序號 model.Barcode = true; - // 抓作業站順序 - var RuleStation = await _basApi.GetRuleStation(model.RuleStation); - model.StationSEQ = RuleStation.FirstOrDefault().Sequence; - model.StationTestType = RuleStation.FirstOrDefault().Station.TestType; + // 確認內部序號是否報廢 + 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 }); + + // 取RuleStationID + var RuleStations = await _basApi.GetRuleStationsByFlow(model.FlowRuleID, 0); + if (RuleStations.Count != 0) + { + // 抓作業站順序 + model.RuleStation = RuleStations.Where(w => w.StationID == model.Station).Select(s => s.RuleStationID).FirstOrDefault(); + model.StationSEQ = RuleStations.Where(w => w.StationID == model.Station).Select(s => s.Sequence).FirstOrDefault(); + model.StationTestType = RuleStations.Where(w => w.StationID == model.Station).Select(s => s.Station.TestType).FirstOrDefault(); + } // 判斷是否有$符號,代表有不良代碼 if (model.Inputs.Where(w => w.Contains("$")).Any()) { @@ -2159,6 +2173,10 @@ namespace AMESCoreStudio.Web.Controllers } } + // 判斷作業站與製程順序是否正確 + + + // 下一個作業站是完工站時再判斷是否都有刷組件 // 判斷組件是否都有輸入 if (Kp.Count() != model.MaterialKps.Count()) { @@ -2166,7 +2184,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - for (int i = 0; i < model.MaterialKps.Count; i++) { if (Kp[i].Length != model.MaterialKps[i].Length) @@ -2177,7 +2194,6 @@ namespace AMESCoreStudio.Web.Controllers if (!Kp[i].ToUpper().StartsWith(model.MaterialKps[i].Title.ToUpper())) Msg += "組件序號【" + Kp[i] + "】 與組件名稱【" + model.MaterialKps[i].Title + "】前置碼不符合
"; } - } } @@ -2186,7 +2202,14 @@ namespace AMESCoreStudio.Web.Controllers { Msg += "內部序號工單號碼與過站工單不相同
"; } + #endregion } + // 當組件時,先新增 + else if (!model.Input.StartsWith('$')) + { + + } + if (!string.IsNullOrWhiteSpace(Msg)) { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 9249f2db..47f4b486 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -84,7 +84,7 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/WipInfos/GetWipInfoSelectParameter")] //ITask> GetWipInfoSelectParameter(string unitno = null, string wipno = null); ITask> GetWipInfoSelectParameter(string unitno = null, string wipno = null, int lineid = 0 - , string itemno = null, DateTime? date_str = null, DateTime? date_end = null , int page = 1, int limit = 10); + , string itemno = null, DateTime? date_str = null, DateTime? date_end = null, int page = 1, int limit = 10); /// /// 查詢工單基本資料+是否已過站 @@ -96,7 +96,7 @@ namespace AMESCoreStudio.Web //ITask> GetWipInfoSelectParameter(string unitno = null, string wipno = null); ITask> GetWipInfoSelectParameterInBarCodeStation(string unitno = null, string wipno = null, int lineid = 0 , string itemno = null, DateTime? date_str = null, DateTime? date_end = null); - + /// /// 查詢工單基本資料-WipID /// @@ -192,7 +192,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpDelete("api/WipBarcode/{wipno}/{strno}/{endno}")] - ITask> DeleteWipBarcode(string wipno , string strno , string endno); + ITask> DeleteWipBarcode(string wipno, string strno, string endno); #endregion #region WipBarcodeOthers 工單條碼區間設定檔(除内部SN) PCS001 @@ -241,12 +241,22 @@ namespace AMESCoreStudio.Web #region BarcodeWip 檔案用途 條碼工單資料檔 PCS021 [WebApiClient.Attributes.HttpGet("api/BarcodeWip/{id}/{wipid}")] - ITask GetBarcodeWipByTwoKey(string id , string wipid); + ITask GetBarcodeWipByTwoKey(string id, string wipid); [WebApiClient.Attributes.HttpPost("api/BarcodeWip")] ITask PostBarcodeWip([FromBody, RawJsonContent] string model); #endregion + #region BarCodeStation 條碼過站資料檔 + /// + /// BarCodeID 查詢過站紀錄 + /// + /// + /// + [WebApiClient.Attributes.HttpGet("api/BarcodeStation/BarCodeID/{barcodeID}")] + ITask> GetBarcodeStationByBarCodeID(int barcodeID); + #endregion + #region CParameterIni MAC資料表 PCS001 [WebApiClient.Attributes.HttpGet("api/MACInfoes/Class/{id}")] ITask GetMACInfo(string id); @@ -495,8 +505,6 @@ namespace AMESCoreStudio.Web ITask> PostWipSopLog([FromBody, RawJsonContent] string model); #endregion - - #region PCS024組件維護相關 /// diff --git a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml index d2bd9a87..bf2a9c6c 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml @@ -88,7 +88,7 @@
-
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs index 3eb386e4..c2c10d96 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeStationController.cs @@ -74,6 +74,25 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return barcodeStation; } + /// + /// 用BarCode查詢過站紀錄 + /// + /// barcodeID + /// + [HttpGet("BarCodeID/{barcodeID}")] + public async Task>> GetBarcodeStationByBarCodeID(int barcodeID) + { + IQueryable q = _context.BarcodeStation.Where(w => w.BarcodeID == barcodeID); + var barcodeStation = await q.ToListAsync(); + + if (barcodeStation == null) + { + return NotFound(); + } + + return barcodeStation; + } + /// /// 用工單ID查是否有過站紀錄 /// @@ -83,8 +102,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> GetBarcodeStationByWipIDList(List wipID) { - var barcodeStation = await _context.BarcodeStation - .Where(w => wipID.Contains(w.WipID)).FirstOrDefaultAsync(); + var barcodeStation = await _context.BarcodeStation + .Where(w => wipID.Contains(w.WipID)).FirstOrDefaultAsync(); if (barcodeStation == null) { diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs index 83b2103c..0d2d7375 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs @@ -39,20 +39,48 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// 線別 /// 流程 /// - [HttpGet("BarCodeDataCheck")] - public IActionResult GetBarCodeDataCheck(string wipno, string unitno, int station, int line, int flowrule) + [HttpGet("CheckWipNoSation")] + public IActionResult GetCheckWipNoSation(string wipno, string unitno, int station, int line, int flowrule) { var result = CheckWipNoSationAsync(WipNo: wipno, UnitNo: unitno, FlowRuleID: flowrule, Station: station, Line: line); return Ok(result.Result); } + /// + /// 判斷序號狀態 + /// + /// + /// + /// + /// + /// + [HttpGet("CheckBarCodeStation")] + public async Task GetCheckBarCodeStation(string wipno, string barcode, string unitno, int station) + { + //ResultModel resultModel = new ResultModel() + //ResultModel aa = await (ResultModel)CheckBarCodeLockAsync(barcode); + //return Ok(aa); + + //return Ok(); + //resultModel = (ResultModel)CheckBarCodeLockAsync(barcode).AsyncState; + //if (!resultModel.Success) + // return Ok(resultModel); + + //resultModel = (ResultModel)CheckBarCodeScrappedAsync(barcode).AsyncState; + //if (!resultModel.Success) + // return Ok(resultModel); + + return Ok(); + } + + /// /// 內部序號查詢工單號碼 /// /// 內部序號 /// Success:true or false [HttpGet("BarCodeFromWip")] - public IActionResult CheckBarCodeFromWip(string barcode) + public ActionResult> CheckBarCodeFromWip(string barcode) { ResultModel resultModel = new ResultModel { Success = false }; if (barcode.Length <= 4) @@ -228,6 +256,151 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return Ok(resultModel); } + /// + /// 確認內部條碼流動 + /// + /// 工單號碼 + /// 內部條碼 + /// 生產單位編號 + /// 作業站編號 + /// + [HttpGet("BarCodeFlow")] + public async Task CheckBarCodeFlowAsync(string wipno, string barcode, string unitno, int station) + { + ResultModel resultModel = new ResultModel { Success = false }; + WipInfosController wipInfosController = new WipInfosController(_context); + var q = await wipInfosController.GetWipInfoByWipNo(wipno); + if (q.Value.Count() == 0) + { + resultModel.Msg = "找不到工單號碼【" + wipno + "】"; + return Ok(resultModel); + } + + // 找該筆工單號碼的生產單位代號 + var q1 = q.Value.Where(w => w.UnitNO == unitno).FirstOrDefault(); + if (q1 == null) + { + resultModel.Msg = "該工單號碼【" + wipno + "】 找不到對應生產單位代號資料"; + return Ok(resultModel); + } + + // 取工單號碼開立的 WipID、生產單位 + var wipinfo = q.Value.Select(s => new { s.WipID, s.UnitNO }).ToList(); + + // 取BarCodeID + int BarCodeID = await BarCodeToID(barcode); + + // 取內部序號過站紀錄 + BarcodeStationController barcodeStationController = new BarcodeStationController(_context); + var BarCodeStations = await barcodeStationController.GetBarcodeStationByBarCodeID(BarCodeID); + BarCodeStations = BarCodeStations.Value.ToList(); + + // 判斷需要前製程是否已經投入 + if (q1.InputFlag == "Y") + { + // 有BarCodeID + if (BarCodeID != 0) + { + // 判斷是否有前製程過站資料 + // SMT(S)->DIP(D) + if (unitno == "D") + { + int? WipID = wipinfo.Where(w => w.UnitNO == "S").Select(s => s.WipID).FirstOrDefault(); + if (WipID == 0) + { + resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; + return Ok(resultModel); + } + + if (!BarCodeStations.Value.Where(w => w.BarcodeID == BarCodeID && w.WipID == WipID && w.RuleStatus == "P").Any()) + { + resultModel.Msg = "該內部序號【" + barcode + "】前製程生產單位尚未有過站紀錄"; + return Ok(resultModel); + } + } + // 組裝(B)->系統測試(T)->成品包裝(P) + else if (unitno == "T") + { + int? WipID = wipinfo.Where(w => w.UnitNO == "B").Select(s => s.WipID).FirstOrDefault(); + if (WipID == 0) + { + resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; + return Ok(resultModel); + } + + if (!BarCodeStations.Value.Where(w => w.BarcodeID == BarCodeID && w.WipID == WipID && w.RuleStatus == "P").Any()) + { + resultModel.Msg = "該內部序號【" + barcode + "】前製程生產單位尚未有過站紀錄"; + return Ok(resultModel); + } + } + else if (unitno == "P") + { + int? WipID = wipinfo.Where(w => w.UnitNO == "T").Select(s => s.WipID).FirstOrDefault(); + if (WipID == 0) + { + resultModel.Msg = "該工單號碼【" + wipno + "】的前製程生產單位尚未建立工單基本資料"; + return Ok(resultModel); + } + + if (!BarCodeStations.Value.Where(w => w.BarcodeID == BarCodeID && w.WipID == WipID && w.RuleStatus == "P").Any()) + { + resultModel.Msg = "該內部序號【" + barcode + "】前製程生產單位尚未有過站紀錄"; + return Ok(resultModel); + } + } + } + // 沒有BarCodeID + else + { + if (unitno != "S" && unitno != "B") + { + resultModel.Msg = "該工單號碼【" + wipno + "】前製程式尚未投產"; + return Ok(resultModel); + } + } + } + + #region 判斷作業站順序 + // 抓流程順序資料 + RuleStationsController ruleStationsController = new RuleStationsController(_context); + var ruleStations = await ruleStationsController.GetRuleStationByFlow(q1.FlowRuleID, 0); + if (ruleStations.Value.Count() == 0) + { + resultModel.Msg = "該工單號碼【" + wipno + "】的流程編號尚未設定流程"; + return Ok(resultModel); + } + + // 該作業站 RuleStationID + int? RuleStationID = ruleStations.Value.Where(w => w.StationID == station).Select(s => s.RuleStationID).FirstOrDefault(); + // 該作業站順序 + int? Sequence = ruleStations.Value.Where(w => w.StationID == station).Select(s => s.Sequence).FirstOrDefault(); + if (RuleStationID == 0) + { + resultModel.Msg = "該工單號碼【" + wipno + "】的流程未設定此作業站"; + return Ok(resultModel); + } + + // 取目前工單ID + int wipID = q1.WipID; + // 該筆工單ID過站紀錄 + var BarCodeStationByWipID = BarCodeStations.Value.Where(w => w.WipID == wipID).ToList(); + foreach (var item in ruleStations.Value.OrderBy(o => o.Sequence)) + { + + } + + + #endregion + return Ok(ruleStations); + //if (q.Value.Any(w => w.RuleStatus == "S")) + //{ + // resultModel.Msg = "內部序號【" + barcode + "】已報廢或轉賣, 不可繼續過站!"; + // return Ok(resultModel); + + //} + } + /// /// 確認工單狀態 /// @@ -291,35 +464,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return resultModel; } - /// - /// 內部序號是否被鎖定 - /// - /// 工單號碼 - /// 內部序號 - /// - private async Task CheckBarCodeStationAsync(string WipNo, string BarCode) - { - BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); - - // 序號與工單相同視為序號 - if (BarCode.IndexOf(WipNo) != -1) - { - // 判斷BarCodeInfo 是否有條碼序號資料 - var q = await barcodeInfoesController.GetBarcodeInfoesByNo(BarCode); - if (q.Value.Count() != 0) - { - // 判斷條碼序號是否有被鎖定 - BarcodeLockController barcodeLockController = new BarcodeLockController(_context); - var q1 = await barcodeLockController.GetBarcodeLockByBarCodeID(q.Value.FirstOrDefault().BarcodeID); - if (q1.Value.Where(w => w.LockStatus == 0).Any()) - { - return "條碼編號:" + BarCode + ",已被鎖定,無法過站"; - } - } - } - return ""; - } - /// /// 內部序號找BarCodeID