From 75aa1d54d3076f6bbf5c4c70869b51bdea1edb9a Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 9 Jun 2022 17:30:15 +0800 Subject: [PATCH] =?UTF-8?q?1.=20PCS009=20=E6=A2=9D=E7=A2=BC=E7=94=9F?= =?UTF-8?q?=E7=94=A2=E6=AD=B7=E7=A8=8B=20=E4=BF=AE=E6=94=B9=E6=A2=9D?= =?UTF-8?q?=E7=A2=BC=E8=AE=8A=E6=9B=B4View=E5=8F=8A=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E7=94=A8=E6=96=B0=E8=88=8A=E6=A2=9D=E7=A2=BC=E6=9F=A5=E8=A9=A2?= =?UTF-8?q?=202.=20PCS023=20=E6=A2=9D=E7=A2=BC=E7=BD=AE=E6=8F=9B=20?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=AC=84=E4=BD=8D=E9=A1=AF=E7=A4=BA=E8=AA=AA?= =?UTF-8?q?=E6=98=8E=E5=8F=8A=E6=96=B0=E5=A2=9E=E5=88=A4=E6=96=B7=20?= =?UTF-8?q?=E5=B7=B2=E6=8F=9B=E9=81=8E=E8=88=8A=E6=A2=9D=E7=A2=BC=E7=84=A1?= =?UTF-8?q?=E6=B3=95=E5=86=8D=E7=BD=AE=E6=8F=9B=203.=20PCS019=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=9F=A5=E8=A9=A2=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 44 +++++- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 11 +- .../ViewModels/PCS/PCS009RViewModel.cs | 12 +- .../ViewModels/PCS/PCS023ViewModel.cs | 8 +- AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml | 130 ++++++++++-------- AMESCoreStudio.Web/Views/PCS/PCS019.cshtml | 3 +- AMESCoreStudio.Web/Views/PCS/PCS023.cshtml | 8 +- .../AMES/BarcodeChangeController.cs | 21 ++- .../Controllers/AMES/NgInfoController.cs | 6 +- 9 files changed, 159 insertions(+), 84 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 86eb106a..b44b8872 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -3809,9 +3809,27 @@ namespace AMESCoreStudio.Web.Controllers if (result_barcodeinfo == null) { - var _msg = "查無相關資料!"; - return RedirectToAction("Refresh", "Home", new { msg = _msg }); + // 判斷是否在BarcodeChange 有被置換過 + var result_BarcodeChangeData = await _pcsApi.GetBarcodeChangeByBarcodeNo(model.BarCodeNo ?? model.ExtraBarCodeNo ?? "A"); + + // 判斷查詢是內部還是出貨條碼 + if (!string.IsNullOrWhiteSpace(model.BarCodeNo)) + result_BarcodeChangeData = result_BarcodeChangeData.Where(w => w.ChangeType == "P").ToList(); + else + result_BarcodeChangeData = result_BarcodeChangeData.Where(w => w.ChangeType == "E").ToList(); + + if (result_BarcodeChangeData.Count() != 0) + { + var barcodeIDChange = result_BarcodeChangeData.FirstOrDefault().BarcodeID; + result_barcodeinfo = _pcsApi.GetBarcodeInfoes(barcodeIDChange).InvokeAsync().Result.FirstOrDefault(); + } + else + { + var _msg = "查無相關資料!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } } + var result = new PCS009RViewModel(); // 條碼資料 result.BarCodeNo = result_barcodeinfo.BarcodeNo; @@ -3860,7 +3878,7 @@ namespace AMESCoreStudio.Web.Controllers // 治具清單 - var barcodeoutfits = await _pcsApi.GetBarcodeOutfitByBarcodeNo(model.BarCodeNo); + var barcodeoutfits = await _pcsApi.GetBarcodeOutfitByBarcodeNo(result.BarCodeNo); foreach (var barcodeoutfit in barcodeoutfits.OrderBy(o => o.CreateDate)) { result.Outfits.Add(new Outfit @@ -3875,7 +3893,7 @@ namespace AMESCoreStudio.Web.Controllers result.KPChanges = await _pcsApi.GetBarcodeItemChangesByBarCodeIDPCS009(result_barcodeinfo.BarcodeID); // 維修 - result.nGInfoDtos = await _pcsApi.GetNgInfoByBarcodeNoFromPCS009(result_barcodeinfo.BarcodeNo); + result.nGInfoDtos = await _pcsApi.GetNgInfoByBarcodeNoFromPCS009(result_barcodeinfo.BarcodeID); // 條碼變更 var barcodeChanges = await _pcsApi.GetBarcodeChangeByBarcodeID(result_barcodeinfo.BarcodeID); @@ -3884,6 +3902,8 @@ namespace AMESCoreStudio.Web.Controllers result.BarCodeChanges.Add(new BarCodeChange { BarCodeOld = item.BarcodeNoOld, + BarCodeNew = item.BarcodeNoNew, + BarCodeChangeType = item.ChangeType == "P" ? "內部條碼變更" : "出貨條碼變更", Memo = item.Memo, User = item.CreateUserName, Date = item.CreateDate.ToString("yyyy/MM/dd HH:mm:ss") @@ -5232,6 +5252,14 @@ namespace AMESCoreStudio.Web.Controllers ModelState.AddModelError("error", "新內部條碼【" + model.BarCodeNoNew + "】,已在使用中"); return View(model); } + + // 新條碼序號是否有置換紀錄 + var result_CheckBarcodeChange = await _pcsApi.GetBarcodeChangeByBarcodeNo(model.BarCodeNoNew); + if (result_CheckBarcodeChange.Any(w => w.BarcodeNoOld == model.BarCodeNoNew && w.ChangeType == "P")) + { + ModelState.AddModelError("error", "新內部條碼【" + model.BarCodeNoNew + "】,已有變更紀錄,無法再次變更"); + return View(model); + } } // 出貨序號置換 else if (model.ChangeType == "E") @@ -5252,6 +5280,14 @@ namespace AMESCoreStudio.Web.Controllers ModelState.AddModelError("error", "新出貨條碼【" + model.BarCodeNoNew + "】,已在使用中"); return View(model); } + + // 新條碼序號是否有置換紀錄 + var result_CheckBarcodeChange = await _pcsApi.GetBarcodeChangeByBarcodeNo(model.BarCodeNoNew); + if (result_CheckBarcodeChange.Any(w => w.BarcodeNoOld == model.BarCodeNoNew && w.ChangeType == "E")) + { + ModelState.AddModelError("error", "新出貨條碼【" + model.BarCodeNoNew + "】,已有變更紀錄,無法再次變更"); + return View(model); + } } var barcodeInfo = result_barcodeInfo.FirstOrDefault(); diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index fd247545..18480dfa 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -376,7 +376,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/NgInfo/BarcodeNoFromPCS009/{id}")] - ITask> GetNgInfoByBarcodeNoFromPCS009(string id); + ITask> GetNgInfoByBarcodeNoFromPCS009(int id); /// /// 更新不良零件資料 @@ -580,7 +580,7 @@ namespace AMESCoreStudio.Web ITask> PutBarcodeLock([FromBody, RawJsonContent] string model); #endregion - #region BarCodeChange 條碼變更資料表 PCS023 + #region BarCodeChange 條碼變更資料表 PCS023 PCS009 /// /// 新增條碼變更資料表 /// @@ -594,6 +594,13 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/BarcodeChange/ByBarcodeID/{id}")] ITask> GetBarcodeChangeByBarcodeID(int id); + + /// + /// 條碼變更資料表 by BarCodeNo 查詢新舊條碼 + /// + /// + [WebApiClient.Attributes.HttpGet("api/BarcodeChange/ByBarcodeNo/{id}")] + ITask> GetBarcodeChangeByBarcodeNo(string id); #endregion #region MaterialItem 料號基本資料檔 diff --git a/AMESCoreStudio.Web/ViewModels/PCS/PCS009RViewModel.cs b/AMESCoreStudio.Web/ViewModels/PCS/PCS009RViewModel.cs index d6f8c1ce..1d06a4d0 100644 --- a/AMESCoreStudio.Web/ViewModels/PCS/PCS009RViewModel.cs +++ b/AMESCoreStudio.Web/ViewModels/PCS/PCS009RViewModel.cs @@ -219,10 +219,20 @@ namespace AMESCoreStudio.Web.ViewModels.PCS public class BarCodeChange { /// - /// 內部序號 + /// 舊條碼序號 /// public string BarCodeOld { get; set; } + /// + /// 新條碼序號 + /// + public string BarCodeNew { get; set; } + + /// + /// 變更類型 + /// + public string BarCodeChangeType { get; set; } + /// /// 備註 /// diff --git a/AMESCoreStudio.Web/ViewModels/PCS/PCS023ViewModel.cs b/AMESCoreStudio.Web/ViewModels/PCS/PCS023ViewModel.cs index 8959a197..90a1c348 100644 --- a/AMESCoreStudio.Web/ViewModels/PCS/PCS023ViewModel.cs +++ b/AMESCoreStudio.Web/ViewModels/PCS/PCS023ViewModel.cs @@ -11,17 +11,17 @@ namespace AMESCoreStudio.Web.ViewModels.PCS public class PCS023ViewModel { /// - /// 舊內部條碼 + /// 舊條碼 /// [Required(ErrorMessage = "{0},不能空白")] - [Display(Name = "舊內部條碼")] + [Display(Name = "舊條碼")] public string BarCodeNoOld { get; set; } /// - /// 新內部條碼 + /// 新條碼 /// [Required(ErrorMessage = "{0},不能空白")] - [Display(Name = "新內部條碼")] + [Display(Name = "新條碼")] public string BarCodeNoNew { get; set; } /// diff --git a/AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml index e520f1d0..24b15966 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml @@ -253,26 +253,26 @@ @foreach (var index in Model.BarCodeKPs) { - - - @index.StationName - - - @index.ItemNoName - - - @index.PartNo - - - @index.KpItemNo - - - @index.CreateUser - - - @index.CreateDate.ToString("yyyy/MM/dd HH:mm:ss") - - + + + @index.StationName + + + @index.ItemNoName + + + @index.PartNo + + + @index.KpItemNo + + + @index.CreateUser + + + @index.CreateDate.ToString("yyyy/MM/dd HH:mm:ss") + + } @@ -310,29 +310,29 @@ @foreach (var index in Model.nGInfoDtos) { - - - @index.StationName - - - @index.NGNo - - - @index.LocationNo - - - @index.RepairNo - - - @index.Status - - - @index.ReplyUser - - - @DateTime.Parse(index.ReplyDate).ToString("yyyy/MM/dd HH:mm:ss") - - + + + @index.StationName + + + @index.NGNo + + + @index.LocationNo + + + @index.RepairNo + + + @index.Status + + + @index.ReplyUser + + + @DateTime.Parse(index.ReplyDate).ToString("yyyy/MM/dd HH:mm:ss") + + } @@ -381,13 +381,19 @@ - (舊)內部序號 + (舊)條碼序號 + + + (新)條碼序號 + + + 變更類型 備註 - 變更人員 + 變更人員 變更時間 @@ -397,20 +403,26 @@ @foreach (var index in Model.BarCodeChanges) { - - - @index.BarCodeOld - - - @index.Memo - - - @index.User - - - @index.Date - - + + + @index.BarCodeOld + + + @index.BarCodeNew + + + @index.BarCodeChangeType + + + @index.Memo + + + @index.User + + + @index.Date + + } diff --git a/AMESCoreStudio.Web/Views/PCS/PCS019.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS019.cshtml index 092dde8b..c5ba259f 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS019.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS019.cshtml @@ -88,7 +88,7 @@ if ($(error).text() != '') { parent.hg.msg(error); } - $("#wipNo").change(function () { + $("#wipNo").keyup(function () { getUnitByWipNoList($("#wipNo").val()); getRuleStationByFlowID(); }); @@ -105,7 +105,6 @@ type: 'post', success: function (result) { - console.info(result.data); $("#unit").empty();//清空下拉框的值 $.each(result.data, function (index, item) { $("#unit").append($(" /// - // GET: api/ [HttpGet] public async Task>> GetBarcodeChange() { @@ -47,7 +46,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// /// BarcodeID /// - // GET api//5 [HttpGet("{id}")] public async Task>> GetBarcodeChange(int id) { @@ -57,6 +55,19 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return await q.ToListAsync(); } + /// + /// 條碼變更資料表 by BarcodeNo 查詢新舊條碼 + /// + /// BarcodeID + /// + [HttpGet("ByBarcodeNo/{id}")] + public async Task>> GetBarcodeChangeByBarcodeNo(string id) + { + IQueryable q = _context.BarcodeChanges.Where(w => w.BarcodeNoOld == id || w.BarcodeNoNew == id); + + return await q.ToListAsync(); + } + /// /// 條碼變更資料表 by id /// @@ -66,12 +77,14 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task>> GetBarcodeChangeByBarcodeID(int id) { var q = from q1 in _context.BarcodeChanges where q1.BarcodeID == id - join q2 in _context.UserInfoes on q1.CreateUserID equals q2.CreateUserId + join q2 in _context.UserInfoes on q1.CreateUserID equals q2.UserID select new BarcodeChange { BarcodeChangeID = q1.BarcodeChangeID, BarcodeID = q1.BarcodeID, BarcodeNoOld = q1.BarcodeNoOld, + BarcodeNoNew = q1.BarcodeNoNew, + ChangeType = q1.ChangeType, CreateUserID = q1.CreateUserID, CreateDate = q1.CreateDate, Memo = q1.Memo, @@ -86,7 +99,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// /// /// - // POST api/ [HttpPost] public async Task> PostBarcodeChange([FromBody] BarcodeChange barcodeChange) { @@ -110,7 +122,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } - // DELETE api//5 [HttpDelete("{id}")] public void Delete(int id) { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs index 80f2955c..148bf3af 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoController.cs @@ -131,14 +131,14 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } /// - /// ByWipNo + /// ByBarcodeID /// /// /// [HttpGet("BarcodeNoFromPCS009/{id}")] - public async Task>> GetNgInfoByBarcodeNoFromPCS009(string id) + public async Task>> GetNgInfoByBarcodeNoFromPCS009(int id) { - var q = from q1 in _context.BarcodeInfoes.Where(w => w.BarcodeNo == id) + var q = from q1 in _context.BarcodeInfoes.Where(w => w.BarcodeID == id) join q2 in _context.NgInfos on q1.BarcodeID equals q2.BarcodeID join q3 in _context.NgComponents on q2.NgID equals q3.NgID join q4 in _context.NGReasons on q3.NgNo.Replace("$","") equals q4.NGReasonNo