From 63dcdb4b1107e886ad3902b66cb3a73531c1b0cf Mon Sep 17 00:00:00 2001 From: Ray Date: Mon, 17 Jan 2022 20:08:12 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E4=BF=AE=E6=AD=A3=E7=B6=AD=E4=BF=AE?= =?UTF-8?q?=E9=81=8E=E7=AB=99=E5=88=A4=E6=96=B7=202.=20=E5=8A=A0=E5=85=A5D?= =?UTF-8?q?emo=20=E6=B8=AC=E8=A9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/FQCController.cs | 17 +- .../Controllers/SYSController.cs | 42 ++- AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs | 7 + AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 5 + AMESCoreStudio.Web/Views/SYS/SYS001.cshtml | 11 +- AMESCoreStudio.Web/Views/SYS/SYS001C.cshtml | 2 +- AMESCoreStudio.Web/Views/SYS/SYS001T.cshtml | 40 +++ .../AMES/BarcodeItemChangesController.cs | 2 +- .../Controllers/AMES/MaterialKpController.cs | 2 +- .../Controllers/AMES/QcCriterionController.cs | 12 + .../AMES/WipBarcodeOthersController.cs | 2 +- .../Controllers/AMES/WipMACController.cs | 2 +- .../Controllers/BLL/BarCodeCheckController.cs | 329 +++++++++++++++++- .../DTO/AMES/BarcodeItemKPDto.cs | 6 +- .../DTO/BLL/BarCodeCheckDto.cs | 33 +- .../Models/AMES/BarcodeInfo.cs | 2 +- 16 files changed, 490 insertions(+), 24 deletions(-) create mode 100644 AMESCoreStudio.Web/Views/SYS/SYS001T.cshtml diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index cf301c63..6edf2bac 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -420,6 +420,20 @@ namespace AMESCoreStudio.Web.Controllers { if (ModelState.IsValid) { + #region 判斷設定起訖數量區間是否有重疊 + var query = await _fqcApi.GetQcCriterionByQuotID(model.QuotID); + if (query.Where(w => w.QcStart <= model.QcStart && model.QcStart <= w.QcEnd).Any() || + query.Where(w => w.QcStart <= model.QcEnd && model.QcEnd <= w.QcEnd).Any()) + { + ModelState.AddModelError("error", "設定起訖數量區間有重疊,請確認"); + if (model.CritID == 0) + { + return View("FQC005C", model); + } + return View("FQC005U", model); + } + #endregion + IResultModel result; if (model.CritID == 0) { @@ -437,7 +451,6 @@ namespace AMESCoreStudio.Web.Controllers } else { - ModelState.AddModelError("error", result.Msg); } } @@ -576,7 +589,7 @@ namespace AMESCoreStudio.Web.Controllers { IResultModel result = await _fqcApi.GetFqcInhouseMasterQuery(barcodeNo: barcodeNo, wipNo: wipNo , boxNo: boxNo, inhouseNo: inhouseNo, date_str: date_str, date_end: date_end - , status: status , page: page, limit: limit); + , status: status, page: page, limit: limit); if (result.Data.Count() != 0) { diff --git a/AMESCoreStudio.Web/Controllers/SYSController.cs b/AMESCoreStudio.Web/Controllers/SYSController.cs index e6e7cd88..0533880c 100644 --- a/AMESCoreStudio.Web/Controllers/SYSController.cs +++ b/AMESCoreStudio.Web/Controllers/SYSController.cs @@ -8,6 +8,7 @@ using System.Collections.Generic; using Microsoft.AspNetCore.Mvc.Rendering; using AMESCoreStudio.WebApi.Models.SYS; using AMESCoreStudio.CommonTools.Result; +using AMESCoreStudio.WebApi.DTO.AMES; namespace AMESCoreStudio.Web.Controllers { @@ -15,10 +16,12 @@ namespace AMESCoreStudio.Web.Controllers { private readonly ILogger _logger; public readonly ISYS _sysApi; - public SYSController(ILogger logger, ISYS sysApi) + public readonly IPCS _pcsApi; + public SYSController(ILogger logger, ISYS sysApi , IPCS pCS) { _logger = logger; _sysApi = sysApi; + _pcsApi = pCS; //if (Request.Cookies["_AMESCookie"] != null) //{ // HttpContext.Request.Cookies.TryGetValue("UserID", out userID); @@ -217,6 +220,43 @@ namespace AMESCoreStudio.Web.Controllers return Json(new Table() { count = 0, data = null }); } + #region Ray 維修測試 + //新增頁面 + public IActionResult SYS001T() + { + return View(); + } + + [HttpPost] + public async Task SYS001TAsync(SystemInfo model) + { + var x = new BarCodeCheckDto + { + wipNo = "WO0002A1", + barcode = "WO0002A10006", + barcodeType = "S", + station = 1017, + line = 1001, + unitNo = "B", + inputItems = new List { + new BarCodeCheckDto.inputItem + { + inputType = "KP", + inputData = "CPUSN199", + oldInputData = "CPUSN103" + }, + new BarCodeCheckDto.inputItem + { + inputType = "KP", + inputData = "RAMSN293", + oldInputData = "RAMSN203" + } } + }; + + var aa = await _pcsApi.PassIngByCheck(JsonConvert.SerializeObject(x)); + return Ok(aa); + } + #endregion #endregion #region SYS002模组资料维护相关 diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index b79f7db3..0d62e973 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -221,6 +221,13 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/QcQuot")] ITask> GetQcQuot(); + + /// + /// 查詢抽驗標準 ByQuotID + /// + /// + [WebApiClient.Attributes.HttpGet("api/QcCriterion/ByQuotID/{id}")] + ITask> GetQcCriterionByQuotID(int id); #endregion #region FQC006 FQC狀態維護 diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index a35a3f3c..49e39b9a 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -14,6 +14,11 @@ namespace AMESCoreStudio.Web [JsonReturn] public interface IPCS : IHttpApi { + ////////////////////////////////////// + [WebApiClient.Attributes.HttpPost("api/BarCodeCheck/PassIngByCheck")] + ITask> PassIngByCheck([FromBody,RawJsonContent] string model); + ////////////////////////////////////// + #region 下拉選單 /// /// 產品別 diff --git a/AMESCoreStudio.Web/Views/SYS/SYS001.cshtml b/AMESCoreStudio.Web/Views/SYS/SYS001.cshtml index 669b1766..4783815f 100644 --- a/AMESCoreStudio.Web/Views/SYS/SYS001.cshtml +++ b/AMESCoreStudio.Web/Views/SYS/SYS001.cshtml @@ -100,7 +100,16 @@ hg.open('新增系統', '/SYS/SYS001C', 720, 600); } - } + }, + { + text: '維修過站測試', + layuiicon: '', + class: 'layui-btn-normal', + handler: function () { + hg.open('新增系統', '/SYS/SYS001T', 720, 600); + + } + } ]; //基本数据表格 var table = hg.table.datatable('test', '系統資料管理', '/SYS/GetSystemInfoes', {}, tableCols, toolbar, true, 'full-100', ['filter', 'print', 'exports']); diff --git a/AMESCoreStudio.Web/Views/SYS/SYS001C.cshtml b/AMESCoreStudio.Web/Views/SYS/SYS001C.cshtml index c9f2a364..db5a159f 100644 --- a/AMESCoreStudio.Web/Views/SYS/SYS001C.cshtml +++ b/AMESCoreStudio.Web/Views/SYS/SYS001C.cshtml @@ -12,7 +12,7 @@
-
+
diff --git a/AMESCoreStudio.Web/Views/SYS/SYS001T.cshtml b/AMESCoreStudio.Web/Views/SYS/SYS001T.cshtml new file mode 100644 index 00000000..1a14e893 --- /dev/null +++ b/AMESCoreStudio.Web/Views/SYS/SYS001T.cshtml @@ -0,0 +1,40 @@ +@model AMESCoreStudio.WebApi.Models.SYS.SystemInfo + + +@{ ViewData["Title"] = "SYS001C"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + + + +
+
+ +
+ @Html.ValidationMessage("error") +
+ +
+ + +
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemChangesController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemChangesController.cs index 99d5369c..3b72c73e 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemChangesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/BarcodeItemChangesController.cs @@ -117,7 +117,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); Helper helper = new Helper(_context); - var BarcodeItemChangeID = helper.GetIDKey("B_I_CHANGE_ID").Result; + var BarcodeItemChangeID = helper.GetIDKey("BARCODE_ITEM_CHANGE").Result; //請RITA加ID barcodeItemChange.BarcodeItemChangeID = BarcodeItemChangeID; _context.BarcodeItemChanges.Add(barcodeItemChange); diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialKpController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialKpController.cs index 014ca7c5..fd623a73 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialKpController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialKpController.cs @@ -12,7 +12,7 @@ using AMESCoreStudio.WebApi.DTO.AMES; namespace AMESCoreStudio.WebApi.Controllers.AMES { /// - /// 料號基本資料檔Controller + /// 料號對應組件資料檔Controller /// [Route("api/[controller]")] [ApiController] diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/QcCriterionController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/QcCriterionController.cs index cd24744e..3ab71288 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/QcCriterionController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/QcCriterionController.cs @@ -47,6 +47,18 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return qcCriterion; } + /// + /// ByQuotID + /// + /// QuotID + /// + [HttpGet("ByQuotID/{id}")] + public async Task>> GetQcCriterionByQuotID(int id) + { + var qcCriterion = await _context.QcCriteria.Where(w => w.QuotID == id).ToListAsync(); + return qcCriterion; + } + [HttpGet("QcCriterionQuery")] public async Task> GetQcCriterionQuery(int quotID = 0,int page = 1, int limit = 10) { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeOthersController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeOthersController.cs index e49c3c76..cedf5ffc 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeOthersController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipBarcodeOthersController.cs @@ -12,7 +12,7 @@ using AMESCoreStudio.CommonTools.Result; namespace AMESCoreStudio.WebApi.Controllers.AMES { /// - /// + /// 工單條碼區間設定檔 /// [Route("api/[controller]")] [ApiController] diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipMACController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipMACController.cs index 8460bfa7..4d7d77d9 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipMACController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipMACController.cs @@ -19,7 +19,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES private readonly AMESContext _context; /// - /// + /// 工單MAC資料檔 /// /// public WipMACController(AMESContext context) diff --git a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs index ecd4ba59..82e07411 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/BarCodeCheckController.cs @@ -31,6 +31,307 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES _context = context; } + #region + /// + /// 過站判斷 + /// + /// + /// + [HttpPost("PassIngByCheck")] + public async Task>> CheckBarCodeCheck([FromBody] BarCodeCheckDto barCodeCheckDto) + { + ResultModel resultModel = new ResultModel { Success = false }; + //resultModel = (ResultModel)await CheckWipNoSationAsync("1", "1", 1, 1); + + #region 欄位資料空值判斷 + if (string.IsNullOrWhiteSpace(barCodeCheckDto.wipNo)) + { + resultModel.Msg = "請輸入工單號碼"; + return Ok(resultModel); + } + + if (string.IsNullOrWhiteSpace(barCodeCheckDto.barcode)) + { + resultModel.Msg = "請輸入內部條碼"; + return Ok(resultModel); + } + + if (string.IsNullOrWhiteSpace(barCodeCheckDto.unitNo)) + { + resultModel.Msg = "請輸入生產單位"; + return Ok(resultModel); + } + + if (barCodeCheckDto.station == 0) + { + resultModel.Msg = "請輸入作業站代碼"; + return Ok(resultModel); + } + + if (barCodeCheckDto.line == 0) + { + resultModel.Msg = "請輸入線別代碼"; + return Ok(resultModel); + } + #endregion + + #region 宣告各個Controller + WipInfosController wipInfosController = new WipInfosController(_context); + WipMACController wipMACController = new WipMACController(_context); + WipBarcodeOtherController wipBarcodeOtherController = new WipBarcodeOtherController(_context); + BarcodeItemsController barcodeItemsController = new BarcodeItemsController(_context); + BarcodeInfoesController barcodeInfoesController = new BarcodeInfoesController(_context); + BarcodeStationController barcodeStationController = new BarcodeStationController(_context); + BarcodeItemChangesController barcodeItemChangesController = new BarcodeItemChangesController(_context); + RuleStationsController ruleStationsController = new RuleStationsController(_context); + MaterialKpController materialKpController = new MaterialKpController(_context); + #endregion + + #region 宣告參數 + // 工單ID + int wipID = 0; + // 內部條碼ID + int barCodeID = 0; + // 流程ID + int flowRule = 0; + // 流程站別順序ID + int ruleStation = 0; + // 料號ID + int itemID = 0; + // 作業站順序 + int stationSEQ = 0; + // 料號 + string item = string.Empty; + // 站別測試類別 + string stationTestType = string.Empty; + // 存放要更新BarCodeItem + var update_BarCodeItem = new List(); + var insert_BarCodeItemChange = new List(); + #endregion + + var q_wipinfo = await wipInfosController.GetWipInfoByWipNo(barCodeCheckDto.wipNo); + + if (!q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).Any()) + { + resultModel.Msg = "找不到工單號碼【" + barCodeCheckDto.wipNo + "】或所對應的生產單位"; + return resultModel; + } + wipID = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().WipID; + flowRule = q_wipinfo.Value.Where(w => w.UnitNO == barCodeCheckDto.unitNo).FirstOrDefault().FlowRuleID; + barCodeID = BarCodeToID(barCodeCheckDto.barcode).Result; + item = q_wipinfo.Value.FirstOrDefault().GetWipAtt.ItemNO; + itemID = ItemNoToItemID(item).Result; + + var q_rulestation = await ruleStationsController.GetRuleStationByFlow(flowRule, 0, 0); + if (q_rulestation.Value.Count() == 0) + { + resultModel.Msg = "找不到工單號碼【" + barCodeCheckDto.wipNo + "】綁定的流程順序檔"; + return resultModel; + } + else if (!q_rulestation.Value.Where(w => w.StationID == barCodeCheckDto.station).Any()) + { + resultModel.Msg = "找不到工單號碼【" + barCodeCheckDto.wipNo + "】所對應的作業站別"; + return resultModel; + } + + // 抓作業站順序 + ruleStation = q_rulestation.Value.Where(w => w.StationID == barCodeCheckDto.station).FirstOrDefault().RuleStationID; + stationSEQ = q_rulestation.Value.Where(w => w.StationID == barCodeCheckDto.station).FirstOrDefault().Sequence; + stationTestType = q_rulestation.Value.Where(w => w.StationID == barCodeCheckDto.station).FirstOrDefault().Station.TestType; + + // 維修過站 組件需獨立判斷 + if (barCodeCheckDto.barcodeType == "S") + { + // 確認新舊組件序號是否都有值 + if (barCodeCheckDto.inputItems.Where(w => w.inputType != "NG" && + (string.IsNullOrWhiteSpace(w.inputData) || string.IsNullOrWhiteSpace(w.oldInputData))).Any()) + { + resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】維修過站資料有缺新舊組件序號,請確認"; + return resultModel; + } + + // 用BarCodeID And WipID 取BarCodeItem + + var q_BarCodeItem = await barcodeItemsController.GetBarcodeItemByBarCodeID(barCodeID); + q_BarCodeItem = q_BarCodeItem.Value.Where(w => w.WipID == wipID).ToList(); + + foreach (var KPs in barCodeCheckDto.inputItems) + { + // 用舊組件序號比對 + var barCodeItem = q_BarCodeItem.Value.Where(w => w.PartNo == KPs.oldInputData).FirstOrDefault(); + + if (barCodeItem != null) + { + + var MaterialKps = (await materialKpController.GetMaterialKpByItemID(itemID)).ToList(); + MaterialKps = MaterialKps.Where(w => w.StationType == barCodeCheckDto.unitNo).OrderBy(o => o.KpSeq).ToList(); + if (MaterialKps.Count == 0) + { + resultModel.Msg = "工單號碼【" + barCodeCheckDto.wipNo + "】找不到相關Key Parts對應"; + } + else + { + var q_Kp = MaterialKps.Where(w => w.KpNo == barCodeItem.ItemNo).FirstOrDefault(); + if (q_Kp != null) + { + #region 比對序號長度是否正確 + if (!string.IsNullOrWhiteSpace(q_Kp.Length.ToString())) + { + if (q_Kp.Length != KPs.inputData.Length) + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.KpName + "】長度不符合
"; + } + #endregion + + #region 前置碼正確 + if (!string.IsNullOrWhiteSpace(q_Kp.Title)) + { + if (!KPs.inputData.ToUpper().StartsWith(q_Kp.Title.ToUpper())) + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與組件名稱【" + q_Kp.Title + "】前置碼不符合
"; + } + #endregion + + #region 組件代碼-組件序號是否重複 + var checkDataRedundancy = await barcodeItemsController.GetBarcodeItemByDataRedundancy(q_Kp.KpNo, KPs.inputData); + if (checkDataRedundancy.Value.Count() != 0) + { + resultModel.Msg += "組件名稱【" + q_Kp.KpName + "】已有相同組件序號【" + KPs.inputData + "】紀錄
"; + } + #endregion + + #region 判斷組件序號是否在製狀態 + if (q_Kp.KpName.ToUpper() == "BOARD") + { + + var BarCodeInfo = await barcodeInfoesController.GetBarcodeInfoesByNo(KPs.inputData); + if (BarCodeInfo.Value.Where(w => w.StatusID != -1).Any()) + { + resultModel.Msg += "組件序號【" + KPs.inputData + "】 目前是在製狀態
"; + } + } + #endregion + + #region 判斷MAC區間 + if (q_Kp.KpName.ToUpper() == "MAC") + { + + var wipMAC = await wipMACController.GetWipMAC(barCodeCheckDto.wipNo); + if (wipMAC.Value == null) + { + resultModel.Msg += "工單號碼【" + barCodeCheckDto.wipNo + "】 找不到綁定MAC區間
"; + } + else + { + // 判斷MAC前置碼是否一樣 + if (!KPs.inputData.StartsWith(wipMAC.Value.Title)) + { + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與MAC【" + wipMAC.Value.Title + "】前置碼不符合
"; + } + else + { + // 判斷是否符合區間 + if (KPs.inputData.Length == 12) + { + if (!(Convert.ToInt32(wipMAC.Value.StartNO, 16) <= Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) + && Convert.ToInt32(KPs.inputData.Substring(7, 6), 16) <= Convert.ToInt32(wipMAC.Value.EndNO, 16))) + { + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定MAC區間不符合
"; + } + } + } + } + } + #endregion + + #region 判斷出貨序號 + // 當KP_NAME是 EXT_NO 判斷組件-出貨序號 是否有在區間 + if (q_Kp.KpName.ToUpper() == "EXT_NO") + { + + var WipBarCodeOther = await wipBarcodeOtherController.CheckWipBarcodeOtherByNo(barCodeCheckDto.wipNo, KPs.inputData); + if (WipBarCodeOther.Value.Count() == 0) + { + resultModel.Msg += "組件序號【" + KPs.inputData + "】 與工單設定出貨序號區間不符合
"; + } + else + { + //resultModel.Data = new List { KPs.inputData }; + //resultModel.Msg = "EXT_NO"; + } + } + #endregion + } + } + + barCodeItem.PartNo = KPs.inputData; + barCodeItem.RuleStationID = ruleStation; + barCodeItem.UpdateDate = DateTime.Now; + update_BarCodeItem.Add(barCodeItem); + + insert_BarCodeItemChange.Add(new BarcodeItemChange + { + WipID = wipID, + RuleStationID = ruleStation, + BarcodeID = barCodeID, + ItemNo = barCodeItem.ItemNo, + PartNoOld = KPs.oldInputData, + ChangeType = "RP", + KpItemNo = KPs.inputData + }); + } + } + + if (!string.IsNullOrWhiteSpace(resultModel.Msg)) + return resultModel; + } + + //var NextStopCloseStation = await CheckNextStopCloseStation(barCodeCheckDto.wipNo, barCodeCheckDto.unitNo, barCodeCheckDto.station); + + #region 過站判斷正常 往下處理Table + + #region 內部序號輸入後新增 or 更新 + var barcodeInfo = barcodeInfoesController.GetBarcodeInfoes(barCodeID).Result.Value.FirstOrDefault(); + barcodeInfo.RuleStationID = ruleStation; + barcodeInfo.RuleStatus = "P"; + + + var resultBarCodeInfo = await barcodeInfoesController.PutBarcodeInfoes(barcodeInfo); + if (resultBarCodeInfo.Success) + { + // 新增 BarCodeStation + BarcodeStation barcodeStation = new BarcodeStation + { + BarcodeID = barCodeID, + WipID = wipID, + RuleStationID = ruleStation, + RuleStatus = "P", //F 不良 + InputDate = DateTime.Now, + LineId = barCodeCheckDto.line + }; + await barcodeStationController.PostBarcodeStation(barcodeStation); + + // 新增 BarCodeItem + // 先查詢已綁定組件數量 + //var BarCodeItems = await _pcsApi.GetBarcodeItemByBarCodeID(model.BarCodeID); + //int KpItemQty = BarCodeItems.Count(); + + foreach (var item_barCodeItem in update_BarCodeItem) + { + await barcodeItemsController.PutBarcodeItems(item_barCodeItem.BarcodeItemID, item_barCodeItem); + } + + foreach (var item_barCodeItemChange in insert_BarCodeItemChange) + { + await barcodeItemChangesController.PostBarcodeItemChanges(item_barCodeItemChange); + } + #endregion + #endregion + } + resultModel.Msg = "內部序號【" + barCodeCheckDto.barcode + "】 過站完成!"; + resultModel.Success = true; + return resultModel; + } + #endregion + /// /// 判斷工單狀態 /// @@ -73,7 +374,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return Ok(); } - /// /// 內部序號查詢工單號碼 /// @@ -194,7 +494,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// 內部序號 /// Success:true or false [HttpGet("BarCodeLock")] - public async Task CheckBarCodeLockAsync(string barcode) + public async Task>> CheckBarCodeLockAsync(string barcode) { ResultModel resultModel = new ResultModel { Success = false }; if (barcode.Length <= 4) @@ -482,7 +782,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES ///
/// [HttpGet("BarCodeKP")] - public async Task CheckBarCodeKPAsync([FromQuery]BarcodeItemKPDto barcodeItemKPDto) + public async Task CheckBarCodeKPAsync([FromQuery] BarcodeItemKPDto barcodeItemKPDto) { ResultModel resultModel = new ResultModel { Success = false }; @@ -550,13 +850,13 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES #region 比對組件資料 var CheckMsg = string.Empty; - int x= BarCodeItems.Count; + int x = BarCodeItems.Count; #endregion for (int i = 0; i < barcodeItemKPDto.inputKP.Count; i++) { #region 比對序號長度是否正確 - if (!string.IsNullOrWhiteSpace(MaterialKps[x+i].Length.ToString())) + if (!string.IsNullOrWhiteSpace(MaterialKps[x + i].Length.ToString())) { if (MaterialKps[x + i].Length != barcodeItemKPDto.inputKP[i].Length) CheckMsg += "組件序號【" + barcodeItemKPDto.inputKP[i] + "】 與組件名稱【" + MaterialKps[x + i].KpName + "】長度不符合
"; @@ -575,7 +875,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES var checkDataRedundancy = await barcodeItemsController.GetBarcodeItemByDataRedundancy(MaterialKps[x + i].KpNo, barcodeItemKPDto.inputKP[i]); if (checkDataRedundancy.Value.Count() != 0) { - CheckMsg += "組件名稱【" + MaterialKps[x + i].KpName + "】已有相同組件序號【"+ barcodeItemKPDto.inputKP[i] + "】紀錄
"; + CheckMsg += "組件名稱【" + MaterialKps[x + i].KpName + "】已有相同組件序號【" + barcodeItemKPDto.inputKP[i] + "】紀錄
"; } #endregion @@ -741,7 +1041,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// /// 內部序號找BarCodeID /// - /// + /// 內部條碼 /// 0:找不到 private async Task BarCodeToID(string BarCode) { @@ -754,6 +1054,21 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } + /// + /// 料號找料號ID + /// + /// 料號 + /// 0:找不到 + private async Task ItemNoToItemID(string ItemNo) + { + MaterialItemController materialItemController = new MaterialItemController(_context); + var q = await materialItemController.GetMaterialItemByItemNO(ItemNo); + if (q == null) + return 0; + else + return q.ItemID; + + } /// /// 取得上一個作業站RuleStationID diff --git a/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemKPDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemKPDto.cs index 41ab20b9..53ac1f26 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemKPDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/BarcodeItemKPDto.cs @@ -12,7 +12,7 @@ namespace AMESCoreStudio.WebApi.DTO.AMES { /// - /// 條碼鎖定ID + /// 工單號碼 /// public string WipNo { get; set; } @@ -22,12 +22,12 @@ namespace AMESCoreStudio.WebApi.DTO.AMES public string barcode { get; set; } /// - /// 工單號碼 + /// 生產單位 /// public string unitNo { get; set; } /// - /// 鎖定狀態(0:鎖定;1:解鎖) + /// List /// public List inputKP { get; set; } diff --git a/AMESCoreStudio.WebApi/DTO/BLL/BarCodeCheckDto.cs b/AMESCoreStudio.WebApi/DTO/BLL/BarCodeCheckDto.cs index 855e9e93..8d1dbb61 100644 --- a/AMESCoreStudio.WebApi/DTO/BLL/BarCodeCheckDto.cs +++ b/AMESCoreStudio.WebApi/DTO/BLL/BarCodeCheckDto.cs @@ -2,65 +2,89 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using System.Runtime.Serialization; namespace AMESCoreStudio.WebApi.DTO.AMES { /// /// (過站資料)BarCodeCheck Dto /// + [DataContract] public class BarCodeCheckDto { /// /// 工單號碼 /// - public string WipNo { get; set; } + [DataMember] + public string wipNo { get; set; } /// /// 內部條碼 /// + [DataMember] public string barcode { get; set; } + /// + /// 過站狀態 M:一般 S:維修 + /// + [DataMember] + public string barcodeType { get; set; } = "M"; + /// /// 生產單位 /// + [DataMember] public string unitNo { get; set; } /// /// 作業站 /// + [DataMember] public int station { get; set; } = 0; /// /// 線別站 /// + [DataMember] public int line { get; set; } = 0; /// /// 紀錄組件或不良代碼 /// - public List inputItems { get; set; } + [DataMember] + public List inputItems { get; set; } /// /// 治具條碼 /// - public List Outfits { get; set; } + [DataMember] + public List outfits { get; set; } /// /// 紀錄組件或不良代碼 /// - public class InputItem + + public class inputItem { /// /// 刷入類型 NG or KP(Item_No) /// + [DataMember] public string inputType { get; set; } /// /// 刷入組件資料或不良代碼 /// + [DataMember] public string inputData { get; set; } + + /// + /// 組件:舊組件序號 + /// + [DataMember] + public string oldInputData { get; set; } } /// @@ -71,6 +95,7 @@ namespace AMESCoreStudio.WebApi.DTO.AMES /// /// 刷入治具條碼 /// + [DataMember] public string inputData { get; set; } } } diff --git a/AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs b/AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs index 16c5d6f5..d5cc32ec 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/BarcodeInfo.cs @@ -60,7 +60,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES public int RuleStationID { get; set; } /// - /// 條碼過站狀態 + /// 條碼過站狀態 P:PASS F:不良 /// [Column("RULE_STATUS")] [DataMember]