diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index cc98044c..553f4cd8 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -105,19 +105,59 @@ namespace AMESCoreStudio.Web.Controllers } /// - /// 不良狀態 Select + /// 不良群組 /// /// - private async Task GetNGReasonSelect() + private async Task GetNGGroupSelect() { - var result = await _fqcApi.GetNGReasons(); + var result = await _fqcApi.GetNGGroups(0); - var NGReasonList = new List(); + var NGGroupList = new List(); for (int i = 0; i < result.Count; i++) { - NGReasonList.Add(new SelectListItem(result[i].NGReasonDesc, result[i].NGReasonNo.ToString())); + NGGroupList.Add(new SelectListItem(result[i].NGGroupName, result[i].NGGroupNo.ToString())); } - ViewBag.NGReasonSelect = NGReasonList; + 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 }); } #endregion @@ -457,6 +497,7 @@ namespace AMESCoreStudio.Web.Controllers [HttpPost] public async Task FQC005Async(QcCriterion model) { + await GetQcQuotSelect(); if (ModelState.IsValid) { #region 判斷設定起訖數量區間是否有重疊 @@ -605,7 +646,7 @@ namespace AMESCoreStudio.Web.Controllers #endregion #region FQC007 FQC抽驗作業 - public async Task FQC007() + public IActionResult FQC007() { var model = new FqcDto(); return View(model); @@ -615,9 +656,15 @@ namespace AMESCoreStudio.Web.Controllers [HttpPost] public async Task FQC007Async(FqcDto model) { + if (string.IsNullOrWhiteSpace(model.InhouseNo)) + { + ModelState.AddModelError("error", "請輸入入庫單號"); + return View("FQC007", model); + } + IResultModel result; - result = await _fqcApi.GetFqcQuery(model.InhouseNo , model.SeqID); + result = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); //if (result.Success) //{ @@ -628,24 +675,41 @@ namespace AMESCoreStudio.Web.Controllers //{ // ModelState.AddModelError("error", result.Msg); //} - model = result.Data.FirstOrDefault(); + + + if (result.Data.Count() != 0) + { + model = result.Data.FirstOrDefault(); + model.h_InhouseNo = model.InhouseNo; + model.h_SeqID = model.SeqID.ToString(); + } + else + { + ModelState.AddModelError("error", "找不到入庫單號【" + model.InhouseNo + "】的資料"); + model.h_InhouseNo = ""; + model.h_SeqID = ""; + } + return View("FQC007", model); } [HttpGet] - public async Task FQC007C(string inhouseNo, int seq) + public async Task FQC007C(string inhouseNo, string seq) { await GetStatusTypeSelect(); - await GetNGReasonSelect(); - return View(); + await GetNGGroupSelect(); + var model = new FqcResultDto(); + model.InhouseNo = inhouseNo; + model.SeqID = int.Parse(seq); + return View(model); } [HttpPost] - public async Task FQC007CAsync(FqcResultDetail model) + public async Task FQC007CAsync(FqcResultDto model) { await GetStatusTypeSelect(); - await GetNGReasonSelect(); - if (string.IsNullOrWhiteSpace(model.BarcodeNo) && + await GetNGGroupSelect(); + if (string.IsNullOrWhiteSpace(model.BarcodeNo) && string.IsNullOrWhiteSpace(model.BoxNo) && string.IsNullOrWhiteSpace(model.ExtraBarcodeNo)) { @@ -653,29 +717,187 @@ namespace AMESCoreStudio.Web.Controllers 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 (ModelState.IsValid) + if (result_BarCodeInfo.Count == 0) { - IResultModel result; + ModelState.AddModelError("error", "找不到相關資料"); + return View("FQC007C", model); + } + else + model.BoxNo = result_BarCodeInfo.FirstOrDefault().BoxNo; + #endregion - result = await _fqcApi.PostStatusType(JsonConvert.SerializeObject(model)); + #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 - if (result.Success) - { - var _msg = "新增成功!"; - return RedirectToAction("Refresh", "Home", new { msg = _msg }); - } - else + #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 + }; + #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", result.Msg); + ModelState.AddModelError("error", "內部序號【" + FqcResultDetail.BarcodeNo + "】已抽驗過"); + return View("FQC007C", model); } } + #endregion - return View("FQC006C", model); - return View(); + #region Set_FqcResultMaster + var FqcResultMaster = new FqcResultMaster(); + if (result_FqcResultMaster.Count != 0) + { + FqcResultMaster = result_FqcResultMaster.FirstOrDefault(); + FqcResultMaster.QaQty += 1; + FqcResultMaster.UpdateDate = DateTime.Now; + } + 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; + } + + // 判斷是PASS || FAIL + if (model.StatusNo == "F") + FqcResultMaster.FailQty += 1; + else + FqcResultMaster.PassQty += 1; + #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) + { + var _msg = "新增成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + + + return View("FQC007C", model); } #endregion + [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; + return View(model); + } + + [HttpPost] + public async Task FQC007BAsync(FqcResultMaster model) + { + var fqcResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID); + var fqcInhouseMaster = await _fqcApi.GetFqcInhouseMaster(model.InhouseNo, model.SeqID); + if (model.QaResult == "P") + { + fqcResultMaster.QaResult = model.QaResult; + fqcResultMaster.QaMeno = model.QaMeno; + fqcResultMaster.EndTime = DateTime.Now; + fqcResultMaster.UpdateDate = DateTime.Now; + + fqcInhouseMaster.Status = model.QaResult; + fqcInhouseMaster.UpdateDate = DateTime.Now; + } + else + { + fqcResultMaster.QaResult = model.QaResult; + fqcResultMaster.QaMeno = model.QaMeno; + fqcResultMaster.EndTime = DateTime.Now; + fqcResultMaster.UpdateDate = DateTime.Now; + + fqcInhouseMaster.Status = model.QaResult; + fqcInhouseMaster.UpdateDate = DateTime.Now; + + //var qngInfo = new QngInfo(); + //qngInfo.FqcID = model.FqcID; + } + + IResultModel result; + result = await _fqcApi.PutFqcInhouseMaster(JsonConvert.SerializeObject(fqcInhouseMaster)); + result = await _fqcApi.PutFqcResultMaster(JsonConvert.SerializeObject(fqcResultMaster)); + if (result.Success) + { + var _msg = "新增成功!"; + return RedirectToAction("Refresh", "Home", new { msg = _msg }); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + + + return View("FQC007B", model); + } + #region FQC008 FQC查詢 public IActionResult FQC008() { diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index ced4092c..615b0530 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -276,21 +276,130 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/StatusType")] ITask> GetStatusType(); + + #endregion + + #region FQC007 FQC抽驗作業 /// - /// 不良現象-List + /// 新增FQC檢驗單結果 /// /// - [WebApiClient.Attributes.HttpGet("api/NGReasons")] - ITask> GetNGReasons(); - #endregion + [WebApiClient.Attributes.HttpPost("api/FqcResultMaster")] + ITask> PostFqcResultMaster([FromBody, RawJsonContent] string model); + + /// + /// 更新FQC檢驗單結果 + /// + /// + [WebApiClient.Attributes.HttpPut("api/FqcResultMaster")] + ITask> PutFqcResultMaster([FromBody, RawJsonContent] string model); + + /// + /// 新增FQC檢驗結果明細 + /// + /// + [WebApiClient.Attributes.HttpPost("api/FqcResultDetail")] + ITask> PostFqcResultDetail([FromBody, RawJsonContent] string model); + + /// + /// 更新入庫單 + /// + /// + [WebApiClient.Attributes.HttpPut("api/FqcInhouseMaster")] + ITask> PutFqcInhouseMaster([FromBody, RawJsonContent] string model); + + /// + /// 新增抽驗批退 + /// + /// + [WebApiClient.Attributes.HttpPost("api/QngInfo")] + ITask> PostQngInfo([FromBody, RawJsonContent] string model); - #region FQC007 FQC抽驗作業 /// /// 查詢過站狀態檔 ID /// /// [WebApiClient.Attributes.HttpGet("api/FqcInhouseMaster/FqcQuery/{inhouseNo}")] - ITask> GetFqcQuery(string inhouseNo,int seqid = 1); + ITask> GetFqcQuery(string inhouseNo,int? seqid = 1); + + /// + /// 獲取不良現象群組資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGGroups")] + ITask> GetNGGroups(int page = 1, int limit = 10); + + /// + /// 根据群組代碼獲取不良現象類別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGClasses/Group/{no}")] + ITask> GetNGClassesByGroup(string no, int page = 1, int limit = 10); + + + /// + /// 不良現象-List + /// + /// + [WebApiClient.Attributes.HttpGet("api/NGReasons/Class/{no}")] + ITask> GetNGReasonsByClass(string no , int page = 0, int limit = 1000); + + /// + /// 用內部序號取BarCode資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/BarcodeInfoes/No/{id}")] + ITask> GetBarcodeInfoesByNo(string id); + + /// + /// 用客戶序號取BarCode資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/BarcodeInfoes/ByExtraNo/{extraNo}")] + ITask> GetBarcodeInfoesByExtraNo(string extraNo); + + /// + /// 用包裝箱號取BarCode資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/BarcodeInfoes/ByBoxNo/{boxNo}")] + ITask> GetBarcodeInfoesByBoxNo(string boxNo); + + /// + /// 用入庫單號與序號取檢驗單結果 + /// + /// + [WebApiClient.Attributes.HttpGet("api/FqcResultMaster/ByInhouseNo/{inhouseNo}/{seq}")] + ITask> GetFqcResultMasterByInhouseNo(string inhouseNo,int seq); + + /// + /// 用入庫單號與序號取檢驗單明细資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/FqcInhouseDetail/{inhouseNo}/{seq}")] + ITask> GetFqcInhouseDetail(string inhouseNo, int seq); + + /// + /// 用FQCID取檢驗結果明細 + /// + /// + [WebApiClient.Attributes.HttpGet("api/FqcResultDetail/{id}")] + ITask> GetFqcResultDetail(int id); + + + /// + /// 用id取檢驗單結果 + /// + /// + [WebApiClient.Attributes.HttpGet("api/FqcResultMaster/{id}")] + ITask GetFqcResultMaster(int id); + + /// + /// 用id取檢驗單結果 + /// + /// + [WebApiClient.Attributes.HttpGet("api/FqcInhouseMaster/{inhouseNo}/{seqID}")] + ITask GetFqcInhouseMaster(string inhouseNo, int seqID); #endregion #region FQC008 FQC查詢 diff --git a/AMESCoreStudio.Web/Views/FQC/FQC006.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC006.cshtml index 0afff99b..8874c0bb 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC006.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC006.cshtml @@ -20,7 +20,7 @@ } \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007B.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007B.cshtml new file mode 100644 index 00000000..f5e0a5a8 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC007B.cshtml @@ -0,0 +1,115 @@ +@model AMESCoreStudio.WebApi.Models.AMES.FqcResultMaster + + +@{ + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+ + +
+
+ + + +
+
+
+ +
+
+
+
+
+ +
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+
+ @Html.ValidationMessage("error") +
+
+ +
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007C.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007C.cshtml index a8aa1636..1f921d3c 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007C.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007C.cshtml @@ -1,7 +1,7 @@ -@model AMESCoreStudio.WebApi.Models.AMES.FqcResultDetail +@model AMESCoreStudio.WebApi.DTO.AMES.FqcResultDto -@{ +@{ Layout = "~/Views/Shared/_AMESLayout.cshtml"; }