diff --git a/AMESCoreStudio.Web/Controllers/PCBController.cs b/AMESCoreStudio.Web/Controllers/PCBController.cs index fface035..a8f6ec78 100644 --- a/AMESCoreStudio.Web/Controllers/PCBController.cs +++ b/AMESCoreStudio.Web/Controllers/PCBController.cs @@ -21,6 +21,7 @@ using Microsoft.AspNetCore.Hosting; using System.ComponentModel.DataAnnotations; using AspNetCore.Reporting; using System.Text.Encodings; +using AMESCoreStudio.WebApi.Enum; namespace AMESCoreStudio.Web.Controllers { @@ -42,1366 +43,26 @@ namespace AMESCoreStudio.Web.Controllers } //#region 下拉選單 - ///// - ///// 檢驗類別 Select - ///// - ///// - //private async Task GetQCGroupSelect() - //{ - - // var result = await _fqcApi.GetQcGroup(); - - // var QCGroupList = new List(); - // for (int i = 0; i < result.Count; i++) - // { - // QCGroupList.Add(new SelectListItem(result[i].GroupNameCN + "【" + result[i].GroupNameEN + "】", result[i].GroupID.ToString())); - // } - - // if (QCGroupList.Count == 0) - // { - // QCGroupList.Add(new SelectListItem("N/A", null)); - // } - - // ViewBag.QCGroupSelect = QCGroupList; - //} - - ///// - ///// 抽驗係數 Select - ///// - ///// - //private async Task GetQcQuotSelect() - //{ - // var result = await _fqcApi.GetQcQuot(); - - // var QcQuotList = new List(); - // for (int i = 0; i < result.Count; i++) - // { - // QcQuotList.Add(new SelectListItem(result[i].QuotName, result[i].QuotID.ToString())); - // } - - // if (QcQuotList.Count == 0) - // { - // QcQuotList.Add(new SelectListItem("N/A", null)); - // } - - // ViewBag.QcQuotSelect = QcQuotList; - //} - - ///// - ///// FQC狀態維護 Select - ///// - ///// - //private async Task GetStatusTypeSelect() - //{ - // var result = await _fqcApi.GetStatusType(); - - // var StatusTypetList = new List(); - // result = result.OrderByDescending(o => o.StatusNo).ToList(); - // for (int i = 0; i < result.Count; i++) - // { - // StatusTypetList.Add(new SelectListItem(result[i].StatusName, result[i].StatusNo.ToString())); - // } - - // if (StatusTypetList.Count == 0) - // { - // StatusTypetList.Add(new SelectListItem("N/A", null)); - // } - - // ViewBag.StatusTypeSelect = StatusTypetList; - //} - - ///// - ///// 不良群組 - ///// - ///// - //private async Task GetNGGroupSelect() - //{ - // var result = await _fqcApi.GetNGGroups(0); - - // var NGGroupList = new List(); - // for (int i = 0; i < result.Count; i++) - // { - // NGGroupList.Add(new SelectListItem(result[i].NGGroupName, result[i].NGGroupNo.ToString())); - // } - // ViewBag.NGGroupSelect = NGGroupList; - //} - - ///// - ///// 不良類別 By NGGroup - ///// - ///// NGGroupNo - ///// - //[HttpPost] - //public async Task GetNGClassByGroupAsync(string group_no) - //{ - // var result = await _fqcApi.GetNGClassesByGroup(group_no); - - // var item = new List(); - - // for (int i = 0; i < result.Count; i++) - // { - // item.Add(new SelectListItem(result[i].NGClassName, result[i].NGClassNo.ToString())); - // } - // //将数据Json化并传到前台视图 - // return Json(new { data = item }); - //} - - ///// - ///// 不良原因 By NGClass - ///// - ///// - ///// - //[HttpPost] - //public async Task GetNGReasonsByClassAsync(string ngClassNo) - //{ - // var result = await _fqcApi.GetNGReasonsByClass(ngClassNo); - - // var item = new List(); - - // for (int i = 0; i < result.Count; i++) - // { - // item.Add(new SelectListItem(result[i].NGReasonDesc, result[i].NGReasonNo.ToString())); - // } - // //将数据Json化并传到前台视图 - // return Json(new { data = item }); - //} - - ///// - ///// 廠別/委外廠 - ///// - ///// - //private async Task GetFactoryInfo() - //{ - // var result = await _pcsApi.GetFactoryInfo(); - - // var FactoryInfo = new List(); - // for (int i = 0; i < result.Count; i++) - // { - // FactoryInfo.Add(new SelectListItem(result[i].FactoryNo + "-" + result[i].FactoryNameCh, result[i].FactoryID.ToString())); - // } - - // if (FactoryInfo.Count == 0) - // { - // FactoryInfo.Add(new SelectListItem("N/A", null)); - // } - - // ViewBag.FactoryInfoList = FactoryInfo; - //} - //#endregion - - //#region FQC001 檢驗類別維護 - //public IActionResult FQC001() - //{ - // return View(); - //} - - ////新增頁面 - //public IActionResult FQC001C() - //{ - // return View(); - //} - - ////修改页面 - //[HttpGet] - //public async Task FQC001UAsync(int id) - //{ - // var result = await _fqcApi.GetQcGroup(id); - // return View(result); - //} - - //public async Task FQC001DAsync(int id) - //{ - // var result = await _fqcApi.DeleteQcGroup(id); - // return Json(new Result() { success = result.Success, msg = result.Msg }); - //} - - ////頁面提交,id=0 添加,id>0 修改 - //[HttpPost] - //public async Task FQC001Async(QcGroup model) - //{ - // if (ModelState.IsValid) - // { - // IResultModel result; - // if (model.GroupID == 0) - // { - // result = await _fqcApi.PostQcGroup(JsonConvert.SerializeObject(model)); - // } - // else - // { - // result = await _fqcApi.PutQcGroup(JsonConvert.SerializeObject(model)); - // } - - // if (result.Success) - // { - // var _msg = model.GroupID == 0 ? "新增成功!" : "修改成功!"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - // } - // else - // { - - // ModelState.AddModelError("error", result.Msg); - // } - // } - // if (model.GroupID == 0) - // { - // return View("FQC001C", model); - // } - // return View("FQC001U", model); - //} - - //[ResponseCache(Duration = 0)] - //[HttpGet] - //public async Task FQC001QueryAsync(int page = 0, int limit = 10) - //{ - // var result = await _fqcApi.GetQcGroupQuery(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 }); - //} - //#endregion - - //#region FQC002 檢驗項目維護 - //public async Task FQC002() - //{ - // await GetQCGroupSelect(); - // return View(); - //} - - ////新增頁面 - //public async Task FQC002C() - //{ - // await GetQCGroupSelect(); - // return View(); - //} - - ////修改页面 - //[HttpGet] - //public async Task FQC002UAsync(int id) - //{ - // await GetQCGroupSelect(); - // var result = await _fqcApi.GetQcItem(id); - // return View(result); - //} - - //public async Task FQC002DAsync(int id) - //{ - // var result = await _fqcApi.DeleteQcItem(id); - // return Json(new Result() { success = result.Success, msg = result.Msg }); - //} - - ////頁面提交,id=0 添加,id>0 修改 - //[HttpPost] - //public async Task FQC002Async(QcItem model) - //{ - // if (ModelState.IsValid) - // { - // IResultModel result; - // if (model.ItemID == 0) - // { - // result = await _fqcApi.PostQcItem(JsonConvert.SerializeObject(model)); - // } - // else - // { - // result = await _fqcApi.PutQcItem(JsonConvert.SerializeObject(model)); - // } - - // if (result.Success) - // { - // var _msg = model.ItemID == 0 ? "新增成功!" : "修改成功!"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - // } - // else - // { - - // ModelState.AddModelError("error", result.Msg); - // } - // } - // if (model.ItemID == 0) - // { - // return View("FQC002C", model); - // } - // return View("FQC002U", model); - //} - - //[ResponseCache(Duration = 0)] - //[HttpGet] - //public async Task FQC002QueryAsync(int groupID = 0, int page = 0, int limit = 10) - //{ - // var result = await _fqcApi.GetQcItemQuery(groupID, 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 }); - //} - //#endregion - - //#region FQC003 檢驗結果維護 - //public IActionResult FQC003() - //{ - // return View(); - //} - - ////新增頁面 - //public IActionResult FQC003C() - //{ - // return View(); - //} - - ////修改页面 - //[HttpGet] - //public async Task FQC003UAsync(string id) - //{ - // var result = await _fqcApi.GetFqcResult(id); - // return View(result); - //} - - //public async Task FQC003DAsync(string id) - //{ - // var result = await _fqcApi.DeleteFqcResult(id); - // return Json(new Result() { success = result.Success, msg = result.Msg }); - //} - - ////頁面提交,id=0 添加,id>0 修改 - //[HttpPost] - //public async Task FQC003Async(FqcResult model) - //{ - // if (ModelState.IsValid) - // { - // IResultModel result; - // if (string.IsNullOrWhiteSpace(model.FqcNo)) - // { - // result = await _fqcApi.PostFqcResult(JsonConvert.SerializeObject(model)); - // } - // else - // { - // result = await _fqcApi.PutFqcResult(JsonConvert.SerializeObject(model)); - // } - - // if (result.Success) - // { - // var _msg = string.IsNullOrWhiteSpace(model.FqcNo) ? "新增成功!" : "修改成功!"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - // } - // else - // { - - // ModelState.AddModelError("error", result.Msg); - // } - // } - // if (string.IsNullOrWhiteSpace(model.FqcNo)) - // { - // return View("FQC003C", model); - // } - // return View("FQC003U", model); - //} - - //[ResponseCache(Duration = 0)] - //[HttpGet] - //public async Task FQC003QueryAsync(int page = 0, int limit = 10) - //{ - // var result = await _fqcApi.GetFqcResultQuery(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 }); - //} - //#endregion - - //#region FQC004 抽驗係數維護 - //public IActionResult FQC004() - //{ - // return View(); - //} - - ////新增頁面 - //public IActionResult FQC004C() - //{ - // return View(); - //} - - ////修改页面 - //[HttpGet] - //public async Task FQC004UAsync(int id) - //{ - // var result = await _fqcApi.GetQcQuot(id); - // return View(result); - //} - - //public async Task FQC004DAsync(int id) - //{ - // var result = await _fqcApi.DeleteQcQuot(id); - // return Json(new Result() { success = result.Success, msg = result.Msg }); - //} - - ////頁面提交,id=0 添加,id>0 修改 - //[HttpPost] - //public async Task FQC004Async(QcQuot model) - //{ - // if (ModelState.IsValid) - // { - // IResultModel result; - // if (model.QuotID == 0) - // { - // result = await _fqcApi.PostQcQuot(JsonConvert.SerializeObject(model)); - // } - // else - // { - // result = await _fqcApi.PutQcQuot(JsonConvert.SerializeObject(model)); - // } - - // if (result.Success) - // { - // var _msg = model.QuotID == 0 ? "新增成功!" : "修改成功!"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - // } - // else - // { - - // ModelState.AddModelError("error", result.Msg); - // } - // } - // if (model.QuotID == 0) - // { - // return View("FQC004C", model); - // } - // return View("FQC004U", model); - //} - - //[ResponseCache(Duration = 0)] - //[HttpGet] - //public async Task FQC004QueryAsync(int page = 0, int limit = 10) - //{ - // var result = await _fqcApi.GetQcQuotQuery(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 }); - //} - //#endregion - - //#region FQC005 抽驗係數維護 - //public async Task FQC005() - //{ - // await GetQcQuotSelect(); - // return View(); - //} - - ////新增頁面 - //public async Task FQC005C() - //{ - // await GetQcQuotSelect(); - // return View(); - //} - - ////修改页面 - //[HttpGet] - //public async Task FQC005UAsync(int id) - //{ - // await GetQcQuotSelect(); - // var result = await _fqcApi.GetQcCriterion(id); - // return View(result); - //} - - //public async Task FQC005DAsync(int id) - //{ - // var result = await _fqcApi.DeleteQcCriterion(id); - // return Json(new Result() { success = result.Success, msg = result.Msg }); - //} - - ////頁面提交,id=0 添加,id>0 修改 - //[HttpPost] - //public async Task FQC005Async(QcCriterion model) - //{ - // await GetQcQuotSelect(); - // if (ModelState.IsValid) - // { - // #region 判斷設定起訖數量區間是否有重疊 - // var query = await _fqcApi.GetQcCriterionByQuotID(model.QuotID); - // // 排除自己 - // query = query.Where(w => w.CritID != model.CritID).ToList(); - - // if (query.Where(w => w.QcStart <= model.QcStart && model.QcStart <= w.QcEnd).Any() || - // query.Where(w => w.QcStart <= model.QcEnd && model.QcEnd <= w.QcEnd).Any()) - // { - // ModelState.AddModelError("error", "設定起訖數量區間有重疊,請確認"); - // if (model.CritID == 0) - // { - // return View("FQC005C", model); - // } - // return View("FQC005U", model); - // } - // #endregion - - // IResultModel result; - // if (model.CritID == 0) - // { - // result = await _fqcApi.PostQcCriterion(JsonConvert.SerializeObject(model)); - // } - // else - // { - // result = await _fqcApi.PutQcCriterion(JsonConvert.SerializeObject(model)); - // } - - // if (result.Success) - // { - // var _msg = model.CritID == 0 ? "新增成功!" : "修改成功!"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - // } - // else - // { - // ModelState.AddModelError("error", result.Msg); - // } - // } - // if (model.CritID == 0) - // { - // return View("FQC005C", model); - // } - // return View("FQC005U", model); - //} - - //[ResponseCache(Duration = 0)] - //[HttpGet] - //public async Task FQC005QueryAsync(int quotID = 0, int page = 0, int limit = 10) - //{ - // var result = await _fqcApi.GetQcCriterionQuery(quotID, 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 }); - //} - //#endregion - - //#region FQC006 FQC狀態維護 - //public IActionResult FQC006() - //{ - // return View(); - //} - - ////新增頁面 - //public IActionResult FQC006C() - //{ - // return View(); - //} - - ////修改页面 - //[HttpGet] - //public async Task FQC006UAsync(string id) - //{ - // var result = await _fqcApi.GetStatusType(id); - // return View(result); - //} - - //public async Task FQC006DAsync(string id) - //{ - // var result = await _fqcApi.DeleteStatusType(id); - // return Json(new Result() { success = result.Success, msg = result.Msg }); - //} - - //// 添加 - //[HttpPost] - //public async Task FQC006CAsync(StatusType model) - //{ - // if (ModelState.IsValid) - // { - // IResultModel result; - - // result = await _fqcApi.PostStatusType(JsonConvert.SerializeObject(model)); - - // if (result.Success) - // { - // var _msg = "新增成功!"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - // } - // else - // { - // ModelState.AddModelError("error", result.Msg); - // } - // } - - // return View("FQC006C", model); - //} - - //// 修改 - //[HttpPost] - //public async Task FQC006UAsync(StatusType model) - //{ - // if (ModelState.IsValid) - // { - // IResultModel result; - - // result = await _fqcApi.PutStatusType(JsonConvert.SerializeObject(model)); - - // if (result.Success) - // { - // var _msg = "修改成功!"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - // } - // else - // { - // ModelState.AddModelError("error", result.Msg); - // } - // } - - // return View("FQC006U", model); - //} - - //[ResponseCache(Duration = 0)] - //[HttpGet] - //public async Task FQC006QueryAsync(int page = 0, int limit = 10) - //{ - // var result = await _fqcApi.GetStatusTypeQuery(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 }); - //} - //#endregion - - //#region FQC007 FQC抽驗作業 - //public async Task FQC007(string inhouseNo = null, int seqID = 0) - //{ - // var model = new FqcDto(); - // if (!string.IsNullOrWhiteSpace(inhouseNo) && seqID != 0) - // { - // IResultModel result; - // result = await _fqcApi.GetFqcQuery(inhouseNo, seqID); - // if (result.Data.Count() != 0) - // { - // model = result.Data.FirstOrDefault(); - // model.h_InhouseNo = model.InhouseNo; - // model.h_SeqID = model.SeqID.ToString(); - - // // 抓全部檢驗工項 - // var result_QcItem = await _fqcApi.GetQcItemQuery(0, 0, 0); - // // 取綁定工單檢驗工項資料 - // var result_WipFQC = await _fqcApi.GetWipFqcItemByWipNo(model.WipNo); - // if (result_WipFQC.Count == 0) - // { - // //工單無設定檢驗工項時 在抓料號綁定檢驗工項 - // 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 - // { - // model.qcItemDtos = result_QcItem.Data.Where(w => result_WipFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); - // } - // } - // else - // { - // ModelState.AddModelError("error", "找不到入庫單號【" + model.InhouseNo + "】的資料"); - // model.h_InhouseNo = ""; - // model.h_SeqID = ""; - // } - // } - - // return View(model); - //} - - //[HttpPost] - //public async Task FQC007Async(FqcDto model, string action) - //{ - // if (string.IsNullOrWhiteSpace(model.InhouseNo)) - // { - // ModelState.AddModelError("error", "請輸入入庫單號"); - // return View("FQC007", model); - // } - - // IResultModel result; - - // result = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); - - // if (action == "儲存") - // { - // var result_FQCResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID); - - // if (result_FQCResultMaster != null) - // { - // result_FQCResultMaster.OS = model.OS; - // result_FQCResultMaster.CPU = model.CPU; - // result_FQCResultMaster.RAM = model.RAM; - // result_FQCResultMaster.BIOS = model.BIOS; - // result_FQCResultMaster.Supervisor = model.Supervisor; - // result_FQCResultMaster.Proved = model.Proved; - // result_FQCResultMaster.OutfitNo = model.OutfitNo; - // await _fqcApi.PutFqcResultMaster(JsonConvert.SerializeObject(result_FQCResultMaster)); - // ModelState.AddModelError("error", "儲存成功!"); - // } - // } - - // if (result.Data.Count() != 0) - // { - // model = result.Data.FirstOrDefault(); - // model.h_InhouseNo = model.InhouseNo; - // model.h_SeqID = model.SeqID.ToString(); - - // // 抓全部檢驗工項 - // var result_QcItem = await _fqcApi.GetQcItemQuery(0, 0, 0); - // // 取綁定工單檢驗工項資料 - // var result_WipFQC = await _fqcApi.GetWipFqcItemByWipNo(model.WipNo); - // if (result_WipFQC.Count == 0) - // { - // //工單無設定檢驗工項時 在抓料號綁定檢驗工項 - // 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 - // { - // model.qcItemDtos = result_QcItem.Data.Where(w => result_WipFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); - // } - // } - // else - // { - // ModelState.AddModelError("error", "找不到入庫單號【" + model.InhouseNo + "】的資料"); - // model.h_InhouseNo = ""; - // model.h_SeqID = ""; - // } - - - - // return View(model); - //} - - //#region 抽驗 - //[HttpGet] - //public async Task FQC007C(string inhouseNo, string seq) - //{ - // await GetStatusTypeSelect(); - // await GetNGGroupSelect(); - // var model = new FqcResultDto(); - // model.InhouseNo = inhouseNo; - // model.SeqID = int.Parse(seq); - // return View(model); - //} - - //[HttpPost] - //public async Task FQC007CAsync(FqcResultDto model) - //{ - // await GetStatusTypeSelect(); - // await GetNGGroupSelect(); - // if (string.IsNullOrWhiteSpace(model.BarcodeNo) && - // string.IsNullOrWhiteSpace(model.BoxNo) && - // string.IsNullOrWhiteSpace(model.ExtraBarcodeNo)) - // { - // ModelState.AddModelError("error", "請輸入要抽驗的相關序號"); - // return View("FQC007C", model); - // } - - // #region 相關查詢序號找出包裝箱號 - // var result_BarCodeInfo = new List(); - // if (!string.IsNullOrWhiteSpace(model.BarcodeNo)) - // { - // result_BarCodeInfo = await _fqcApi.GetBarcodeInfoesByNo(model.BarcodeNo); - // } - // else if (!string.IsNullOrWhiteSpace(model.ExtraBarcodeNo)) - // { - // result_BarCodeInfo = await _fqcApi.GetBarcodeInfoesByExtraNo(model.ExtraBarcodeNo); - // } - // else if (!string.IsNullOrWhiteSpace(model.BoxNo)) - // { - // result_BarCodeInfo = await _fqcApi.GetBarcodeInfoesByBoxNo(model.BoxNo); - // } - - // if (result_BarCodeInfo.Count == 0) - // { - // ModelState.AddModelError("error", "找不到相關資料"); - // return View("FQC007C", model); - // } - // else - // model.BoxNo = result_BarCodeInfo.FirstOrDefault().BoxNo; - // #endregion - - // #region 判斷是否包裝外箱是否跟入庫單號綁一起 - // var result_FqcInhouseDetail = await _fqcApi.GetFqcInhouseDetail(model.InhouseNo, model.SeqID); - // if (!result_FqcInhouseDetail.Where(w => w.SerialNo == model.BoxNo).Any()) - // { - // ModelState.AddModelError("error", "入庫單號【" + model.InhouseNo + "】找不到包裝箱號【" + model.BoxNo + "】"); - // return View("FQC007C", model); - // } - // #endregion - - // #region Set_FqcResultDetail - // if (model.StatusNo == "F" && model.NgReasonNo == "0") - // { - // ModelState.AddModelError("error", "請選擇不良代碼"); - // return View("FQC007C", model); - // }; - - // var FqcResultDetail = new FqcResultDetail - // { - // BarcodeNo = result_BarCodeInfo.FirstOrDefault().BarcodeNo, - // ExtraBarcodeNo = result_BarCodeInfo.FirstOrDefault().ExtraBarcodeNo, - // BoxNo = result_BarCodeInfo.FirstOrDefault().BoxNo, - // StatusNo = model.StatusNo, - // NgMemo = model.NgMemo, - // NgReasonNo = model.NgReasonNo, - // CreateUserID = GetLogInUserID(), - // UpdateUserID = GetLogInUserID() - // }; - - // if (string.IsNullOrWhiteSpace(FqcResultDetail.ExtraBarcodeNo)) - // { - // ModelState.AddModelError("error", "找不到該筆資料的客戶序號"); - // return View("FQC007C", model); - // } - // #endregion - - // #region 判斷已有抽驗過 - // var result_FqcResultMaster = await _fqcApi.GetFqcResultMasterByInhouseNo(model.InhouseNo, model.SeqID); - // if (result_FqcResultMaster.Count() != 0) - // { - // var result_ResultDetail = await _fqcApi.GetFqcResultDetail(result_FqcResultMaster.FirstOrDefault().FqcID); - // if (result_ResultDetail.Where(w => w.BarcodeNo == FqcResultDetail.BarcodeNo).Any()) - // { - // ModelState.AddModelError("error", "內部序號【" + FqcResultDetail.BarcodeNo + "】已抽驗過"); - // return View("FQC007C", model); - // } - // } - // #endregion - - // #region Set_FqcResultMaster - // var FqcResultMaster = new FqcResultMaster(); - // if (result_FqcResultMaster.Count != 0) - // { - // FqcResultMaster = result_FqcResultMaster.FirstOrDefault(); - // FqcResultMaster.QaQty += 1; - // FqcResultMaster.UpdateDate = DateTime.Now; - // FqcResultMaster.UpdateUserID = GetLogInUserID(); - // } - // else - // { - // IResultModel FqcDto; - // FqcDto = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); - // var FirstFqc = FqcDto.Data.FirstOrDefault(); - // FqcResultMaster.InhouseNo = model.InhouseNo; - // FqcResultMaster.SeqID = model.SeqID; - // FqcResultMaster.LotQty = FirstFqc.InhouseQty; - // FqcResultMaster.WipNo = FirstFqc.WipNo; - // FqcResultMaster.QaQty = 1; - // FqcResultMaster.ItemNo = FirstFqc.ItemNo; - // FqcResultMaster.ModelNo = FirstFqc.ModelNo; - // FqcResultMaster.StartTime = DateTime.Now; - // FqcResultMaster.EndTime = DateTime.Now; - // FqcResultMaster.CreateUserID = GetLogInUserID(); - // } - - // // 判斷是PASS || FAIL - // if (model.StatusNo == "F") - // FqcResultMaster.FailQty += 1; - // else - // { - // FqcResultMaster.PassQty += 1; - // FqcResultDetail.NgReasonNo = ""; - // FqcResultDetail.NgMemo = ""; - // } - // #endregion - - // IResultModel result; - // if (result_FqcResultMaster.Count == 0) - // { - // result = await _fqcApi.PostFqcResultMaster(JsonConvert.SerializeObject(FqcResultMaster)); - // FqcResultDetail.FqcID = result.Data.FirstOrDefault().FqcID; - // } - // else - // { - // result = await _fqcApi.PutFqcResultMaster(JsonConvert.SerializeObject(FqcResultMaster)); - // FqcResultDetail.FqcID = result_FqcResultMaster.FirstOrDefault().FqcID; - // } - // IResultModel result_detail; - // result_detail = await _fqcApi.PostFqcResultDetail(JsonConvert.SerializeObject(FqcResultDetail)); - - // if (result_detail.Success) - // { - // ModelState.AddModelError("error", "新增成功!"); - // //return RedirectToAction("WindowReload", "Home", new { msg = _msg }); - // return View("FQC007C", model); - // } - // else - // { - // ModelState.AddModelError("error", result_detail.Msg); - // } - - - // return View("FQC007C", model); - //} - //#endregion - - //#region 檢驗結果 - //[HttpGet] - //public async Task FQC007B(string inhouseNo, string seq, int fqc) - //{ - // var model = new FqcResultMaster(); - // model.InhouseNo = inhouseNo; - // model.SeqID = int.Parse(seq); - // model.FqcID = fqc; - // var result = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); - // var fqcItem = result.Data.FirstOrDefault(); - - // //當抽驗數量 小於 抽樣數量就離開 - // if (fqcItem.QcQty > fqcItem.PassQty + fqcItem.FailQty) - // { - // var _msg = "抽樣數量不足,無法判定"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - // } - - // // 判斷狀態選擇 - // if (fqcItem.FailQty >= fqcItem.ReQty) - // model.QaResult = "R"; - // else - // model.QaResult = "P"; - - // return View(model); - //} - - //[HttpPost] - //public async Task FQC007BAsync(FqcResultMaster model, string Result) - //{ - // var FqcQuery = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); - // var fqcItem = FqcQuery.Data.FirstOrDefault(); - // // 判斷狀態選擇 - // if (fqcItem.FailQty >= fqcItem.ReQty) - // { - // if (model.QaResult == "P" && string.IsNullOrWhiteSpace(model.SpecialPo)) - // { - // ModelState.AddModelError("error", "請輸入特採單號"); - // return View("FQC007B", model); - // } - // } - - // var fqcResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID); - // var fqcInhouseMaster = await _fqcApi.GetFqcInhouseMaster(model.InhouseNo, model.SeqID); - - // fqcResultMaster.QaResult = model.QaResult; - // fqcResultMaster.QaMeno = model.QaMeno; - // fqcResultMaster.EndTime = DateTime.Now; - // fqcResultMaster.UpdateDate = DateTime.Now; - // fqcResultMaster.SpecialPo = model.SpecialPo; - // fqcResultMaster.UpdateUserID = GetLogInUserID(); - - // fqcInhouseMaster.Status = model.QaResult; - // fqcInhouseMaster.UpdateDate = DateTime.Now; - // fqcInhouseMaster.UpdateUserID = GetLogInUserID(); - - // IResultModel result; - // result = await _fqcApi.PutFqcInhouseMaster(JsonConvert.SerializeObject(fqcInhouseMaster)); - // result = await _fqcApi.PutFqcResultMaster(JsonConvert.SerializeObject(fqcResultMaster)); - // if (result.Success) - // { - // if (model.QaResult == "P") - // await _fqcApi.PassingByFQC(model.InhouseNo, model.SeqID, GetLogInUserID()); - - // var _msg = "新增成功!"; - // return RedirectToAction("WindowReload", "Home", new { msg = _msg }); - // } - // else - // { - // ModelState.AddModelError("error", result.Msg); - // } - - // return View("FQC007B", model); - //} - //#endregion - - //#region 附件 - //[HttpGet] - //public async Task FQC007D(int fqc) - //{ - // FqcDto fqcDto = new FqcDto(); - // var model = await _fqcApi.GetFqcResultMasterBlobByFqcID(fqc); - // fqcDto.fqcResultMasterBlobs = model; - // fqcDto.FqcID = fqc; - // return View(fqcDto); - //} - - //[HttpPost] - //public async Task FQC007DAsync(FqcDto model, string Result, IFormFile formFile) - //{ - // FqcResultMaster fqcResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID); - // if (fqcResultMaster == null) - // { - // ModelState.AddModelError("error", "找不到FQC開單紀錄"); - // return View("FQC007D", model); - // } - - // if (formFile != null) - // { - // if (formFile.Length > 0) - // { - // // 檔案上傳 - // string FileName = string.Empty; - // string NewName = string.Empty; - // string FilePath = string.Empty; - // //取得使用者上傳檔案的原始檔名 - // FileName = Path.GetFileName(formFile.FileName); - // //取原始檔名中的副檔名 - // //var fileExt = Path.GetExtension(FileName); - // //為避免使用者上傳的檔案名稱發生重複,重新給一個亂數名稱 - // //NewName = Path.GetRandomFileName() + fileExt; - // //指定要寫入的路徑、檔名和副檔名 - // FilePath = $@"{_env.WebRootPath}\UploadFolder\FQC\{fqcResultMaster.InhouseNo}-{fqcResultMaster.SeqID}"; - // var path = $@"{FilePath}\{FileName}"; - - // if (!System.IO.Directory.Exists(FilePath)) - // { - // System.IO.Directory.CreateDirectory(FilePath); - // } - - // using (var stream = new FileStream(path, FileMode.Create)) - // { - // await formFile.CopyToAsync(stream); - // } - - // FqcResultMasterBlob fqcResultMasterBlob = new FqcResultMasterBlob() - // { - // FqcID = model.FqcID, - // ImageName = FileName, - // Filepath = $@"\UploadFolder\FQC\{fqcResultMaster.InhouseNo}-{fqcResultMaster.SeqID}\", - // CreateUserID = GetLogInUserID(), - // UpdateUserID = GetLogInUserID() - // }; - - // var result = await _fqcApi.PostFqcResultMasterBlob(JsonConvert.SerializeObject(fqcResultMasterBlob)); - - // if (result.Success) - // { - // ModelState.AddModelError("error", "上傳成功!"); - // } - // else - // { - // ModelState.AddModelError("error", "上傳失敗,錯誤訊息:" + result.Msg); - // } - // } - // } - // else - // { - // ModelState.AddModelError("error", "ssddf"); - // } - // model.fqcResultMasterBlobs = await _fqcApi.GetFqcResultMasterBlobByFqcID(model.FqcID); - // return View("FQC007D", model); - //} - //#endregion - - //#region 檢驗工項維護 - //[HttpGet] - //public ActionResult FQC007A(FqcDto model) - //{ - // return View(model); - //} - - //[HttpGet] - //public async Task FQC007AItemQuery(string wipNo, string itemNo) - //{ - // var result = await _fqcApi.GetQcItemQuery(0, 0, 0, itemNo, wipNo); - // return Json(new Table() { code = 0, data = result.Data, count = result.DataTotal }); - //} - - //[HttpPost] - //public async Task FQC007AAsync(string itemID, string groupID, string wipNo, string itemNo) - //{ - // // 取工單綁定檢驗工項 - // var result_WipFQC = await _fqcApi.GetWipFqcItemByWipNo(wipNo); - // // 有勾選的ItemID - // var checkItemID = itemID.Split(',').ToList(); - // // 有勾選的GroupID - // var checkGroupID = groupID.Split(',').ToList(); - - // // 取勾選有的 = 新增 - // var insertItemID = checkItemID.Except(result_WipFQC.Select(s => s.QcItemID.ToString())); - // for (int i = 0; i < checkItemID.Count; i++) - // { - // if (insertItemID.Where(w => w == checkItemID[i]).Any()) - // { - // WipFqcItem wipFqcItem = new WipFqcItem - // { - // WipNo = wipNo, - // ItemNo = itemNo, - // QcItemID = Int32.Parse(checkItemID[i]), - // QcGroupID = Int32.Parse(checkGroupID[i]), - // CreateUserID = GetLogInUserID(), - // CreateDate = DateTime.Now, - // UpdateUserID = GetLogInUserID(), - // UpdateDate = DateTime.Now - // }; - // await _fqcApi.PostWipFqcItem(JsonConvert.SerializeObject(wipFqcItem)); - // } - // } - - // // 取有料號綁定 = 需要刪除 - // var deteleItemID = result_WipFQC.Select(s => s.QcItemID.ToString()).Except(checkItemID); - // foreach (var item in deteleItemID) - // { - // var wipFQCID = result_WipFQC.Where(w => w.QcItemID == Int32.Parse(item)).FirstOrDefault().WipFqcitemID; - // await _fqcApi.DeleteWipFqcItem(wipFQCID); - // } - - // return Json(new { code = 0, msg = "", success = true }); - //} - //#endregion - - //#region FQC細項資料 - //[HttpGet] - //public async Task FQC007V(string inhouseNo, int seqID, string boxNo) - //{ - // ViewBag.inhouseNo = inhouseNo; - // ViewBag.seqID = seqID; - // ViewBag.boxNo = boxNo; - // return View(); - //} - - - //public async Task GetFQC007V(string inhouseNo, int seqID, string boxNo) - //{ - // var result = await _fqcApi.FQC007V(inhouseNo, seqID, boxNo); - - // 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 }); - //} - //#endregion - - //#endregion - - //#region FQC008 FQC查詢 - //public async Task FQC008() - //{ - // await GetFactoryInfo(); - // return View(); - //} - - //public async Task FQC008QueryAsync(string barcodeNo, string wipNo - // , string boxNo, string inhouseNo, string date_str, string date_end, string factoryID - // , string status, int page = 0, int limit = 10) - //{ - // IResultModel result = await _fqcApi.GetFqcInhouseMasterQuery(barcodeNo: barcodeNo, wipNo: wipNo - // , boxNo: boxNo, inhouseNo: inhouseNo, date_str: date_str, date_end: date_end - // , status: status, page: page, limit: limit, factoryID: factoryID); - - // await GetFactoryInfo(); - // 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 }); - //} - //#endregion - - //#region FQC009 料號對應檢驗工項 - - //public ActionResult FQC009() - //{ - // return View(); - //} - - //[HttpPost] - //public async Task FQC009Async(string itemID, string groupID, string itemNo) - //{ - // var result = await _fqcApi.GetMaterialItemByItemNO(itemNo); - // if (result == null) - // { - // var Msg = "在料號主檔找不到該筆料號【" + itemNo + "】"; - // return Json(new { code = 0, msg = Msg, success = false }); - // } - - // // 取料號綁定檢驗工項 - // var result_MasterFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(itemNo); - // // 有勾選的ItemID - // var checkItemID = itemID.Split(',').ToList(); - // // 有勾選的GroupID - // var checkGroupID = groupID.Split(',').ToList(); - - // // 取勾選有的 = 新增 - // var insertItemID = checkItemID.Except(result_MasterFQC.Select(s => s.QcItemID.ToString())); - // for (int i = 0; i < checkItemID.Count; i++) - // { - // if (insertItemID.Where(w => w == checkItemID[i]).Any()) - // { - // MaterialFqcItem materialFqcItem = new MaterialFqcItem - // { - // ItemID = result.ItemID, - // QcItemID = Int32.Parse(checkItemID[i]), - // QcGroupID = Int32.Parse(checkGroupID[i]), - // CreateUserID = GetLogInUserID(), - // CreateDate = DateTime.Now, - // UpdateUserID = GetLogInUserID(), - // UpdateDate = DateTime.Now - // }; - // await _fqcApi.PostMaterialFqcItem(JsonConvert.SerializeObject(materialFqcItem)); - // } - // } - - // // 取有料號綁定 = 需要刪除 - // var deteleItemID = result_MasterFQC.Select(s => s.QcItemID.ToString()).Except(checkItemID); - // foreach (var item in deteleItemID) - // { - // var masterFQCID = result_MasterFQC.Where(w => w.QcItemID == Int32.Parse(item)).FirstOrDefault().MaterialFqcitemID; - // await _fqcApi.DeleteMaterialFqcItem(masterFQCID); - // } - - // return Json(new { code = 0, msg = "", success = true }); - //} - - //[HttpGet] - //public async Task FQC009ItemQueryAsync(int groupID = 0, int page = 0, int limit = 1, string itemNo = null) - //{ - // var msg = ""; - // var result = await _fqcApi.GetQcItemQuery(groupID, 0, limit, itemNo); - // if (result.Data.Count() != 0) - // { - // if (!string.IsNullOrWhiteSpace(itemNo)) - // { - // var masterlItem = await _fqcApi.GetMaterialItemByItemNO(itemNo); - // if (masterlItem == null) - // { - // msg = "在料號主檔找不到該筆料號【" + itemNo + "】"; - // } - // } - // return Json(new Table() { code = 0, msg = msg, data = result.Data, count = result.DataTotal }); - // } - - // return Json(new Table() { count = 0, data = null }); - //} - //#endregion - - //#region FQC010 報表 - //public ActionResult FQC010() - //{ - // string mimeType = ""; - // int extension = 1; - // var path = $"{this._env.WebRootPath}\\Reports\\View.rdlc"; - // LocalReport localReport = new LocalReport(path); - // Dictionary param = new Dictionary(); - // System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); - // System.Text.Encoding.GetEncoding(1252); - // var FQC010Master = new FQC010VIiew - // { - // DefectDescription = "N/A", - // InspectionDate = "2022/06/30", - // AC = "0", - // Approved = "王曉明", - // AQL = "2.5", - // SpeciallyAdoption = "特採Specially Adoption", - // BIOSVer = "2.04A CS:7672H", - // ECN = "22N0202", - // ECNMemo = "工單生產已是最新ECN", - // Factory = "YS00", - // FactoryRemark = "N/A", - // InspectionInstrumentNumber = "N/A", - // InspectionItems = "OS:[Win10 IoT]CPU test:[1.10G] RAM test:[4096]", - // InspectionNumber = "Q944000114000001", - // InspectionStatus = "廠驗", - // InspectionType = "First Insp.", - // Inspector = "蔡喬虎", - // Judgment = "Defect Quantity", - // Line = "安勤產線", - // LotSize = "1", - // Major = "0", - // MedicalModel = "N", - // Minor = "1", - // Model = "CAXA0-1000A1-S01R", - // ModelName = "CAXA0 w/N3350/4G RAM/64G SSD/NFC", - // NOTE = @"ACC-M2 - // E1589 - // ESW-075R - // ACC-BAT", - // OrderNumber = "9440001400", - // Product99 = "一般二級水準正常檢驗", - // ReMajor = "1", - // Sample = "5", - // SamplingInspectionPlan = "ANSI/ASQZ 1.4II", - // StorageLocation = "9000", - // Avalue = "AVALUE", - // VIP = "N", - // WaiveRequisition = "XX", - // Detail1 = new List{ - // new FQC010Detail1 - // { - // ItemID = "1", - // ItemName = "AA", - // ItemType = "Major" - // }, - // new FQC010Detail1{ - // ItemID = "2", - // ItemName = "BB", - // ItemType = "Major" - // }, - // new FQC010Detail1{ - // ItemID = "2", - // ItemName = "BB", - // ItemType = "Major" - // }, - // new FQC010Detail1{ - // ItemID = "2", - // ItemName = "BB", - // ItemType = "Major" - // }, - // new FQC010Detail1{ - // ItemID = "2", - // ItemName = "BB", - // ItemType = "Major" - // }, - // new FQC010Detail1{ - // ItemID = "2", - // ItemName = "BB", - // ItemType = "Major" - // }, - // new FQC010Detail1{ - // ItemID = "2", - // ItemName = "BB", - // ItemType = "Major" - // }, - // new FQC010Detail1{ - // ItemID = "2", - // ItemName = "BB", - // ItemType = "Major" - // }}, - // Detail2 = new List - // { - // new FQC010Detail2 - // { - // ShippingSerialNumber= "AAAAAAAAAAAAAAAA", - // IsSample ="Y", - // ProductionSerialNumber = "DASKJDKLFJS", - // InspectionResults = "1" - // }} - // }; - - // var FQC010Masters = new List(); - // FQC010Masters.Add(FQC010Master); - - // localReport.AddDataSource("DataSet1", FQC010Masters); - // localReport.AddDataSource("DataSet2", FQC010Master.Detail1); - // localReport.AddDataSource("DataSet3", FQC010Master.Detail2); - - // var result = localReport.Execute(RenderType.Pdf, extension, param, mimeType); - // return File(result.MainStream, "application/pdf"); - //} + /// + /// SOP_Type + /// + /// + private void GetSteelPlateStatusSelect(string SelectedValue = null) + { + List values = new List(); + if (SelectedValue != null) + { + values = SelectedValue.Split(',').ToList(); + } + var q = Enum.GetValues(typeof(EnumPCB.EnumSteelPlateStatus)).Cast() + .Select(s => new SelectListItem + { + Text = EnumPCB.GetDisplayName(s).ToString(), + Value = s.ToString() + }).ToList(); + + ViewBag.GetSteelPlateStatusSelect = q; + } //#endregion #region PCB013 鋼板量測紀錄 @@ -1477,6 +138,75 @@ namespace AMESCoreStudio.Web.Controllers } return View("PCB013U", model); } + + + public IActionResult PCB013A(int steelPlateID, string steelPlateNo) + { + GetSteelPlateStatusSelect(); + ViewBag.steelPlateID = steelPlateID; + ViewBag.steelPlateNo = steelPlateNo; + return View(); + } + + /// + /// 鋼板量測記錄 + /// + /// + /// + [HttpPost] + public async Task PCB013ASave(SteelPlateMeasure model) + { + + IResultModel result; + + model.MeasureResult = "P"; + model.CreateUserID = GetLogInUserID(); + model.CreateDate = DateTime.Now; + model.UpdateUserID = GetLogInUserID(); + model.UpdateDate = DateTime.Now; + result = await _pcbApi.PostSteelPlateMeasure(JsonConvert.SerializeObject(model)); + + + if (result.Success) + { + var _msg = model.SteelPlateID == 0 ? "新增成功!" : "修改成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + + ModelState.AddModelError("error", result.Msg); + } + + + if (model.SteelPlateID == 0) + { + return View("PCB013A", model); + } + return View("PCB013A", model); + } + + + [HttpGet] + public IActionResult PCB013V(int steelPlateID, string steelPlateNo) + { + ViewBag.steelPlateID = steelPlateID; + ViewBag.steelPlateNo = steelPlateNo; + return View(); + } + + [HttpGet] + public async Task PCB013VQuery(int steelPlateID, string steelPlateNo, int page = 0, int limit = 10) + { + var result = await _pcbApi.GetSteelPlateMeasureBySteelPlateID(steelPlateID, page, limit); + + if (result.DataTotal > 0) + { + return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + } + + return Json(new Table() { count = 0, data = null }); + } #endregion #region PCB014 錫膏使用管控 diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index 181b34c0..7026e723 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -5681,7 +5681,7 @@ namespace AMESCoreStudio.Web.Controllers } [HttpGet] - public async Task PCS022VQuery(int page = 0, int limit = 10) + public async Task PCS022VQuery(int wipID, int ruleStationID,int page = 0, int limit = 10) { var result = await _pcsApi.GetWipStationBarcodeByPCS022(wipID, ruleStationID, page, limit); diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCB.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCB.cs index 40619be4..f14bc8ec 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCB.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCB.cs @@ -501,6 +501,17 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/SteelPlateInfo/ByNo/{id}")] ITask> GetSteelPlateInfoByNo(string id); + + /// + /// 新增鋼板資料 + /// + /// + [WebApiClient.Attributes.HttpPost("api/SteelPlateMeasure")] + ITask> PostSteelPlateMeasure([FromBody, RawJsonContent] string model); + + + [WebApiClient.Attributes.HttpGet("api/SteelPlateMeasure/BySteelPlateID/{id}")] + ITask> GetSteelPlateMeasureBySteelPlateID(int id, int page = 0, int limit = 10); #endregion #region PCB014 錫膏使用管控 diff --git a/AMESCoreStudio.Web/Views/PCB/PCB013.cshtml b/AMESCoreStudio.Web/Views/PCB/PCB013.cshtml index 6ce89669..47ec39fd 100644 --- a/AMESCoreStudio.Web/Views/PCB/PCB013.cshtml +++ b/AMESCoreStudio.Web/Views/PCB/PCB013.cshtml @@ -193,10 +193,11 @@ }, { title: '操作', - align: 'center', - width: 80, + width: 230, templet: function (d) { - return '修改' + return '修改\ + 新增量測\ + 檢視量測' } } ]]; @@ -207,6 +208,18 @@ } } + function detail(obj) { + if (obj.data.steelPlateID) { + hg.open('新增量測記錄', '/PCB/PCB013A?steelPlateID=' + obj.data.steelPlateID + '&steelPlateNo=' + obj.data.steelPlateNo, 700, 500); + } + } + + function View(obj) { + if (obj.data.steelPlateID) { + hg.open('檢視量測記錄', '/PCB/PCB013V?steelPlateID=' + obj.data.steelPlateID + '&steelPlateNo=' + obj.data.steelPlateNo, 1000, 500); + } + } + //新增按鈕 var toolbar = [{ text: '新增', diff --git a/AMESCoreStudio.Web/Views/PCB/PCB013A.cshtml b/AMESCoreStudio.Web/Views/PCB/PCB013A.cshtml new file mode 100644 index 00000000..59739b65 --- /dev/null +++ b/AMESCoreStudio.Web/Views/PCB/PCB013A.cshtml @@ -0,0 +1,113 @@ +@model AMESCoreStudio.WebApi.Models.AMES.SteelPlateMeasure +@{ Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
+ + +
+ +
+ +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ + +
+
+ +
+ +
+ +
+
+ + @Html.ValidationMessage("error") +
+
+ +
+
+
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/PCB/PCB013V.cshtml b/AMESCoreStudio.Web/Views/PCB/PCB013V.cshtml new file mode 100644 index 00000000..691bf7e4 --- /dev/null +++ b/AMESCoreStudio.Web/Views/PCB/PCB013V.cshtml @@ -0,0 +1,77 @@ +@{ + ViewData["Title"] = "檢視鋼板量測紀錄"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+ + +
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/SteelPlateMeasureController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/SteelPlateMeasureController.cs index 2fcf47fc..6119399c 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/SteelPlateMeasureController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/SteelPlateMeasureController.cs @@ -8,6 +8,7 @@ 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 { @@ -46,6 +47,62 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return steelPlateMeasure; } + /// + /// 鋼板編號紀錄 By 鋼板編號 + /// + /// + /// + /// + /// + [HttpGet("BySteelPlateID/{id}")] + public async Task> GetSteelPlateMeasureBySteelPlateID(int id, int page = 0, int limit = 10) + { + var q = from q1 in _context.SteelPlateMeasures.Where(w => w.SteelPlateID == id) + join q2 in _context.SteelPlateInfos on q1.SteelPlateID equals q2.SteelPlateID + join q3 in _context.UserInfoes on q1.CreateUserID equals q3.UserID + select new SteelPlateMeasureDto + { + SpMeasureID = q1.SpMeasureID, + SteelPlateID = q1.SteelPlateID, + SteelPlateNo = q2.SteelPlateNo, + MeasureResult = q1.MeasureResult, + Tension1 = q1.Tension1, + Tension2 = q1.Tension2, + Tension3 = q1.Tension3, + Tension4 = q1.Tension4, + Tension5 = q1.Tension5, + Remark = q1.Remark, + Status = q1.Status, + CreateUserID = q1.CreateUserID, + CreateDate = q1.CreateDate, + CreateUserName = q3.UserName + }; + + ResultModel result = new ResultModel(); + //紀錄筆數 + result.DataTotal = q.Count(); + + //Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + + result.Data = await q.OrderBy(o => o.CreateDate).ToListAsync(); + result.Data.Select(s => s.Status + = Enum.EnumPCB.GetDisplayName((Enum.EnumPCB.EnumSteelPlateStatus)System.Enum.Parse(typeof(Enum.EnumPCB.EnumSteelPlateStatus), s.Status))).ToList(); + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + /// /// 更新鋼板量測記錄資料檔 /// @@ -76,10 +133,10 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// /// 新增鋼板量測記錄資料檔 /// - /// + /// /// [HttpPost] - public async Task> PostSolderPasteRecord(SteelPlateMeasure steelPlateMeasure) + public async Task> PostSteelPlateMeasure(SteelPlateMeasure steelPlateMeasure) { ResultModel result = new ResultModel(); Helper helper = new Helper(_context); diff --git a/AMESCoreStudio.WebApi/DTO/AMES/SteelPlateMeasureDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/SteelPlateMeasureDto.cs new file mode 100644 index 00000000..62ecce52 --- /dev/null +++ b/AMESCoreStudio.WebApi/DTO/AMES/SteelPlateMeasureDto.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace AMESCoreStudio.WebApi.DTO.AMES +{ + /// + /// SteelPlateInfoDto 鋼板紀錄資料檔Dto + /// + public partial class SteelPlateMeasureDto + { + /// + /// 鋼板量測記錄ID + /// + + public int SpMeasureID { get; set; } + + /// + /// 鋼板ID + /// + + public int SteelPlateID { get; set; } + + /// + /// 鋼板編號 + /// + + public string SteelPlateNo { get; set; } + + /// + /// 張力_1 + /// + public string Tension1 { get; set; } + + /// + /// 張力_2 + /// + public string Tension2 { get; set; } + + /// + /// 張力_3 + /// + public string Tension3 { get; set; } + + /// + /// 張力_4 + /// + public string Tension4 { get; set; } + + /// + /// 張力_5 + /// + public string Tension5 { get; set; } + + /// + /// 檢查狀態 + /// + public string Status { get; set; } + + /// + /// 備註 + /// + + public string Remark { get; set; } + + /// + /// 判定結果 P=PASS ; F=FAIL ; N=未量測 + /// + public string MeasureResult { get; set; } + + /// + /// 建立UserID + /// + + public int CreateUserID { get; set; } = 0; + + /// + /// 建立User + /// + public string CreateUserName { get; set; } + + /// + /// 建立日期 + /// + + public DateTime CreateDate { get; set; } = DateTime.Now; + + } +} diff --git a/AMESCoreStudio.WebApi/Enums/EnumPCB.cs b/AMESCoreStudio.WebApi/Enums/EnumPCB.cs new file mode 100644 index 00000000..8139c80a --- /dev/null +++ b/AMESCoreStudio.WebApi/Enums/EnumPCB.cs @@ -0,0 +1,53 @@ +using System.ComponentModel; +using System.ComponentModel.DataAnnotations; +using System; +using System.Linq; +using System.Reflection; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc.Rendering; + +namespace AMESCoreStudio.WebApi.Enum +{ + /// + /// + /// + public class EnumPCB + { + /// + /// 鋼板量測狀態 + /// + public enum EnumSteelPlateStatus + { + /// + /// 上線前 + /// + [Display(Name = "上線前")] + A = 1, + + /// + /// 清洗後 + /// + [Display(Name = "清洗後")] + B = 2, + + /// + /// 每周點檢 + /// + [Display(Name = "每周點檢")] + C = 3 + } + + /// + /// Get Enum Display + /// + /// + /// + public static string GetDisplayName(System.Enum enumValue) + { + return enumValue.GetType()? + .GetMember(enumValue.ToString())?.First()? + .GetCustomAttribute()? + .Name; + } + } +} \ No newline at end of file