diff --git a/AMESCoreStudio.Web/Controllers/FQCController.cs b/AMESCoreStudio.Web/Controllers/FQCController.cs index 8c169640..6231fcb9 100644 --- a/AMESCoreStudio.Web/Controllers/FQCController.cs +++ b/AMESCoreStudio.Web/Controllers/FQCController.cs @@ -911,6 +911,61 @@ namespace AMESCoreStudio.Web.Controllers } #endregion + #region 文件 + [HttpGet] + public async Task FQC007D(int fqc) + { + FqcDto fqcDto = new FqcDto(); + var model = await _fqcApi.GetFqcResultMasterBlobByFqcID(fqc); + fqcDto.fqcResultMasterBlobs = model; + fqcDto.FqcID = fqc; + return View(fqcDto); + } + + [HttpPost] + public async Task FQC007DAsync(FqcResultMaster model, string Result) + { + var FqcQuery = await _fqcApi.GetFqcQuery(model.InhouseNo, model.SeqID); + var fqcItem = FqcQuery.Data.FirstOrDefault(); + // 判斷狀態選擇 + if (fqcItem.FailQty >= fqcItem.ReQty) + { + if (model.QaResult == "P" && string.IsNullOrWhiteSpace(model.SpecialPo)) + { + ModelState.AddModelError("error", "請輸入特採單號"); + return View("FQC007B", model); + } + } + + var fqcResultMaster = await _fqcApi.GetFqcResultMaster(model.FqcID); + var fqcInhouseMaster = await _fqcApi.GetFqcInhouseMaster(model.InhouseNo, model.SeqID); + + fqcResultMaster.QaResult = model.QaResult; + fqcResultMaster.QaMeno = model.QaMeno; + fqcResultMaster.EndTime = DateTime.Now; + fqcResultMaster.UpdateDate = DateTime.Now; + fqcResultMaster.SpecialPo = model.SpecialPo; + + fqcInhouseMaster.Status = model.QaResult; + fqcInhouseMaster.UpdateDate = DateTime.Now; + + IResultModel result; + result = await _fqcApi.PutFqcInhouseMaster(JsonConvert.SerializeObject(fqcInhouseMaster)); + result = await _fqcApi.PutFqcResultMaster(JsonConvert.SerializeObject(fqcResultMaster)); + if (result.Success) + { + var _msg = "新增成功!"; + return RedirectToAction("WindowReload", "Home", new { msg = _msg }); + } + else + { + ModelState.AddModelError("error", result.Msg); + } + + return View("FQC007B", model); + } + #endregion + #endregion #region FQC008 FQC查詢 @@ -937,24 +992,75 @@ namespace AMESCoreStudio.Web.Controllers #region FQC009 料號對應檢驗工項 - public ActionResult FQC009C() + public ActionResult FQC009() { return View(); } [HttpPost] - public ActionResult FQC009CAsync(string ids, string itemNo) + public async Task FQC009Async(string itemID, string groupID, string itemNo) { - return View(); + var result = await _fqcApi.GetMaterialItemByItemNO(itemNo); + if (result == null) + { + var Msg = "在料號主檔找不到該筆料號【" + itemNo + "】"; + return Json(new { code = 0, msg = Msg, success = false }); + } + + // 取料號綁定檢驗工項 + var result_MasterFQC = await _fqcApi.GetMaterialFqcItemsByitemNo(itemNo); + // 有勾選的ItemID + var checkItemID = itemID.Split(',').ToList(); + // 有勾選的GroupID + var checkGroupID = groupID.Split(',').ToList(); + + // 取勾選有的 = 新增 + var insertItemID = checkItemID.Except(result_MasterFQC.Select(s => s.QcItemID.ToString())); + for (int i = 0; i < checkItemID.Count; i++) + { + if (insertItemID.Where(w => w == checkItemID[i]).Any()) + { + MaterialFqcItem materialFqcItem = new MaterialFqcItem + { + ItemID = result.ItemID, + QcItemID = Int32.Parse(checkItemID[i]), + QcGroupID = Int32.Parse(checkGroupID[i]), + CreateUserID = GetLogInUserID(), + CreateDate = DateTime.Now, + UpdateUserID = GetLogInUserID(), + UpdateDate = DateTime.Now + }; + await _fqcApi.PostMaterialFqcItem(JsonConvert.SerializeObject(materialFqcItem)); + } + } + + // 取有料號綁定 = 需要刪除 + var deteleItemID = result_MasterFQC.Select(s => s.QcItemID.ToString()).Except(checkItemID); + foreach (var item in deteleItemID) + { + var masterFQCID = result_MasterFQC.Where(w => w.QcItemID == Int32.Parse(item)).FirstOrDefault().MaterialFqcitemID; + await _fqcApi.DeleteMaterialFqcItem(masterFQCID); + } + + return Json(new { code = 0, msg = "", success = true }); } [HttpGet] - public async Task FQC009ItemQueryAsync(int groupID = 0, int page = 0, int limit = 1, string itemID = null) + public async Task FQC009ItemQueryAsync(int groupID = 0, int page = 0, int limit = 1, string itemNo = null) { - var result = await _fqcApi.GetQcItemQuery(groupID, 0, limit); + var msg = ""; + var result = await _fqcApi.GetQcItemQuery(groupID, 0, limit, itemNo); if (result.Data.Count() != 0) { - return Json(new Table() { code = 0, msg = "", data = result.Data, count = result.DataTotal }); + if (!string.IsNullOrWhiteSpace(itemNo)) + { + var masterlItem = await _fqcApi.GetMaterialItemByItemNO(itemNo); + if (masterlItem == null) + { + msg = "在料號主檔找不到該筆料號【" + itemNo + "】"; + } + } + return Json(new Table() { code = 0, msg = msg, data = result.Data, count = result.DataTotal }); } return Json(new Table() { count = 0, data = null }); diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs index dfb56054..1769ee3c 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IFQC.cs @@ -81,7 +81,7 @@ namespace AMESCoreStudio.Web /// 比數 /// [WebApiClient.Attributes.HttpGet("api/QcItem/QcItemQuery")] - ITask> GetQcItemQuery(int groupID, int page, int limit); + ITask> GetQcItemQuery(int groupID, int page, int limit,string itemNo = null); /// /// 查詢檢驗項目維護 ID @@ -232,7 +232,7 @@ namespace AMESCoreStudio.Web #region FQC006 FQC狀態維護 /// - /// 刪除過站狀態檔 + /// 新增過站狀態檔 /// /// /// @@ -400,6 +400,22 @@ namespace AMESCoreStudio.Web /// [WebApiClient.Attributes.HttpGet("api/FqcInhouseMaster/{inhouseNo}/{seqID}")] ITask GetFqcInhouseMaster(string inhouseNo, int seqID); + + /// + /// 新增 檢驗結果上傳圖檔資料表 + /// + /// + /// + [WebApiClient.Attributes.HttpPost("api/FqcResultMasterBlob")] + ITask> PostFqcResultMasterBlob([FromBody, RawJsonContent] string model); + + /// + /// 查詢 檢驗結果上傳圖檔資料表 By FQCID + /// + /// + /// + [WebApiClient.Attributes.HttpGet("api/FqcResultMasterBlob/ByFQCID/{id}")] + ITask> GetFqcResultMasterBlobByFqcID(int id); #endregion #region FQC008 FQC查詢 @@ -422,5 +438,33 @@ namespace AMESCoreStudio.Web , string status = null, int page = 0, int limit = 10); #endregion + #region FQC009 + /// + /// MaterialItem 料號基本資料檔 + /// + /// 料號 + [WebApiClient.Attributes.HttpGet("api/MaterialItem/ByItemNO/{id}")] + ITask GetMaterialItemByItemNO(string id); + + /// + /// MaterialItem 料號查詢綁定檢驗工項 + /// + /// 料號 + [WebApiClient.Attributes.HttpGet("api/MaterialFqcItem/ByitemNo/{id}")] + ITask> GetMaterialFqcItemsByitemNo(string id); + + /// + /// MaterialItem 新增料號綁定檢驗工項 + /// + [WebApiClient.Attributes.HttpPost("api/MaterialFqcItem")] + ITask> PostMaterialFqcItem([FromBody, RawJsonContent] string model); + + /// + /// MaterialItem 刪除料號綁定檢驗工項 + /// + /// + [WebApiClient.Attributes.HttpDelete("api/MaterialFqcItem/{id}")] + ITask> DeleteMaterialFqcItem(int id); + #endregion } } diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml index 118bec7f..81708ead 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC007.cshtml @@ -26,7 +26,9 @@ - + + + @**@ @@ -312,6 +314,20 @@ }); }; + function upload() { + layui.use('layer', function () { + var layer = layui.layer; + layer.open({ + title: '文件上傳', + type: 2, + area: ['600px', '400px'], + fixed: false, //不固定 + maxmin: true, + content: '/FQC/FQC007D?fqc=@Model.FqcID' + }); + }); + }; + $(document).ready(function () { var error = '@Html.ValidationMessage("error")'; if ($(error).text() != '') { diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml new file mode 100644 index 00000000..69f04377 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC007A.cshtml @@ -0,0 +1,280 @@ + +@{ ViewData["Title"] = "工單檢驗工項維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+
@ViewBag.Title
+
+ +
+ + +
+
+
+ +
+
+
+
+ + +
+ +
+
+
+ + + + +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml new file mode 100644 index 00000000..20ee04c2 --- /dev/null +++ b/AMESCoreStudio.Web/Views/FQC/FQC007D.cshtml @@ -0,0 +1,94 @@ +@model AMESCoreStudio.WebApi.DTO.AMES.FqcDto + + +@{ ViewData["Title"] = "FQC文件維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + + + +
+
+
+
+ + + + + + + + + + + @foreach (var index in Model.fqcResultMasterBlobs) + { + + + + + + } + +
檔案名稱檔案路徑預覽
+ @index.ImageName + + @index.Filepath + + 預覽 +
+
+
+
+ + + +
+
+
+
+ +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + + + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC009.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC009.cshtml index 795380ba..7a824a95 100644 --- a/AMESCoreStudio.Web/Views/FQC/FQC009.cshtml +++ b/AMESCoreStudio.Web/Views/FQC/FQC009.cshtml @@ -1,28 +1,220 @@ -@{ - ViewData["Title"] = "料號檢驗工項維護"; - Layout = "~/Views/Shared/_AMESLayout.cshtml"; -} + +@{ ViewData["Title"] = "料號檢驗工項維護"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; } + +
@ViewBag.Title
+
+ +
+ + +
+
+
+ +
+ +
-
+ +
+ + + + +@section Scripts { + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } -@section Scripts{ -} \ No newline at end of file + + +} diff --git a/AMESCoreStudio.Web/Views/FQC/FQC009C.cshtml b/AMESCoreStudio.Web/Views/FQC/FQC009C.cshtml deleted file mode 100644 index d3862502..00000000 --- a/AMESCoreStudio.Web/Views/FQC/FQC009C.cshtml +++ /dev/null @@ -1,257 +0,0 @@ -@model AMESCoreStudio.WebApi.Models.AMES.QcGroup - - -@{ ViewData["Title"] = "料號檢驗工項新增"; - Layout = "~/Views/Shared/_AMESLayout.cshtml"; } - - - -
-
-
-
-
@ViewBag.Title
-
- -
- -
-
-
- -
-
-
-
- - -
- @Html.ValidationMessage("error") -
-
-
- - - - -@section Scripts { - @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); - await Html.RenderPartialAsync("_FileinputScriptsPartial"); } - - - - -} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs index 0dc53a6e..b5eb65de 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/FqcResultMasterBlobController.cs @@ -46,6 +46,18 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return fqcResultMasterBlob; } + /// + /// 檢驗結果上傳圖檔資料表 By FQCID + /// + /// FQCID + /// + [HttpGet("ByFQCID/{id}")] + public async Task>> GetFqcResultMasterBlobByFqcID(int id) + { + var fqcResultMasterBlobs = await _context.FqcResultMasterBlobs.Where(w => w.FqcID == id).ToListAsync(); + return fqcResultMasterBlobs; + } + /// /// 更新 檢驗結果上傳圖檔資料表 /// diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialFqcItemController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialFqcItemController.cs index 5714249b..9c0d0d6c 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/MaterialFqcItemController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/MaterialFqcItemController.cs @@ -46,6 +46,22 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return materialFqcItem; } + /// + /// 料號查詢綁定檢驗工項 + /// + /// 料號 + /// + [HttpGet("ByitemNo/{id}")] + public async Task>> GetMaterialFqcItemsByitemNo(string id) + { + var itemID = 0; + var result = await _context.MaterialItems.Where(w => w.ItemNo == id).ToListAsync(); + if (result.Count() != 0) + itemID = result.FirstOrDefault().ItemID; + + return await _context.MaterialFqcItems.Where(w => w.ItemID == itemID).ToListAsync(); + } + /// /// 更新料號對應工項資料檔 /// @@ -99,20 +115,38 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } - // DELETE: api/MaterialFqcItem/5 + /// + /// 刪除料號對應工項資料檔 + /// + /// + /// [HttpDelete("{id}")] - public async Task> DeleteMaterialFqcItem(int id) + public async Task> DeleteMaterialFqcItem(int id) { + ResultModel result = new ResultModel(); var materialFqcItem = await _context.MaterialFqcItems.FindAsync(id); - if (materialFqcItem == null) + + try { - return NotFound(); + if (materialFqcItem == null) + { + result.Success = false; + result.Msg = "找不到要刪除資料"; + } + else + { + _context.MaterialFqcItems.Remove(materialFqcItem); + await _context.SaveChangesAsync(); + result.Success = true; + result.Msg = "OK"; + } } - - _context.MaterialFqcItems.Remove(materialFqcItem); - await _context.SaveChangesAsync(); - - return materialFqcItem; + catch (Exception ex) + { + result.Success = false; + result.Msg = ex.InnerException.Message; + } + return result; } private bool MaterialFqcItemExists(int id) diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs index 1c4008dc..41c8c426 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/QcItemController.cs @@ -53,15 +53,16 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES /// 檢驗類別ID /// 頁數 /// 筆數 + /// 料號 /// [HttpGet("QcItemQuery")] - public async Task> GetQcItemQuery(int groupID = 0, int page = 0, int limit = 10) + public async Task> GetQcItemQuery(int groupID = 0, int page = 0, int limit = 10, string itemNo = null) { IQueryable q = _context.QcItems; ResultModel result = new ResultModel(); if (groupID != 0) - q = q.Where(w => w.GroupID == groupID); + q = q.Where(w => w.GroupID == groupID); // 紀錄筆數 result.DataTotal = q.Count(); @@ -86,6 +87,18 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES GroupNameEN = s.GetQcGroup.GroupNameEN }).ToListAsync(); + // 有輸入料號跟QCITEM 比對有資料打勾 + var itemID = _context.MaterialItems.Where(w => w.ItemNo == itemNo).FirstOrDefault(); + if (itemID != null) + { + var marterialFQCItems = _context.MaterialFqcItems.Where(w => w.ItemID == itemID.ItemID); + foreach (var item in result.Data) + { + if (marterialFQCItems.Where(w => w.QcItemID == item.ItemID).Any()) + item.check = true; + } + } + return result; } diff --git a/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs index 35b81114..c93ff183 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/FqcDto.cs @@ -18,6 +18,7 @@ namespace AMESCoreStudio.WebApi.DTO.AMES public FqcDto() { fqcDetails = new List(); + fqcResultMasterBlobs = new List(); } /// @@ -150,6 +151,11 @@ namespace AMESCoreStudio.WebApi.DTO.AMES public List fqcDetails { get; set; } + /// + /// 附件檔案 + /// + public List fqcResultMasterBlobs { get; set; } + public class FqcDetailDto { /// diff --git a/AMESCoreStudio.WebApi/DTO/AMES/QcItemDto.cs b/AMESCoreStudio.WebApi/DTO/AMES/QcItemDto.cs index 75784ec4..13054205 100644 --- a/AMESCoreStudio.WebApi/DTO/AMES/QcItemDto.cs +++ b/AMESCoreStudio.WebApi/DTO/AMES/QcItemDto.cs @@ -58,6 +58,9 @@ namespace AMESCoreStudio.WebApi.DTO.AMES /// public DateTime? UpdateDate { get; set; } = DateTime.Now; + /// + /// 料號檢驗工項是否有資料 + /// public bool check {get;set;}= false; } } diff --git a/AMESCoreStudio.WebApi/Models/AMES/FqcResultMasterBlob.cs b/AMESCoreStudio.WebApi/Models/AMES/FqcResultMasterBlob.cs index 6fc8765e..0ab1f9dc 100644 --- a/AMESCoreStudio.WebApi/Models/AMES/FqcResultMasterBlob.cs +++ b/AMESCoreStudio.WebApi/Models/AMES/FqcResultMasterBlob.cs @@ -13,6 +13,7 @@ namespace AMESCoreStudio.WebApi.Models.AMES /// 檢驗結果上傳圖檔資料表 /// [Table("FQC_RESULT_MASTER_BLOB", Schema = "JHAMES")] + [DataContract] public partial class FqcResultMasterBlob { ///