From c7cd7b51b09c108ad13d5363259c7b73c42bacc9 Mon Sep 17 00:00:00 2001 From: Yiru Date: Wed, 25 Dec 2024 16:40:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0FQC014=E4=B8=8D=E8=89=AF?= =?UTF-8?q?=E8=AD=A6=E5=A0=B1=E7=95=AB=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AMESCoreStudio.Web/AppSetting.cs | 5 + .../Controllers/FQCController.cs | 295 ++++++++++++- AMESCoreStudio.Web/FQC014U.cshtml | 210 +++++++++ AMESCoreStudio.Web/HttpApis/AMES/IESUN.cs | 9 + AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs | 101 +++++ AMESCoreStudio.Web/Views/FQC/FQC014.cshtml | 416 ++++++++++++++++++ AMESCoreStudio.Web/Views/FQC/FQC014R.cshtml | 171 +++++++ AMESCoreStudio.Web/Views/FQC/FQC014RV.cshtml | 136 ++++++ AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml | 213 +++++++++ .../Views/FQC/FQC014U.cshtml.bak | 188 ++++++++ AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml | 135 ++++++ AMESCoreStudio.Web/appsettings.json | 3 +- .../AMES/NgInfoAlertBlobsController.cs | 198 +++++++++ .../AMES/NgInfoAlertDetailController.cs | 142 ++++++ .../AMES/NgInfoAlertMasterController.cs | 268 +++++++++++ .../Controllers/AMES/NgRepairsController.cs | 64 +++ .../Controllers/SYS/UserInfoesController.cs | 32 ++ .../Models/AMES/NgInfoAlertBlob.cs | 102 +++++ .../Models/AMES/NgInfoAlertDetail.cs | 129 ++++++ .../Models/AMES/NgInfoAlertMaster.cs | 195 ++++++++ AMESCoreStudio.WebApi/Models/AMESContext.cs | 20 + 21 files changed, 3030 insertions(+), 2 deletions(-) create mode 100644 AMESCoreStudio.Web/FQC014U.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC014.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC014R.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC014RV.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml.bak create mode 100644 AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertBlobsController.cs create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertDetailController.cs create mode 100644 AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertMasterController.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertBlob.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertDetail.cs create mode 100644 AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs diff --git a/AMESCoreStudio.Web/AppSetting.cs b/AMESCoreStudio.Web/AppSetting.cs index abc45533..085ff190 100644 --- a/AMESCoreStudio.Web/AppSetting.cs +++ b/AMESCoreStudio.Web/AppSetting.cs @@ -22,6 +22,11 @@ namespace AMESCoreStudio.Web //2023-02-12 add public string PTD101Key { get; set; } + /// + /// FQC014上傳檔案大小限制 以MB為單位 + /// + public int FQC014FileSize { get; set; } + //Yiru End ------------------------------------------------------------------- public static AppSetting Setting { get; set; } = new AppSetting(); diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index 00576ecf..6ba098df 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -35,7 +35,8 @@ namespace AMESCoreStudio.Web.Controllers public readonly IBAS _basApi; public readonly IBLL _bllApi; public readonly ISYS _sysApi; - public FQCController(ILogger logger, IFQC fqcApi, IWebHostEnvironment env, IPCS pcsApi, IBLL bllApi, IBAS basApi, ISYS sysApi) + public readonly IESUN _esuncApi; + public FQCController(ILogger logger, IFQC fqcApi, IWebHostEnvironment env, IPCS pcsApi, IBLL bllApi, IBAS basApi, ISYS sysApi, IESUN esuncApi) { _logger = logger; _fqcApi = fqcApi; @@ -44,6 +45,7 @@ namespace AMESCoreStudio.Web.Controllers _bllApi = bllApi; _basApi = basApi; _sysApi = sysApi; + _esuncApi = esuncApi; } #region 下拉選單 @@ -2662,6 +2664,272 @@ namespace AMESCoreStudio.Web.Controllers #endregion + #region FQC014 異常不良警示 + + public IActionResult FQC014(string caseID) + { + var tt = Request.Cookies["UserID"]; + ViewBag.caseID = caseID;//給MAIL裡的連結使用 + + return View(); + } + + // [HttpGet] + public async Task GetNGINFOAlertMasterByQuery(string caseID,string itemNoF,string modelName,string wipNoF,string errorCode,string statusNo, string dateStart, string dateEnd, int page, int limit) + { + var result = await _fqcApi.GetNGINFOAlertMasterByQuery(caseID, itemNoF, modelName, wipNoF, errorCode, statusNo, dateStart, dateEnd, page, limit); + + if (result.Data.Count() > 0) + { + + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + + } + + return Json(new Table() { count = 0, data = null }); + } + + + public async Task GetNGINFOAlertDetailByQueryAsync(string caseID) + { + var result = await _fqcApi.GetNgInfoAlertDetail(caseID); + List result_data = new List(); + foreach (var item in result) + { + var nginfo = new ResultModel(); + if (item.Source == "1") //安勤 + { + nginfo = await _fqcApi.GetNgRepairDataByBarcodeNO(item.BarcodeNo); + } + else // 昶亨 + { + nginfo = await _esuncApi.GetNgRepairDataByBarcodeNO(item.BarcodeNo); + } + + + result_data.Add(new + { + barcodeNo = item.BarcodeNo, + factoryNo = nginfo.Data.Select(s => s.FACTORYNO).FirstOrDefault(), + wipNoF = item.WipNoF, + itemNoF = item.ItemNoF, + modelName = item.ModelName, + wipNoH = item.WipNoH, + itemNoH = item.ItemNoH, + createDate = item.CreateDate, + reasonNo = item.ReasonNo, + stationNo = nginfo.Data.Select(s => s.STATIONNAME).FirstOrDefault(), + userID = nginfo.Data.Select(s => s.USERNAME).FirstOrDefault(), + repairNo = nginfo.Data.Select(s => s.REPAIRNO).FirstOrDefault(), + repairDesc = nginfo.Data.Select(s => s.REPAIRDESC).FirstOrDefault() + }); + + + } + if (result_data.Count() > 0) + { + + return Json(new Table() { code = 0, msg = "", data = result_data, count = result_data.Count }); + + } + + return Json(new Table() { count = 0, data = null }); + } + + public async Task FQC014RSaveAsync(NgInfoAlertBlob model, IFormFile formFile) + { + IResultModel result; + var userID = ""; + HttpContext.Request.Cookies.TryGetValue("UserID", out userID); + int user_id = 0; + if (userID != null) + { + if (int.Parse(userID.ToString()) >= 0) + { + user_id = int.Parse(userID.ToString()); + } + } + model.CreateUserID = user_id; + model.CreateDate = System.DateTime.Now; + model.UpdateUserID = user_id; + model.UpdateDate = System.DateTime.Now; + string FileName = string.Empty; + string NewName = string.Empty; + string FilePath = string.Empty; + + + if (formFile != null) + { + int FileSize = AppSetting.Setting.FQC014FileSize; + // 檢查檔案大小 (5MB = 5 * 1024 * 1024 bytes) + if (formFile.Length > FileSize * 1024 * 1024) + { + ModelState.AddModelError("error", $"檔案大小不可超過 {FileSize}MB"); + ViewBag.CaseID = model.CaseID; + return View("FQC014R"); + } + + // 檢查檔案副檔名 + var allowedExtensions = new[] { ".png", ".jpg", ".bmp", ".gif", ".xlsx",".xls",".docx",".pdf",".pptx",".txt",".eml",".etc" }; + var fileExtension = Path.GetExtension(formFile.FileName).ToLower(); + + if (!allowedExtensions.Contains(fileExtension)) + { + ModelState.AddModelError("error", "僅允許上傳 png、jpg、bmp、gif、xlsx、xls、docx、pdf、pptx、txt、eml、etc 格式的檔案!"); + ViewBag.CaseID = model.CaseID; + return View("FQC014R"); + } + if (formFile.Length > 0) + { + //取得使用者上傳檔案的原始檔名 + FileName = Path.GetFileName(formFile.FileName); + + //指定要寫入的路徑、檔名和副檔名 + + FilePath = $"D:\\JinHon\\AMES_Upload\\FactoryMergerDocuments\\" +model.CaseID +"\\";//本機目錄 + if (!System.IO.Directory.Exists( FilePath)) + { + System.IO.Directory.CreateDirectory( FilePath); + } + using (var stream = new FileStream( FilePath + formFile.FileName, FileMode.Create)) + { + await formFile.CopyToAsync(stream); + } + model.ImageName = FileName; + model.FilePath = FilePath;// fileInfo.PhysicalPath; + + result = await _fqcApi.PostNgInfoAlertBlob(JsonConvert.SerializeObject(model)); + + if (result.Success) + { + //var _msg = "上傳成功!"; + ViewBag.CaseID = model.CaseID; + + return View("FQC014R"); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + } + } + else + { + ModelState.AddModelError("error", "請選擇要上傳檔案"); + } + + + ViewBag.CaseID = model.CaseID; + + + return View("FQC014R"); + } +\\ + public async Task FQC014RAsync(string id ) + { + + ViewBag.CaseID = id; + + return View(); + } + public async Task GetNgInfoAlertBlobsAsync(string id ) + { + if (id == null) + return Json(new Table() { count = 0, data = null }); + + // var result = await _fqcApi.GetNgInfoAlertBlobs(id); + var result = await _fqcApi.GetNgInfoAlertBlob(id); + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } + + return Json(new Table() { count = 0, data = null }); + } + + public async Task FQC014RDAsync(int id) + { + var result = await _fqcApi.DeleteNgInfoAlertBlob(id); + return Json(new Result() { success = true, msg = "" }); + } + + public async Task FQC014RVAsync(string id) + { + + ViewBag.CaseID = id; + + return View(); + } + [HttpGet] + public async Task FQC014UAsync(string id) + { + var tt = Request.Cookies["UserID"]; + ViewBag.UserID = tt; + await GetUserInfo("1004,1009"); + + var result = await _fqcApi.GetNgInfoAlertMaster(id); + return View(result); + + } + + [HttpGet] + public async Task FQC014UVAsync(string id) + { + var tt = Request.Cookies["UserID"]; + ViewBag.UserID = tt; + await GetUserInfo("1004,1009"); + + var result = await _fqcApi.GetNgInfoAlertMaster(id); + return View(result); + + } + public async Task FQC014USaveAsync(NgInfoAlertMaster model) + { + if (ModelState.IsValid) + { + IResultModel result; + + result = await _fqcApi.PutNgInfoAlertMaster(model.CaseID, JsonConvert.SerializeObject(model)); + + if (result.Success) + { + var _msg = "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + var tt = Request.Cookies["UserID"]; + ViewBag.UserID = tt; + + ModelState.AddModelError("error", result.Msg); + + } + } + return View("FQC014U", model); + + } + + /// + /// 檔案下載 + /// + /// 路徑 + /// 檔名 + /// + public async Task FileDownload_byPath(string Path, string FileName) + { + var path = $@"{Path}{FileName}"; + var memoryStream = new MemoryStream(); + using (var stream = new FileStream(path, FileMode.Open)) + { + await stream.CopyToAsync(memoryStream); + } + memoryStream.Seek(0, SeekOrigin.Begin); + string contentType = await GetFileContentTypeAsync(FileName); + // 回傳檔案到 Client 需要附上 Content Type,否則瀏覽器會解析失敗。 + return File(memoryStream, contentType, FileName); + } + #endregion + #endregion /// @@ -2682,5 +2950,30 @@ namespace AMESCoreStudio.Web.Controllers } return user_id; } + /// + /// 使用角色ID查詢人員清單 + /// + /// + /// + private async Task GetUserInfo(string DeptIDs) + { + string[] DeptIDList = DeptIDs.Split(','); + var UserItems = new List(); + // 顯示分割後的結果 + foreach (var item1 in DeptIDList) + { + var result = await _fqcApi.GetUserInfoByRoleID(int.Parse(item1)); + foreach (var item in result.Data) + { + // 檢查是否已有相同 UserID + if (!UserItems.Any(x => x.Value == item.UserID.ToString())) + { + UserItems.Add(new SelectListItem(item.UserName, item.UserID.ToString())); + } + } + } + + ViewBag.UserList = UserItems; + } } } diff --git a/AMESCoreStudio.Web/FQC014U.cshtml b/AMESCoreStudio.Web/FQC014U.cshtml new file mode 100644 index 00000000..eb935d4d --- /dev/null +++ b/AMESCoreStudio.Web/FQC014U.cshtml @@ -0,0 +1,210 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NgInfoAlertMaster + + +@{ ViewData["Title"] = "FQC014U"; + // Layout = "~/Views/Shared/_FormLayout.cshtml"; + Layout = "~/Views/Shared/_AMESLayout.cshtml";} + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ CASE 編輯 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ @Html.ValidationMessage("error") +
+ +
+
+
+
+
+
+
+
+@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + +} diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IESUN.cs b/AMESCoreStudio.Web/HttpApis/AMES/IESUN.cs index ef25545f..ee55adb5 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IESUN.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IESUN.cs @@ -201,5 +201,14 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/MFGTypes")] ITask> GetMFGTypes(); + + + /// + /// 查詢工單條碼資料-WipNo + /// + /// + [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/NgRepairs/GetNgRepairDataByBarcodeNO")] + ITask> GetNgRepairDataByBarcodeNO(string barcodeNo); + } } diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index 05ee9816..f648f60b 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc; using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.CommonTools.Result; using AMESCoreStudio.WebApi.DTO.AMES; +using AMESCoreStudio.WebApi.Models.SYS; namespace AMESCoreStudio.Web { @@ -794,6 +795,106 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/MaterialItem/AutoComplete/{id}")] ITask> GetMeterialAutoComplete(string id); + #endregion + + #region FQC014 異常不良警示 + + + /// + /// 查詢異常不良警示 + /// + /// + [WebApiClient.Attributes.HttpGet("api/UserInfoes/RoleID/{id}")] + ITask> GetUserInfoByRoleID(int id ); + + /// + /// 查詢異常不良警示 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgInfoAlertMaster/GetNGINFOAlertMasterByQuery")] + ITask> GetNGINFOAlertMasterByQuery(string caseID,string itemNoF, string modelName, string wipNoF, string errorCode, string statusNo, string dateStart, string dateEnd, int page, int limit); + + + /// + /// 查詢異常不良警示 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgInfoAlertMaster/{id}")] + ITask GetNgInfoAlertMaster(string id); + + /// + /// 更新異常不良警示 + /// + /// + [WebApiClient.Attributes.HttpPut("api/NgInfoAlertMaster")] + ITask> PutNgInfoAlertMaster(string id,[FromBody, RawJsonContent] string model); + + + /// + /// 新增 異常不良警示上傳圖檔資料表 + /// + /// + /// + [WebApiClient.Attributes.HttpPost("api/NgInfoAlertBlobs")] + ITask> PostNgInfoAlertBlob([FromBody, RawJsonContent] string model); + + + /// + /// 更新 檢驗結果上傳圖檔資料表 + /// + /// + [WebApiClient.Attributes.HttpPut("api/NgInfoAlertBlobs/{id}")] + ITask> PutNgInfoAlertBlob(int id, [FromBody, RawJsonContent] string model); + + + /// + /// 查詢 檢驗結果上傳圖檔資料表 By OUTFITID + /// + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgInfoAlertBlobs/{id}")] + ITask> GetNgInfoAlertBlob(string id); + + + /// + /// 獲取指定巡檢表單Blob資料By Query + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgInfoAlertBlobs/Query/{id}/{itemID}")] + ITask> GetNgInfoAlertBlobsByQuery(string id, int itemid); + + /// + /// 獲取指定巡檢表單Blob資料By Query + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgInfoAlertBlobs/{id}")] + ITask> GetNgInfoAlertBlobs(string id); + + + + /// + /// 刪除圖檔資料表 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/NgInfoAlertBlobs/{id}")] + ITask> DeleteNgInfoAlertBlob(int id); + + /// + /// 查詢工單條碼資料-WipNo + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgRepairs/GetNgRepairDataByBarcodeNO")] + ITask> GetNgRepairDataByBarcodeNO(string barcodeNo); + + /// + /// 查詢異常不良警示 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NgInfoAlertDetail/{id}")] + ITask> GetNgInfoAlertDetail(string id); + + + #endregion } } diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014.cshtml new file mode 100644 index 00000000..daca5846 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC014.cshtml @@ -0,0 +1,416 @@ +@{ + ViewData["Title"] = "異常警報資料維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+ +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+ +
+
+
+
+
+
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+ +
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+
+ +@section Scripts{ + + + + + + + + + + + + + + + + + + + + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014R.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014R.cshtml new file mode 100644 index 00000000..044cf4cc --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC014R.cshtml @@ -0,0 +1,171 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NgInfoAlertBlob + + + +@{ ViewData["Title"] = "FQC014R"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+ + +
+
+ + +
+
+
+ + + +
+
+
+ @Html.ValidationMessage("error") +
+
+
+ @* SOP文件 sheet *@ +
+
+
+ + +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014RV.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014RV.cshtml new file mode 100644 index 00000000..5c960d7c --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC014RV.cshtml @@ -0,0 +1,136 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NgInfoAlertBlob + + + +@{ ViewData["Title"] = "FQC014RV"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+ + +
+
+ @Html.ValidationMessage("error") + @* *@ +
+
+
+ @* SOP文件 sheet *@ +
+ +
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml new file mode 100644 index 00000000..1e7f1fe4 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml @@ -0,0 +1,213 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NgInfoAlertMaster + + +@{ ViewData["Title"] = "FQC014U"; + // Layout = "~/Views/Shared/_FormLayout.cshtml"; + Layout = "~/Views/Shared/_AMESLayout.cshtml";} + +
+
+
+
+
+ + + + + + + + + + + + + @*//
*@ + + + + + + + + + + + + + + + + + + + + + + + +
+ CASE 編輯 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ @Html.ValidationMessage("error") +
+ +
+
+
+
+
+
+
+
+@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml.bak b/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml.bak new file mode 100644 index 00000000..be771a83 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC014U.cshtml.bak @@ -0,0 +1,188 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NgInfoAlertMaster + + +@{ ViewData["Title"] = "FQC014U"; + // Layout = "~/Views/Shared/_FormLayout.cshtml"; + Layout = "~/Views/Shared/_AMESLayout.cshtml";} + +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ CASE 編輯 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ @Html.ValidationMessage("error") +
+ +
+
+
+
+
+
+
+
+@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml new file mode 100644 index 00000000..9c8e9bee --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC014UV.cshtml @@ -0,0 +1,135 @@ +@model AMESCoreStudio.WebApi.Models.AMES.NgInfoAlertMaster + + +@{ ViewData["Title"] = "FQC014U"; + Layout = "~/Views/Shared/_FormLayout.cshtml"; } + +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ CASE 內容 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ @Html.ValidationMessage("error") + +
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} + diff --git a/AMESCoreStudio.Web/appsettings.json b/AMESCoreStudio.Web/appsettings.json index 6ee999cc..7c789476 100644 --- a/AMESCoreStudio.Web/appsettings.json +++ b/AMESCoreStudio.Web/appsettings.json @@ -1,7 +1,8 @@ { "Setting": { "Urls": "http://*:8080", - "ApiUrl": "http://127.0.0.1:5000" + "ApiUrl": "http://127.0.0.1:5000", + "FQC014FileSize" : 5 }, "Logging": { "LogLevel": { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertBlobsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertBlobsController.cs new file mode 100644 index 00000000..a8adeb3b --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertBlobsController.cs @@ -0,0 +1,198 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore; +using AMESCoreStudio.WebApi; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.CommonTools.Result; + + +namespace AMESCoreStudio.WebApi.Controllers.AMES +{ + /// + /// 巡檢類別資料维护 + /// + [Route("api/[controller]")] + [ApiController] + public class NgInfoAlertBlobsController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public NgInfoAlertBlobsController(AMESContext context) + { + _context = context; + } + + /// + /// 获取全部巡檢類別資料 + /// + /// + // GET: api/NgInfoAlertBlobs + [HttpGet] + public async Task>> GetNgInfoAlertBlobs() + { + IQueryable q = _context.NgInfoAlertBlobs; + q = q.OrderBy(p => p.CaseID); + q = q.OrderBy(p => p.CaseItemID); + + var NgInfoAlertBlobs = await q.ToListAsync(); + + return NgInfoAlertBlobs; + } + + /// + /// 用ID获取该巡檢類別資料 + /// + /// + /// + // GET: api/NgInfoAlertBlobs/5 + [HttpGet("{id}")] + public async Task>> GetNgInfoAlertBlobs(string id ) + { + + IQueryable q = _context.NgInfoAlertBlobs; + q = q.Where(p => p.CaseID.Equals(id)); + var NgInfoAlertBlob = await q.ToListAsync(); + + if (NgInfoAlertBlob == null) + { + return NotFound(); + } + + return NgInfoAlertBlob; + } + + /// + /// 获取该巡檢表單Blob By Query + /// + /// + /// + /// + // GET: api/NgInfoAlertBlobs/Query/5 + [HttpGet("Query/{id}/{itemID}")] + public async Task>> GetNgInfoAlertBlobsByQuery(string id, int itemID) + { + + IQueryable q = _context.NgInfoAlertBlobs; + q = q.Where(p => p.CaseID.Equals(id)); + q = q.Where(p => p.CaseItemID.Equals(itemID)); + var NgInfoAlertBlob = await q.ToListAsync(); + + if (NgInfoAlertBlob.Count == 0 ) + { + return NgInfoAlertBlob; + } + + return NgInfoAlertBlob; + } + + + + /// + /// 更新巡檢類別資料 + /// + /// + /// + /// + // PUT: api/NgInfoAlertBlobs/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> PutNgInfoAlertBlobs(int id, [FromBody] NgInfoAlertBlob NgInfoAlertBlob) + { + ResultModel result = new ResultModel(); + if (id != NgInfoAlertBlob.CaseItemID) + { + result.Success = false; + result.Msg = "錯誤"; + return result; + } + + _context.Entry(NgInfoAlertBlob).State = EntityState.Modified; + + try + { + await _context.SaveChangesAsync(); + } + catch (Exception e) + { + result.Success = false; + result.Msg = e.Message; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// + /// 新增 檢驗結果上傳圖檔資料表 + /// + /// + /// + [HttpPost] + public async Task> PostNgInfoAlertBlob(NgInfoAlertBlob NgInfoAlertBlob) + { + ResultModel result = new ResultModel(); + NgInfoAlertBlob.CreateDate = DateTime.Now; + NgInfoAlertBlob.UpdateDate = DateTime.Now; + Helper helper = new Helper(_context); + NgInfoAlertBlob.CaseItemID = helper.GetIDKey("NGINFOALERT_BLOBID").Result; + + _context.NgInfoAlertBlobs.Add(NgInfoAlertBlob); + 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/NgInfoAlertBlobs/5 + [HttpDelete("{id}")] + public async Task> DeleteNgInfoAlertBlobs(int id) + { + ResultModel result = new ResultModel(); + var inspectionType = await _context.NgInfoAlertBlobs.Where(m => m.CaseItemID == id).FirstOrDefaultAsync(); + if (inspectionType == null) + { + result.Success = false; + result.Msg = "序號不存在"; + return result; + } + + _context.NgInfoAlertBlobs.Remove(inspectionType); + await _context.SaveChangesAsync(); + + result.Success = true; + result.Msg = "OK"; + return result; + } + + private bool NgInfoAlertBlobsExists(int id) + { + return _context.NgInfoAlertBlobs.Any(e => e.CaseItemID == id); + } + + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertDetailController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertDetailController.cs new file mode 100644 index 00000000..8e8d27d4 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertDetailController.cs @@ -0,0 +1,142 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.CommonTools.Result; +using AMESCoreStudio.WebApi.DTO.AMES; +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace AMESCoreStudio.WebApi.Controllers.AMES +{ + [Route("api/[controller]")] + [ApiController] + public class NgInfoAlertDetailController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public NgInfoAlertDetailController(AMESContext context) + { + _context = context; + } + + /// + /// 異常Alert序號明細資料 + /// + /// + [HttpGet] + public async Task>> GetNgInfoAlertDetail() + { + IQueryable q = _context.NgInfoAlertDetails; + q = q.OrderBy(p => p.CaseID).ThenBy(p=>p.CaseItemID); + var NgInfoAlertDetail = await q.ToListAsync(); + return NgInfoAlertDetail; + } + + /// + /// 異常Alert序號明細資料by CaseID + /// + /// + /// + [HttpGet("{id}")] + public async Task>> GetNgInfoAlertDetails(string id) + { + + IQueryable q = _context.NgInfoAlertDetails; + q = q.Where(p => p.CaseID.Equals(id)); + var NgInfoAlertDetails = await q.ToListAsync(); + + if (NgInfoAlertDetails == null) + { + return NotFound(); + } + + return NgInfoAlertDetails; + } + + /// + /// 新增異常Alert序號明細資料 + /// + /// + /// + [HttpPost] + public async Task> PostNgInfoAlertDetail(List NgInfoAlertDetail) + { + ResultModel result = new ResultModel(); + + try + { + IQueryable q = _context.NgInfoAlertDetails; + Helper helper = new Helper(_context); + foreach (var item in NgInfoAlertDetail) + { + + item.CaseItemID = helper.GetIDKey("CASE_ITEM_ID").Result;// CaseItemID; + item.CreateDate = DateTime.Now; + _context.NgInfoAlertDetails.Add(item); + + } + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + } + + + + + /// + /// 更新異常Alert序號明細資料 + /// + /// + /// + [HttpPut] + public async Task> PutNgInfoAlertDetail(NgInfoAlertDetail NgInfoAlertDetail) + { + ResultModel result = new ResultModel(); + var CaseItemID = NgInfoAlertDetail.CaseItemID; + try + { + if (_context.NgInfoAlertDetails.Any(e => e.CaseItemID == CaseItemID)) + { + _context.Entry(NgInfoAlertDetail).State = EntityState.Modified; + _context.Entry(NgInfoAlertDetail).Property("CreateDate").IsModified = false; + } + else + { + _context.NgInfoAlertDetails.Add(NgInfoAlertDetail); + } + + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + } + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertMasterController.cs new file mode 100644 index 00000000..ccbf2da9 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgInfoAlertMasterController.cs @@ -0,0 +1,268 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.CommonTools.Result; +using AMESCoreStudio.WebApi.DTO.AMES; +// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 + +namespace AMESCoreStudio.WebApi.Controllers.AMES +{ + [Route("api/[controller]")] + [ApiController] + public class NgInfoAlertMasterController : ControllerBase + { + private readonly AMESContext _context; + + /// + /// + /// + /// + public NgInfoAlertMasterController(AMESContext context) + { + _context = context; + } + + /// + /// 異常Alert資料 + /// + /// + [HttpGet] + public async Task>> GetNgInfoAlertMaster() + { + IQueryable q = _context.NgInfoAlertMasters; + q = q.OrderBy(p => p.CaseID); + var NgInfoAlertMaster = await q.ToListAsync(); + return NgInfoAlertMaster; + } + + /// + /// 異常Alert資料by CaseID + /// + /// + /// + [HttpGet("{id}")] + public async Task> GetNgInfoAlertMaster(string id) + { + IQueryable q = _context.NgInfoAlertMasters; + + var NgInfoAlertMaster = await q.Where(p => p.CaseID == id).FirstOrDefaultAsync(); + + //if (NgInfoAlertMaster == null) + //{ + // return NotFound(); + //} + + return NgInfoAlertMaster; + } + + + /// + /// 新增異常Alert資料 + /// + /// + /// + [HttpPost] + public async Task> PostNgInfoAlertMaster([FromBody] NgInfoAlertMaster NgInfoAlertMaster) + { + ResultModel result = new ResultModel(); + var TmpCaseID = "R" + DateTime.Now.ToString("yyyy"); + var MaxCaseID= _context.NgInfoAlertMasters.Where(w => w.CaseID.Contains(TmpCaseID)).Max(m => m.CaseID); + if (String.IsNullOrWhiteSpace(MaxCaseID)) + { + MaxCaseID = "0000"; + } + else + { + MaxCaseID = MaxCaseID.Substring(4); + } + int serialNumber = int.Parse(MaxCaseID); // 將四位數字轉換為整數 + // 若流水號小於9999,則加1 + if (serialNumber < 9999) + { + serialNumber++; + } + // 用新的流水號更新字串,若流水號為9999,則不再進位 + NgInfoAlertMaster.CaseID = TmpCaseID + serialNumber.ToString("D4"); + _context.NgInfoAlertMasters.Add(NgInfoAlertMaster); + try + { + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = NgInfoAlertMaster.CaseID.ToString(); + + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + } + + /// + /// 更新異常Alert資料 + /// + /// + /// + [HttpPut] + public async Task> PutNgInfoAlertMaster(NgInfoAlertMaster NgInfoAlertMaster) + { + ResultModel result = new ResultModel(); + var CaseID = NgInfoAlertMaster.CaseID; + try + { + if (_context.NgInfoAlertMasters.Any(e => e.CaseID == CaseID)) + { + _context.Entry(NgInfoAlertMaster).State = EntityState.Modified; + _context.Entry(NgInfoAlertMaster).Property("CreateDate").IsModified = false; + _context.Entry(NgInfoAlertMaster).Property("UserID").IsModified = false; + if (NgInfoAlertMaster.StatusNo == "F") + { + NgInfoAlertMaster.FinishDate = DateTime.Now; + if (NgInfoAlertMaster.UpdateDate == null) + { + NgInfoAlertMaster.UpdateDate = DateTime.Now; + } + } + else + { + NgInfoAlertMaster.UpdateDate = DateTime.Now; + } + } + else + { + _context.NgInfoAlertMasters.Add(NgInfoAlertMaster); + } + + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; + } + + /// + /// 查詢工單站別在製條碼資料 + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetNGINFOAlertMasterByQuery(string caseID,string itemNoF, string modelName, string wipNoF, string errorCode, string statusNo, string dateStart, string dateEnd, int page = 0, int limit = 10) + { + ResultModel result = new ResultModel(); + + var q = from m in _context.NgInfoAlertMasters + join s in _context.Stationses on m.StationID equals s.StationID into stationsJoin + from s in stationsJoin.DefaultIfEmpty() + join u in _context.UserInfoes on m.UpdateUserID equals u.UserID into userJoin + from u in userJoin.DefaultIfEmpty() + join f in _context.FactoryInfos on m.FactoryID equals f.FactoryID into factoryJoin + from f in factoryJoin.DefaultIfEmpty() + select new + { + m.CaseID, + m.FactoryID, + m.BarcodeNo, + m.WipNoF, + m.ItemNoF, + m.ModelName, + m.WipNoH, + m.ItemNoH, + m.StationID, + m.CreateDate, + m.ReasonNo, + m.UpdateUserID, + StatusNo = m.StatusNo == "A" ? "未處理" : + m.StatusNo == "E" ? "處理中" : + m.StatusNo == "F" ? "已結案" : "未知狀態", // 根據 StatusNo 顯示不同的狀態 + s.StationName, + u.UserName, + f.FactoryNo, + m.UpdateDate, + m.FinishDate + }; + if (!string.IsNullOrWhiteSpace(caseID)) + { + q = q.Where(w => w.CaseID == caseID); + } + if (!string.IsNullOrWhiteSpace(itemNoF)) + { + q = q.Where(w => w.ItemNoF == itemNoF); + } + if (!string.IsNullOrWhiteSpace(modelName)) + { + q = q.Where(w => w.ModelName == modelName); + } + if (!string.IsNullOrWhiteSpace(wipNoF)) + { + q = q.Where(w => w.WipNoF == wipNoF); + } + if (!string.IsNullOrWhiteSpace(errorCode)) + { + + q = q.Where(w => w.ReasonNo == errorCode); + } + if (!string.IsNullOrWhiteSpace(statusNo) && statusNo != "ALL") + { + + q = q.Where(w => w.StatusNo == statusNo); + } + + if (dateStart != null && dateStart != "" && dateEnd != null && dateEnd != "") + { + q = q.Where(w => w.CreateDate >= DateTime.Parse(dateStart + " 00:00:00") && w.CreateDate <= DateTime.Parse(dateEnd + " 23:59:59")); + } + + if (string.IsNullOrWhiteSpace(itemNoF) && string.IsNullOrWhiteSpace(modelName) && + string.IsNullOrWhiteSpace(wipNoF) && string.IsNullOrWhiteSpace(errorCode) && + string.IsNullOrWhiteSpace(statusNo) && string.IsNullOrWhiteSpace(dateStart) + && string.IsNullOrWhiteSpace(dateEnd)) + { + q = q.OrderByDescending(c => c.CreateDate).Take(5); + } + + + + //紀錄筆數 + + result.DataTotal = q.Count(); + + // Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Data = await q.ToListAsync(); + result.Success = true; + return result; + + + + } + + + + // DELETE api//5 + [HttpDelete("{id}")] + public void Delete(int id) + { + } + } +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs index a209914c..d6881fed 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs @@ -1631,6 +1631,70 @@ and d.wip_no = '{0}' and a.station_id={1} and b.part_no='{2}'", wipNo, stationID return result; } + + /// + /// 安勤異常警示使用 + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetNgRepairDataByBarcodeNO(string barcodeNo) + { + ResultModel result = new ResultModel(); + var q = from q1 in _context.NgRepairs + join q2 in _context.NgInfos on q1.NgID equals q2.NgID + join q3 in _context.BarcodeInfoes on q2.BarcodeID equals q3.BarcodeID + where q3.BarcodeNo == barcodeNo + join q4 in _context.WipInfos on q2.WipId equals q4.WipID + join q5 in _context.WipAtts on q4.WipNO equals q5.WipNO + join q6 in _context.LineInfoes on q4.LineID equals q6.LineID + join q7 in _context.Stationses on q2.StationId equals q7.StationID + join q8 in _context.UserInfoes on q1.CreateUserID equals q8.UserID + select new + { + q4.UnitNO, + q6.LineDesc, + q1.CreateDate, + q7.StationName, + q4.WipNO, + q5.ItemNO, + q5.ModelNO, + q4.LineID, + q3.BarcodeNo, + q2.TypeNo, + q2.StationId, + q2.ReasonNo, + q1.RepairNo, + q1.RepairTypeNo, + q1.RepairDesc, + q1.PartNo, + q8.UserName + }; + + + + + q = q.OrderBy(w => w.CreateDate); + + //紀錄筆數 + result.DataTotal = q.Count(); + + result.Data = await q.ToListAsync(); + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// /// diff --git a/AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs index fc667083..ff1525ab 100644 --- a/AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/SYS/UserInfoesController.cs @@ -180,6 +180,38 @@ namespace AMESCoreStudio.WebApi.Controllers.SYS return userInfo; } + /// + /// 根据角色资料查詢人員清單 + /// + /// + /// + // GET: api/UserRoles/User/5 + [HttpGet("RoleID/{id}")] + public async Task> GetUserInfoByRoleID(int id) + { + ResultModel result = new ResultModel(); + var q = from u in _context.UserRoles + join f in _context.UserInfoes on u.UserID equals f.UserID + where u.RoleID == id + select new UserInfo + { + DeptID = f.DeptID, + UserName = f.UserName, + UserID = f.UserID + }; + result.DataTotal = q.ToList().Count; + var userRole = await q.ToListAsync(); + result.Data = q; + if (userRole == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + result.Msg = "OK"; + result.Success = true; + return result; + } /// /// /// diff --git a/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertBlob.cs b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertBlob.cs new file mode 100644 index 00000000..66971400 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertBlob.cs @@ -0,0 +1,102 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Runtime.Serialization; +using Microsoft.EntityFrameworkCore; + +#nullable disable + +namespace AMESCoreStudio.WebApi.Models.AMES +{ // YIRU 2022-90-20 + /// + /// 設備圖 + /// + [Table("NG_INFO_ALERT_BLOB", Schema = "JHAMES")] + public partial class NgInfoAlertBlob + { + /// + /// 警報ID + /// + [Column("CASE_ID")] + [DataMember] + [Key] + [Required] + + public string CaseID { get; set; } + + + /// + /// 警報ID + /// + [Column("CASE_ITEMID")] + [DataMember] + [Key] + [Required] + + public int CaseItemID { get; set; } + + + /// + /// 檔名 + /// + [Column("IMAGE_NAME")] + [Display(Name = "檔名")] + [DataMember] + [Required(ErrorMessage = "{0},不能空白")] + public string ImageName { get; set; } + + /// + /// 圖檔 + /// + [Column("IMAGE_BLOB")] + [Display(Name = "圖檔")] + [DataMember] + public byte[] ImageBlob { get; set; } + + + /// + /// 儲存路徑 + /// + [Column("FILEPATH")] + [Display(Name = "儲存路徑")] + [DataMember] + public string FilePath { get; set; } + + + /// + /// 備註 + /// + [Column("MEMOS")] + [Display(Name = "檔案備註")] + [DataMember] + public string Memos { get; set; } + + /// + /// 創建者ID + /// + [Column("CREATE_USERID")] + [DataMember] + public int CreateUserID { get; set; } = 0; + + /// + /// 創建日期 + /// + [Column("CREATE_DATE")] + [DataMember] + public DateTime CreateDate { get; set; } = System.DateTime.Now; + + /// + /// 更新者ID + /// + [Column("UPDATE_USERID")] + [DataMember] + public int UpdateUserID { get; set; } = 0; + + /// + /// 更新日期 + /// + [Column("UPDATE_DATE")] + [DataMember] + public DateTime UpdateDate { get; set; } = System.DateTime.Now; + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertDetail.cs b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertDetail.cs new file mode 100644 index 00000000..13d457ca --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertDetail.cs @@ -0,0 +1,129 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; +using System.Runtime.Serialization; + +#nullable disable + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + [Table("NG_INFO_ALERT_DETAIL", Schema = "JHAMES")] + public partial class NgInfoAlertDetail + { + /// + /// 案件編號 (Case ID) + /// + [DataMember] + [Display(Name = "CASE ID")] + [Required(ErrorMessage = "{0} 不能空白")] + [Column("CASE_ID")] + public string CaseID { get; set; } + + /// + /// 案件項目編號 (Case Item ID) + /// + [DataMember] + [Display(Name = "CASEITEM ID")] + [Key] + [Column("CASE_ITEM_ID")] + public int CaseItemID { get; set; } + + /// + /// 生產序號 (Production Serial Number) + /// + [DataMember] + [Display(Name = "生產序號")] + [Column("BARCODE_NO")] + public string BarcodeNo { get; set; } + + /// + /// 發生站別 (Station ID) + /// + [DataMember] + [Display(Name = "發生站別")] + [Column("STATION_ID")] + public int StationID { get; set; } + + /// + /// 警報時間 (Alert Time) + /// + [DataMember] + [Display(Name = "建立時間")] + [Column("CREATE_DATE")] + public DateTime CreateDate { get; set; } + + /// + /// 作業人員 (Operator ID) + /// + [DataMember] + [Display(Name = "作業人員")] + [Column("USER_ID")] + public int UserID { get; set; } + + /// + /// 資料來源 (Data Source) + /// + [DataMember] + [Display(Name = "資料來源")] + [Column("SOURCE")] + public string Source { get; set; } + + /// + /// 警報原因 (Alert Reason) + /// + [DataMember] + [Display(Name = "警報原因")] + [Column("REASON_NO")] + public string ReasonNo { get; set; } + + /// + /// 機種 (Model Name) + /// + [DataMember] + [Display(Name = "機種")] + [Column("MODEL_NAME")] + public string ModelName { get; set; } + + /// + /// 系統工單 (System Work Order) + /// + [DataMember] + [Display(Name = "系統工單")] + [Column("WIP_NO_F")] + public string WipNoF { get; set; } + + /// + /// 單板工單 (Sub-Board Work Order) + /// + [DataMember] + [Display(Name = "單板工單")] + [Column("WIP_NO_H")] + public string WipNoH { get; set; } + + /// + /// 系統料號 (System Item Number) + /// + [DataMember] + [Display(Name = "系統料號")] + [Column("ITEM_NO_F")] + public string ItemNoF { get; set; } + + /// + /// 單板料號 (Sub-Board Item Number) + /// + [DataMember] + [Display(Name = "單板料號")] + [Column("ITEM_NO_H")] + public string ItemNoH { get; set; } + + /// + /// 廠別 (Factory ID) + /// + [DataMember] + [Display(Name = "廠別")] + [Column("FACTORY_ID")] + public int FactoryID { get; set; } + } +} \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs new file mode 100644 index 00000000..020863a9 --- /dev/null +++ b/AMESCoreStudio.WebApi/Models/AMES/NgInfoAlertMaster.cs @@ -0,0 +1,195 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using Microsoft.EntityFrameworkCore; +using System.Runtime.Serialization; +using AMESCoreStudio.WebApi.Models.BAS; + +#nullable disable + +namespace AMESCoreStudio.WebApi.Models.AMES +{ + /// + /// 異常警報 + /// + [Table("NG_INFO_ALERT_MASTER", Schema = "JHAMES")] + public partial class NgInfoAlertMaster + { + /// + /// 案件編號 + /// + [DataMember] + [Display(Name = "CASE ID")] + [Required(ErrorMessage = "{0} 不能空白")] + [Key] + [Column("CASE_ID")] + public string CaseID { get; set; } + + /// + /// 廠別 + /// + [DataMember] + [Display(Name = "廠別")] + [Required(ErrorMessage = "{0} 不能空白")] + [Column("FACTORY_ID")] + public int FactoryID { get; set; } + + /// + /// 生產序號 + /// + [DataMember] + [Display(Name = "生產序號")] + [Column("BARCODE_NO")] + public string BarcodeNo { get; set; } + + /// + /// 系統工單 + /// + [DataMember] + [Display(Name = "系統工單")] + [Column("WIP_NO_F")] + public string WipNoF { get; set; } + + /// + /// 系統料號 + /// + [DataMember] + [Display(Name = "系統料號")] + [Column("ITEM_NO_F")] + public string ItemNoF { get; set; } + + /// + /// 機種 + /// + [DataMember] + [Display(Name = "機種")] + [Column("MODEL_NAME")] + public string ModelName { get; set; } + + /// + /// 單板工單 + /// + [DataMember] + [Display(Name = "單板工單")] + [Column("WIP_NO_H")] + public string WipNoH { get; set; } + + /// + /// 單板料號 + /// + [DataMember] + [Display(Name = "單板料號")] + [Column("ITEM_NO_H")] + public string ItemNoH { get; set; } + + /// + /// 發生站別 + /// + [DataMember] + [Display(Name = "發生站別")] + [Column("STATION_ID")] + public int StationID { get; set; } + + /// + /// 警報時間 + /// + [DataMember] + [Display(Name = "警報時間")] + [Column("CREATE_DATE")] + public DateTime CreateDate { get; set; } + + /// + /// 警報原因 + /// + [DataMember] + [Display(Name = "警報原因")] + [Column("REASON_NO")] + public string ReasonNo { get; set; } + + /// + /// 作業人員 + /// + [DataMember] + [Display(Name = "作業人員")] + [Column("USER_ID")] + public int UserID { get; set; } + + /// + /// 狀態 (A: 未處理, E: 處理中, F: 已結案) + /// + [DataMember] + [Display(Name = "狀態")] + [StringLength(2)] + [Column("STATUS_NO")] + public string StatusNo { get; set; } + + /// + /// 警報處理時間 + /// + [DataMember] + [Display(Name = "警報處理時間")] + [Column("UPDATE_DATE")] + public DateTime? UpdateDate { get; set; } + + /// + /// 處理完成時間 + /// + [DataMember] + [Display(Name = "處理完成時間")] + [Column("FINISH_DATE")] + public DateTime? FinishDate { get; set; } + + /// + /// 警報處理人員 + /// + [DataMember] + [Display(Name = "QA人員")] + [Column("UPDATE_USERID")] + public int UpdateUserID { get; set; } = 0; + + + + /// + /// 短期對策 + /// + [DataMember] + [Display(Name = "短期對策")] + [Column("SHORT_TERM")] + public string ShortTerm { get; set; } + + + /// + /// 長期對策 + /// + [DataMember] + [Display(Name = "長期對策")] + [Column("LONG_TERM")] + public string LongTerm { get; set; } + + + /// + /// 備註 + /// + [DataMember] + [Display(Name = "備註")] + [Column("MEMOS")] + public string Memos { get; set; } + + + /// + /// 連結 + /// + [DataMember] + [Display(Name = "連結")] + [Column("LINK")] + public string Link { get; set; } + + /// + /// 工單-基本資料 + /// + [ForeignKey("FactoryID")] + [DataMember] + public virtual FactoryInfo GetFactoryInfo { get; set; } + } +} diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index bc228343..bad4098b 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -137,6 +137,9 @@ namespace AMESCoreStudio.WebApi modelBuilder.Entity().HasKey(c => new { c.SerialRuleDetailID }); modelBuilder.Entity().HasNoKey(); modelBuilder.Entity().HasKey(c => new { c.TEMPLATE_ID, c.LABEL_FIELD_ID }); + modelBuilder.Entity().HasKey(c => new { c.CaseID }); + modelBuilder.Entity().HasKey(c => new { c.CaseItemID }); + modelBuilder.Entity().HasKey(c => new { c.CaseID,c.CaseItemID }); //Yiru End --------------------------------------------------------------------------------------------------------------------------- @@ -1063,6 +1066,23 @@ namespace AMESCoreStudio.WebApi ///// DB資料異動紀錄 ///// //public DbSet TableChangeLogs { get; set; } + + + /// + /// 異常警報Master + /// + public virtual DbSet NgInfoAlertMasters { get; set; } + + + /// + /// 異常警報Detail + /// + public virtual DbSet NgInfoAlertDetails { get; set; } + + /// + /// 異常警報檔案 + /// + public virtual DbSet NgInfoAlertBlobs { get; set; } } }