From 49df1eed90480c78585908661f122d6568b798ca Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 16 Mar 2023 17:00:34 +0800 Subject: [PATCH] =?UTF-8?q?1.=20FQC=E6=8A=BD=E9=A9=97=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E5=85=A5=E5=BA=AB=E5=96=AE=E5=82=99=E8=A8=BB=202.=20=E5=B7=A5?= =?UTF-8?q?=E5=96=AE=E6=96=B0=E5=A2=9E=E5=8A=A0=E5=85=A5=20"MoidByOnlyOne"?= =?UTF-8?q?:=20"Y"=20=E5=88=A4=E6=96=B7=E6=98=AF=E5=90=A6=E5=8F=AA?= =?UTF-8?q?=E8=83=BD=E6=9C=89=E4=B8=80=E7=AD=86=E5=B7=A5=E5=96=AE=E8=99=9F?= =?UTF-8?q?=E7=A2=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/PCSController.cs | 88 +++++++++++++++---- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 10 +++ AMESCoreStudio.Web/Views/FQC/FQC007.cshtml | 2 +- AMESCoreStudio.Web/Views/PCS/PCS003.cshtml | 79 +++++++++++++++-- .../AMES/FqcInhouseMasterController.cs | 2 +- .../Controllers/AMES/WipInfoBlobController.cs | 45 +++++++++- .../Controllers/AMES/WipInfosController.cs | 2 +- .../Controllers/AMES/WipSopController.cs | 42 ++++++++- AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs | 5 ++ .../Models/AMES/WipInfoBlob.cs | 8 ++ AMESCoreStudio.WebApi/Models/AMES/WipSop.cs | 7 ++ 11 files changed, 255 insertions(+), 35 deletions(-) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index e3a9062f..df864fa0 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -23,6 +23,7 @@ using AMESCoreStudio.WebApi.Enum; using Microsoft.Extensions.Localization; using Microsoft.Extensions.Configuration; using ClosedXML.Excel; +using Microsoft.VisualBasic; namespace AMESCoreStudio.Web.Controllers { @@ -141,13 +142,13 @@ namespace AMESCoreStudio.Web.Controllers if (!string.IsNullOrWhiteSpace(Msg)) - Msg = "必填欄位未填寫:" + Msg.Substring(0, (Msg.Length - 1)); + Msg = "必填欄位未填寫:(" + Msg.Substring(0, (Msg.Length - 1)) + " )"; return Msg; } /// - /// 工單工程 保存判斷 + /// 工單工程 儲存判斷 /// /// /// @@ -265,8 +266,6 @@ namespace AMESCoreStudio.Web.Controllers } #endregion - - #region 下拉選單 /// /// 產品別 @@ -1455,6 +1454,38 @@ namespace AMESCoreStudio.Web.Controllers var result = await _pcsApi.DeleteWipBarcodeOther(wipNo.Trim().ToUpper()); return Json(new Result() { success = result.Success, msg = result.Msg, data = null }); } + + /// + /// 確認是否PLM有新的 ECN/ECR + /// + /// 工單料號 + /// 目前ECN ECR + /// + public async Task CheckUpdateEcnOrEcr(string ItemNo, string OldEcnEcr) + { + IResultModel result; + result = await _fqcApi.GetPLMEcn(ItemNo); + if (result.Success) + { + // 如果舊的ECN/ECR 跟新的 + //if (OldEcnEcr.Trim().ToUpper() == result.Msg.Trim().ToUpper()) + //result.Msg = ""; + } + return Json(new Result() { success = result.Success, msg = result.Msg, data = null }); + } + + /// + /// 刪除工單檔案 + /// + /// 工單號碼 + /// 檔案名稱 + /// + [HttpPost] + public async Task DeleteWipInfoBlob(string wipNo, string fileName) + { + var result = await _pcsApi.DeleteWipInfoBlobByFileName(wipNo, fileName); + return Json(new Result() { success = result.Success, msg = result.Msg, data = null }); + } #endregion ///// @@ -1632,7 +1663,7 @@ namespace AMESCoreStudio.Web.Controllers TempData["request"] = JsonConvert.SerializeObject(model); return Redirect("PCS001N"); } - // 保存 + // 儲存 await WipDataSelectAll(model.wipInfo.WipNO, model.wipAtt.ItemNO, model.wipInfo.UnitNO); IResultModel result; int UserID = GetLogInUserID(); @@ -1652,10 +1683,18 @@ namespace AMESCoreStudio.Web.Controllers // 判斷是否有開重複工單+生產單位 var wipInfoQuery = await _pcsApi.GetWipInfoByWipNO(model.wipInfo.WipNO); if (wipInfoQuery.Any()) - { - if (wipInfoQuery.Where(w => w.UnitNO == model.wipInfo.UnitNO).Count() != 0) + { // 判斷工單號碼 在工單基本資料檔只能有一筆(不判斷是否不同製程) + ViewBag.MoidByOnlyOne = _configuration["MoidByOnlyOne"]; + if (ViewBag.MoidByOnlyOne == "Y") { - Msg += " 同樣生產單位已建立相同工單了 "; + if (wipInfoQuery.Count() != 0) + { + Msg += $",工單號碼【{model.wipInfo.WipNO}】已重複建立"; + } + } + else if (wipInfoQuery.Where(w => w.UnitNO == model.wipInfo.UnitNO).Count() != 0) + { + Msg += ",同樣生產單位已建立相同工單了"; } } @@ -1693,8 +1732,11 @@ namespace AMESCoreStudio.Web.Controllers model.wipInfo.CustomerMedical = model.wipInfo.CustomerMedical == "Y" ? "true" : "false"; model.wipInfo.CustomerVIP = model.wipInfo.CustomerVIP == "Y" ? "true" : "false"; model.wipInfo.SFISFlowCk = model.wipInfo.SFISFlowCk == "Y" ? "true" : "false"; - ModelState.AddModelError("error", Msg); + if (Msg.StartsWith(",")) + Msg = Msg.Substring(1, Msg.Length - 1); + + ModelState.AddModelError("error", Msg); return View("PCS001N", model); } @@ -2578,8 +2620,6 @@ namespace AMESCoreStudio.Web.Controllers wipDataViewModel.wipBarcodeOther = model.wipBarcodeOther; var Msg = CheckWipInfoInsert(wipDataViewModel); - - // 判斷是否有開重複工單+生產單位 var wipInfoQuery = await _pcsApi.GetWipInfoByWipNO(model.wipInfo.WipNO); if (wipInfoQuery.Any()) @@ -2614,13 +2654,6 @@ namespace AMESCoreStudio.Web.Controllers Msg += ",SOP文件 請填寫SOP文件敘述 "; } - //// 判斷MAC是否正確 - //var CheckMACMsg = CheckMACData(model); - //if (!string.IsNullOrWhiteSpace(CheckMACMsg)) - //{ - // Msg += "," + CheckMACMsg; - //} - // 判斷標籤 工單性質選擇 WipAttr非標96工單時,則旁邊欄位必填 if (model.wipLabel.WipAttr == "B" && string.IsNullOrWhiteSpace(model.wipLabel.NonstandardWoMemo)) { @@ -3146,7 +3179,7 @@ namespace AMESCoreStudio.Web.Controllers } // KP料號正確 var kpNameArray = model.WipKps.Select(s => s.KpName).Distinct().ToList(); - foreach(var item in kpNameArray) + foreach (var item in kpNameArray) { if (_pcsApi.GetPlmMeterialInfo(item.Trim().ToUpper()).InvokeAsync().Result.Count == 0) { @@ -8302,6 +8335,23 @@ namespace AMESCoreStudio.Web.Controllers } foreach (var item in model.WipSops.Where(w => w.WipSOPID != -1)) { + // 判斷是否有紀錄Sop版本,沒有需要建立第一版 + if (item.SOPType == "A") + { + var SopVer = await _pcsApi.GetWipSopForSopVer(model.wipInfo.WipNO, model.wipAtt.ItemNO, item.SOPName); + if (SopVer.Success) + { + if (SopVer.Msg == "N") + { + var GetSopVer = await _pcsApi.GetDocEsopViewByNo(item.SOPName); + if (GetSopVer.Count != 0) + { + item.SOPVer = GetSopVer.FirstOrDefault().document_version; + } + } + } + } + item.WipNo = model.wipInfo.WipNO; item.ItemNo = model.wipAtt.ItemNO; item.CreateUserID = UserID; diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 1cfe4ada..04326589 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -1217,6 +1217,13 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpDelete("api/WipSop/{id}")] ITask> DeleteWipSop(int id); + + /// + /// 查詢是否有紀錄SOP版本 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WipSop/SelectSopVer")] + ITask> GetWipSopForSopVer(string wipNo = "", string itemNo = "", string sopName = ""); #endregion #region RuleStation 流程站別資料維護 @@ -1293,6 +1300,9 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/WipInfoBlob/ByWipNo/{id}")] ITask> GetWipInfoBlob(string id); + + [WebApiClient.Attributes.HttpDelete("api/WipInfoBlob/ByFileName")] + ITask> DeleteWipInfoBlobByFileName(string wipNo, string fileName); #endregion #region OutfitCommodityInfo 治具種類資料檔 diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml index 14e4bbac..890f1625 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml @@ -344,7 +344,7 @@
- +
diff --git a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml index 1ee0c3d9..64032b57 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS003.cshtml @@ -198,12 +198,14 @@
-
- + + + +
@@ -1104,10 +1106,11 @@ + Remark - - + + @@ -1121,10 +1124,13 @@ @index.Filepath } @@ -1306,7 +1312,6 @@ // 刪除出貨序號 $("#DeleteBarcodeOther").click(function (event) { - layer.confirm('確定是否要刪除出貨序號?', { btn: ['確定', '取消'] }, function () { @@ -1359,7 +1364,7 @@ else { var contactdiv = '' + ` - `; + `; $('#MACTable').append(contactdiv); } }, @@ -1485,6 +1490,40 @@ $(obj).attr("href", filePath); }; + // 檔案刪除 + function deleteFile(obj) { + layer.confirm('確定是否要刪除該筆檔案?', { + btn: ['確定', '取消'] + }, function () { + layer.closeAll('dialog'); + var FileName = $(obj).closest("TR").find('span[id*=FileName]').text(); + $.ajax({ + url: '@Url.Action("DeleteWipInfoBlobByFileName", "PCS")', + dataType: 'json', + data: { "wipNo": '@Model.wipInfo.WipNO', "fileName": FileName }, + cache: false, + type: "POST", + success: function (result) { + // 錯誤訊息 + if (!result.success) { + parent.hg.msg(result.msg); + } + else { + $("#wipBarcodeOther_StartNO").val(''); + $("#wipBarcodeOther_EndNO").val(''); + } + }, + error: function (jqXHR, textStatus, errorThrown) { + alert("檔案刪除失敗,請洽系統管理員!!"); + } + }); + }) + var Path = $(obj).closest("TR").find('span[id*=Filepath]').text(); + var FileName = $(obj).closest("TR").find('span[id*=FileName]').text(); + filePath = `/PCS/FileDownload?Path=${Path}&FileName=${FileName}`; + $(obj).attr("href", filePath); + } + function getFlowRuleList(data) { $.ajax( { @@ -1921,7 +1960,31 @@ }); }); - + + // 更新ECN or ECR + function GetPLM_ECN() { + $.ajax({ + url: "@Url.Action("FQC007GetPLMECN", "FQC")", + type: "Post", + data: { "ItemNo": '@Model.wipAtt.ItemNO' }, + success: function (result) { + if (result.success) { + var result_msg = result.msg; + if ('@Model.wipAtt.ItemNO') + layer.confirm('比對與PLM ECN/ECR不一樣,確定更新ECN/ECR嗎?', { + btn: ['確定', '取消'] + }, + $("#wipAtt_ECN").val(result_msg); + } + else { + parent.hg.msg(result.msg); + } + }, + error: function (result) { + parent.hg.msg(`呼叫API失敗`); + } + }); + } } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs index 0df8e41c..1581fb20 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs @@ -263,7 +263,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES SpecialPo = q2.SpecialPo, StatusName = q1.Status == "P" ? string.IsNullOrWhiteSpace(q2.SpecialPo) ? "允收Pass" : "特採允收" : q1.Status == "R" ? "批退Reject" : "", FqcID = q2.WipNo == null ? 0 : q2.FqcID, - InhouseMemo = q2.InhouseMemo, + InhouseMemo = q1.InhouseMemo, ManualQaMeno = q2.ManualQaMeno, QaMeno = q2.QaMeno, CustomerNo = q4.CustomerNO, diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfoBlobController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfoBlobController.cs index 86a39ab6..6b31b862 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfoBlobController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfoBlobController.cs @@ -94,8 +94,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); Helper helper = new Helper(_context); - wipInfoBlob.WipBlobID= helper.GetIDKey("WIP_BLOB_ID").Result; - + wipInfoBlob.WipBlobID = helper.GetIDKey("WIP_BLOB_ID").Result; + try { _context.WipInfoBlobs.Add(wipInfoBlob); @@ -127,6 +127,47 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return wipInfoBlob; } + /// + /// 刪除工單上傳檔案 + /// + /// 工單號碼 + /// 檔案名稱 + /// + [HttpDelete("ByFileName")] + public async Task> DeleteWipInfoBlobByFileName(string wipNo, string fileName) + { + ResultModel result = new ResultModel(); + if (!string.IsNullOrWhiteSpace(wipNo) && !string.IsNullOrWhiteSpace(fileName)) + { + result.Success = false; + result.Msg = "請輸入要刪除的資料"; + } + else + { + var wipInfoBlob = await _context.WipInfoBlobs.Where(w => w.WipNo.Trim().ToUpper() == wipNo.Trim().ToUpper() && + w.ImageName.Trim().ToUpper() == fileName.Trim().ToUpper()).ToListAsync(); + + if (wipInfoBlob.Count() != 0) + { + try + { + _context.WipInfoBlobs.Remove(wipInfoBlob.FirstOrDefault()); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + + } + } + } + + return result; + } + private bool WipInfoBlobExists(int id) { return _context.WipInfoBlobs.Any(e => e.WipBlobID == id); diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs index c76d2594..d9bf5c65 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs @@ -1813,7 +1813,7 @@ FROM [SFIS].[dbo].[ZPDKeyPart] B WHERE B.[IsActive] = 1 AND B.[ProductSN] = (S [HttpGet("WipInfoByWipNo/{wipno}")] public async Task>> GetWipInfoByWipNo(string wipno) { - IQueryable q = _context.WipInfos.Where(w => w.WipNO == wipno); + IQueryable q = _context.WipInfos.Where(w => w.WipNO.ToUpper().Trim() == wipno.ToUpper().Trim()); var WipInfo = await q.ToListAsync(); return WipInfo; } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs index f9c9e18e..09287e08 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipSopController.cs @@ -89,6 +89,43 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + /// + /// 查詢是否有紀錄SOP版本 + /// + /// 工單號碼 + /// 料號 + /// SOP文號 + /// + [HttpGet("SelectSopVer")] + public async Task> GetWipSopForSopVer(string wipNo = "", string itemNo = "", string sopName = "") + { + ResultModel result = new ResultModel(); + IQueryable q = _context.WipSops.Where(w => w.WipNo.Trim().ToUpper() == wipNo.Trim().ToUpper() && + w.ItemNo.Trim().ToUpper() == itemNo.Trim().ToUpper() && + w.SOPName.Trim().ToUpper() == sopName.Trim().ToUpper() && + w.SOPType == "A" && string.IsNullOrWhiteSpace(w.SOPVer)); + var query = await q.ToListAsync(); + try + { + if (query.Count() == 0) + { + result.Msg = "N"; + } + else + { + result.Msg = "Y"; + } + + result.Success = true; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + } + /// /// 新增工單製程對應SOP資料檔 /// @@ -97,7 +134,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES [HttpPost] public async Task> PostWipSop([FromBody] WipSop wipSop) { - ResultModel result = new ResultModel(); Helper helper = new Helper(_context); wipSop.WipSOPID = helper.GetIDKey("WIP_SOP_ID").Result; @@ -122,9 +158,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// /// [HttpPut] - public async Task> PutWipSop(WipSop wipSop) + public async Task> PutWipSop(WipSop wipSop) { - ResultModel result = new ResultModel(); + ResultModel result = new ResultModel(); _context.Entry(wipSop).State = EntityState.Modified; //設置容器空間某一個模型的某一個欄位 不提交到資料庫 //DbContent.Entry是要更新到資料庫的整個對象 diff --git a/AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs index 2aa73df1..dbbb15b2 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/WipSopDto.cs @@ -66,6 +66,11 @@ namespace AMESCoreStudio.WebApi.DTO.AMES public string UnitNoName { get; set; } + /// + /// SOP第一次版本 + /// + public string SOPVer { get; set; } + /// /// 建立UserID /// diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipInfoBlob.cs b/AMESCoreStudio.WebApi/Models/AMES/WipInfoBlob.cs index e38c7bae..5e117d57 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/WipInfoBlob.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/WipInfoBlob.cs @@ -58,6 +58,14 @@ namespace AMESCoreStudio.WebApi.Models.AMES [DataMember] public string Filepath { get; set; } + /// + /// 檔案備註 + /// + [Column("REMARK")] + [StringLength(500)] + [DataMember] + public string Remark { get; set; } + /// /// 建立UserID /// diff --git a/AMESCoreStudio.WebApi/Models/AMES/WipSop.cs b/AMESCoreStudio.WebApi/Models/AMES/WipSop.cs index 85cf386f..52f1a78c 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/WipSop.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/WipSop.cs @@ -72,6 +72,13 @@ namespace AMESCoreStudio.WebApi.Models.AMES [StringLength(10)] public string UnitNo { get; set; } + /// + /// SOP第一次版本 + /// + [Column("SOP_VER")] + [DataMember] + public string SOPVer { get; set; } + /// /// 建立UserID ///
檔案名稱 檔案路徑預覽下載備註
- 預覽 + @index.Remark + + 預覽 下載 + 刪除
${data.mix}${data.max}
${data.max}