diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index ef0c64a6..0ac82978 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -1,23 +1,28 @@ -using AMESCoreStudio.CommonTools.Result; -using AMESCoreStudio.Web.Models; -using AMESCoreStudio.WebApi.DTO.AMES; -using AMESCoreStudio.WebApi.Enum; -using AMESCoreStudio.WebApi.Models.AMES; -using AMESCoreStudio.WebApi.Models.BAS; -using AspNetCore.Reporting; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Rendering; -using Microsoft.AspNetCore.StaticFiles; +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; using Microsoft.Extensions.Logging; +using AMESCoreStudio.Web.Models; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using System; +using AMESCoreStudio.WebApi; using System.Collections.Generic; -using System.IO; +using Microsoft.AspNetCore.Mvc.Rendering; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.WebApi.Models.BAS; +using AMESCoreStudio.Web.ViewModels; +using AMESCoreStudio.Web.ViewModels.PCS; +using AMESCoreStudio.WebApi.DTO.AMES; using System.Linq; -using System.Threading.Tasks; +using AMESCoreStudio.CommonTools.Result; +using System; +using System.IO; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Hosting; +using System.ComponentModel.DataAnnotations; +using AspNetCore.Reporting; +using System.Text.Encodings; +using AMESCoreStudio.WebApi.Enum; +using Microsoft.AspNetCore.StaticFiles; namespace AMESCoreStudio.Web.Controllers { @@ -838,24 +843,11 @@ namespace AMESCoreStudio.Web.Controllers var result_WipFQC = await _fqcApi.GetWipFqcItemByWipNo(model.WipNo); if (result_WipFQC.Count == 0) { - // 2024/02/01 切換判斷 - if (model.CreateDate < new DateTime(2024, 2, 1)) - { - //工單無設定檢驗工項時 在抓料號綁定檢驗工項 - var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(model.ItemNo); - if (result_MaterialFQC.Count != 0) - { - model.qcItemDtos = result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); - } - } - else + //工單無設定檢驗工項時 在抓料號綁定檢驗工項 + var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(model.ItemNo); + if (result_MaterialFQC.Count != 0) { - // 改抓FQC設定群組內綁定的料號取 FQC設定群組項目 - var result_FqcItem = await _fqcApi.GetFqcItemByItemNo(model.ItemNo); - if (result_FqcItem.Count != 0) - { - model.qcItemDtos = result_QcItem.Data.Where(w => result_FqcItem.Select(s => s.QcItemId).Contains(w.ItemID)).ToList(); - } + model.qcItemDtos = result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); } } else @@ -968,24 +960,11 @@ namespace AMESCoreStudio.Web.Controllers var result_WipFQC = await _fqcApi.GetWipFqcItemByWipNo(model.WipNo); if (result_WipFQC.Count == 0) { - // 2024/02/01 切換判斷 - if (model.CreateDate < new DateTime(2024, 2, 1)) - { - //工單無設定檢驗工項時 在抓料號綁定檢驗工項 - var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(model.ItemNo); - if (result_MaterialFQC.Count != 0) - { - model.qcItemDtos = result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); - } - } - else + //工單無設定檢驗工項時 在抓料號綁定檢驗工項 + var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(model.ItemNo); + if (result_MaterialFQC.Count != 0) { - // 改抓FQC設定群組內綁定的料號取 FQC設定群組項目 - var result_FqcItem = await _fqcApi.GetFqcItemByItemNo(model.ItemNo); - if (result_FqcItem.Count != 0) - { - model.qcItemDtos = result_QcItem.Data.Where(w => result_FqcItem.Select(s => s.QcItemId).Contains(w.ItemID)).ToList(); - } + model.qcItemDtos = result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); } } else @@ -1002,20 +981,6 @@ namespace AMESCoreStudio.Web.Controllers return View(model); } - /// - /// 確認是否可以開立FQC檢驗單 - /// - /// 入庫單號碼 - /// 工單號碼 - /// 序號 - /// - [HttpPost] - public async Task CheckFqcIssue(string inhouseNo, string wipNo, int seqID = 0) - { - var result = await _fqcApi.CheckFqcIssue(inhouseNo, wipNo, seqID); - return Json(new Result() { success = result.Success, msg = result.Msg, data = null }); - } - [HttpPost] public async Task FQC007AjaxJson(FqcDto model) { @@ -1337,24 +1302,11 @@ namespace AMESCoreStudio.Web.Controllers var qcItemDtos = new List(); if (result_WipFQC.Count == 0) { - // 2024/02/01 切換判斷 - if (model.CreateDate < new DateTime(2024, 2, 1)) - { - //工單無設定檢驗工項時 在抓料號綁定檢驗工項 - var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(fqcItem.ItemNo); - if (result_MaterialFQC.Count != 0) - { - qcItemDtos = result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); - } - } - else + //工單無設定檢驗工項時 在抓料號綁定檢驗工項 + var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(fqcItem.ItemNo); + if (result_MaterialFQC.Count != 0) { - // 改抓FQC設定群組內綁定的料號取 FQC設定群組項目 - var result_FqcItem = await _fqcApi.GetFqcItemByItemNo(fqcItem.ItemNo); - if (result_FqcItem.Count != 0) - { - qcItemDtos = result_QcItem.Data.Where(w => result_FqcItem.Select(s => s.QcItemId).Contains(w.ItemID)).ToList(); - } + qcItemDtos = result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); } } else @@ -1384,6 +1336,8 @@ namespace AMESCoreStudio.Web.Controllers if (model.QaResult == "P" && string.IsNullOrWhiteSpace(model.SpecialPo)) { return Json(new { data = "請輸入特採單號", success = false }); + //ModelState.AddModelError("error", "請輸入特採單號"); + //return View("FQC007B", model); } } @@ -1396,12 +1350,16 @@ namespace AMESCoreStudio.Web.Controllers if (fqcItem.PassQty + fqcItem.FailQty != fqcItem.InhouseQty && model.QaResult == "P") { return Json(new { data = "抽樣數量不足,不可判定允收", success = false }); + //ModelState.AddModelError("error", "抽樣數量不足,不可判定允收"); + //return View("FQC007B", model); } } //當抽驗數量 小於 抽樣數量就離開 else if (fqcItem.QcQty > fqcItem.PassQty + fqcItem.FailQty && model.QaResult == "P") { return Json(new { data = "抽樣數量不足,不可判定允收", success = false }); + //ModelState.AddModelError("error", "抽樣數量不足,不可判定允收"); + //return View("FQC007B", model); } } } @@ -1427,9 +1385,6 @@ namespace AMESCoreStudio.Web.Controllers result = await _fqcApi.PutFqcResultMaster(JsonConvert.SerializeObject(fqcResultMaster)); if (result.Success) { - // 抽驗時,判斷檢驗項目是否有建立 - await _fqcApi.PostWipFqcItemByWipNo(fqcItem.WipNo); - // 允收且不是無序號供單需要FQC過站 if (model.QaResult == "P" && fqcItem.InspectionStatus != "D") result = await _fqcApi.PassingByFQC(model.InhouseNo, model.SeqID, GetLogInUserID()); @@ -1438,11 +1393,6 @@ namespace AMESCoreStudio.Web.Controllers { await _fqcApi.PostSMS_CAR_FQC(JsonConvert.SerializeObject(fqcResultMaster)); } - // 執行判斷無序號工單檢驗完成 - else if (model.QaResult == "P" && fqcItem.InspectionStatus == "D") - { - await _fqcApi.GetFqcExecuteWithoutWipNoComplete(fqcItem.WipNo); - } if (!result.Success) { @@ -1667,27 +1617,9 @@ namespace AMESCoreStudio.Web.Controllers } [HttpGet] - public async Task FQC007AItemQuery(string wipNo, string itemNo ,DateTime createDate) + public async Task FQC007AItemQuery(string wipNo, string itemNo) { - // 2024/02/01 切換判斷 - var result = new ResultModel(); - if (createDate < new DateTime(2024, 2, 1)) - { - result = await _fqcApi.GetQcItemQuery(0, 0, 0, itemNo, wipNo); - } - else - { - var item = await _pcsApi.GetMaterialItemByItemNO(itemNo); - if (item != null) - { - var fqcGroupId = await _fqcApi.GetFqcItemGroupMaterialByItemId(item.ItemID); - if (fqcGroupId.Any()) - { - result = await _fqcApi.GetQcItemQuery(0, 0, 0, wipNo: wipNo, - fqcItemGroupId: fqcGroupId.FirstOrDefault().GroupId); - } - } - } + var result = await _fqcApi.GetQcItemQuery(0, 0, 0, itemNo, wipNo); return Json(new Table() { code = 0, data = result.Data, count = result.DataTotal }); } @@ -1966,7 +1898,7 @@ namespace AMESCoreStudio.Web.Controllers #endregion #region FQC010 報表 - public IActionResult FQC010_PDF(string inhouseNo, int seqID) + public async Task FQC010_PDF(string inhouseNo, int seqID) { string mimeType = ""; int extension = 1; @@ -1976,7 +1908,7 @@ namespace AMESCoreStudio.Web.Controllers return File(result.MainStream, "application/pdf"); } - public IActionResult FQC010_Excel(string inhouseNo, int seqID) + public async Task FQC010_Excel(string inhouseNo, int seqID) { string mimeType = ""; int extension = 1; @@ -2058,11 +1990,10 @@ namespace AMESCoreStudio.Web.Controllers var result_WipFQC = await _fqcApi.GetWipFqcItemByWipNo(FqcQuery.WipNo); if (result_WipFQC.Count == 0) { - // 2024/02/01 切換判斷 - if (FqcQuery.CreateDate < new DateTime(2024, 2, 1)) + //工單無設定檢驗工項時 在抓料號綁定檢驗工項 + var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(FqcQuery.ItemNo); + if (result_MaterialFQC.Count != 0) { - //工單無設定檢驗工項時 在抓料號綁定檢驗工項 - var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(FqcQuery.ItemNo); // 檢驗工項 foreach (var item in result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList()) { @@ -2074,20 +2005,6 @@ namespace AMESCoreStudio.Web.Controllers }); } } - else - { - // 改抓FQC設定群組內綁定的料號取 FQC設定群組項目 - var result_FqcItem = await _fqcApi.GetFqcItemByItemNo(FqcQuery.ItemNo); - foreach (var item in result_QcItem.Data.Where(w => result_FqcItem.Select(s => s.QcItemId).Contains(w.ItemID)).ToList()) - { - FQC010Master.Detail1.Add(new FQC010Detail1 - { - ItemID = item.ItemID.ToString(), - ItemName = item.ItemNameEN, - ItemType = item.ItemTypeName - }); - } - } } else { @@ -2363,289 +2280,6 @@ namespace AMESCoreStudio.Web.Controllers } #endregion - #region FQC013 檢驗項目群組名稱維護 - public IActionResult FQC013() - { - return View(); - } - - //新增頁面 - public IActionResult FQC013C() - { - return View(); - } - - //修改页面 - [HttpGet] - public async Task FQC013U(int id) - { - var result = await _fqcApi.GetFqcItemGroups(id); - return View(result); - } - - /// - /// 刪除 - /// - /// - /// - public async Task FQC013D(int id) - { - var result = await _fqcApi.DeleteFqcItemGroup(id); - return Json(new Result() { success = result.Success, msg = result.Msg }); - } - - //頁面提交,id=0 添加,id>0 修改 - [HttpPost] - public async Task FQC013Async(FqcItemGroup model) - { - IResultModel result; - // 判斷是否有重複的群組代號 - var checkData = await _fqcApi.GetFqcItemGroupQuery(no: model.ItemGroupNo); - if (checkData.Data.Any(w => w.ItemGroupNo == model.ItemGroupNo)) - { - // 新增 群組 - if (model.FqcItemGroupId == 0) - { - ModelState.AddModelError("error", "已有建立相同的群組代號,請在確認"); - return View("FQC013C", model); - } - // 修改 群組 - else if (checkData.Data.Any(w => w.ItemGroupNo == model.ItemGroupNo && w.FqcItemGroupId != model.FqcItemGroupId)) - { - ModelState.AddModelError("error", "已有建立相同的群組代號,請在確認"); - return View("FQC013U", model); - } - } - - if (ModelState.IsValid) - { - if (model.FqcItemGroupId == 0) - { - model.CreateUserID = GetLogInUserID(); - result = await _fqcApi.PostFqcItemGroup(JsonConvert.SerializeObject(model)); - } - else - { - model.UpdateUserID = GetLogInUserID(); - result = await _fqcApi.PutFqcItemGroup(JsonConvert.SerializeObject(model)); - } - - if (result.Success) - { - var _msg = model.FqcItemGroupId == 0 ? "新增成功!" : "修改成功!"; - return RedirectToAction("Refresh", "Home", new { msg = _msg }); - } - else - { - ModelState.AddModelError("error", result.Msg); - } - } - - if (model.FqcItemGroupId == 0) - { - return View("FQC013C", model); - } - return View("FQC013U", model); - } - - /// - /// FQC檢驗項目群組名稱設定檔 By Query - /// - /// 群組代號 - /// 群組名稱 - /// 群組描述 - /// 料號 - /// 頁數 - /// 筆數 - /// - [HttpGet] - public async Task FQC013Query(string no, - string name, - string desc, - string itemNo, - int page = 0, - int limit = 10) - { - var result = await _fqcApi.GetFqcItemGroupQuery(no, name, desc, itemNo, 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 }); - } - - #region FQC013A FQC群組綁設定檢驗工項維護 - - public async Task FQC013A(int fqcItemGroupId = 0) - { - var result = await _fqcApi.GetFqcItemGroups(fqcItemGroupId); - if (result != null) - { - ViewBag.GroupNo = result.ItemGroupNo; - ViewBag.GroupName = result.ItemGroupName; - } - ViewBag.GroupId = fqcItemGroupId; - return View(); - } - - /// - /// 查詢 FQC檢驗群組綁定工項 - /// - /// - /// - /// - /// - public async Task FQC013A_Query(int fqcItemGroupId = 0, int page = 0, int limit = 1) - { - var result = await _fqcApi.GetQcItemQuery(0, 0, limit, fqcItemGroupId: fqcItemGroupId); - return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); - } - - [HttpPost] - public async Task FQC013A_Submit(string itemID, string groupID, int fqcItemGroupId) - { - // 取料號綁定檢驗工項 - var result_FqcItem = await _fqcApi.GetFqcItemByFqcGroupId(fqcItemGroupId); - // 有勾選的ItemID - var checkItemID = itemID.Split(',').ToList(); - // 有勾選的GroupID - var checkGroupID = groupID.Split(',').ToList(); - - // 取勾選有的 = 新增 - var insertItemID = checkItemID.Except(result_FqcItem.Select(s => s.QcItemId.ToString())); - for (int i = 0; i < checkItemID.Count; i++) - { - if (insertItemID.Where(w => w == checkItemID[i]).Any()) - { - FqcItem FqcItem = new FqcItem - { - GroupId = fqcItemGroupId, - QcItemId = Int32.Parse(checkItemID[i]), - QcGroupId = Int32.Parse(checkGroupID[i]), - CreateUserID = GetLogInUserID(), - CreateDate = DateTime.Now, - UpdateUserID = GetLogInUserID(), - UpdateDate = DateTime.Now - }; - await _fqcApi.PostFqcItem(JsonConvert.SerializeObject(FqcItem)); - } - } - - // 取有料號綁定 = 需要刪除 - var deteleItemID = result_FqcItem.Select(s => s.QcItemId.ToString()).Except(checkItemID); - foreach (var item in deteleItemID) - { - var FqcItemId = result_FqcItem.Where(w => w.QcItemId == Int32.Parse(item)).FirstOrDefault().FqcItemId; - await _fqcApi.DeleteFqcItem(FqcItemId); - } - - return Json(new { code = 0, msg = "", success = true }); - } - - #endregion - - #region FQC013B FQC群組綁定料號 - - public async Task FQC013B(int groupId = 0) - { - var result = await _fqcApi.GetFqcItemGroups(groupId); - if (result != null) - { - ViewBag.GroupNo = result.ItemGroupNo; - ViewBag.GroupName = result.ItemGroupName; - } - ViewBag.GroupId = groupId; - return View(); - } - - /// - /// 查詢 FQC檢驗群組綁定工項 - /// - /// - /// - /// - /// - public async Task FQC013B_Query(int groupId) - { - var result = await _fqcApi.GetFqcItemGroupMaterialByGroupId(groupId); - return Json(new Table() { code = 0, msg = "", data = result, count = result.Count() }); - } - - /// - /// 新增料號 - /// - /// 群組ID - /// 料號 - /// - [HttpPost] - public async Task FQC013B_addMaterial(int groupId, string materialNo) - { - var msg = string.Empty; - var result = await _fqcApi.GetMaterialItemByItemNO(materialNo); - if (result == null) - { - msg = $"在料號主檔找不到該筆料號【{materialNo}】"; - return Json(new { code = 0, msg, success = false }); - } - else - { - var check = await _fqcApi.GetFqcItemGroupMaterialByItemId(result.ItemID); - if (check.Any()) - { - msg = $"該筆料號【{materialNo}】已有在群組綁定了,請在確認"; - return Json(new { code = 0, msg, success = false }); - } - } - - var model = new FqcItemGroupMaterial - { - GroupId = groupId, - ItemId = result.ItemID, - CreateUserID = GetLogInUserID(), - CreateDate = DateTime.Now, - UpdateUserID = GetLogInUserID(), - UpdateDate = DateTime.Now - }; - - await _fqcApi.PostFqcItemGroupMaterial(JsonConvert.SerializeObject(model)); - return Json(new { code = 0, msg = "綁定成功", success = true }); - } - - /// - /// FQC檢驗群組刪除綁定料號 - /// - /// FQC檢驗群組ID - /// 料號ID - /// - [HttpPost] - public async Task FQC013B_Delete(int groupId, int itemId) - { - // 取料號綁定檢驗工項 - var result = await _fqcApi.DeleteFqcItemGroupMaterial(groupId, itemId); - if (result == 1) - return Json(new { code = 0, msg = "", success = true }); - else - return Json(new { code = 0, msg = "", success = false }); - } - - /// - /// 回傳PLM料號品名_AutoComplete - /// - /// - /// - [HttpPost] - public async Task GetMeterialItemAutoComplete(string search) - { - var result = await _fqcApi.GetMeterialAutoComplete(search); - return Json(new { data = result }); - } - - #endregion - - #endregion - /// /// 登入UserID /// diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index 6192f13b..206ab056 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -81,10 +81,9 @@ namespace AMESCoreStudio.Web /// 比數 /// 料號 /// 工單號碼 - /// FQC檢驗設定群組 /// [WebApiClient.Attributes.HttpGet("api/QcItem/QcItemQuery")] - ITask> GetQcItemQuery(int groupID, int page, int limit, string itemNo = null, string wipNo = null ,int fqcItemGroupId = 0) ; + ITask> GetQcItemQuery(int groupID, int page, int limit, string itemNo = null, string wipNo = null); /// /// 查詢檢驗項目維護 ID @@ -412,6 +411,7 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/FqcResultDetail/{id}")] ITask> GetFqcResultDetail(int id); + /// /// 用id取檢驗單結果 /// @@ -462,13 +462,6 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpDelete("api/WipFqcItem/{id}")] ITask> DeleteWipFqcItem(int id); - /// - /// FqcItem 查詢料號對應設定群組綁定檢驗工項 - /// - /// 料號 - [WebApiClient.Attributes.HttpGet("api/FqcItem/ByItemNo/{id}")] - ITask> GetFqcItemByItemNo(string id); - /// /// FQC抽驗過站 /// @@ -533,28 +526,6 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpDelete("api/FqcResultMasterBlob/ByFileName")] ITask> DeleteFqcResultMasterBlob(int fqcId, string fileName); - /// - /// 執行判斷無序號工單檢驗完成 - /// - /// - [WebApiClient.Attributes.HttpGet("api/FqcResultMaster/ExecuteWithoutWipNoComplete/{id}")] - ITask GetFqcExecuteWithoutWipNoComplete(string id); - - /// - /// 確認FQC抽驗時,箱號是否已經跑到FQC流程 - /// - /// 入庫單號 - /// 工單號碼 - /// 順序 - /// - [WebApiClient.Attributes.HttpGet("api/FqcInhouseMaster/CheckFqcIssue")] - ITask> CheckFqcIssue(string inhouseNo, string wipNo , int seqID); - - /// - /// WipFqcItemByWipNo 新增工單綁定檢驗工項,抽驗時判斷沒有資料就新增預設 - /// - [WebApiClient.Attributes.HttpPost("api/WipFqcItem/ByWipNo/{wipNo}")] - ITask> PostWipFqcItemByWipNo(string wipNo); #endregion #region FQC008 FQC查詢 @@ -656,7 +627,7 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpDelete("api/FqcInhouseMaster/{no}/{seq}")] ITask> DeleteFqcInhouseMaster(string no, int seq); - + /// /// 刪除FQC 表身 @@ -666,124 +637,5 @@ namespace AMESCoreStudio.Web ITask> DeleteFqcInhouseDetail(string no, int seq); #endregion - - #region FQC013 檢驗項目群組相關維護 - /// - /// FqcItem 新增檢驗項目群組綁定設定檔 - /// - /// - [WebApiClient.Attributes.HttpPost("api/FqcItem")] - ITask> PostFqcItem([FromBody, RawJsonContent] string model); - - /// - /// FqcItem 更新檢驗項目群組綁定設定檔 - /// - /// - [WebApiClient.Attributes.HttpPut("api/FqcItem")] - ITask> PutFqcItem([FromBody, RawJsonContent] string model); - - /// - /// FqcItem 刪除檢驗項目群組綁定設定檔 - /// - /// - [WebApiClient.Attributes.HttpDelete("api/FqcItem/{id}")] - ITask> DeleteFqcItem(int id); - - /// - /// FqcItem 查詢 ByFqcGroupId - /// - /// FqcGroupId - [WebApiClient.Attributes.HttpGet("api/FqcItem/ByFqcGroupId/{id}")] - ITask> GetFqcItemByFqcGroupId(int id); - - /// - /// FqcItemGroup 查詢FQC檢驗項目群組名稱設定檔 By ID - /// - /// - [WebApiClient.Attributes.HttpGet("api/FqcItemGroup/{id}")] - ITask GetFqcItemGroups(int id); - - /// - /// FqcItemGroup 新增FQC檢驗項目群組名稱設定檔 - /// - /// - [WebApiClient.Attributes.HttpPost("api/FqcItemGroup")] - ITask> PostFqcItemGroup([FromBody, RawJsonContent] string model); - - /// - /// FqcItemGroup 更新FQC檢驗項目群組名稱設定檔 - /// - /// - [WebApiClient.Attributes.HttpPut("api/FqcItemGroup")] - ITask> PutFqcItemGroup([FromBody, RawJsonContent] string model); - - /// - /// FqcItemGroup 刪除FQC檢驗項目群組名稱設定檔 - /// - /// - [WebApiClient.Attributes.HttpDelete("api/FqcItemGroup/{id}")] - ITask> DeleteFqcItemGroup(int id); - - /// - /// FQC檢驗項目群組名稱設定檔 By Query - /// - /// 群組代號 - /// 群組名稱 - /// 群組描述 - /// 料號 - /// 頁數 - /// 筆數 - /// - [WebApiClient.Attributes.HttpGet("api/FqcItemGroup/FqcItemGroupQuery")] - ITask> GetFqcItemGroupQuery(string no = null, - string name = null, - string desc = null, - string itemNo = null, - int page = 0, - int limit = 10); - - /// - /// 新增 檢驗群組指定料號設定檔 - /// - /// - [WebApiClient.Attributes.HttpPost("api/FqcItemGroupMaterial")] - ITask> PostFqcItemGroupMaterial([FromBody, RawJsonContent] string model); - - /// - /// 更新 檢驗群組指定料號設定檔 - /// - /// - [WebApiClient.Attributes.HttpPut("api/FqcItemGroupMaterial")] - ITask> PutFqcItemGroupMaterial([FromBody, RawJsonContent] string model); - - /// - /// FqcItemGroupMaterial 查詢檢驗群組指定料號設定檔 By GroupId - /// - /// - [WebApiClient.Attributes.HttpGet("api/FqcItemGroupMaterial/ByGroupId/{id}")] - ITask> GetFqcItemGroupMaterialByGroupId(int id); - - /// - /// FqcItemGroupMaterial 查詢檢驗群組指定料號設定檔 By ItemId - /// - /// - [WebApiClient.Attributes.HttpGet("api/FqcItemGroupMaterial/ByItemId/{id}")] - ITask> GetFqcItemGroupMaterialByItemId(int id); - - /// - /// 刪除 檢驗群組指定料號設定檔 - /// - /// - [WebApiClient.Attributes.HttpDelete("api/FqcItemGroupMaterial/{id}/{id1}")] - ITask DeleteFqcItemGroupMaterial(int id, int id1); - - /// - /// 查詢料號_AutoComplete - /// - /// 料號 - /// - [WebApiClient.Attributes.HttpGet("api/MaterialItem/AutoComplete/{id}")] - ITask> GetMeterialAutoComplete(string id); - #endregion } } diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml index 28030057..0c8c242d 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml @@ -691,7 +691,7 @@ area: ['700px', '500px'], fixed: false, //不固定 maxmin: true, - content: '/FQC/FQC007A?wipNo=@Model.WipNo&itemNo=@Model.ItemNo&createDate=@Model.CreateDate', + content: '/FQC/FQC007A?wipNo=@Model.WipNo&itemNo=@Model.ItemNo', end: function () { window.location.reload(); } diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml index 35ea46f9..84ba9017 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml @@ -48,7 +48,7 @@ defaultToolbar: ['filter', 'print', 'exports'], cols: tableCols, response: { msgName: 'msg' }, - where: { itemNo: '@Model.ItemNo', wipNo: '@Model.WipNo', createDate:'@Model.CreateDate' }, + where: { itemNo: '@Model.ItemNo', wipNo: '@Model.WipNo' }, done: function (res, curr, count) { //迴圈所有資料,找出對應關係,設定checkbox選中狀態 for (var i = 0; i < res.data.length; i++) { diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007V.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007V.cshtml index 0877895e..cb3bcae7 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007V.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007V.cshtml @@ -59,11 +59,11 @@ title: '', fixed: 'right', templet: function (d) { - if (d.statusNo !== null) { - return '刪除'; + if (d.statusNo.length === 0) { + return ''; } else { - return '' + return '删除'; } } }] diff --git a/AMESCoreStudio.Web/Views/FQC/FQC008.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC008.cshtml index e7c55bbf..2367f947 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC008.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC008.cshtml @@ -7,27 +7,27 @@ /*.layui-table-main .layui-table-cell {*/ /*height: auto !important;*/ /*white-space: normal; - } + } - .layui-table img { - max-width: 60px; - max-height: 28px; - } + .layui-table img { + max-width: 60px; + max-height: 28px; + } - .layui-tree-main { - cursor: pointer; - padding-right: 10px; - float: left; - border-width: 1px; - border-style: solid; - border-color: #e6e6e6; - margin: 10px 0; - } + .layui-tree-main { + cursor: pointer; + padding-right: 10px; + float: left; + border-width: 1px; + border-style: solid; + border-color: #e6e6e6; + margin: 10px 0; + } - .layui-table-cell { - height: auto; - white-space: normal; - }*/ + .layui-table-cell { + height: auto; + white-space: normal; + }*/ @@ -253,8 +253,8 @@ aa = '修改' } else { - aa = '檢視\ - PDF Excel' + aa = '檢視\ + PDF Excel' } return aa; } @@ -273,42 +273,14 @@ //通过行tool编辑,lay-event="edit" function edit(obj) { - $.ajax({ - url: "@Url.Action("CheckFqcIssue", "FQC")", - type: "POST", - data: { "inhouseNo": obj.data.inhouseNo, "wipNo": obj.data.wipNo , "seqID": obj.data.seqID }, - success: function (result) { - if (result.success) { - if (obj.data.inhouseNo) { - hg.open('FQC抽驗作業', '/FQC/FQC007?inhouseNo=' + obj.data.inhouseNo + '&seqID=' + obj.data.seqID, '', '', true); - - var tempwindow = window.open('_blank'); // 先打開頁面 - tempwindow.location = 'https://sms.avalue.com.tw/SMS/SUP/SFIS_SMS001.aspx?MODEL_NO=' + obj.data.modelNo; - var tempwindow1 = window.open('_blank'); // 先打開頁面 - tempwindow1.location = 'http://qazone.avalue.com.tw/qazone/sfislinktocfqr.aspx?QF=2&QA_PRDID=' + obj.data.itemNo; - } - } - else { - parent.hg.msg(result.msg); - } - }, - error: function (result) { - alert(`開啟FQC失敗,請聯繫系統管理員`); - } - }); - - - } - - function view(obj) { - if (obj.data.inhouseNo) { - hg.open('FQC抽驗作業', '/FQC/FQC007?inhouseNo=' + obj.data.inhouseNo + '&seqID=' + obj.data.seqID, '', '', true); + if (obj.data.inhouseNo) { + hg.open('FQC抽驗作業', '/FQC/FQC007?inhouseNo=' + obj.data.inhouseNo + '&seqID=' + obj.data.seqID, '', '', true); - var tempwindow = window.open('_blank'); // 先打開頁面 - tempwindow.location = 'https://sms.avalue.com.tw/SMS/SUP/SFIS_SMS001.aspx?MODEL_NO=' + obj.data.modelNo; - var tempwindow1 = window.open('_blank'); // 先打開頁面 - tempwindow1.location = 'http://qazone.avalue.com.tw/qazone/sfislinktocfqr.aspx?QF=2&QA_PRDID=' + obj.data.itemNo; - } + var tempwindow = window.open('_blank'); // 先打開頁面 + tempwindow.location = 'https://sms.avalue.com.tw/SMS/SUP/SFIS_SMS001.aspx?MODEL_NO=' + obj.data.modelNo; + var tempwindow1 = window.open('_blank'); // 先打開頁面 + tempwindow1.location = 'http://qazone.avalue.com.tw/qazone/sfislinktocfqr.aspx?QF=2&QA_PRDID=' + obj.data.itemNo; + } } function PDF(obj) { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs index f53eaf92..ce1b3305 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs @@ -1,14 +1,16 @@ -using AMESCoreStudio.CommonTools.Result; -using AMESCoreStudio.WebApi.DTO.AMES; -using AMESCoreStudio.WebApi.Extensions; -using AMESCoreStudio.WebApi.Models.AMES; -using Dapper; -using Microsoft.AspNetCore.Mvc; -using Microsoft.EntityFrameworkCore; -using System; +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; +using AMESCoreStudio.WebApi.DTO.AMES; +using Dapper; +using AMESCoreStudio.WebApi.Extensions; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -70,33 +72,32 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); var fqcResultDto = new List(); - var querySql = @" SELECT DISTINCT SERIAL_NO AS BoxNo , BARCODE_NO AS BarcodeNo , EXTRA_BARCODE_NO AS ExtraBarcodeNo - FROM ( - SELECT A.BARCODE_NO , A.EXTRA_BARCODE_NO , B.SERIAL_NO ,B.INHOUSE_NO - FROM JHAMES.BARCODE_INFO A , JHAMES.FQC_INHOUSE_DETAIL B - WHERE B.SERIAL_NO = A.BOX_NO - AND B.INHOUSE_NO = :InhouseNo - AND B.SEQ_ID = :SeqId - AND B.BARCODE_NO = '0' - UNION ALL - SELECT BARCODE_NO , EXTRA_BARCODE_NO , SERIAL_NO ,INHOUSE_NO - FROM JHAMES.FQC_INHOUSE_DETAIL - WHERE INHOUSE_NO = :InhouseNo - AND SEQ_ID = :SeqId - AND BARCODE_NO <> '0') - WHERE SERIAL_NO=:BoxNo "; - - DynamicParameters p = new DynamicParameters(); - p.Add("InhouseNo", inhouseNo); - p.Add("SeqId", seqID); - p.Add("BoxNo", boxNo); - fqcResultDto = _context.Database.DapperQuery(querySql, p).ToList(); + var FqcInhouseDetails = await _context.FqcInhouseDetails.Where(w => w.SerialNo == boxNo && w.InhouseNo == inhouseNo + && w.SeqID == seqID).FirstOrDefaultAsync(); // 取FQC_ID - if (fqcResultDto.Any()) + if (FqcInhouseDetails != null) { - var FqcResultMaster = await _context.FqcResultMasters.Where(w => w.InhouseNo == inhouseNo - && w.SeqID == seqID) + var BarcodeInfo = new List(); + if (FqcInhouseDetails.SerialType == "B") + BarcodeInfo = await _context.BarcodeInfoes.Where(w => w.BoxNo == FqcInhouseDetails.SerialNo).ToListAsync(); + else + BarcodeInfo = await _context.BarcodeInfoes.Where(w => w.BarcodeNo == FqcInhouseDetails.SerialNo).ToListAsync(); + + // 先塞入資料 + foreach (var item in BarcodeInfo) + { + fqcResultDto.Add(new FqcResultDto + { + BarcodeNo = item.BarcodeNo, + ExtraBarcodeNo = item.ExtraBarcodeNo, + BoxNo = item.BoxNo, + StatusNo = "" + }); + } + + var FqcResultMaster = await _context.FqcResultMasters.Where(w => w.InhouseNo == FqcInhouseDetails.InhouseNo + && w.SeqID == FqcInhouseDetails.SeqID) .FirstOrDefaultAsync(); // 取抽驗結果 if (FqcResultMaster != null) @@ -109,7 +110,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { if (item.BarcodeNo == item2.BarcodeNo) { - item2.StatusNo = item.StatusNo == "P" ? "PASS" : "NG"; + item2.StatusNo = item.StatusNo; item2.NgReasonNo = item.NgReasonNo; item2.NgReasonDesc = NgReasons.Where(w => w.NGReasonNo == item.NgReasonNo).FirstOrDefault() == null ? "" : NgReasons.Where(w => w.NGReasonNo == item.NgReasonNo).FirstOrDefault().NGReasonDesc; item2.NgMemo = item.NgMemo; @@ -144,51 +145,54 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); var fqcResultDto = new List(); - var querySql = @" SELECT DISTINCT SERIAL_NO AS BoxNo , BARCODE_NO AS BarcodeNo , EXTRA_BARCODE_NO AS ExtraBarcodeNo - FROM ( - SELECT A.BARCODE_NO , A.EXTRA_BARCODE_NO , B.SERIAL_NO ,B.INHOUSE_NO - FROM JHAMES.BARCODE_INFO A , JHAMES.FQC_INHOUSE_DETAIL B - WHERE B.SERIAL_NO = A.BOX_NO - AND B.INHOUSE_NO = :InhouseNo - AND B.SEQ_ID = :SeqId - AND B.BARCODE_NO = '0' - UNION ALL - SELECT BARCODE_NO , EXTRA_BARCODE_NO , SERIAL_NO ,INHOUSE_NO - FROM JHAMES.FQC_INHOUSE_DETAIL - WHERE INHOUSE_NO = :InhouseNo - AND SEQ_ID = :SeqId - AND BARCODE_NO <> '0') "; - - DynamicParameters p = new DynamicParameters(); - p.Add("InhouseNo", inhouseNo); - p.Add("SeqId", seqID); - fqcResultDto = _context.Database.DapperQuery(querySql, p).ToList(); + var FqcInhouseDetails = await _context.FqcInhouseDetails.Where(w => w.InhouseNo == inhouseNo + && w.SeqID == seqID).ToListAsync(); // 取FQC_ID - if (fqcResultDto.Any()) + if (FqcInhouseDetails.Count != 0) { - var FqcResultMaster = await _context.FqcResultMasters.Where(w => w.InhouseNo == inhouseNo - && w.SeqID == seqID) - .FirstOrDefaultAsync(); - if (FqcResultMaster != null) + foreach (var item in FqcInhouseDetails) { + var BarcodeInfo = new List(); + if (item.SerialType == "B") + BarcodeInfo = await _context.BarcodeInfoes.Where(w => w.BoxNo == item.SerialNo).ToListAsync(); + else + BarcodeInfo = await _context.BarcodeInfoes.Where(w => w.BarcodeNo == item.SerialNo).ToListAsync(); + + // 先塞入資料 + foreach (var item1 in BarcodeInfo) + { + fqcResultDto.Add(new FqcResultDto + { + BarcodeNo = item1.BarcodeNo, + ExtraBarcodeNo = item1.ExtraBarcodeNo, + BoxNo = item1.BoxNo, + StatusNo = "" + }); + } + + var FqcResultMaster = await _context.FqcResultMasters.Where(w => w.InhouseNo == item.InhouseNo + && w.SeqID == item.SeqID) + .FirstOrDefaultAsync(); + var NgReasons = await _context.NGReasons.ToListAsync(); - var FqcResultDetail = await _context.FqcResultDetails.Where(w => w.FqcID == FqcResultMaster.FqcID).ToListAsync(); - foreach (var item in fqcResultDto) + + // 取抽驗結果 + if (FqcResultMaster != null) { - // 取抽驗結果 - if (FqcResultMaster != null) + var FqcResultDetail = await _context.FqcResultDetails.Where(w => w.FqcID == FqcResultMaster.FqcID).ToListAsync(); + foreach (var item1 in FqcResultDetail) { - foreach (var item1 in FqcResultDetail) + foreach (var item2 in fqcResultDto) { - if (item1.BarcodeNo == item.BarcodeNo) + if (item1.BarcodeNo == item2.BarcodeNo) { - item.StatusNo = item1.StatusNo == "P" ? "PASS" : "NG"; - item.NgReasonNo = item1.NgReasonNo; - item.NgReasonDesc = NgReasons.Where(w => w.NGReasonNo == item1.NgReasonNo).FirstOrDefault() == null ? "" : NgReasons.Where(w => w.NGReasonNo == item1.NgReasonNo).FirstOrDefault().NGReasonDesc; - item.NgMemo = item1.NgMemo; - item.IsSample = "Y"; - item.CreateName = await new Helper(_context).GetUserName(item1.CreateUserID); + item2.StatusNo = item1.StatusNo == "P" ? "PASS" : "NG"; + item2.NgReasonNo = item1.NgReasonNo; + item2.NgReasonDesc = NgReasons.Where(w => w.NGReasonNo == item1.NgReasonNo).FirstOrDefault() == null ? "" : NgReasons.Where(w => w.NGReasonNo == item1.NgReasonNo).FirstOrDefault().NGReasonDesc; + item2.NgMemo = item1.NgMemo; + item2.IsSample = "Y"; + item2.CreateName = await new Helper(_context).GetUserName(item.CreateUserID); continue; } } @@ -218,7 +222,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// WIPID /// [HttpGet("GetCheckFqcOnGoIng")] - public async Task> GetCheckFqcOnGoIng(string boxNo, int wipId) + public async Task> GetCheckFqcOnGoIng(string boxNo , int wipId) { var querySql = @" SELECT * FROM JHAMES.FQC_INHOUSE_MASTER M INNER JOIN JHAMES.FQC_INHOUSE_DETAIL D ON M.INHOUSE_NO = D.INHOUSE_NO AND M.SEQ_ID = D.SEQ_ID diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs index d4413d5d..e56034fa 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs @@ -10,8 +10,6 @@ using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.WebApi.DTO.AMES; using AMESCoreStudio.CommonTools.Result; using AMESCoreStudio.WebApi.Enum; -using AMESCoreStudio.WebApi.Extensions; -using Dapper; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -224,6 +222,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { resultQuery = resultQuery.Skip((page - 1) * limit).Take(limit).ToList(); } + result.Data = resultQuery; // 判斷結束時間 @@ -306,8 +305,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES Note = q2.Note, InspectionStatus = q2.InspectionStatus, Description = q4.Description, - LocationNo = q1.LocationNo, - CreateDate = q1.CreateDate + LocationNo = q1.LocationNo }; var query = await q.Distinct().ToListAsync(); @@ -371,89 +369,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } - /// - /// 確認FQC開立抽驗時,是否資料與流程都完成 - /// - /// 入庫單號碼 - /// 工單號碼 - /// 序號 - /// - [HttpGet("CheckFqcIssue")] - public async Task> CheckFqcIssue(string inhouseNo, string wipNo, int seqid = 1) - { - ResultModel result = new ResultModel { Success = true }; - var wip = await _context.WipInfos.Where(w => w.WipNO.Trim().ToUpper() == wipNo.Trim().ToUpper()).FirstOrDefaultAsync(); - - // 無序號工單不需要判斷 - if (wip != null) - { - if (wip.WipType == "N") - return result; - } - - var CheckFqcNextProcess = await GetCheckFqcNextProcess(inhouseNo, seqid); - - if (CheckFqcNextProcess.Any()) - { - result.Success = false; - result.Msg = "該筆入庫單尚有序號未跑完流程,請確認"; - return result; - } - - var CheckFqcDetailExist = await GetCheckFqcDetailExist(inhouseNo, seqid); - if (!CheckFqcDetailExist.Any()) - { - result.Success = false; - result.Msg = "該筆入庫單未有箱號紀錄,請確認"; - return result; - } - - return result; - } - - /// - /// 確認FQC抽驗時是否已經跑到FQC流程 - /// - /// 入庫單號碼 - /// 序號 - /// 有資料:尚未跑完流程 - private async Task> GetCheckFqcNextProcess(string inhouseNo, int seqid = 1) - { - var querySql = @" SELECT A.STATION_ID , A.WIP_ID , A.FLOW_RULE_ID , A.NEXT_STATION_ID FROM - (SELECT B.STATION_ID , B.WIP_ID , W.FLOW_RULE_ID , R.NEXT_STATION_ID FROM JHAMES.FQC_INHOUSE_DETAIL D - INNER JOIN JHAMES.BARCODE_INFO B ON D.SERIAL_NO = B.BOX_NO - INNER JOIN JHAMES.WIP_INFO W ON B.WIP_ID = W.WIP_ID - INNER JOIN JHAMES.RULES R ON R.FLOW_RULE_ID = W.FLOW_RULE_ID AND R.STATION_ID = B.STATION_ID - WHERE D.INHOUSE_NO = :InhouseNo AND D.SEQ_ID=:Seqid - GROUP BY B.STATION_ID , B.WIP_ID , W.FLOW_RULE_ID , R.NEXT_STATION_ID) A , - JHAMES.STATIONS S WHERE S.STATION_ID=A.NEXT_STATION_ID AND S.TYPE_NO != 'F' "; - - DynamicParameters p = new DynamicParameters(); - p.Add("InhouseNo", inhouseNo); - p.Add("SeqId", seqid); - var result = await _context.Database.DapperQueryAsync(querySql, p); - return result.ToList(); - } - - /// - /// 確認FQC開立抽驗時,InhouseDetail是否有資料 - /// - /// 入庫單號碼 - /// 序號 - /// 沒資料:Detail沒有資料 - private async Task> GetCheckFqcDetailExist(string inhouseNo, int seqid = 1) - { - var querySql = @" SELECT * FROM JHAMES.FQC_INHOUSE_MASTER M - INNER JOIN JHAMES.FQC_INHOUSE_DETAIL D ON M.INHOUSE_NO = D.INHOUSE_NO AND M.SEQ_ID = D.SEQ_ID - INNER JOIN JHAMES.WIP_INFO W ON W.WIP_NO = M.WIP_NO AND W.WIP_TYPE != 'N' - WHERE D.INHOUSE_NO = :InhouseNo AND D.SEQ_ID=:Seqid "; - DynamicParameters p = new DynamicParameters(); - p.Add("InhouseNo", inhouseNo); - p.Add("SeqId", seqid); - var result = await _context.Database.DapperQueryAsync(querySql, p); - return result.ToList(); - } - /// /// 更新入庫單 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemController.cs index 26865ac9..1b0d01fb 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemController.cs @@ -7,13 +7,11 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using AMESCoreStudio.WebApi; using AMESCoreStudio.WebApi.Models.AMES; -using AMESCoreStudio.CommonTools.Result; -using AMESCoreStudio.WebApi.DTO.AMES; namespace AMESCoreStudio.WebApi.Controllers.AMES { /// - /// FQC檢驗項目群組綁定設定檔 + /// FQC檢驗結果ID /// [Route("api/[controller]")] [ApiController] @@ -26,134 +24,104 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES _context = context; } + // GET: api/FqcItem [HttpGet] public async Task>> GetFqcItems() { return await _context.FqcItems.ToListAsync(); } + // GET: api/FqcItem/5 [HttpGet("{id}")] public async Task> GetFqcItem(int id) { var fqcItem = await _context.FqcItems.FindAsync(id); - return fqcItem; - } - /// - /// FQC檢驗項目群組綁定設定檔 to GroupID(FQC檢驗群組) - /// - /// 料號 - /// - [HttpGet("ByFqcGroupId/{id}")] - public async Task> GetFqcItemByFqcGroupId(int id) - { - IQueryable q = _context.FqcItems; - var result = await q.Where(p => p.GroupId == id).ToListAsync(); - return result; - } + if (fqcItem == null) + { + return NotFound(); + } - /// - /// 料號查詢FQC檢驗群組及綁定檢驗工項 - /// - /// 料號 - /// - [HttpGet("ByItemNo/{id}")] - public async Task>> GetFqcItemByItemNo(string id) - { - var itemID = 0; - var result = await _context.MaterialItems.Where(w => w.ItemNo == id).ToListAsync(); - if (result.Count() != 0) - itemID = result.FirstOrDefault().ItemID; - - var q = from q1 in _context.FqcItems - join q2 in _context.FqcItemGroupMaterials on q1.GroupId equals q2.GroupId where q2.ItemId == itemID - select q1; - - return await q.ToListAsync(); + return fqcItem; } - /// - /// 更新檢驗項目群組綁定設定檔 - /// - /// - /// - [HttpPut] - public async Task> PutFqcItem(FqcItem fqcItem) + // PUT: api/FqcItem/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 PutFqcItem(int id, FqcItem fqcItem) { - ResultModel result = new ResultModel(); + if (id != fqcItem.FqcID) + { + return BadRequest(); + } + _context.Entry(fqcItem).State = EntityState.Modified; - _context.Entry(fqcItem).Property("CreateDate").IsModified = false; - _context.Entry(fqcItem).Property("CreateUserID").IsModified = false; - fqcItem.UpdateDate = DateTime.Now; try { await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; } - catch (Exception ex) + catch (DbUpdateConcurrencyException) { - result.Success = false; - result.Msg = ex.InnerException.Message; + if (!FqcItemExists(id)) + { + return NotFound(); + } + else + { + throw; + } } - return result; + + return NoContent(); } - /// - /// 新增檢驗項目群組綁定設定檔 - /// - /// - /// + // POST: api/FqcItem + // 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. [HttpPost] - public async Task> PostFqcItem(FqcItem fqcItem) + public async Task> PostFqcItem(FqcItem fqcItem) { - ResultModel result = new ResultModel(); - Helper helper = new Helper(_context); - fqcItem.FqcItemId = helper.GetIDKey("FQC_ITEM_ID").Result; _context.FqcItems.Add(fqcItem); try { await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; } - catch (Exception ex) + catch (DbUpdateException) { - result.Success = false; - result.Msg = ex.InnerException.Message; + if (FqcItemExists(fqcItem.FqcID)) + { + return Conflict(); + } + else + { + throw; + } } - return result; + + return CreatedAtAction("GetFqcItem", new { id = fqcItem.FqcID }, fqcItem); } // DELETE: api/FqcItem/5 [HttpDelete("{id}")] - public async Task> DeleteFqcItem(int id) + public async Task> DeleteFqcItem(int id) { - ResultModel result = new ResultModel(); var fqcItem = await _context.FqcItems.FindAsync(id); - - try + if (fqcItem == null) { - if (fqcItem == null) - { - result.Success = false; - result.Msg = "找不到要刪除資料"; - } - else - { - _context.FqcItems.Remove(fqcItem); - await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; - } - } - catch (Exception ex) - { - result.Success = false; - result.Msg = ex.InnerException.Message; + return NotFound(); } - return result; + + _context.FqcItems.Remove(fqcItem); + await _context.SaveChangesAsync(); + + return fqcItem; + } + + private bool FqcItemExists(int id) + { + return _context.FqcItems.Any(e => e.FqcID == id); } } } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupController.cs deleted file mode 100644 index 3b4f284d..00000000 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupController.cs +++ /dev/null @@ -1,196 +0,0 @@ -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; -using System.Text.RegularExpressions; -using Dapper; -using AMESCoreStudio.WebApi.Extensions; -using System.Data; - -namespace AMESCoreStudio.WebApi.Controllers.AMES -{ - /// - /// FQC檢驗項目群組名稱設定檔 - /// - [Route("api/[controller]")] - [ApiController] - public class FqcItemGroupController : ControllerBase - { - private readonly AMESContext _context; - - public FqcItemGroupController(AMESContext context) - { - _context = context; - } - - [HttpGet] - public async Task>> GetFqcItemGroups() - { - return await _context.FqcItemGroups.ToListAsync(); - } - - [HttpGet("{id}")] - public async Task> GetFqcItemGroup(int id) - { - var fqcItemGroup = await _context.FqcItemGroups.FindAsync(id); - return fqcItemGroup; - } - - /// - /// FQC檢驗項目群組名稱設定檔 By Query - /// - /// 群組代號 - /// 群組名稱 - /// 群組描述 - /// 料號 - /// 頁數 - /// 筆數 - /// - [HttpGet("FqcItemGroupQuery")] - public async Task> GetFqcItemGroupQuery(string no, string name, string desc, string itemNo, int page = 0, int limit = 10) - { - ResultModel result = new ResultModel(); - - var query = @$" SELECT DISTINCT - G.FQC_ITEM_GROUP_ID AS fqcItemGroupId , - G.ITEM_GROUP_NO AS itemGroupNo , - G.ITEM_GROUP_NAME AS itemGroupName , - G.ITEM_GROUP_DESC AS itemGroupDesc - FROM JHAMES.FQC_ITEM_GROUP G - LEFT JOIN JHAMES.FQC_ITEM_GROUP_MATERIAL GM ON G.FQC_ITEM_GROUP_ID = GM.GROUP_ID - LEFT JOIN JHAMES.MATERIAL_ITEM M ON GM.ITEM_ID = M.ITEM_ID - WHERE 1 = 1 "; - - DynamicParameters p = new DynamicParameters(); - if (!string.IsNullOrWhiteSpace(no)) - { - query += " AND UPPER(G.ITEM_GROUP_NO) LIKE :No "; - p.Add("No", $"%{no.Trim().ToUpper()}%", DbType.String); - } - - if (!string.IsNullOrWhiteSpace(name)) - { - query += " AND G.ITEM_GROUP_NAME LIKE :Name "; - p.Add("Name", $"%{name.Trim().ToUpper()}%", DbType.String); - } - - if (!string.IsNullOrWhiteSpace(desc)) - { - query += " AND G.ITEM_GROUP_DESC LIKE :GroupDesc "; - p.Add("GroupDesc", $"%{desc.Trim().ToUpper()}%", DbType.String); - } - - if (!string.IsNullOrWhiteSpace(itemNo)) - { - query += " AND UPPER(M.ITEM_NO) LIKE :ItemNo "; - p.Add("ItemNo", $"%{itemNo.Trim().ToUpper()}%", DbType.String); - } - - var q = await _context.Database.DapperQueryAsync(query, p); - - // 紀錄筆數 - result.DataTotal = q.Count(); - - // Table 頁數 - if (page > 0) - { - q = q.Skip((page - 1) * limit).Take(limit); - } - result.Data = q; - return result; - } - - /// - /// 更新FQC檢驗項目群組名稱設定檔 - /// - /// - /// - [HttpPut] - public async Task> PutFqcItemGroup(FqcItemGroup fqcItemGroup) - { - ResultModel result = new ResultModel(); - _context.Entry(fqcItemGroup).State = EntityState.Modified; - _context.Entry(fqcItemGroup).Property("CreateDate").IsModified = false; - _context.Entry(fqcItemGroup).Property("CreateUserID").IsModified = false; - fqcItemGroup.UpdateDate = DateTime.Now; - - try - { - await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; - } - catch (Exception ex) - { - result.Success = false; - result.Msg = ex.InnerException.Message; - } - return result; - } - - /// - /// 新增FQC檢驗項目群組名稱設定檔 - /// - /// - /// - [HttpPost] - public async Task> PostFqcItemGroup(FqcItemGroup fqcItemGroup) - { - ResultModel result = new ResultModel(); - Helper helper = new Helper(_context); - fqcItemGroup.FqcItemGroupId = helper.GetIDKey("FQC_ITEM_GROUP_ID").Result; - _context.FqcItemGroups.Add(fqcItemGroup); - try - { - await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; - } - catch (Exception ex) - { - result.Success = false; - result.Msg = ex.InnerException.Message; - } - return result; - } - - [HttpDelete("{id}")] - public async Task> DeleteFqcItemGroup(int id) - { - ResultModel result = new ResultModel(); - var fqcItemGroup = await _context.FqcItemGroups.FindAsync(id); - var fqcItem = await _context.FqcItems.Where(w => w.GroupId == id).ToListAsync(); - var fqcItemGroupMaterial = await _context.FqcItemGroupMaterials - .Where(w => w.GroupId == id).ToListAsync(); - try - { - if (fqcItemGroup == null) - { - result.Success = false; - result.Msg = "找不到要刪除資料"; - } - else - { - _context.FqcItemGroups.Remove(fqcItemGroup); - _context.FqcItems.RemoveRange(fqcItem); - _context.FqcItemGroupMaterials.RemoveRange(fqcItemGroupMaterial); - await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; - } - } - catch (Exception ex) - { - result.Success = false; - result.Msg = ex.InnerException.Message; - } - return result; - } - } -} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupMaterialController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupMaterialController.cs deleted file mode 100644 index 5e1412f7..00000000 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupMaterialController.cs +++ /dev/null @@ -1,159 +0,0 @@ -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; -using System.Text.RegularExpressions; -using Dapper; -using AMESCoreStudio.WebApi.Extensions; - -namespace AMESCoreStudio.WebApi.Controllers.AMES -{ - /// - /// FQC檢驗項目群組指定料號設定檔 - /// - [Route("api/[controller]")] - [ApiController] - public class FqcItemGroupMaterialController : ControllerBase - { - private readonly AMESContext _context; - - public FqcItemGroupMaterialController(AMESContext context) - { - _context = context; - } - - [HttpGet] - public async Task>> GetFqcItemGroupMaterials() - { - return await _context.FqcItemGroupMaterials.ToListAsync(); - } - - /// - /// By GroupId 查詢 - /// - /// GroupId - /// - [HttpGet("ByGroupId/{id}")] - public async Task>> GetFqcItemGroupMaterialByGroupId(int id) - { - var query = @" SELECT - F.GROUP_ID AS groupId , - M.ITEM_ID AS itemId , - M.ITEM_NO AS itemNo , - M.ITEM_DESC AS itemDesc , - F.CREATE_USERID AS createUserID , - F.CREATE_DATE AS createDate , - F.UPDATE_USERID AS updateUserID , - F.UPDATE_DATE AS updateDate - FROM JHAMES.FQC_ITEM_GROUP_MATERIAL F - INNER JOIN JHAMES.MATERIAL_ITEM M ON F.ITEM_ID = M.ITEM_ID - WHERE F.GROUP_ID = :GroupId"; - DynamicParameters p = new DynamicParameters(); - p.Add("GroupId", id); - var result = await _context.Database.DapperQueryAsync(query, p); - return result.ToList(); - } - - /// - /// By ItemId 查詢 - /// - /// ItemId - /// - [HttpGet("ByItemId/{id}")] - public async Task>> GetFqcItemGroupMaterialByItemId(int id) - { - var query = @" SELECT - F.GROUP_ID AS groupId , - M.ITEM_ID AS itemId , - M.ITEM_NO AS itemNo , - M.ITEM_DESC AS itemDesc , - F.CREATE_USERID AS createUserID , - F.CREATE_DATE AS createDate , - F.UPDATE_USERID AS updateUserID , - F.UPDATE_DATE AS updateDate - FROM JHAMES.FQC_ITEM_GROUP_MATERIAL F - INNER JOIN JHAMES.MATERIAL_ITEM M ON F.ITEM_ID = M.ITEM_ID - WHERE F.ITEM_ID = :ItemId"; - DynamicParameters p = new DynamicParameters(); - p.Add("ItemId", id); - var result = await _context.Database.DapperQueryAsync(query, p); - return result.ToList(); - } - - /// - /// 更新檢驗群組指定料號設定檔 - /// - /// - /// - [HttpPut] - public async Task> PutFqcItemGroupMaterial(FqcItemGroupMaterial fqcItemGroupMaterial) - { - ResultModel result = new ResultModel(); - _context.Entry(fqcItemGroupMaterial).State = EntityState.Modified; - _context.Entry(fqcItemGroupMaterial).Property("CreateDate").IsModified = false; - _context.Entry(fqcItemGroupMaterial).Property("CreateUserID").IsModified = false; - fqcItemGroupMaterial.UpdateDate = DateTime.Now; - - try - { - await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; - } - catch (Exception ex) - { - result.Success = false; - result.Msg = ex.InnerException.Message; - } - return result; - } - - /// - /// 新增檢驗群組指定料號設定檔 - /// - /// - /// - [HttpPost] - public async Task> PostFqcItemGroupMaterial(FqcItemGroupMaterial fqcItemGroupMaterial) - { - ResultModel result = new ResultModel(); - _context.FqcItemGroupMaterials.Add(fqcItemGroupMaterial); - try - { - await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; - } - catch (Exception ex) - { - result.Success = false; - result.Msg = ex.InnerException.Message; - } - return result; - } - - /// - /// 刪除 檢驗群組指定料號設定檔 - /// - /// GroupId - /// itemId - /// - [HttpDelete("{id}/{id1}")] - public async Task> DeleteFqcItemGroupMaterial(int id, int id1) - { - var query = @" DELETE JHAMES.FQC_ITEM_GROUP_MATERIAL WHERE GROUP_ID =:id - AND ITEM_ID = :id1"; - DynamicParameters p = new DynamicParameters(); - p.Add("id", id); - p.Add("id1", id1); - var result = await _context.Database.DapperExecuteAsync(query, p); - return result; - } - } -} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs index 390b12be..361758cd 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs @@ -345,39 +345,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } - /// - /// 執行判斷無序號工單檢驗完成 - /// - /// - /// - [HttpGet("ExecuteWithoutWipNoComplete/{id}")] - public async Task> ExecuteWithoutWipNoComplete(string id) - { - var query = @$" SELECT SUM(INHOUSE_QTY) , PLAN_QTY , WIP_NO FROM - (SELECT DISTINCT I.INHOUSE_QTY , I.INHOUSE_NO , I.SEQ_ID , W.PLAN_QTY, W.WIP_NO - FROM JHAMES.FQC_INHOUSE_MASTER I - INNER JOIN JHAMES.FQC_RESULT_MASTER F ON I.INHOUSE_NO = F.INHOUSE_NO AND I.SEQ_ID = F.SEQ_ID - INNER JOIN JHAMES.WIP_INFO W ON F.WIP_NO = W.WIP_NO - WHERE F.INSPECTION_STATUS = 'D' - AND I.STATUS = 'P' - AND I.WIP_NO=:WipNo) A - GROUP BY WIP_NO, PLAN_QTY - HAVING SUM(INHOUSE_QTY) = PLAN_QTY "; - - DynamicParameters p = new DynamicParameters(); - p.Add("WipNo", id.Trim().ToUpper(), DbType.String); - var q = await _context.Database.DapperQueryAsync(query, p); - - if (q.Any()) - { - query = @" UPDATE JHAMES.WIP_INFO SET STATUS_NO='E' WHERE WIP_NO=:WipNo "; - await _context.Database.DapperExecuteAsync(query, p); - return "該筆工單已執行結案"; - } - - return "該筆工單尚未全部抽驗完成"; - } - /// /// 更新FQC檢驗單結果 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialItemController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialItemController.cs index 4971d029..734bc238 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialItemController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialItemController.cs @@ -68,7 +68,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task GetMaterialItemByItemNO(string id) { IQueryable q = _context.MaterialItems; - var result = await q.Where(p => p.ItemNo == id).FirstOrDefaultAsync(); + var result = q.Where(p => p.ItemNo == id).FirstOrDefault(); return result; } @@ -87,18 +87,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } - /// - /// 關鍵字查詢 - /// - /// 料號 - /// - [HttpGet("AutoComplete/{id}")] - public async Task>> GetMeterialAutoComplete(string id) - { - var materialItems = await _context.MaterialItems.Where(w => w.ItemNo.ToUpper().Contains(id.ToUpper())).Take(20).ToListAsync(); - return materialItems; - } - /// /// 新增料號基本資料檔 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs index 78b52aba..d8501646 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs @@ -56,10 +56,9 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// 筆數 /// 料號 /// 工單號碼 - /// FQC檢驗設定群組 /// [HttpGet("QcItemQuery")] - public async Task> GetQcItemQuery(int groupID = 0, int page = 0, int limit = 10, string itemNo = null, string wipNo = null, int fqcItemGroupId = 0) + public async Task> GetQcItemQuery(int groupID = 0, int page = 0, int limit = 10, string itemNo = null, string wipNo = null) { IQueryable q = _context.QcItems; ResultModel result = new ResultModel(); @@ -76,6 +75,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES q = q.Skip((page - 1) * limit).Take(limit); } + //var aa = System.Enum.IsDefined(typeof(EnumFQC.EnumQCItem_Type), "A") ? EnumFQC.GetDisplayName((EnumFQC.EnumQCItem_Type)System.Enum.Parse(typeof(EnumFQC.EnumQCItem_Type), "A")) : ""; + result.Data = await q.Select(s => new QcItemDto { ItemID = s.ItemID, @@ -90,30 +91,19 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES GroupNameEN = s.GetQcGroup.GroupNameCN ?? "", ItemType = s.Type }).ToListAsync(); - // 先判斷工單是否有資料 - if (!string.IsNullOrWhiteSpace(wipNo)) + var wipFqcItem = await _context.WipFqcItems.Where(w => w.WipNo == wipNo).ToListAsync(); + if (wipFqcItem.Count != 0) { - var wipFqcItem = await _context.WipFqcItems.Where(w => w.WipNo == wipNo).ToListAsync(); - if (wipFqcItem.Count != 0) + foreach (var item in result.Data) { - foreach (var item in result.Data) - { - if (wipFqcItem.Where(w => w.QcItemID == item.ItemID).Any()) - item.check = true; - } - result.Data.Select(s => s.ItemTypeName = - System.Enum.IsDefined(typeof(EnumFQC.EnumQCItem_Type), s.ItemType ?? "") ? - EnumFQC.GetDisplayName((EnumFQC.EnumQCItem_Type)System.Enum.Parse(typeof(EnumFQC.EnumQCItem_Type), s.ItemType)) : "") - .ToList(); - - return result; + if (wipFqcItem.Where(w => w.QcItemID == item.ItemID).Any()) + item.check = true; } } - - // 有輸入料號跟QCITEM 比對有資料打勾 - if (!string.IsNullOrWhiteSpace(itemNo)) + else { + // 有輸入料號跟QCITEM 比對有資料打勾 var itemID = _context.MaterialItems.Where(w => w.ItemNo == itemNo).FirstOrDefault(); if (itemID != null) { @@ -126,17 +116,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } } - // 有設定FQC檢驗項目群組 - if (fqcItemGroupId != 0) - { - var fqcItem = await _context.FqcItems.Where(w => w.GroupId == fqcItemGroupId).ToListAsync(); - foreach (var item in result.Data) - { - if (fqcItem.Where(w => w.QcItemId == item.ItemID).Any()) - item.check = true; - } - } - result.Data.Select(s => s.ItemTypeName = System.Enum.IsDefined(typeof(EnumFQC.EnumQCItem_Type), s.ItemType ?? "") ? EnumFQC.GetDisplayName((EnumFQC.EnumQCItem_Type)System.Enum.Parse(typeof(EnumFQC.EnumQCItem_Type), s.ItemType)) : "") diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipFqcItemController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipFqcItemController.cs index 154d675e..3fe31a14 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipFqcItemController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipFqcItemController.cs @@ -8,8 +8,6 @@ using Microsoft.EntityFrameworkCore; using AMESCoreStudio.WebApi; using AMESCoreStudio.WebApi.Models.AMES; using AMESCoreStudio.CommonTools.Result; -using Dapper; -using AMESCoreStudio.WebApi.Extensions; namespace AMESCoreStudio.WebApi.Controllers.AMES { @@ -115,59 +113,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } - /// - /// 判斷工單號碼是否有資料,沒有在取FQC群組建立資料 - /// - /// 工單號碼 - /// - [HttpPost("ByWipNo/{wipNo}")] - public async Task> PostWipFqcItemByWipNo(string wipNo) - { - var wipFqcItem = await _context.WipFqcItems.Where(w => w.WipNo == wipNo).AnyAsync(); - ResultModel result = new ResultModel { Success = true }; - // 沒有資料 再由FQC_ITEM新增 - if (!wipFqcItem) - { - var querySql = @" SELECT DISTINCT A.WIP_NO AS WipNo , - A.ITEM_NO AS ItemNo , - F.QC_GROUP_ID AS QcGroupID , - F.QC_ITEM_ID AS QcItemID - FROM JHAMES.WIP_ATT A - INNER JOIN JHAMES.MATERIAL_ITEM M ON A.ITEM_NO = M.ITEM_NO-- 料號對應檔 - INNER JOIN JHAMES.FQC_ITEM_GROUP_MATERIAL FM ON FM.ITEM_ID = M.ITEM_ID--料號ID對應FQC群組 - INNER JOIN JHAMES.FQC_ITEM F ON F.GROUP_ID = FM.GROUP_ID-- FQC群組對應綁定項目 - WHERE A.WIP_NO = :WipNo "; - - DynamicParameters p = new DynamicParameters(); - p.Add("WipNo", wipNo); - var query = await _context.Database.DapperQueryAsync(querySql, p); - - if (query.Any()) - { - Helper helper = new Helper(_context); - foreach (var item in query) - { - item.WipFqcitemID = helper.GetIDKey("WIP_FQCITEM_ID").Result; - _context.WipFqcItems.Add(item); - } - - try - { - await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; - } - catch (Exception ex) - { - result.Success = false; - result.Msg = ex.InnerException.Message; - } - return result; - } - } - return result; - } - // DELETE: api/WipFqcItem/5 [HttpDelete("{id}")] public async Task> DeleteWipFqcItem(int id) diff --git a/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs index 1b885659..85777e3c 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs @@ -375,15 +375,7 @@ namespace AMESCoreStudio.WebApi.DTO.AMES [DataMember] [StringLength(5)] public string LocationNo { get; set; } - - /// - /// 入庫單開單時間 - /// - [NotMapped] - [DataMember] - [Display(Name = "入庫單開單時間")] - public DateTime CreateDate { get; set; } - + public List fqcDetails { get; set; } diff --git a/AMESCoreStudio.WebApi/DTO/AMES/FqcResultDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/FqcResultDto.cs index 75da362d..b970b3a0 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/FqcResultDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/FqcResultDto.cs @@ -63,7 +63,7 @@ namespace AMESCoreStudio.WebApi.DTO.AMES /// [Display(Name = "狀態")] [Column("STATUS_NO")] - public string StatusNo { get; set; } + public string StatusNo { get; set; } = "P"; /// /// IsSample diff --git a/AMESCoreStudio.WebApi/Models/AMES/FqcItem.cs b/AMESCoreStudio.WebApi/Models/AMES/FqcItem.cs index f3cd5815..bc1b9e88 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/FqcItem.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/FqcItem.cs @@ -2,47 +2,51 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using System.Runtime.Serialization; using Microsoft.EntityFrameworkCore; +using System.Runtime.Serialization; #nullable disable namespace AMESCoreStudio.WebApi.Models.AMES { /// - /// FQC檢驗項目群組綁定設定檔 + /// FQC细目資料檔 /// + [Keyless] [Table("FQC_ITEM", Schema = "JHAMES")] + [Index(nameof(FqcID), nameof(ItemID), Name = "FQC_ITEM_AK1", IsUnique = true)] public partial class FqcItem { - /// - /// ID - /// - [Key] - [DataMember] - [Column("FQC_ITEM_ID")] - public int FqcItemId { get; set; } /// - /// FQC檢驗項目群組ID + /// FQC檢驗結果ID /// + [Key] [DataMember] - [Column("GROUP_ID")] - public int GroupId { get; set; } + [Display(Name = "FQC檢驗結果ID")] + [Required(ErrorMessage = "{0},不能空白")] + [Column("FQC_ID")] + public int FqcID { get; set; } /// - /// 檢驗類別ID + /// 细目序號ID /// + [Key] [DataMember] - [Column("QC_GROUP_ID")] - public int QcGroupId { get; set; } + [Display(Name = "细目序號ID")] + [Required(ErrorMessage = "{0},不能空白")] + [Column("ITEM_ID")] + public int ItemID { get; set; } /// - /// 檢驗項目ID + /// 细目内容 /// [DataMember] - [Column("QC_ITEM_ID")] - public int QcItemId { get; set; } + [Display(Name = "细目内容")] + [Required(ErrorMessage = "{0},不能空白")] + [Column("ITEM_CONTENT")] + [StringLength(200)] + public string ItemContent { get; set; } /// /// 建立UserID diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index 2dc23eb1..7807edb2 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -117,6 +117,7 @@ namespace AMESCoreStudio.WebApi modelBuilder.Entity().HasKey(c => new { c.InhouseNo, c.SeqID, c.SerialNo }); modelBuilder.Entity().HasKey(c => new { c.FqcID, c.BoxNo, c.BarcodeNo }); modelBuilder.Entity().HasKey(c => new { c.FqcID, c.BarcodeID }); + modelBuilder.Entity().HasKey(c => new { c.FqcID, c.ItemID }); modelBuilder.Entity().HasKey(e => new { e.FqcID, e.CreateDate }); modelBuilder.Entity().HasOne(r => r.Barcode).WithMany().HasForeignKey(r => r.BarcodeID).IsRequired(); modelBuilder.Entity().HasOne(r => r.Wip).WithMany().HasForeignKey(r => r.WipId).IsRequired(); @@ -155,7 +156,6 @@ namespace AMESCoreStudio.WebApi modelBuilder.Entity().HasKey(c => new { c.NGClassNo, c.NGReasonNo }); modelBuilder.Entity().HasKey(c => new { c.Yrer, c.Month, c.QcRateType, c.ProductType }); modelBuilder.Entity().HasNoKey(); - modelBuilder.Entity().HasKey(c => new { c.GroupId, c.ItemId }); } /// @@ -654,6 +654,11 @@ namespace AMESCoreStudio.WebApi /// public virtual DbSet FqcBarcodes { get; set; } + /// + /// FQC细目資料檔 + /// + public virtual DbSet FqcItems { get; set; } + /// /// 抽驗批退資料檔 /// @@ -996,21 +1001,6 @@ namespace AMESCoreStudio.WebApi /// public DbSet TestInfoes { get; set; } - /// - /// FQC檢驗項目群組綁定設定檔 - /// - public virtual DbSet FqcItems { get; set; } - - /// - /// FQC檢驗項目群組名稱 - /// - public virtual DbSet FqcItemGroups { get; set; } - - /// - /// FQC檢驗項目群組指定料號設定檔 - /// - public virtual DbSet FqcItemGroupMaterials { get; set; } - /// /// 維修不良序號 ///