From 37ac9d7b5f02b1f217817cb53ae8beff8e518919 Mon Sep 17 00:00:00 2001 From: Ray Date: Thu, 9 Dec 2021 17:31:34 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E6=96=B0=E5=A2=9EMAC=E5=8F=96=E8=99=9F?= =?UTF-8?q?=E7=A2=BC=E4=BD=B5=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AMESCoreStudio.Web/Code/Entire.cs | 76 ++++ .../Controllers/PCSController.cs | 144 +++++-- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 9 +- AMESCoreStudio.Web/Views/PCS/PCS001.cshtml | 372 ++++++++++-------- AMESCoreStudio.Web/Views/PCS/PCS001R.cshtml | 6 +- AMESCoreStudio.Web/Views/PCS/PCS010.cshtml | 1 - .../Controllers/AMES/BarcodeTypeController.cs | 12 +- .../Controllers/AMES/MACInfoesController.cs | 45 +++ .../Controllers/AMES/MatPropertyController.cs | 139 +++++++ .../Controllers/AMES/WipLogController.cs | 8 +- .../Models/AMES/BarcodeType.cs | 7 +- AMESCoreStudio.WebApi/Models/AMES/MACInfo.cs | 14 +- .../Models/AMES/MatProperty.cs | 67 ++++ AMESCoreStudio.WebApi/Models/AMESContext.cs | 7 +- 14 files changed, 678 insertions(+), 229 deletions(-) create mode 100644 AMESCoreStudio.Web/Code/Entire.cs create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/MatPropertyController.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/MatProperty.cs diff --git a/AMESCoreStudio.Web/Code/Entire.cs b/AMESCoreStudio.Web/Code/Entire.cs new file mode 100644 index 00000000..9f0c293e --- /dev/null +++ b/AMESCoreStudio.Web/Code/Entire.cs @@ -0,0 +1,76 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace AMESCoreStudio.Web.Code +{ + + public class Entire + { + /// + /// 10進位與16進位互轉 Types = DecToHex/HexToDec + /// + /// + /// 10-16:DecToHex 16-10:HexToDec + /// + public string DecHex(string InputTXT, string Types) + { + // 10 to 16 + if (Types == "DecToHex") + { + + // To hold our converted unsigned integer32 value + uint uiDecimal = 0; + try + { + // Convert text string to unsigned integer + uiDecimal = checked((uint)System.Convert.ToUInt32(InputTXT)); + } + + catch (System.OverflowException exception) + { + // Show overflow message and return + return "Overflow" + exception.ToString(); + + } + + // Format unsigned integer value to hex and show in another textbox + return String.Format("{0:x2}", uiDecimal); + } + + // 16 to 10 + else if (Types == "HexToDec") + { + + + // To hold our converted unsigned integer32 value + uint uiHex = 0; + + try + { + // Convert hex string to unsigned integer + uiHex = System.Convert.ToUInt32(InputTXT, 16); + } + + catch (System.OverflowException exception) + { + // Show overflow message and return + return "Overflow " + exception.ToString(); + + } + + // Format it and show as a string + return uiHex.ToString(); + + + } + else + { + return "input Type ERROR"; + + } + + } + } +} diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index e0b42cb4..ea9077cc 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -56,16 +56,16 @@ namespace AMESCoreStudio.Web.Controllers string Msg = string.Empty; if (string.IsNullOrWhiteSpace(model.wipInfo.LineID.ToString())) - Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.LineID)).Name; + Msg += model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.LineID)).Name + ","; if (string.IsNullOrWhiteSpace(model.wipInfo.UnitNO)) - Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.UnitNO)).Name; + Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.UnitNO)).Name + ","; if (model.wipInfo.WipDueDate == DateTime.MinValue) - Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.WipDueDate)).Name; + Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.WipDueDate)).Name + ","; if (model.wipInfo.WipScheduleDate == DateTime.MinValue) - Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.WipScheduleDate)).Name; + Msg += "," + model.wipInfo.GetAttributeFrom(nameof(model.wipInfo.WipScheduleDate)).Name + ","; // 序號編碼sheet @@ -100,6 +100,9 @@ namespace AMESCoreStudio.Web.Controllers Msg += ",MAC未填完整"; } + if (!string.IsNullOrWhiteSpace(Msg)) + Msg = "必填欄位未填寫:" + Msg.Substring(0, (Msg.Length - 1)); + return Msg; } @@ -126,19 +129,19 @@ namespace AMESCoreStudio.Web.Controllers !string.IsNullOrWhiteSpace(model.Ram)) { if (string.IsNullOrWhiteSpace(model.BiTemperature)) - Msg += "," + model.GetAttributeFrom(nameof(model.BiTemperature)).Name; + Msg += model.GetAttributeFrom(nameof(model.BiTemperature)).Name + ","; if (string.IsNullOrWhiteSpace(model.BiTime)) - Msg += "," + model.GetAttributeFrom(nameof(model.BiTime)).Name; + Msg += model.GetAttributeFrom(nameof(model.BiTime)).Name + ","; if (string.IsNullOrWhiteSpace(model.Checksum)) - Msg += "," + model.GetAttributeFrom(nameof(model.Checksum)).Name; + Msg += model.GetAttributeFrom(nameof(model.Checksum)).Name + ","; if (string.IsNullOrWhiteSpace(model.Cpu)) - Msg += "," + model.GetAttributeFrom(nameof(model.Cpu)).Name; + Msg += model.GetAttributeFrom(nameof(model.Cpu)).Name + ","; if (string.IsNullOrWhiteSpace(model.Ram)) - Msg += "," + model.GetAttributeFrom(nameof(model.Ram)).Name; + Msg += model.GetAttributeFrom(nameof(model.Ram)).Name + ","; } @@ -160,16 +163,16 @@ namespace AMESCoreStudio.Web.Controllers !string.IsNullOrWhiteSpace(model.BurnLocation)) { if (string.IsNullOrWhiteSpace(model.BiTemperature)) - Msg += "," + model.GetAttributeFrom(nameof(model.BiTemperature)).Name; + Msg += model.GetAttributeFrom(nameof(model.BiTemperature)).Name + ","; if (string.IsNullOrWhiteSpace(model.BiTime)) - Msg += "," + model.GetAttributeFrom(nameof(model.BiTime)).Name; + Msg += model.GetAttributeFrom(nameof(model.BiTime)).Name + ","; if (string.IsNullOrWhiteSpace(model.Checksum)) - Msg += "," + model.GetAttributeFrom(nameof(model.Checksum)).Name; + Msg += model.GetAttributeFrom(nameof(model.Checksum)).Name + ","; if (string.IsNullOrWhiteSpace(model.BurnLocation)) - Msg += "," + model.GetAttributeFrom(nameof(model.BurnLocation)).Name; + Msg += model.GetAttributeFrom(nameof(model.BurnLocation)).Name + ","; } @@ -876,6 +879,32 @@ namespace AMESCoreStudio.Web.Controllers [HttpPost] public async Task PCS001Async(WipViewModel model, IFormFile formFile) { + #region 選單 + await GetProductType(); + await GetFactoryInfo(); + await GetFactoryUnit(); + await GetLineInfo(); + await GetMFGType(); + await GetProcessTypes(); + await GetFlowRuleList(); + GetSMDType(); + GetDIPType(); + GetWipSEQType(); + GetBurnType(); + GetPartsBakeType(); + GetPCBBakeType(); + GetPCBWorkingType(); + GetSolderPaste(); + GetWipType(); + GetCustomerType(); + GetPCSList1(); + GetPCSOPList(); + GetCheckboxApproveLogo(); + GetCheckboxCompanyLogo(); + GetCheckboxPrintMode(); + GetCheckboxWipAttr(); + #endregion + IResultModel result; // Checkbox轉換 model.wipInfo.ECNCheck = model.wipInfo.ECNCheck == "true" ? "Y" : "N"; @@ -889,7 +918,20 @@ namespace AMESCoreStudio.Web.Controllers //系統 model.wipSystem.FinePackage = model.wipSystem.FinePackage == "true" ? "Y" : "N"; + // 判斷資料填寫 var Msg = CheckWipInfoInsert(model); + + + // 判斷是否有開重複工單+生產單位 + var wipInfoQuery = await _pcsApi.GetWipInfoByWipNO(model.wipInfo.WipNO); + if (wipInfoQuery.Any()) + { + if (wipInfoQuery.Where(w => w.UnitNO == model.wipInfo.UnitNO).Count() != 0) + { + Msg += " 同樣生產單位已建立相同工單了 "; + } + } + if (!string.IsNullOrWhiteSpace(Msg)) { model.wipInfo.ECNCheck = model.wipInfo.ECNCheck == "Y" ? "true" : "false"; @@ -903,10 +945,7 @@ namespace AMESCoreStudio.Web.Controllers //系統 model.wipSystem.FinePackage = model.wipSystem.FinePackage == "Y" ? "true" : "false"; ModelState.AddModelError("error", Msg); - GetCheckboxApproveLogo(); - GetCheckboxCompanyLogo(); - GetCheckboxPrintMode(); - GetCheckboxWipAttr(); + return View("PCS001", model); } @@ -920,7 +959,7 @@ namespace AMESCoreStudio.Web.Controllers await _pcsApi.PostWipAtt(JsonConvert.SerializeObject(model.wipAtt)); // 標籤 - model.wipLabel.ApproveLogo = model.wipLabel.ApproveLogos.Count == 0 ? null : string.Join(',', model.wipLabel.ApproveLogos); + model.wipLabel.ApproveLogo = model.wipLabel.ApproveLogos == null ? null : string.Join(',', model.wipLabel.ApproveLogos); model.wipLabel.WipNO = model.wipInfo.WipNO; await _pcsApi.PostWipLabel(JsonConvert.SerializeObject(model.wipLabel)); @@ -936,19 +975,25 @@ namespace AMESCoreStudio.Web.Controllers { if (string.IsNullOrWhiteSpace(CheckWipInfoInsert_WipSystem(model.wipSystem))) { - model.wipSystem.ItemNo = model.wipAtt.ItemNO; - model.wipSystem.WipNo = model.wipInfo.WipNO; - await _pcsApi.PostWipSystem(JsonConvert.SerializeObject(model.wipSystem)); + if (!string.IsNullOrWhiteSpace(model.wipSystem.BiTemperature)) + { + model.wipSystem.ItemNo = model.wipAtt.ItemNO; + model.wipSystem.WipNo = model.wipInfo.WipNO; + await _pcsApi.PostWipSystem(JsonConvert.SerializeObject(model.wipSystem)); + } } } else // 板卡 { - if (string.IsNullOrWhiteSpace(CheckWipInfoInsert_WipSystem(model.wipSystem))) + if (string.IsNullOrWhiteSpace(CheckWipInfoInsert_WipBoard(model.wipBoard))) { - model.wipBoard.ItemNo = model.wipAtt.ItemNO; - model.wipBoard.WipNo = model.wipInfo.WipNO; - await _pcsApi.PostWipBoard(JsonConvert.SerializeObject(model.wipBoard)); + if (!string.IsNullOrWhiteSpace(model.wipBoard.BiTemperature)) + { + model.wipBoard.ItemNo = model.wipAtt.ItemNO; + model.wipBoard.WipNo = model.wipInfo.WipNO; + await _pcsApi.PostWipBoard(JsonConvert.SerializeObject(model.wipBoard)); + } } } @@ -981,10 +1026,10 @@ namespace AMESCoreStudio.Web.Controllers if (!string.IsNullOrWhiteSpace(model.wipBarcodeOther.StartNO) && !string.IsNullOrWhiteSpace(model.wipBarcodeOther.EndNO)) { var type_no = await _pcsApi.GetBarcodeTypeByTypeName("客戶條碼區間"); - if (type_no.Any()) + if (type_no != null) { model.wipBarcodeOther.WipNO = model.wipInfo.WipNO; - model.wipBarcodeOther.TypeNO = type_no.FirstOrDefault().TypeNO; + model.wipBarcodeOther.TypeNO = type_no.TypeNo; result = await _pcsApi.PostWipBarcodeOther(JsonConvert.SerializeObject(model.wipBarcodeOther)); } } @@ -992,8 +1037,15 @@ namespace AMESCoreStudio.Web.Controllers // MAC if (!string.IsNullOrWhiteSpace(model.wipMAC.StartNO) && !string.IsNullOrWhiteSpace(model.wipMAC.EndNO)) { - model.wipMAC.WipNO = model.wipInfo.WipNO; - result = await _pcsApi.PostWipMAC(JsonConvert.SerializeObject(model.wipMAC)); + var mACInfo = await _pcsApi.GetMACInfo(model.wipAtt.ItemNO); + if (mACInfo != null) + { + model.wipMAC.WipNO = model.wipInfo.WipNO; + model.wipMAC.Title = mACInfo.Title; + model.wipMAC.ClassGroup = mACInfo.ClassGroup; + result = await _pcsApi.PostWipMAC(JsonConvert.SerializeObject(model.wipMAC)); + result = await _pcsApi.PutMACInfoByClassGroup(mACInfo.ClassGroup, model.wipMAC.EndNO); + } } } @@ -1001,8 +1053,8 @@ namespace AMESCoreStudio.Web.Controllers if (result.Success) { - var _msg = model.wipInfo.WipID == 0 ? "添加成功!" : "修改成功!"; - return RedirectToAction("PCB", "Home", new { msg = _msg }); + var _msg = "新增成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); } else { @@ -1073,6 +1125,32 @@ namespace AMESCoreStudio.Web.Controllers return View(model); } + + public async Task GetMAC(string itemno, int planQTY) + { + var q = await _pcsApi.GetMACInfo(itemno); + + if (q != null) + { + // 當前值 16 進位 + var Value = q.Value; + + var Entire = new Code.Entire(); + + // 最小值 + var Mix = (int.Parse(Entire.DecHex(Value, "HexToDec")) + 1); + // 最大值 + var Max = (int.Parse(Entire.DecHex(Value, "HexToDec")) + planQTY); + + var x = new + { + mix = Entire.DecHex(Mix.ToString(), "DecToHex").ToUpper(), + max = Entire.DecHex(Max.ToString(), "DecToHex").ToUpper(), + }; + return Json(x); + } + return Json(new { _msg = "查無相關MAC對應" }); + } #endregion #region PCS004 工單條碼區間設定 @@ -1272,8 +1350,8 @@ namespace AMESCoreStudio.Web.Controllers #region PCS010 工單對應站別鎖定 public async Task PCS010() { - var fileProvider = _fileServerProvider.GetProvider("/aa"); - var fileInfo = fileProvider.GetFileInfo("/"); + //var fileProvider = _fileServerProvider.GetProvider("/aa"); + //var fileInfo = fileProvider.GetFileInfo("/"); await GetStations(); GetLockReasonType(); GetLockType(); diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index f1b17af7..fe679d1b 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -186,8 +186,15 @@ namespace AMESCoreStudio.Web #region BarcodeType 條碼類別資料檔 PCS001 [WebApiClient.Attributes.HttpGet("api/BarcodeType/TypeName/{id}")] - ITask> GetBarcodeTypeByTypeName(string id); + ITask GetBarcodeTypeByTypeName(string id); + #endregion + + #region CParameterIni MAC資料表 PCS001 + [WebApiClient.Attributes.HttpGet("api/MACInfoes/Class/{id}")] + ITask GetMACInfo(string id); + [WebApiClient.Attributes.HttpPut("api/MACInfoes/MACInfoByClassGroup/{id}/{value}")] + ITask> PutMACInfoByClassGroup(string id,string value); #endregion #region WipLog 工單投產纪錄資料文件 PCS006 diff --git a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml index a292279e..e684c5d9 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS001.cshtml @@ -3,7 +3,7 @@ @{ ViewData["Title"] = "PCS001C"; Layout = "~/Views/Shared/_AMESLayout.cshtml"; - } +}