diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index 0ac82978..ec81e4d8 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -1,28 +1,23 @@ -using Microsoft.AspNetCore.Mvc; -using System.Threading.Tasks; -using Microsoft.Extensions.Logging; +using AMESCoreStudio.CommonTools.Result; using AMESCoreStudio.Web.Models; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using AMESCoreStudio.WebApi; -using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc.Rendering; +using AMESCoreStudio.WebApi.DTO.AMES; +using AMESCoreStudio.WebApi.Enum; 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 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.Hosting; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.StaticFiles; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; namespace AMESCoreStudio.Web.Controllers { @@ -843,11 +838,24 @@ namespace AMESCoreStudio.Web.Controllers 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) + // 2024/02/01 切換判斷 + if (model.CreateDate < new DateTime(2024, 2, 1)) { - model.qcItemDtos = result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); + //工單無設定檢驗工項時 在抓料號綁定檢驗工項 + 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 + { + // 改抓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(); + } } } else @@ -960,11 +968,24 @@ namespace AMESCoreStudio.Web.Controllers 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) + // 2024/02/01 切換判斷 + if (model.CreateDate < new DateTime(2024, 2, 1)) { - model.qcItemDtos = result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); + //工單無設定檢驗工項時 在抓料號綁定檢驗工項 + 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 + { + // 改抓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(); + } } } else @@ -981,6 +1002,20 @@ 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) { @@ -1302,11 +1337,24 @@ namespace AMESCoreStudio.Web.Controllers var qcItemDtos = new List(); if (result_WipFQC.Count == 0) { - //工單無設定檢驗工項時 在抓料號綁定檢驗工項 - var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(fqcItem.ItemNo); - if (result_MaterialFQC.Count != 0) + // 2024/02/01 切換判斷 + if (model.CreateDate < new DateTime(2024, 2, 1)) { - qcItemDtos = result_QcItem.Data.Where(w => result_MaterialFQC.Select(s => s.QcItemID).Contains(w.ItemID)).ToList(); + //工單無設定檢驗工項時 在抓料號綁定檢驗工項 + 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 + { + // 改抓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(); + } } } else @@ -1336,8 +1384,6 @@ 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); } } @@ -1350,16 +1396,12 @@ 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); } } } @@ -1385,6 +1427,9 @@ 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()); @@ -1393,6 +1438,11 @@ 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) { @@ -1617,9 +1667,31 @@ namespace AMESCoreStudio.Web.Controllers } [HttpGet] - public async Task FQC007AItemQuery(string wipNo, string itemNo) + public async Task FQC007AItemQuery(string wipNo, string itemNo, DateTime createDate) { - var result = await _fqcApi.GetQcItemQuery(0, 0, 0, itemNo, wipNo); + // 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); + } + else + { + result = await _fqcApi.GetQcItemQuery(0, 0, 0, wipNo: wipNo); + } + } + } return Json(new Table() { code = 0, data = result.Data, count = result.DataTotal }); } @@ -1898,7 +1970,7 @@ namespace AMESCoreStudio.Web.Controllers #endregion #region FQC010 報表 - public async Task FQC010_PDF(string inhouseNo, int seqID) + public IActionResult FQC010_PDF(string inhouseNo, int seqID) { string mimeType = ""; int extension = 1; @@ -1908,7 +1980,7 @@ namespace AMESCoreStudio.Web.Controllers return File(result.MainStream, "application/pdf"); } - public async Task FQC010_Excel(string inhouseNo, int seqID) + public IActionResult FQC010_Excel(string inhouseNo, int seqID) { string mimeType = ""; int extension = 1; @@ -1990,10 +2062,11 @@ namespace AMESCoreStudio.Web.Controllers var result_WipFQC = await _fqcApi.GetWipFqcItemByWipNo(FqcQuery.WipNo); if (result_WipFQC.Count == 0) { - //工單無設定檢驗工項時 在抓料號綁定檢驗工項 - var result_MaterialFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(FqcQuery.ItemNo); - if (result_MaterialFQC.Count != 0) + // 2024/02/01 切換判斷 + if (FqcQuery.CreateDate < new DateTime(2024, 2, 1)) { + //工單無設定檢驗工項時 在抓料號綁定檢驗工項 + 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()) { @@ -2005,6 +2078,20 @@ 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 { @@ -2280,6 +2367,289 @@ 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/Controllers/LABController.cs b/AMESCoreStudio.Web/Controllers/LABController.cs index 48ea1a94..4e36e627 100644 --- a/AMESCoreStudio.Web/Controllers/LABController.cs +++ b/AMESCoreStudio.Web/Controllers/LABController.cs @@ -15,6 +15,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Microsoft.AspNetCore.Mvc.Rendering; using AMESCoreStudio.WebApi.DTO.AMES; +using AMESCoreStudio.Web.ViewModels.LAB; +using System.Dynamic; namespace AMESCoreStudio.Web.Controllers { @@ -22,6 +24,7 @@ namespace AMESCoreStudio.Web.Controllers { public readonly ISYS _sysApi; public readonly ILAB _labApi; + public readonly IPCS _pcsApi; public LABController(ILogger logger, ILAB labApi, ISYS sysApi, IPCS pcsApi, IStringLocalizer sharedLocalizer) @@ -29,6 +32,7 @@ namespace AMESCoreStudio.Web.Controllers _sysApi = sysApi; _labApi = labApi; + _pcsApi = pcsApi; } @@ -166,42 +170,84 @@ namespace AMESCoreStudio.Web.Controllers #region LAB002 標籤樣板維護 - public IActionResult LAB002() + + /// + /// + /// + /// + /// + /// + /// + public async Task LAB002Async(string LabelMatnr, int page = 0, int limit = 10) { return View(); } + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetLabelTemplateDtoAsync(string LabelMatnr, int page = 0, int limit = 10) + { + var result = await _labApi.LabelTemplatebyMatnr(LabelMatnr, 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 }); + } + + + + //新增頁面 public IActionResult LAB002C() { GetUserID(); + @ViewBag.MasterID = 0; return View(); } - //修改页面 - [HttpGet] - public async Task LAB002UAsync(int id) - { - // var resultMaster = await _labApi.GetLabelTemplateMaster(id); - // var resultDetail = await _labApi.GetLabelTemplateDetail(id); - // var result = new LabelTemplateDto(); + public async Task CheckLabelMatnrAsync(string LabelMatnr) + { + //判斷為E209開頭的料號才可輸入 + if (LabelMatnr.StartsWith("E209")) + { + var PlmMeterial = await _pcsApi.GetPlmMeterialInfo(LabelMatnr); - // result.labelTemplateMaster = resultMaster; - // result.labelTemplateDetails = resultDetail; - // var result + if (PlmMeterial.Count > 0) + { + var Master = await _labApi.LabelTemplatebyMatnr(LabelMatnr,0,10); + if (Master.DataTotal > 0) + return Json(new Table() { count = 0, msg = "料號已存在", data = null }); + else + return Json(new Table() { code = 0, msg = "", data = PlmMeterial, count = 1 }); + } + else + return Json(new Table() { count = 0, msg = "料號不存在", data = null }); + } + else + return Json(new Table() { count = 0, msg = "請輸入Label料號", data = null }); + } - GetUserID(); + public async Task GetLabelTemplatebyMatnrAsync(int id) + { + var result = await _labApi.GetLabelTemplatebyMatnr(id); + // var result = await _labApi.GetLabelParams(); + if (result.Count > 0) + { + return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + } - return View(); + return Json(new Table() { count = 0, data = null }); } //頁面提交,id=0 添加,id>0 修改 [HttpPost] - public async Task LAB002CSaveAsync(LabelTemplateDto model) + public async Task LAB002CSaveAsync(LabelTemplateMaster model) { - GetUserID(); if (ModelState.IsValid) { IResultModel result; @@ -211,85 +257,126 @@ namespace AMESCoreStudio.Web.Controllers if (result.Success) { - var _msg = "添加成功!"; - return RedirectToAction("Refresh", "Home", new { msg = _msg }); + //var _msg = "添加成功!"; + return Json(new Result() { success = true, msg = result.Msg }); } else { - ModelState.AddModelError("error", result.Msg); - return View("LAB002C", model); + ModelState.AddModelError("error", result.Msg); + } } + return Json(new Result() { success = false, msg = "缺少必填資料!!" }); + + } + + public async Task DeleteLabelTemplateDetailAsync(int id) + { + var result = await _labApi.DeleteLabelTemplateDetail(id); + if (result.Success) + { + return Json(new Result() { success = true, msg = result.Msg }); + } else { - - ModelState.AddModelError("error", "缺少必填資料"); - return View("LAB002C", model); + return Json(new Result() { success = false, msg = "資料有誤!!" }); } } - - public async Task LAB002USaveAsync(LabelTemplateDto model) + + public async Task LAB002CListSaveAsync(LabelTemplateDetail model) { - if (ModelState.IsValid) - { - IResultModel result; - //result = await _labApi.PutLabeTemplateMaster(model.labelTemplateMaster.TemplateID, JsonConvert.SerializeObject(model.labelTemplateMaster)); - //foreach (var item in model.labelTemplateDetails) - //{ - // result = await _labApi.PutLabeTemplateDetail(item.TemplateDetailID, JsonConvert.SerializeObject(item)); - //} - - //if (result.Success) - //{ - // var _msg = "修改成功!"; - // return RedirectToAction("Refresh", "Home", new { msg = _msg }); - //} - //else - //{ - // GetUserID(); - // ModelState.AddModelError("error", result.Msg); - // return View("LAB002C", model); - - //} - return View("LAB002U", model); + + var result = await _labApi.PostLabelTemplateDetail(JsonConvert.SerializeObject(model)); + if (result.Success) + { + //var _msg = "添加成功!"; + return Json(new Result() { success = true, msg = result.Msg }); } else { - GetUserID(); - ModelState.AddModelError("error", "缺少必填資料"); - return View("LAB002U", model); + return Json(new Result() { success = false, msg = "資料有誤!!" }); } } - [ResponseCache(Duration = 0)] + //修改页面 [HttpGet] - public async Task GetLabelTemplateDtoAsync(string LabelMatnr, string Status, int page = 0, int limit = 10) + public async Task LAB002UAsync(int id) { - var result = await _labApi.GetLabelTemplateDto(LabelMatnr, Status, page, limit); + GetUserID(); + var result = await _labApi.GetLabelTemplateMaster(id); + if (result.LABEL_FILE == null) + { + return View(); + } + return View(result); + + } - if (result.Count > 0) + //頁面提交,id=0 添加,id>0 修改 + [HttpPost] + public async Task LAB002USaveAsync(LabelTemplateMaster model) + { + if (ModelState.IsValid) { - return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + IResultModel result; + + result = await _labApi.PutLabeTemplateMaster(JsonConvert.SerializeObject(model)); + + + if (result.Success) + { + //var _msg = "添加成功!"; + return Json(new Result() { success = true, msg = result.Msg }); + } + else + { + + ModelState.AddModelError("error", result.Msg); + + } } + return Json(new Result() { success = false, msg = "資料有誤!!" }); + //else + //{ - return Json(new Table() { count = 0, data = null }); + // ModelState.AddModelError("error", "缺少必填資料"); + // return View("LAB002C", model); + //} } - public async Task GetLabelTemplatebyMatnrAsync(int id) + public async Task LAB002UListSaveAsync(LabelTemplateDetail model) { - var result = await _labApi.GetLabelTemplatebyMatnr(id); - if (result.Count > 0) + + var result = await _labApi.PostLabelTemplateDetail(JsonConvert.SerializeObject(model)); + if (result.Success) { - return Json(new Table() { code = 0, msg = "", data = result, count = result.Count }); + //var _msg = "添加成功!"; + return Json(new Result() { success = true, msg = result.Msg }); } + else + { + return Json(new Result() { success = false, msg = "資料有誤!!" }); + } + } + + [HttpGet] + public async Task LAB002VAsync(int id) + { + GetUserID(); + var result = await _labApi.GetLabelTemplateMaster(id); + if (result.LABEL_FILE == null) + { + return View(); + } + return View(result); - return Json(new Table() { count = 0, data = null }); } #endregion + #region Lab003 public async Task LAB003(string mat) diff --git a/AMESCoreStudio.Web/Controllers/PCSController.cs b/AMESCoreStudio.Web/Controllers/PCSController.cs index b7ebb498..b3c98d2f 100644 --- a/AMESCoreStudio.Web/Controllers/PCSController.cs +++ b/AMESCoreStudio.Web/Controllers/PCSController.cs @@ -4735,7 +4735,7 @@ namespace AMESCoreStudio.Web.Controllers } // TestLog - var testLogResult = await _pcsApi.GetTestLogByMSSql(result.BarCodeNo); + var testLogResult = await _pcsApi.GetTestLog(result.BarCodeNo); foreach (var item in testLogResult) { var FileName = (string)item.filename; @@ -4754,12 +4754,34 @@ namespace AMESCoreStudio.Web.Controllers FilePath = $"{(string)item.workOrder}\{FileName}" }); } + + // 包裝秤重 + try + { + var packingWeighResult = await _pcsApi.GetPackingWeigh(result.ExtraBarCodeNo); + foreach (var item in packingWeighResult) + { + var RecordTime = ((DateTime)item.record_Time).ToString("yyyy/MM/dd HH:mm:ss"); + result.packingWeighs.Add(new PackingWeigh + { + Weight = item.weight, + Result = item.result, + Record_Time = RecordTime, + FileName = item.filename + }); + } + } + catch + { + + } + return View(result); } public async Task PCS009T(string sn, string id) { - var query = await _pcsApi.GetTestLogByMSSql(sn); + var query = await _pcsApi.GetTestLog(sn); var result = new List(); if (query.Any()) diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index 206ab056..6192f13b 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -81,9 +81,10 @@ namespace AMESCoreStudio.Web /// 比數 /// 料號 /// 工單號碼 + /// FQC檢驗設定群組 /// [WebApiClient.Attributes.HttpGet("api/QcItem/QcItemQuery")] - ITask> GetQcItemQuery(int groupID, int page, int limit, string itemNo = null, string wipNo = null); + ITask> GetQcItemQuery(int groupID, int page, int limit, string itemNo = null, string wipNo = null ,int fqcItemGroupId = 0) ; /// /// 查詢檢驗項目維護 ID @@ -411,7 +412,6 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/FqcResultDetail/{id}")] ITask> GetFqcResultDetail(int id); - /// /// 用id取檢驗單結果 /// @@ -462,6 +462,13 @@ 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抽驗過站 /// @@ -526,6 +533,28 @@ 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查詢 @@ -627,7 +656,7 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpDelete("api/FqcInhouseMaster/{no}/{seq}")] ITask> DeleteFqcInhouseMaster(string no, int seq); - + /// /// 刪除FQC 表身 @@ -637,5 +666,124 @@ 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/HttpApis/AMES/ILAB.cs b/AMESCoreStudio.Web/HttpApis/AMES/ILAB.cs index 87a2c187..c498f09c 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/ILAB.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/ILAB.cs @@ -104,14 +104,14 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpPut("api/LabelTemplateMaster")] - ITask> PutLabeTemplateMaster(int id, [FromBody, RawJsonContent] string model); + ITask> PutLabeTemplateMaster([FromBody, RawJsonContent] string model); /// /// Label 參數儲存 /// /// - [WebApiClient.Attributes.HttpPost("api/LabelTemplatDetail")] + [WebApiClient.Attributes.HttpPost("api/LabelTemplateDetail")] ITask> PostLabelTemplateDetail([FromBody, RawJsonContent] string model); /// @@ -122,6 +122,13 @@ namespace AMESCoreStudio.Web ITask> PutLabeTemplateDetail(int id, [FromBody, RawJsonContent] string model); + /// + /// Label 參數刪除 + /// + /// GroupID + /// + [WebApiClient.Attributes.HttpDelete("api/LabelTemplateDetail/{id}")] + ITask> DeleteLabelTemplateDetail(int id); @@ -143,15 +150,15 @@ namespace AMESCoreStudio.Web /// 獲取Label 全部參數資料 /// /// - [WebApiClient.Attributes.HttpGet("api/LabelTemplateMaster/LabelTemplatebyMatnr/{LabelMatnr}/{Status}")] - ITask> GetLabelTemplateDto(string LabelMatnr, string Status, int page, int limit); + [WebApiClient.Attributes.HttpGet("api/LabelTemplateMaster/byMatnr")] + ITask> LabelTemplatebyMatnr(string LabelMatnr, int page, int limit); /// /// 獲取Label 全部參數資料 /// /// - [WebApiClient.Attributes.HttpGet("api/LabelTemplateDetail/byTemplateIDMulti/{id}")] + [WebApiClient.Attributes.HttpGet("api/LabelParam/byMulti/{id}")] ITask> GetLabelTemplatebyMatnr(int id); diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 5246f8ae..708a57eb 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -16,7 +16,7 @@ namespace AMESCoreStudio.Web [JsonReturn] public interface IPCS : IHttpApi { - + ////////////////////////////////////// [WebApiClient.Attributes.HttpPost("api/BarCodeCheck/PassIngByCheck")] @@ -93,7 +93,7 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/WipInfos/GetWipInfoSelectParameter")] //ITask> GetWipInfoSelectParameter(string unitno = null, string wipno = null); ITask> GetWipInfoSelectParameter(string unitno = null, string wipno = null, int lineid = 0 - , string itemno = null, DateTime? date_str = null, DateTime? date_end = null, string wipType = null, string factoryno = null, int page = 0, int limit = 10 , string statusNo = null); + , string itemno = null, DateTime? date_str = null, DateTime? date_end = null, string wipType = null, string factoryno = null, int page = 0, int limit = 10, string statusNo = null); /// /// 查詢工單基本資料+是否已過站 @@ -1109,7 +1109,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/WipInfos/GetWipInfo4QRS011")] - ITask> GetWipInfo4QRS011(string unitNo, string itemNO, string wipNO , string wipStatus); + ITask> GetWipInfo4QRS011(string unitNo, string itemNO, string wipNO, string wipStatus); #endregion @@ -1171,7 +1171,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/FqcResultMaster/GetFQCHeaderData4QRS016")] - ITask> GetFQCHeaderData4QRS016(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd ,string factoryID); + ITask> GetFQCHeaderData4QRS016(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd, string factoryID); /// /// FQC查詢報表 細項統計 @@ -1414,7 +1414,7 @@ namespace AMESCoreStudio.Web /// WIPID /// [WebApiClient.Attributes.HttpGet("api/FqcInhouseDetail/GetCheckFqcOnGoIng")] - ITask> GetCheckFqcOnGoIng(string boxNo , int wipId); + ITask> GetCheckFqcOnGoIng(string boxNo, int wipId); #endregion #region 取出貨序號 @@ -1549,7 +1549,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpGet("api/WipClears")] - ITask> GetWipClears(string wipNo,string itemNo,string dateStart,string dateEnd,int page, int limit); + ITask> GetWipClears(string wipNo, string itemNo, string dateStart, string dateEnd, int page, int limit); /// /// 新增清線資料 @@ -1701,7 +1701,7 @@ namespace AMESCoreStudio.Web /// /// [WebApiClient.Attributes.HttpPost("http://192.168.4.109:5088/api/WareHouseing")] - ITask> PostWareHouseing_EVER([FromBody, RawJsonContent] string model); + ITask> PostWareHouseing_EVER([FromBody, RawJsonContent] string model); /// /// FQC抽驗資料 /// @@ -1808,7 +1808,7 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/SerialRuleDetails/SerialRuleDetailbyPCS040/{id}")] ITask> GetSerialRuleDetailbyPCS040(int id); - + /// /// 查詢SerialRuleDetail /// @@ -1935,11 +1935,12 @@ namespace AMESCoreStudio.Web ITask> GetTestLog(string id); /// - /// Test Log 查詢 + /// 包裝秤重 查詢 /// + /// 出貨序號 /// - [WebApiClient.Attributes.HttpGet("api/TestLog/ByMSSql/{id}")] - ITask> GetTestLogByMSSql(string id); + [WebApiClient.Attributes.HttpGet("api/TestLog/PackingWeigh/{id}")] + ITask> GetPackingWeigh(string id); #endregion @@ -1966,7 +1967,7 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/WipInfos/GetData4PTD003")] ITask> GetData4PTD003(string recordType, string recordNumber, string lineNo, string materialNo, string shippingSN, string dateStart, string dateEnd); - + [WebApiClient.Attributes.HttpGet("api/WipInfos/GetCustomer/{recordNumber}")] ITask GetCustomer(string recordNumber); #endregion diff --git a/AMESCoreStudio.Web/ViewModels/LAB/LAB002ViewModel.cs b/AMESCoreStudio.Web/ViewModels/LAB/LAB002ViewModel.cs new file mode 100644 index 00000000..1b1ee94e --- /dev/null +++ b/AMESCoreStudio.Web/ViewModels/LAB/LAB002ViewModel.cs @@ -0,0 +1,34 @@ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace AMESCoreStudio.Web.ViewModels.LAB +{ + public class LAB002ViewModel + { + + public LAB002ViewModel() + { + LabData = new List(); + } + + public List LabData { get; set; } + } + + public class LabelParamGroup + { + + /// + /// 欄位 + /// + public string Param { get; set; } + + /// + /// 值 + /// + public double Value { get; set; } + } + +} diff --git a/AMESCoreStudio.Web/ViewModels/PCS/PCS009RViewModel.cs b/AMESCoreStudio.Web/ViewModels/PCS/PCS009RViewModel.cs index d206db3c..bda4eead 100644 --- a/AMESCoreStudio.Web/ViewModels/PCS/PCS009RViewModel.cs +++ b/AMESCoreStudio.Web/ViewModels/PCS/PCS009RViewModel.cs @@ -21,6 +21,7 @@ namespace AMESCoreStudio.Web.ViewModels.PCS Outfits = new List(); nGInfoDtos = new List(); testLogs = new List(); + packingWeighs = new List(); } /// @@ -101,6 +102,13 @@ namespace AMESCoreStudio.Web.ViewModels.PCS get; set; } + /// + /// 包裝秤重 + /// + public List packingWeighs + { + get; set; + } } /// @@ -319,4 +327,35 @@ namespace AMESCoreStudio.Web.ViewModels.PCS /// public string FilePath { get; set; } } + + /// + /// 包裝秤重 + /// + public class PackingWeigh + { + /// + /// 重量 + /// + public string Weight { get; set; } + + /// + /// 結果 + /// + public string Result { get; set; } + + /// + /// 測試時間 RECORD_TIME + /// + public string Record_Time { get; set; } + + /// + /// 檔案名稱 + /// + public string FileName { get; set; } + + /// + /// 檔案路徑 + /// + public string FilePath { get; set; } + } } diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml index 0c8c242d..36d07e6a 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml @@ -64,6 +64,7 @@ +
@@ -691,7 +692,7 @@ area: ['700px', '500px'], fixed: false, //不固定 maxmin: true, - content: '/FQC/FQC007A?wipNo=@Model.WipNo&itemNo=@Model.ItemNo', + content: '/FQC/FQC007A?wipNo=@Model.WipNo&itemNo=@Model.ItemNo&createDate=@Model.CreateDate.ToShortDateString()', end: function () { window.location.reload(); } diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml index 84ba9017..183a2aa6 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml @@ -14,6 +14,7 @@
+
@@ -31,7 +32,7 @@ } +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/LAB/LAB002C.cshtml b/AMESCoreStudio.Web/Views/LAB/LAB002C.cshtml new file mode 100644 index 00000000..fa6f534a --- /dev/null +++ b/AMESCoreStudio.Web/Views/LAB/LAB002C.cshtml @@ -0,0 +1,444 @@ +@model AMESCoreStudio.WebApi.Models.AMES.LabelTemplateMaster + +@{ + ViewData["Title"] = "Label料號參數新增"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ + + + + + +
+
+ + + +
+
+ +
+
+ + + +
+
+
+
+ + +
+
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ +
+ + +
+
+
+
+
+
+ +
+
+ + +
+
+
+ @Html.ValidationMessage("error") + +
+ +
+
+
+
+
+ +
+ +
+
+
+ +@*備註*@ + +@section Scripts{ + +} + diff --git a/AMESCoreStudio.Web/Views/LAB/LAB002U.cshtml b/AMESCoreStudio.Web/Views/LAB/LAB002U.cshtml new file mode 100644 index 00000000..c50dffc9 --- /dev/null +++ b/AMESCoreStudio.Web/Views/LAB/LAB002U.cshtml @@ -0,0 +1,406 @@ +@model AMESCoreStudio.WebApi.Models.AMES.LabelTemplateMaster + + +@{ + ViewData["Title"] = "Label料號參數修改"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ + + + + +
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + +
+
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + +
+
+ +
+
+ +
+ + +
+
+
+
+
+
+ +
+
+ +
+
+
+ @Html.ValidationMessage("error") + +
+ +
+
+ + +
+ +
+
+
+ +
+
+
+
+
+ +@*備註*@ + +@section Scripts{ + +} + diff --git a/AMESCoreStudio.Web/Views/LAB/LAB002V.cshtml b/AMESCoreStudio.Web/Views/LAB/LAB002V.cshtml new file mode 100644 index 00000000..144b3134 --- /dev/null +++ b/AMESCoreStudio.Web/Views/LAB/LAB002V.cshtml @@ -0,0 +1,163 @@ +@model AMESCoreStudio.WebApi.Models.AMES.LabelTemplateMaster + + +@{ + ViewData["Title"] = "Label料號參數檢視"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+ + + + + + +
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+
+ + + +
+
+
+ +
+ +
+ + 上架中 +
+ +
+ + 未上架 +
+
+
+
+
+
+ +
+
+
+ @*
*@ +
+
+ +@*備註*@ + +@section Scripts{ + +} + diff --git a/AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml b/AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml index 052d4858..cbb14c86 100644 --- a/AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml +++ b/AMESCoreStudio.Web/Views/PCS/PCS009R.cshtml @@ -280,6 +280,60 @@
} + @if (Model.packingWeighs.Count != 0) + { +
+
+ 包裝秤重 +
+ + + + + + + + + + + @foreach (var index in Model.packingWeighs) + { + + + + + + + } + +
+ 結果 + + 秤重時間 + + 秤重值 + + 檔案名稱 +
+ @if (index.Result == "FAIL") + { + @index.Result + } + else + { + @index.Result + } + + @index.Record_Time + + @index.Weight + + @index.FileName + @*檔案下載*@ +
+
+ } +
組件清單 diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs index ce1b3305..f53eaf92 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseDetailController.cs @@ -1,16 +1,14 @@ -using System; +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.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 { @@ -72,32 +70,33 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); var fqcResultDto = new List(); - var FqcInhouseDetails = await _context.FqcInhouseDetails.Where(w => w.SerialNo == boxNo && w.InhouseNo == inhouseNo - && w.SeqID == seqID).FirstOrDefaultAsync(); + 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(); // 取FQC_ID - if (FqcInhouseDetails != null) + if (fqcResultDto.Any()) { - 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) + var FqcResultMaster = await _context.FqcResultMasters.Where(w => w.InhouseNo == inhouseNo + && w.SeqID == seqID) .FirstOrDefaultAsync(); // 取抽驗結果 if (FqcResultMaster != null) @@ -110,7 +109,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { if (item.BarcodeNo == item2.BarcodeNo) { - item2.StatusNo = item.StatusNo; + item2.StatusNo = item.StatusNo == "P" ? "PASS" : "NG"; 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; @@ -145,54 +144,51 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { ResultModel result = new ResultModel(); var fqcResultDto = new List(); - var FqcInhouseDetails = await _context.FqcInhouseDetails.Where(w => w.InhouseNo == inhouseNo - && w.SeqID == seqID).ToListAsync(); + 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(); // 取FQC_ID - if (FqcInhouseDetails.Count != 0) + if (fqcResultDto.Any()) { - foreach (var item in FqcInhouseDetails) + var FqcResultMaster = await _context.FqcResultMasters.Where(w => w.InhouseNo == inhouseNo + && w.SeqID == seqID) + .FirstOrDefaultAsync(); + if (FqcResultMaster != null) { - 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(); - - // 取抽驗結果 - if (FqcResultMaster != null) + var FqcResultDetail = await _context.FqcResultDetails.Where(w => w.FqcID == FqcResultMaster.FqcID).ToListAsync(); + foreach (var item in fqcResultDto) { - var FqcResultDetail = await _context.FqcResultDetails.Where(w => w.FqcID == FqcResultMaster.FqcID).ToListAsync(); - foreach (var item1 in FqcResultDetail) + // 取抽驗結果 + if (FqcResultMaster != null) { - foreach (var item2 in fqcResultDto) + foreach (var item1 in FqcResultDetail) { - if (item1.BarcodeNo == item2.BarcodeNo) + if (item1.BarcodeNo == item.BarcodeNo) { - 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); + 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); continue; } } @@ -222,7 +218,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 e56034fa..b8239287 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcInhouseMasterController.cs @@ -10,6 +10,8 @@ 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 { @@ -222,7 +224,6 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { resultQuery = resultQuery.Skip((page - 1) * limit).Take(limit).ToList(); } - result.Data = resultQuery; // 判斷結束時間 @@ -305,7 +306,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES Note = q2.Note, InspectionStatus = q2.InspectionStatus, Description = q4.Description, - LocationNo = q1.LocationNo + LocationNo = q1.LocationNo, + CreateDate = q1.CreateDate }; var query = await q.Distinct().ToListAsync(); @@ -320,15 +322,17 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { var Detail = _context.FqcInhouseDetails.Where(w => w.InhouseNo == inhouseNo && w.SeqID == seqid); - foreach (var item in Detail) + foreach (var serialNo in Detail.Select(s => s.SerialNo).Distinct()) { // 取抽驗結果明細檔資料 var FqcResultDetail = _context.FqcResultDetails.Where(w => w.FqcID == query.FirstOrDefault().FqcID - && w.BoxNo == item.SerialNo).ToList(); + && w.BoxNo == serialNo).ToList(); + var barInfoBoxCount = _context.BarcodeInfoes.Where(w => w.BoxNo == serialNo).Count(); + var FqcInhouseDetailBoxCount = Detail.Where(w => w.SerialNo == serialNo).Count(); FqcDetail.Add(new FqcDto.FqcDetailDto { - SerialNo = item.SerialNo, - Qty = _context.BarcodeInfoes.Where(w => w.BoxNo == item.SerialNo).Count(), + SerialNo = serialNo, + Qty = barInfoBoxCount == 0 ? FqcInhouseDetailBoxCount : barInfoBoxCount, HasQty = FqcResultDetail.Count(), PassQty = FqcResultDetail.Where(w => w.StatusNo != "F").Count(), FailQty = FqcResultDetail.Where(w => w.StatusNo == "F").Count() @@ -369,6 +373,89 @@ 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 1b0d01fb..26865ac9 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemController.cs @@ -7,11 +7,13 @@ 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檢驗結果ID + /// FQC檢驗項目群組綁定設定檔 /// [Route("api/[controller]")] [ApiController] @@ -24,104 +26,134 @@ 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); - - if (fqcItem == null) - { - return NotFound(); - } - return 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) + /// + /// FQC檢驗項目群組綁定設定檔 to GroupID(FQC檢驗群組) + /// + /// 料號 + /// + [HttpGet("ByFqcGroupId/{id}")] + public async Task> GetFqcItemByFqcGroupId(int id) { - if (id != fqcItem.FqcID) - { - return BadRequest(); - } + IQueryable q = _context.FqcItems; + var result = await q.Where(p => p.GroupId == id).ToListAsync(); + return result; + } + + /// + /// 料號查詢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(); + } + /// + /// 更新檢驗項目群組綁定設定檔 + /// + /// + /// + [HttpPut] + public async Task> PutFqcItem(FqcItem fqcItem) + { + ResultModel result = new ResultModel(); _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 (DbUpdateConcurrencyException) + catch (Exception ex) { - if (!FqcItemExists(id)) - { - return NotFound(); - } - else - { - throw; - } + result.Success = false; + result.Msg = ex.InnerException.Message; } - - return NoContent(); + return result; } - // 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 (DbUpdateException) + catch (Exception ex) { - if (FqcItemExists(fqcItem.FqcID)) - { - return Conflict(); - } - else - { - throw; - } + result.Success = false; + result.Msg = ex.InnerException.Message; } - - return CreatedAtAction("GetFqcItem", new { id = fqcItem.FqcID }, fqcItem); + return result; } // 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); - if (fqcItem == null) + + try { - return NotFound(); + if (fqcItem == null) + { + result.Success = false; + result.Msg = "找不到要刪除資料"; + } + else + { + _context.FqcItems.Remove(fqcItem); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } } - - _context.FqcItems.Remove(fqcItem); - await _context.SaveChangesAsync(); - - return fqcItem; - } - - private bool FqcItemExists(int id) - { - return _context.FqcItems.Any(e => e.FqcID == id); + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; } } } diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupController.cs new file mode 100644 index 00000000..3b4f284d --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupController.cs @@ -0,0 +1,196 @@ +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 new file mode 100644 index 00000000..5e1412f7 --- /dev/null +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcItemGroupMaterialController.cs @@ -0,0 +1,159 @@ +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 361758cd..390b12be 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterController.cs @@ -345,6 +345,39 @@ 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/LabelParamController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/LabelParamController.cs index a3371c6c..9d12324d 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/LabelParamController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/LabelParamController.cs @@ -145,7 +145,37 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return LabelParam; } + //// GET: api/LabelTemplateDetail/5 + [HttpGet("byMulti/{id}")] + public async Task>> GetLabelParambyTemplateIDMulti(int id) + { + + var query = from p in _context.LabelParam.Where(w => w.STATUS_NO == "Y") + select new + { + p.LABEL_FIELD_ID, + p.LABEL_FIELD_NAME, + DATA = "0" + }; + if (id != 0) + { + query = from p in _context.LabelParam.Where(w => w.STATUS_NO == "Y") + join d in _context.LabelTemplateDetail.Where(w => w.TEMPLATE_ID == id) + on new { p.LABEL_FIELD_ID } equals new { d.LABEL_FIELD_ID } into joined + from sub in joined.DefaultIfEmpty() + select new + { + p.LABEL_FIELD_ID, + p.LABEL_FIELD_NAME, + DATA = sub == null ? "0" : "1" + }; + } + // 执行查询 + var result = query.ToList(); + return result; + + } private bool LabelParamExists(int id) { return _context.LabelParam.Any(e => e.LABEL_FIELD_ID == id); diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/LabelTemplateDetailController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/LabelTemplateDetailController.cs index 55015abf..f399c613 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/LabelTemplateDetailController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/LabelTemplateDetailController.cs @@ -36,36 +36,19 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES [HttpGet("{id}")] public async Task>> GetLabelTemplateDetail(int id) { - var labelTemplateDetail = await _context.LabelTemplateDetail.Where(w=>w.TEMPLATE_ID == id).ToListAsync(); + IQueryable q = _context.LabelTemplateDetail; + q = q.Where(p => p.TEMPLATE_ID.Equals(id)); + var LabelTemplatedetail = await q.ToListAsync(); - return labelTemplateDetail; - } - - //// GET: api/LabelTemplateDetail/5 - //[HttpGet("byTemplateIDMulti/{id}")] - //public async Task>> GetLabelTemplateDetailbyTemplateIDMulti(int id) - //{ - // var q = from p in _context.LabelParam - // join d in _context.LabelTemplateDetail - // on new { p.LABEL_FIELD_ID, TemplateID = id } equals new { d.LABEL_FIELD_ID, d.TEMPLATE_ID } into d1 - // from subd in d1.DefaultIfEmpty() - // where p.StatusNo == "Y" - // select new - // { - // LabelFieldID = p.LabelFieldID, - // LabelFieldName = p.LabelFieldName, - // ParamName = p.ParamName, - // TemplateID = subd != null ? 1 : 0 //有此欄位則顯示為1 沒有就為0 - // }; - - - - // var query = await q.ToListAsync(); - - // return query; - //} + if (LabelTemplatedetail == null) + { + return NotFound(); + } + return LabelTemplatedetail; + } + /// /// 更新Label參數檔 /// @@ -108,8 +91,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES try { - Helper helper = new Helper(_context); - LabelTemplateDetail.TEMPLATE_ID = helper.GetIDKey("TEMPLATE_ID").Result; + _context.LabelTemplateDetail.Add(LabelTemplateDetail); await _context.SaveChangesAsync(); result.Success = true; @@ -125,18 +107,24 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES // DELETE: api/LabelTemplateDetail/5 [HttpDelete("{id}")] - public async Task> DeleteLabelTemplateDetail(int id) + public async Task> DeleteLabelTemplateDetail(int id) { - var LabelTemplateDetail = await _context.LabelTemplateDetail.FindAsync(id); - if (LabelTemplateDetail == null) + + ResultModel result = new ResultModel(); + var query = await _context.LabelTemplateDetail.Where(w => w.TEMPLATE_ID == id).ToListAsync(); + try { - return NotFound(); + _context.LabelTemplateDetail.RemoveRange(query); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; } - - _context.LabelTemplateDetail.Remove(LabelTemplateDetail); - await _context.SaveChangesAsync(); - - return LabelTemplateDetail; + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; } private bool LabelTemplateDetailExists(int id) diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/LabelTemplateMasterController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/LabelTemplateMasterController.cs index cb60fe2a..1b85cdc9 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/LabelTemplateMasterController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/LabelTemplateMasterController.cs @@ -59,10 +59,8 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES ResultModel result = new ResultModel(); _context.Entry(LabelTemplateMaster).State = EntityState.Modified; //設置容器空間某一個模型的某一個欄位 不提交到資料庫 - _context.Entry(LabelTemplateMaster).Property("CreateDate").IsModified = false; - _context.Entry(LabelTemplateMaster).Property("CreateUserID").IsModified = false; - LabelTemplateMaster.UPDATE_DATE = DateTime.Now; - LabelTemplateMaster.UPDATE_USERID = 0; + _context.Entry(LabelTemplateMaster).Property("CREATE_DATE").IsModified = false; + _context.Entry(LabelTemplateMaster).Property("CREATE_USERID").IsModified = false; try { @@ -90,12 +88,22 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES try { - Helper helper = new Helper(_context); - LabelTemplateMaster.TEMPLATE_ID = helper.GetIDKey("TEMPLATE_ID").Result; - _context.LabelTemplateMaster.Add(LabelTemplateMaster); - await _context.SaveChangesAsync(); - result.Success = true; - result.Msg = "OK"; + IQueryable q = _context.LabelTemplateMaster; + q=q.Where(w => w.LABEL_MATNR.Equals(LabelTemplateMaster.LABEL_MATNR)); + if (q.Count() == 0) + { + Helper helper = new Helper(_context); + LabelTemplateMaster.TEMPLATE_ID = helper.GetIDKey("TEMPLATE_ID").Result; + _context.LabelTemplateMaster.Add(LabelTemplateMaster); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = LabelTemplateMaster.TEMPLATE_ID.ToString(); + } + else { + + result.Success = false; + result.Msg = "Label料號已新增"; + } } catch (Exception ex) { @@ -122,23 +130,19 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } // GET: api/LabelTemplateMaster/5 - [HttpGet("LabelTemplatebyMatnr/{LabelMatnr}/{Status}")] - public async Task>> GetLabelTemplatebyMatnr(string LabelMatnr, string Status, int page = 0, int limit = 10) + [HttpGet("byMatnr")] + public async Task> GetLabelTemplatebyMatnr(string LabelMatnr, int page = 0, int limit = 10) { - + ResultModel result = new ResultModel(); + IQueryable q = _context.LabelTemplateMaster; if (!string.IsNullOrEmpty(LabelMatnr) && LabelMatnr != "*") { - q.Where(w => w.LABEL_MATNR.Equals(LabelMatnr)); + q = q.Where(w => w.LABEL_MATNR.StartsWith(LabelMatnr)); } - - if (!string.IsNullOrEmpty(Status) && Status != "*") - { - q.Where(w => w.STATUS_NO.Equals(Status) ); - } - + result.DataTotal = q.Count(); if (page > 0) { q = q.OrderBy(p => p.LABEL_MATNR).Skip((page - 1) * limit).Take(limit); @@ -149,64 +153,15 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES } var labelTemplateMasters = await q.ToListAsync(); + // 紀錄筆數 + - - - return labelTemplateMasters; + result.Data = labelTemplateMasters; + return result; } - //// GET: api/LabelTemplateMaster/5 - //[HttpGet("LabelTemplateMulti/{LabelMatnr}/{Status}")] - //public async Task>> GetLabelTemplateDto(string LabelMatnr, string Status, int page = 0, int limit = 10) - //{ - // List TemplateDtoList = new List(); - // var LabelTemplateMaster = await _context.LabelTemplateMaster.Where(w => w.LabelMatnr == LabelMatnr).ToListAsync(); - // foreach (var item in LabelTemplateMaster) - // { - // var LabelTemplateDetail = await _context.LabelTemplateDetails.Where(w => w.TemplateID == item.TemplateID).ToListAsync(); - - // var TemplateDto= new LabelTemplateDto - // { - // TemplateID = item.TemplateID, - // LabelMatnr = item.LabelMatnr, - // LabelFile = item.LabelFile, - // ImageName = item.ImageName, - // Remark = item.Remark, - // CreateDate = item.CreateDate, - // CreateUserID = item.CreateUserID, - // UpdateDate = item.UpdateDate, - // UpdateUserID = item.UpdateUserID - - // }; - - // foreach (var item1 in LabelTemplateDetail) - // { - // TemplateDto.labelTemplateDetails.Add(new Models.AMES.LabelTemplateDetail - // { - // TemplateID = item1.TemplateID, - // LabelFieldID = item1.LabelFieldID, - // CreateDate = item1.CreateDate, - // CreateUserID = item1.CreateUserID, - // UpdateDate = item1.UpdateDate, - // UpdateUserID = item1.UpdateUserID - // }); - - // } - - // TemplateDtoList.Add(TemplateDto); - - - // } - - // if (LabelTemplateMaster == null) - // { - // return NotFound(); - // } - - // return TemplateDtoList; - - //} + private bool LabelTemplateMasterExists(int id) { diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialItemController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialItemController.cs index 734bc238..4971d029 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 = q.Where(p => p.ItemNo == id).FirstOrDefault(); + var result = await q.Where(p => p.ItemNo == id).FirstOrDefaultAsync(); return result; } @@ -87,6 +87,18 @@ 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 d8501646..78b52aba 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs @@ -56,9 +56,10 @@ 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) + public async Task> GetQcItemQuery(int groupID = 0, int page = 0, int limit = 10, string itemNo = null, string wipNo = null, int fqcItemGroupId = 0) { IQueryable q = _context.QcItems; ResultModel result = new ResultModel(); @@ -75,8 +76,6 @@ 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, @@ -91,19 +90,30 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES GroupNameEN = s.GetQcGroup.GroupNameCN ?? "", ItemType = s.Type }).ToListAsync(); + // 先判斷工單是否有資料 - var wipFqcItem = await _context.WipFqcItems.Where(w => w.WipNo == wipNo).ToListAsync(); - if (wipFqcItem.Count != 0) + if (!string.IsNullOrWhiteSpace(wipNo)) { - foreach (var item in result.Data) + var wipFqcItem = await _context.WipFqcItems.Where(w => w.WipNo == wipNo).ToListAsync(); + if (wipFqcItem.Count != 0) { - if (wipFqcItem.Where(w => w.QcItemID == item.ItemID).Any()) - item.check = true; + 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; } } - else + + // 有輸入料號跟QCITEM 比對有資料打勾 + if (!string.IsNullOrWhiteSpace(itemNo)) { - // 有輸入料號跟QCITEM 比對有資料打勾 var itemID = _context.MaterialItems.Where(w => w.ItemNo == itemNo).FirstOrDefault(); if (itemID != null) { @@ -116,6 +126,17 @@ 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 3fe31a14..154d675e 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipFqcItemController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipFqcItemController.cs @@ -8,6 +8,8 @@ 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 { @@ -113,6 +115,59 @@ 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/Controllers/BLL/TestLogController.cs b/AMESCoreStudio.WebApi/Controllers/BLL/TestLogController.cs index 788fce0f..67d051d4 100644 --- a/AMESCoreStudio.WebApi/Controllers/BLL/TestLogController.cs +++ b/AMESCoreStudio.WebApi/Controllers/BLL/TestLogController.cs @@ -41,30 +41,13 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL _context = context; } - /// /// 查詢 TestLog /// /// 條碼 /// [HttpGet("{id}")] - public List GetTestLog(string id) - { - var query = @$" SELECT * FROM JHAMES.TEST_FUNCTION_TABLE WHERE SN=:id"; - - DynamicParameters p = new DynamicParameters(); - p.Add("id", id, DbType.String); - var q = _context.Database.DapperQuery(query, p); - return q.ToList(); - } - - /// - /// 查詢 TestLog ByMSSql - /// - /// 條碼 - /// - [HttpGet("ByMSSql/{id}")] - public async Task> GetTestLogByMSSql(string id) + public async Task> GetTestLog(string id) { var context = _config.GetConnectionString("TestLogConnection"); using (IDbConnection _TestLog_context = new SqlConnection(context)) @@ -103,5 +86,29 @@ namespace AMESCoreStudio.WebApi.Controllers.BLL return q.ToList(); } } + + /// + /// 查詢 是否有包裝秤重 + /// + /// 出貨序號 + /// + [HttpGet("PackingWeigh/{id}")] + public async Task> GetPackingWeighing(string id) + { + var context = _config.GetConnectionString("TestLogConnection"); + using (IDbConnection _TestLog_context = new SqlConnection(context)) + { + if (_TestLog_context.State != ConnectionState.Open) + { + _TestLog_context.Open(); + } + var query = @$" SELECT * FROM TestAutomate.dbo.Packing_Weighing_View + WHERE SN =@Sn "; + DynamicParameters p = new DynamicParameters(); + p.Add("Sn", id, DbType.String); + var q = await _TestLog_context.QueryAsync(query, p); + return q.ToList(); + } + } } } diff --git a/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs index 85777e3c..1b885659 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs @@ -375,7 +375,15 @@ 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 b970b3a0..75da362d 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; } = "P"; + public string StatusNo { get; set; } /// /// IsSample diff --git a/AMESCoreStudio.WebApi/Models/AMES/FqcItem.cs b/AMESCoreStudio.WebApi/Models/AMES/FqcItem.cs index bc1b9e88..f3cd5815 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/FqcItem.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/FqcItem.cs @@ -2,51 +2,47 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using Microsoft.EntityFrameworkCore; using System.Runtime.Serialization; +using Microsoft.EntityFrameworkCore; #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 { - /// - /// FQC檢驗結果ID + /// ID /// [Key] [DataMember] - [Display(Name = "FQC檢驗結果ID")] - [Required(ErrorMessage = "{0},不能空白")] - [Column("FQC_ID")] - public int FqcID { get; set; } + [Column("FQC_ITEM_ID")] + public int FqcItemId { get; set; } /// - /// 细目序號ID + /// FQC檢驗項目群組ID + /// + [DataMember] + [Column("GROUP_ID")] + public int GroupId { get; set; } + + /// + /// 檢驗類別ID /// - [Key] [DataMember] - [Display(Name = "细目序號ID")] - [Required(ErrorMessage = "{0},不能空白")] - [Column("ITEM_ID")] - public int ItemID { get; set; } + [Column("QC_GROUP_ID")] + public int QcGroupId { get; set; } /// - /// 细目内容 + /// 檢驗項目ID /// [DataMember] - [Display(Name = "细目内容")] - [Required(ErrorMessage = "{0},不能空白")] - [Column("ITEM_CONTENT")] - [StringLength(200)] - public string ItemContent { get; set; } + [Column("QC_ITEM_ID")] + public int QcItemId { get; set; } /// /// 建立UserID diff --git a/AMESCoreStudio.WebApi/Models/AMES/LabelTemplateDetail.cs b/AMESCoreStudio.WebApi/Models/AMES/LabelTemplateDetail.cs index 0fd9b5ce..973a3031 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/LabelTemplateDetail.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/LabelTemplateDetail.cs @@ -12,6 +12,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// /// 標籤樣本細項 /// + [Keyless] [Table("LABEL_TEMPLATE_DETAIL", Schema = "JHAMES")] [DataContract] public class LabelTemplateDetail @@ -19,25 +20,19 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// /// 樣版ID /// - [Key] [Column("TEMPLATE_ID")] [DataMember] + [Required(ErrorMessage = "{0},不能空白")] public int TEMPLATE_ID { get; set; } - - /// - /// - /// - [Column("TEMPLATE_DETAIL_ID")] - [DataMember] - public int TEMPLATE_DETAIL_ID { get; set; } - /// /// 標籤檔案ID /// + /// [Column("LABEL_FIELD_ID")] [DataMember] + [Required(ErrorMessage = "{0},不能空白")] public int LABEL_FIELD_ID { get; set; } /// diff --git a/AMESCoreStudio.WebApi/Models/AMES/LabelTemplateMaster.cs b/AMESCoreStudio.WebApi/Models/AMES/LabelTemplateMaster.cs index af8710d8..08ecfdbc 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/LabelTemplateMaster.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/LabelTemplateMaster.cs @@ -37,7 +37,8 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 標籤檔案 /// [DataMember] - [Display(Name = "標籤檔案")] + [Display(Name = "標籤檔名")] + [Required(ErrorMessage = "{0},不能空白")] [Column("LABEL_FILE")] public string LABEL_FILE { get; set; } @@ -55,6 +56,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// [Column("IMAGE_NAME")] [Display(Name = "圖檔")] + [Required(ErrorMessage = "{0},不能空白")] [DataMember] public string IMAGE_NAME { get; set; } @@ -89,6 +91,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 備註說明 /// [Column("REMARK")] + [Display(Name = "備註說明")] [DataMember] public string REMARK { get; set; } diff --git a/AMESCoreStudio.WebApi/Models/AMESContext.cs b/AMESCoreStudio.WebApi/Models/AMESContext.cs index 9283bd46..64db368e 100644 --- a/AMESCoreStudio.WebApi/Models/AMESContext.cs +++ b/AMESCoreStudio.WebApi/Models/AMESContext.cs @@ -114,10 +114,9 @@ namespace AMESCoreStudio.WebApi modelBuilder.Entity().HasKey(c => new { c.GroupID, c.BarcodeID }); modelBuilder.Entity().HasKey(c => new { c.InhouseNo, c.SeqID }); - modelBuilder.Entity().HasKey(c => new { c.InhouseNo, c.SeqID, c.SerialNo }); + modelBuilder.Entity().HasKey(c => new { c.InhouseNo, c.SeqID, c.SerialNo,c.BarcodeNo }); 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(); @@ -136,6 +135,7 @@ namespace AMESCoreStudio.WebApi modelBuilder.Entity().HasNoKey(); modelBuilder.Entity().HasKey(c => new { c.SerialRuleDetailID }); modelBuilder.Entity().HasNoKey(); + modelBuilder.Entity().HasKey(c => new { c.TEMPLATE_ID, c.LABEL_FIELD_ID }); //Yiru End --------------------------------------------------------------------------------------------------------------------------- @@ -156,7 +156,7 @@ 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 }); //modelBuilder.Entity().HasOne(r => r.LabelTemplateMaster).WithMany().HasForeignKey(r => r.TEMPLATE_ID).IsRequired(); //modelBuilder.Entity().HasOne(r => r.LabelParam).WithMany().HasForeignKey(r => r.LABEL_FIELD_ID).IsRequired(); //modelBuilder.Entity().HasOne(r => r.LabelTemplateMaster).WithMany().HasForeignKey(r => r.TEMPLATE_ID).IsRequired(); @@ -660,11 +660,6 @@ namespace AMESCoreStudio.WebApi /// public virtual DbSet FqcBarcodes { get; set; } - /// - /// FQC细目資料檔 - /// - public virtual DbSet FqcItems { get; set; } - /// /// 抽驗批退資料檔 /// @@ -1016,6 +1011,21 @@ namespace AMESCoreStudio.WebApi public DbSet LabelItemParam { get; set; } public DbSet NgKeyparts { get; set; } + + /// + /// FQC檢驗項目群組綁定設定檔 + /// + public virtual DbSet FqcItems { get; set; } + + /// + /// FQC檢驗項目群組名稱 + /// + public virtual DbSet FqcItemGroups { get; set; } + + /// + /// FQC檢驗項目群組指定料號設定檔 + /// + public virtual DbSet FqcItemGroupMaterials { get; set; } } }