From 51e47044b3d7405b2e6916fc4dc9f178ec6c44b4 Mon Sep 17 00:00:00 2001 From: Ray Date: Tue, 1 Mar 2022 18:57:23 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=B7=A5=E5=96=AE=E5=9F=BA=E6=9C=AC?= =?UTF-8?q?=E8=B3=87=E6=96=99=202.=20=E6=A2=9D=E7=A2=BC=E6=AD=B7=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 76 ++++-- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 7 + .../ViewModels/PCS/PCS009ViewModel.cs | 34 +++ AMESCoreStudio.Web/Views/PCS/PCS001.cshtml | 2 +- AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml | 10 +- AMESCoreStudio.Web/Views/PCS/PCS003.cshtml | 30 +-- AMESCoreStudio.Web/Views/PCS/PCS009.cshtml | 241 +++--------------- .../Controllers/AMES/WipKpsController.cs | 92 +++++-- AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs | 9 + 9 files changed, 222 insertions(+), 279 deletions(-) create mode 100644 AMESCoreStudio.Web/ViewModels/PCS/PCS009ViewModel.cs diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 50abf365..2c292d58 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -1145,6 +1145,28 @@ namespace AMESCoreStudio.Web.Controllers result = await _pcsApi.PutMACInfoByClassGroup(mACInfo.ClassGroup, model.wipMAC.EndNO); } } + + // KeyParts 組合 + var materialItem = await _pcsApi.GetMaterialItemByItemNO(model.wipAtt.ItemNO); + if (materialItem != null) + { + var materialKp = await _pcsApi.GetMaterialKpByItemID(materialItem.ItemID); + foreach(var item in materialKp.Where(w => w.StationType == model.wipInfo.UnitNO)) + { + var wipKp = new WipKp + { + WipID = wipID, + ItemNo = model.wipAtt.ItemNO, + UnitNo = model.wipInfo.UnitNO, + KpName = item.KpName, + KpNo = item.KpNo, + KpSeq = item.KpSeq, + Length = item.Length, + Title = item.Title + }; + await _pcsApi.PostWipKp(JsonConvert.SerializeObject(wipKp)); + } + } } @@ -1230,6 +1252,16 @@ namespace AMESCoreStudio.Web.Controllers var q = await _pcsApi.GetWipInfo(id); if (q.Count != 0) { + // 判斷工單號碼是否已經開線 + var resultLineInfo = await _basApi.GetLineInfoes(); + var resultWipNo = await _pcsApi.GetWipInfoByWipNO(q.FirstOrDefault().WipNO); + var WipIDs = resultWipNo.Select(s => s.WipID); + if (resultLineInfo.Where(w => WipIDs.Contains(w.WipNo)).Any()) + { + var _msg = "工單號碼【" + q.FirstOrDefault().WipNO + "】,工單已開線,不可修改!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + model.wipInfo = q.FirstOrDefault(); model.wipAtt = await _pcsApi.GetWipAtt(model.wipInfo.WipNO); model.wipBarcodes = await _pcsApi.GetWipBarcode(model.wipInfo.WipNO); @@ -1314,16 +1346,16 @@ namespace AMESCoreStudio.Web.Controllers IResultModel result; // Checkbox轉換 - model.wipInfo.ECNCheck = model.wipInfo.ECNCheck == "true" ? "Y" : "N"; - model.wipInfo.ModelCheck = model.wipInfo.ModelCheck == "true" ? "Y" : "N"; - model.wipInfo.InputFlag = model.wipInfo.InputFlag == "true" ? "Y" : "N"; - model.wipInfo.Priority = model.wipInfo.Priority == "true" ? "Y" : "N"; + model.wipInfo.ECNCheck = model.wipInfo.ECNCheck == "on" ? "Y" : "N"; + model.wipInfo.ModelCheck = model.wipInfo.ModelCheck == "on" ? "Y" : "N"; + model.wipInfo.InputFlag = model.wipInfo.InputFlag == "on" ? "Y" : "N"; + model.wipInfo.Priority = model.wipInfo.Priority == "on" ? "Y" : "N"; //板卡 - model.wipBoard.DipCarrier = model.wipBoard.DipCarrier == "true" ? "Y" : "N"; - model.wipBoard.DipTape = model.wipBoard.DipTape == "true" ? "Y" : "N"; - model.wipBoard.Burn = model.wipBoard.Burn == "true" ? "Y" : "N"; + model.wipBoard.DipCarrier = model.wipBoard.DipCarrier == "on" ? "Y" : "N"; + model.wipBoard.DipTape = model.wipBoard.DipTape == "on" ? "Y" : "N"; + model.wipBoard.Burn = model.wipBoard.Burn == "on" ? "Y" : "N"; //系統 - model.wipSystem.FinePackage = model.wipSystem.FinePackage == "true" ? "Y" : "N"; + model.wipSystem.FinePackage = model.wipSystem.FinePackage == "on" ? "Y" : "N"; // 判斷資料填寫 WipDataViewModel wipDataViewModel = new WipDataViewModel(); @@ -1335,7 +1367,7 @@ namespace AMESCoreStudio.Web.Controllers var Msg = CheckWipInfoInsert(wipDataViewModel); // KeyParts 判斷 - foreach(var item in model.WipKps) + foreach (var item in model.WipKps) { item.ItemNo = model.wipAtt.ItemNO; item.Status = item.Status == "on" ? "A" : "S"; @@ -1343,16 +1375,16 @@ namespace AMESCoreStudio.Web.Controllers if (!string.IsNullOrWhiteSpace(Msg)) { - model.wipInfo.ECNCheck = model.wipInfo.ECNCheck == "Y" ? "true" : "false"; - model.wipInfo.ModelCheck = model.wipInfo.ModelCheck == "Y" ? "true" : "false"; - model.wipInfo.InputFlag = model.wipInfo.InputFlag == "Y" ? "true" : "false"; - model.wipInfo.Priority = model.wipInfo.Priority == "Y" ? "true" : "false"; - //板卡 - model.wipBoard.DipCarrier = model.wipBoard.DipCarrier == "Y" ? "true" : "false"; - model.wipBoard.DipTape = model.wipBoard.DipTape == "Y" ? "true" : "false"; - model.wipBoard.Burn = model.wipBoard.Burn == "Y" ? "true" : "false"; - //系統 - model.wipSystem.FinePackage = model.wipSystem.FinePackage == "Y" ? "true" : "false"; + //model.wipInfo.ECNCheck = model.wipInfo.ECNCheck == "Y" ? "true" : "false"; + //model.wipInfo.ModelCheck = model.wipInfo.ModelCheck == "Y" ? "true" : "false"; + //model.wipInfo.InputFlag = model.wipInfo.InputFlag == "Y" ? "true" : "false"; + //model.wipInfo.Priority = model.wipInfo.Priority == "Y" ? "true" : "false"; + ////板卡 + //model.wipBoard.DipCarrier = model.wipBoard.DipCarrier == "Y" ? "true" : "false"; + //model.wipBoard.DipTape = model.wipBoard.DipTape == "Y" ? "true" : "false"; + //model.wipBoard.Burn = model.wipBoard.Burn == "Y" ? "true" : "false"; + ////系統 + //model.wipSystem.FinePackage = model.wipSystem.FinePackage == "Y" ? "true" : "false"; ModelState.AddModelError("error", Msg); return View("PCS003", model); @@ -1447,6 +1479,12 @@ namespace AMESCoreStudio.Web.Controllers result = await _pcsApi.PutMACInfoByClassGroup(mACInfo.ClassGroup, model.wipMAC.EndNO); } } + + // KeyParts + foreach (var item in model.WipKps) + { + await _pcsApi.PutWipKpByStatus(JsonConvert.SerializeObject(item)); + } } diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index e5ca1c7e..ee2b833a 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -826,6 +826,13 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpPost("api/WipKps")] ITask> PostWipKp([FromBody, RawJsonContent] string model); + + /// + /// 新增工單對應SOP + /// + /// + [WebApiClient.Attributes.HttpPut("api/WipKps/Status")] + ITask> PutWipKpByStatus([FromBody, RawJsonContent] string model); #endregion diff --git a/AMESCoreStudio.Web/ViewModels/PCS/PCS009ViewModel.cs b/AMESCoreStudio.Web/ViewModels/PCS/PCS009ViewModel.cs new file mode 100644 index 00000000..376c9072 --- /dev/null +++ b/AMESCoreStudio.Web/ViewModels/PCS/PCS009ViewModel.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.WebApi.Models.BAS; +using System.ComponentModel.DataAnnotations; + +namespace AMESCoreStudio.Web.ViewModels.PCS +{ + public class PCS009ViewModel + { + /// + /// 內部條碼 + /// + public string BarCodeNo { get; set; } + + /// + /// 組件條碼 + /// + public string PartNo { get; set; } + + /// + /// 外部條碼 EXTRA_BARCODE_NO + /// + public string ExtraBarCodeNo { get; set; } + + /// + /// 包裝箱號 + /// + public string BoxNo { get; set; } + + } +} diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml index 4723bc47..50d36d6a 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml @@ -381,7 +381,7 @@
- +
diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml index 0125cad6..a8903640 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml @@ -344,9 +344,6 @@ @{ int i = 0;} - - 料號 - KP料號名稱 @@ -374,9 +371,6 @@ @foreach (var index in Model.WipKps) { - - @index.ItemNo - @index.KpName @@ -500,7 +494,7 @@
- + @@ -555,7 +549,7 @@
- +
diff --git a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml index 7abd48b0..76136955 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml @@ -26,8 +26,8 @@ -
- +
+
@@ -142,10 +142,10 @@
-
- - - +
+ + +
@@ -237,7 +237,7 @@
- +
@@ -349,9 +349,7 @@ @{ int i = 0;} - + @@ -382,10 +380,6 @@ - @@ -490,8 +484,8 @@
- - + + @@ -499,7 +493,7 @@
- +
@@ -545,7 +539,7 @@
- +
diff --git a/AMESCoreStudio.Web/Views/PCS/PCS009.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS009.cshtml index d1dd6d56..cced14a8 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS009.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS009.cshtml @@ -1,4 +1,6 @@ -@{ +@model AMESCoreStudio.Web.ViewModels.PCS.PCS009ViewModel + +@{ ViewData["Title"] = "條碼生產歷程查詢"; Layout = "~/Views/Shared/_AMESLayout.cshtml"; } @@ -27,233 +29,58 @@
-
-
+
+
@ViewBag.Title
-
-
-
-
+
+
-
-
- -
- -
-
-
-
-
- -
- -
+
+ +
+
-
-
- -
- -
+
+
+
+ +
+
-
-
-
-
-
- -
- -
+
+ +
+
-
-
- -
- -
-
-
- -
+
+
+
+ +
+
-
-
- -
+
+
+
+
- 料號 - KP料號名稱 - - @index.ItemNo - @index.KpName
-
+ @section Scripts{ - - - } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipKpsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipKpsController.cs index 0e3f4efb..367838ef 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipKpsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipKpsController.cs @@ -77,48 +77,88 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return await q.ToListAsync(); } - // PUT: api/WipKps/5 - // To protect from overposting attacks, enable the specific properties you want to bind to, for - // more details, see https://go.microsoft.com/fwlink/?linkid=2123754. - [HttpPut("{id}")] - public async Task PutWipKp(int id, WipKp wipKp) + /// + /// 更新工單KP資訊資料檔 + /// + /// + /// + [HttpPut] + public async Task> PutWipKp(WipKp wipKp) { - if (id != wipKp.WipKpID) + ResultModel result = new ResultModel(); + _context.Entry(wipKp).State = EntityState.Modified; + wipKp.UpdateDate = DateTime.Now; + wipKp.UpdateUserID = 0; + + try { - return BadRequest(); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; - _context.Entry(wipKp).State = EntityState.Modified; + } + return result; + } + + /// + /// 更新工單KP資訊資料檔-狀態 + /// + /// + /// + [HttpPut("Status")] + public async Task> PutWipKpByStatus(WipKp wipKp) + { + ResultModel result = new ResultModel(); + var resultWipKp = GetWipKp(wipKp.WipKpID).Result.Value; + _context.Entry(resultWipKp).State = EntityState.Modified; + resultWipKp.Status = wipKp.Status; + resultWipKp.UpdateDate = DateTime.Now; + resultWipKp.UpdateUserID = 0; try { await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } - catch (DbUpdateConcurrencyException) + catch (Exception ex) { - if (!WipKpExists(id)) - { - return NotFound(); - } - else - { - throw; - } - } + result.Success = false; + result.Msg = ex.InnerException.Message; - return NoContent(); + } + return result; } - // POST: api/WipKps - // To protect from overposting attacks, enable the specific properties you want to bind to, for - // more details, see https://go.microsoft.com/fwlink/?linkid=2123754. + /// + /// 新增工單KP資訊資料檔 + /// + /// + /// [HttpPost] - public async Task> PostWipKp(WipKp wipKp) + public async Task> PostWipKp(WipKp wipKp) { + ResultModel result = new ResultModel(); + Helper helper = new Helper(_context); + wipKp.WipKpID= helper.GetIDKey("WIP_KP_ID").Result; _context.WipKps.Add(wipKp); - await _context.SaveChangesAsync(); - - return CreatedAtAction("GetWipKp", new { id = wipKp.WipKpID }, wipKp); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; } // DELETE: api/WipKps/5 diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs b/AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs index 3a85caac..799b07d1 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/WipBoard.cs @@ -118,6 +118,15 @@ namespace AMESCoreStudio.WebApi.Models.AMES [Required(ErrorMessage = "{0},不能空白")] public decimal PcbBake { get; set; } + /// + /// PCB加工 + /// + [Column("PCB_PROCESSING")] + [DataMember] + [Display(Name = "PCB加工")] + [Required(ErrorMessage = "{0},不能空白")] + public string PcbProcessing { get; set; } + /// /// 錫膏 ///