From 5b3c76d6a8e924b8b79b16147cd1abdab1cfa3f7 Mon Sep 17 00:00:00 2001 From: Ray Date: Fri, 14 Oct 2022 16:52:00 +0800 Subject: [PATCH] =?UTF-8?q?1.=20PCS021=20=E5=AE=A2=E8=A3=BD=E5=88=B0?= =?UTF-8?q?=E4=B8=80=E5=8D=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 287 +++++------------- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 7 + AMESCoreStudio.Web/Models/LayuiViewModel.cs | 5 + .../ViewModels/PCS/PCS021ViewModel.cs | 29 +- AMESCoreStudio.Web/Views/PCS/PCS021.cshtml | 195 ++++++++---- .../AMES/InspectionResultMastersController.cs | 1 - .../Controllers/AMES/MaterialKpController.cs | 18 ++ .../Controllers/BLL/BarCodeCheckController.cs | 35 ++- AMESCoreStudio.WebApi/Models/AMESContext.cs | 8 +- 9 files changed, 296 insertions(+), 289 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 68a2f35f..0fddfe63 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -2739,15 +2739,21 @@ namespace AMESCoreStudio.Web.Controllers // KeyParts // 判斷料號KP有資料 沒有資料時 一起新增到料號KP - bool addMasterKP = false; + // 2022.10.12 取消判斷 刪除料號KP,在逐一新增 var materialItem = await _pcsApi.GetMaterialItemByItemNO(model.wipAtt.ItemNO); if (materialItem != null) { - var materialKp = await _pcsApi.GetMaterialKpByItemID(materialItem.ItemID); - if (materialKp.Count() == 0) - addMasterKP = true; + await _pcsApi.DeleteMaterialKpByItem(materialItem.ItemID); } + //bool addMasterKP = false; + //if (materialItem != null) + //{ + // var materialKp = await _pcsApi.GetMaterialKpByItemID(materialItem.ItemID); + // if (materialKp.Count() == 0) + // addMasterKP = true; + //} + // 先比對新舊ID 當舊ID有 新的沒有代表已刪除 var resultOld_WipKp = await _pcsApi.GetWipKpByWipNo(model.wipInfo.WipNO); var delete_WipKpID = resultOld_WipKp.Select(s => s.WipKpID).Except(model.WipKps.Select(s => s.WipKpID)); @@ -2755,6 +2761,7 @@ namespace AMESCoreStudio.Web.Controllers { await _pcsApi.DeleteWipKp(id); } + foreach (var item in model.WipKps.Where(w => w.WipKpID != -1)) { item.WipNo = model.wipInfo.WipNO; @@ -2764,23 +2771,20 @@ namespace AMESCoreStudio.Web.Controllers else await _pcsApi.PutWipKp(JsonConvert.SerializeObject(item)); - // 判斷料號KP有資料 沒有資料時 一起新增到料號KP - if (addMasterKP) + // 新增到料號KP檔 + await _pcsApi.PostMaterialKp(JsonConvert.SerializeObject(new MaterialKp { - await _pcsApi.PostMaterialKp(JsonConvert.SerializeObject(new MaterialKp - { - ItemID = materialItem.ItemID, - KpName = item.KpName, - KpNo = item.KpNo, - KpSeq = Convert.ToInt32(item.KpSeq), - Length = item.Length, - StationType = item.UnitNo, - IsRepeat = "N", - Title = item.Title, - CreateUserID = UserID, - UpdateUserID = UserID - })); - } + ItemID = materialItem.ItemID, + KpName = item.KpName, + KpNo = item.KpNo, + KpSeq = Convert.ToInt32(item.KpSeq), + Length = item.Length, + StationType = item.UnitNo, + IsRepeat = "N", + Title = item.Title, + CreateUserID = UserID, + UpdateUserID = UserID + })); } // 治具 @@ -3518,14 +3522,18 @@ namespace AMESCoreStudio.Web.Controllers await PCS006OnOffAsync(LineID, -1); } } + else + { + // 計算工單開工數 +1 + var wipInfos = await _pcsApi.GetWipInfo(wipID); + var wipInfo = wipInfos.FirstOrDefault(); + wipInfo.WipTimes += 1; + wipInfo.UpdateDate = DateTime.Now; + await _pcsApi.PutWipInfo(JsonConvert.SerializeObject(wipInfo)); + } await _pcsApi.PostWipLog(JsonConvert.SerializeObject(wipLog)); await _pcsApi.PutWipinfoToStatusNO(wipID, statusNO); - //if (result.) - //{ - // var msg = "修改失敗!"; - // return Json(msg); - //} var _msg = "修改成功!"; return Json(_msg); } @@ -5158,7 +5166,7 @@ namespace AMESCoreStudio.Web.Controllers public async Task PCS021() { var model = new PCS021ViewModel(); - await GetFactoryUnit(); + await GetFactoryUnit(false); //await GetLineInfo(); //await GetStation(); return View(model); @@ -5167,10 +5175,10 @@ namespace AMESCoreStudio.Web.Controllers [HttpPost] public async Task PCS021_GetWip(PCS021ViewModel model) { - await GetFactoryUnit(); + await GetFactoryUnit(false); await GetItemsList(); //await GetLineInfo(); - + model.KpItemName += "null"; if (string.IsNullOrWhiteSpace(model.WipNO)) { ModelState.AddModelError("error", "請輸入工單號碼"); @@ -5186,14 +5194,22 @@ namespace AMESCoreStudio.Web.Controllers ModelState.AddModelError("error", "請選擇線別"); } - //if (model.RolwStation == 0) - //{ - // ModelState.AddModelError("error", "請選擇作業站"); - //} - var q = await _pcsApi.GetWipInfoByWipNO(model.WipNO); q = q.Where(w => w.UnitNO == model.UnitNO).ToList(); + // 取作業站的生產製程 + var stationUnit = string.Empty; + var station = await _basApi.GetStations(model.Station); + if (station.Count() != 0) + { + stationUnit = station.FirstOrDefault().UnitNo; + } + else + { + ModelState.AddModelError("error", "找不到該作業站的生產單位"); + } + + if (q.Count() == 0) { ModelState.AddModelError("error", "找不到該生產單位的工單號碼"); @@ -5207,7 +5223,6 @@ namespace AMESCoreStudio.Web.Controllers model.FlowRuleID = q.FirstOrDefault().FlowRuleID; model.ItemNO = (await _pcsApi.GetWipAtt(model.WipNO)).ItemNO; - // 判斷工單狀態 var BarCodeWip = await _pcsApi.CheckBarCodeWip(model.WipNO, model.UnitNO, model.LineID, model.FlowRuleID); if (!BarCodeWip.Success) @@ -5235,7 +5250,7 @@ namespace AMESCoreStudio.Web.Controllers // 工單KeyParts model.WipKps = await _pcsApi.GetWipKpByWipNo(model.WipNO); - model.WipKps = model.WipKps.Where(w => w.UnitNo == model.UnitNO).OrderBy(o => o.KpSeq).ToList(); + model.WipKps = model.WipKps.Where(w => w.UnitNo == stationUnit).OrderBy(o => o.KpSeq).ToList(); // 料號檔案 model.MaterialItem = await _pcsApi.GetMaterialItemByItemNO(model.ItemNO); @@ -5273,6 +5288,17 @@ namespace AMESCoreStudio.Web.Controllers if (wipsystem != null) model.SystemMemo = wipsystem.Memo; + model.Sops.Add(new PCS021ViewModel_SOP + { + SopName = "AA", + SopPath = "/PDF/33.pdf" + }); + + model.Sops.Add(new PCS021ViewModel_SOP + { + SopName = "BB", + SopPath = "/PDF/CL3800NW-ATA-KK.pdf" + }); } return View("PCS021", model); @@ -5316,7 +5342,6 @@ namespace AMESCoreStudio.Web.Controllers } #endregion - var Kp = model.Inputs.Where(w => !w.Input.Contains("$")).ToList(); // 撈非不良代碼 = 組件序號 var q = await _pcsApi.GetBarCodeFromWip(model.Input); // 判斷是否用內部序號有對應到工單號碼,沒對應到視為組件或不良代碼 if (q.Success) @@ -5434,6 +5459,7 @@ namespace AMESCoreStudio.Web.Controllers 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 = barcode_result.Msg; @@ -5447,6 +5473,23 @@ namespace AMESCoreStudio.Web.Controllers } #endregion } + else + { + // 判斷是否刷KeyPart 代號 + // 取作業站的生產製程 + var stationUnit = string.Empty; + var station = await _basApi.GetStations(model.Station); + if (station.Count() != 0) + { + stationUnit = station.FirstOrDefault().UnitNo; + } + var items = await _pcsApi.GetItems(); + items = items.Where(w => model.WipKps.Any(wi => wi.KpNo == w.ItemNo)).ToList(); + if (items.Any(a => a.ItemName.ToUpper() == Data.ToUpper())) + { + return Json(new Result1() { success = Success, msg = Msg, data = "", data1 = Data }) ; + } + } #region 判斷下一站為完工站 @@ -5454,132 +5497,6 @@ namespace AMESCoreStudio.Web.Controllers #endregion #region 過站判斷正常 往下處理Table 移到API執行 - - //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; - - // 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(); - // } - - // // 新增 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)); - - // 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)); - // } - // } - // } - // #region 當生產單位為SMT或DIP時,確認是否有綁Group,有綁連片一起過站 // List GroupBarCodeID = new List(); // if (model.UnitNO == "S" || model.UnitNO == "D") @@ -5640,47 +5557,6 @@ namespace AMESCoreStudio.Web.Controllers // 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; - - //} #endregion if (NextStopCloseStation.Success) @@ -5694,12 +5570,9 @@ namespace AMESCoreStudio.Web.Controllers await _pcsApi.DeleteBarcodeGroupByGroupID(GroupID.FirstOrDefault().GroupID); } } - - // 確認完工數是否等於工單數 - // await _pcsApi.CheckWipNoBarCodeAllClost(model.WipNO, model.UnitNO, model.RuleStation); } - return Json(new Result() { success = Success, msg = Msg, data = Data }); + return Json(new Result1() { success = Success, msg = Msg, data = Data ,data1 =""}); } #endregion diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 380106fd..4a4eb9c5 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -693,6 +693,13 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpPost("api/MaterialKp")] ITask> PostMaterialKp([FromBody, RawJsonContent] string model); + + /// + /// 料號KP資訊資料檔 ByItemID + /// + /// 料號ID + [WebApiClient.Attributes.HttpDelete("api/MaterialKp/ByItem/{id}")] + ITask> DeleteMaterialKpByItem(int id); #endregion #region MaterialOutfit 料號治具資訊資料檔 diff --git a/AMESCoreStudio.Web/Models/LayuiViewModel.cs b/AMESCoreStudio.Web/Models/LayuiViewModel.cs index 11c819d4..71923b1b 100644 --- a/AMESCoreStudio.Web/Models/LayuiViewModel.cs +++ b/AMESCoreStudio.Web/Models/LayuiViewModel.cs @@ -19,4 +19,9 @@ namespace AMESCoreStudio.Web.Models public string msg { get; set; } = "成功!"; public dynamic data { get; set; } } + + public class Result1 : Result + { + public dynamic data1 { get; set; } + } } diff --git a/AMESCoreStudio.Web/ViewModels/PCS/PCS021ViewModel.cs b/AMESCoreStudio.Web/ViewModels/PCS/PCS021ViewModel.cs index d1b12504..4953664f 100644 --- a/AMESCoreStudio.Web/ViewModels/PCS/PCS021ViewModel.cs +++ b/AMESCoreStudio.Web/ViewModels/PCS/PCS021ViewModel.cs @@ -65,12 +65,6 @@ namespace AMESCoreStudio.Web.ViewModels.PCS /// public string StationTypeNo { get; set; } - - /// - /// SOP路徑 - /// - public string SopPath { get; set; } = ""; - /// /// 料號 /// @@ -111,6 +105,11 @@ namespace AMESCoreStudio.Web.ViewModels.PCS /// public string SystemMemo { get; set; } + /// + /// KeyPart 代號 + /// + public string KpItemName { get; set; } = string.Empty; + /// /// inputs /// @@ -136,6 +135,8 @@ namespace AMESCoreStudio.Web.ViewModels.PCS /// 站別工項資料檔 /// public List MaterialStationsItems { get; set; } = new List(); + + public List Sops { get; set; } = new List(); } public class WipOutfitDtos : WipOutfitDto @@ -155,4 +156,20 @@ namespace AMESCoreStudio.Web.ViewModels.PCS /// public string InputNo { get; set; } } + + /// + /// SOP + /// + public class PCS021ViewModel_SOP + { + /// + /// 檔案名稱 + /// + public string SopName { get; set; } + + /// + /// 檔案路徑 + /// + public string SopPath { get; set; } + } } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml index 9ab7c966..15e3645f 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS021.cshtml @@ -53,17 +53,25 @@ border: 3px solid #0026ff; color: blue; } + + /* .layui-tab-brief>.layui-tab-title .layui-this{ + color: #5672a7 + } + + .layui-tab-brief>.layui-tab-title .layui-this:after{ + border-bottom: 2px solid #5672a7; + }*/
@*
-
-
-
@ViewBag.Title
-
-
-
*@ +
+
+
@ViewBag.Title
+
+
+
*@
@@ -92,7 +100,6 @@
-
@@ -151,18 +158,19 @@ @* - - - - - *@ - + + + + + *@
檢查項目 - @{ int i = 0;} + @{ + int i = 0; + }
@@ -196,6 +204,10 @@
+
+ 指定KeyPart + +
工程備註
@@ -208,7 +220,9 @@
- @{ int j = 0;} + @{ + int j = 0; + }
@@ -263,7 +277,9 @@
- @{int k = 0;} + @{ + int k = 0; + }
@@ -307,7 +323,45 @@
- + @if (Model.Sops.Count != 0) + { + bool sopfirst = true; +
+
    + @foreach (var index in Model.Sops) + { + if (sopfirst) + { +
  • @index.SopName
  • + sopfirst = false; + } + else + { +
  • @index.SopName
  • + } + } +
+ +
+ @foreach (var index in Model.Sops) + { + if (!sopfirst) + { +
+ +
+ sopfirst = true; + } + else + { +
+ +
+ } + } +
+
+ }
@@ -315,33 +369,45 @@ @section Scripts{ - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); - await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + @{ + await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); + }