From 205c29fc67b3d6adc7ef97285cfda7c84c13fbe3 Mon Sep 17 00:00:00 2001 From: Marvin Date: Thu, 15 Dec 2022 16:09:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9EIPQC=E5=A0=B1=E8=A1=A8?= =?UTF-8?q?=E6=9F=A5=E8=A9=A2QRS015=202.=E4=BF=AE=E6=94=B9=E5=BB=A0?= =?UTF-8?q?=E5=88=A5=E8=B3=87=E6=96=99=E7=B6=AD=E8=AD=B7BAS001=202.1.?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E5=A2=9EBAS001C,textbox=E5=9B=9E?= =?UTF-8?q?=E8=BB=8A=E4=B8=8D=E8=A7=B8=E7=99=BC=E6=8F=90=E4=BA=A4,?= =?UTF-8?q?=E5=8F=AA=E8=83=BDclick=E6=8C=89=E9=88=95=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/QRSController.cs | 87 ++++++++++++++- AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 7 ++ .../ViewModels/QRS/QRS015ViewModel.cs | 45 ++++++++ AMESCoreStudio.Web/Views/BAS/BAS001C.cshtml | 10 +- AMESCoreStudio.Web/Views/QRS/QRS015.cshtml | 4 +- AMESCoreStudio.Web/Views/QRS/QRS015A.cshtml | 55 ++++++++++ .../AMES/InspectionResultMastersController.cs | 103 ++++++++++++++++-- 7 files changed, 292 insertions(+), 19 deletions(-) create mode 100644 AMESCoreStudio.Web/ViewModels/QRS/QRS015ViewModel.cs diff --git a/AMESCoreStudio.Web/Controllers/QRSController.cs b/AMESCoreStudio.Web/Controllers/QRSController.cs index e7e4bc2d..13290fa7 100644 --- a/AMESCoreStudio.Web/Controllers/QRSController.cs +++ b/AMESCoreStudio.Web/Controllers/QRSController.cs @@ -1057,12 +1057,43 @@ namespace AMESCoreStudio.Web.Controllers { await GetUnitList(); - ViewBag.StartDate = System.DateTime.Now.AddDays(-7).ToString("yyyy/MM/dd"); - ViewBag.EndDate = System.DateTime.Now.ToString("yyyy/MM/dd"); + ViewBag.StartDate = System.DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"); + ViewBag.EndDate = System.DateTime.Now.ToString("yyyy-MM-dd"); return View(); } + [HttpPost] + public async Task GetIPQCData4QRS015Async(string id) + { + string[] param = id.Split('_'); + string wip_no = param[0]; + string item_no = param[1]; + string model_no = param[2]; + string start_date = param[3]; + string end_date = param[4]; + + var result = await _pcsApi.GetIPQCHeaderData4QRS015(wip_no, item_no, model_no, start_date, end_date); + + var query = new QRS015ViewModel(); + + foreach (var data in result.Data) + { + JObject jo = JObject.Parse(data.ToString()); + + query.IpqcDatas.Add(new IpqcData + { + WeekCode = jo["ipqcWeek"].ToString(), + IpqcCnt = int.Parse(jo["ipqcCnt"].ToString()), + PassCnt = int.Parse(jo["passCnt"].ToString()), + FailCnt = int.Parse(jo["failCnt"].ToString()), + Rate = double.Parse((int.Parse(jo["passCnt"].ToString()) * 1.0 / int.Parse(jo["ipqcCnt"].ToString()) * 100.0).ToString("0.00")) + }); + } + + return Json(query.IpqcDatas); + } + public async Task QRS015AAsync(string modelNO, string itemNO, string wipNO, string dateStart, string dateEnd) { ViewData["ParamList"] = modelNO + "_" + itemNO + "_" + wipNO + "_" + dateStart + "_" + dateEnd; @@ -1075,15 +1106,24 @@ namespace AMESCoreStudio.Web.Controllers if (result.DataTotal > 0) { - ipqcDataList = ipqcDataList + ""; + ipqcDataList = ipqcDataList + "
周次抽驗總筆數通過筆數不良筆數通過率
"; + int sumIpqcCnt = 0, sumPassCnt = 0, sumFailCnt = 0; + foreach (var item in result.Data) { JObject jo = JObject.Parse(item.ToString()); string ipqc_week = jo["ipqcWeek"].ToString(); - string ipqc_cnt = jo["ipqcCnt"].ToString(); - ipqcDataList = ipqcDataList + ""; - + int ipqc_cnt = int.Parse(jo["ipqcCnt"].ToString()); + int pass_cnt = int.Parse(jo["passCnt"].ToString()); + int fail_cnt = int.Parse(jo["failCnt"].ToString()); + double ipqc_rate = pass_cnt * 100.0 / ipqc_cnt; + ipqcDataList = ipqcDataList + ""; + sumIpqcCnt = sumIpqcCnt + ipqc_cnt; + sumPassCnt = sumPassCnt + pass_cnt; + sumFailCnt = sumFailCnt + fail_cnt; } + double sum_ipqc_rate = sumPassCnt * 100.0 / sumIpqcCnt; + ipqcDataList = ipqcDataList + ""; ipqcDataList = ipqcDataList + "
周次抽驗總筆數通過筆數不良筆數通過率
" + ipqc_week + "" + ipqc_cnt + "" + ipqc_cnt + "0100%
" + ipqc_week + "" + "  " + ipqc_cnt + "" + "  " + pass_cnt + "" + "  " + fail_cnt + "" + "  " + ipqc_rate.ToString("0.00") + "%
" + " " + "Total" + "" + "  " + sumIpqcCnt + "" + "  " + sumPassCnt + "" + "  " + sumFailCnt + "" + "  " + sum_ipqc_rate.ToString("0.00") + "%
"; } @@ -1092,6 +1132,41 @@ namespace AMESCoreStudio.Web.Controllers return View(); } + public IActionResult QRS015B(string id) + { + string[] param = id.Split("_"); + ViewBag.WIP_NO = param[0]; + ViewBag.ITEM_NO = param[1]; + ViewBag.MODEL_NO = param[2]; + ViewBag.START_DATE = param[3]; + ViewBag.END_DATE = param[4]; + ViewBag.WEEK = param[5]; + + return View(); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetIPQCDetailData(string id, int page = 0, int limit = 10) + { + string[] param = id.Split("_"); + string wip_no = param[0]; + string item_no = param[1]; + string model_no = param[2]; + string start_date = param[3]; + string end_date = param[4]; + string week = param[5]; + + var result = await _pcsApi.GetIPQCDetailData(wip_no, item_no, model_no, start_date, end_date, week, 0, 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 async Task QRS016() { await GetUnitList(); diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 8bbac8ce..17322df9 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -1077,6 +1077,13 @@ namespace AMESCoreStudio.Web [WebApiClient.Attributes.HttpGet("api/InspectionResultMasters/GetIPQCHeaderData4QRS015")] ITask> GetIPQCHeaderData4QRS015(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd); + /// + /// 查詢IPQC明細資料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/InspectionResultMasters/GetIPQCDetailData")] + ITask> GetIPQCDetailData(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd, string weekCode, int page, int limit); + #endregion #region QRS016 FQC查詢報表 diff --git a/AMESCoreStudio.Web/ViewModels/QRS/QRS015ViewModel.cs b/AMESCoreStudio.Web/ViewModels/QRS/QRS015ViewModel.cs new file mode 100644 index 00000000..2107244f --- /dev/null +++ b/AMESCoreStudio.Web/ViewModels/QRS/QRS015ViewModel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace AMESCoreStudio.Web.ViewModels.QRS +{ + public class QRS015ViewModel + { + public QRS015ViewModel() + { + IpqcDatas = new List(); + } + + public List IpqcDatas { get; set; } + } + + public class IpqcData + { + /// + /// 周次 + /// + public string WeekCode { get; set; } + + /// + /// 抽檢總筆數 + /// + public int IpqcCnt { get; set; } + + /// + /// 通過筆數 + /// + public int PassCnt { get; set; } + + /// + /// 不良筆數 + /// + public int FailCnt { get; set; } + + /// + /// 通過率 + /// + public double Rate { get; set; } + } +} diff --git a/AMESCoreStudio.Web/Views/BAS/BAS001C.cshtml b/AMESCoreStudio.Web/Views/BAS/BAS001C.cshtml index be266bfa..ec4b3129 100644 --- a/AMESCoreStudio.Web/Views/BAS/BAS001C.cshtml +++ b/AMESCoreStudio.Web/Views/BAS/BAS001C.cshtml @@ -13,7 +13,7 @@
-
+
@@ -61,7 +61,7 @@
*@ @Html.ValidationMessage("error")
- +
@@ -79,6 +79,12 @@ parent.hg.msg(error); } }); + + function postformsubmit() { + //获取form表单对象,提交选择项目 + var form = document.getElementById("filter_all"); + form.submit();//form表单提交 + } diff --git a/AMESCoreStudio.Web/Views/QRS/QRS015.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS015.cshtml index bf3905f5..51827a31 100644 --- a/AMESCoreStudio.Web/Views/QRS/QRS015.cshtml +++ b/AMESCoreStudio.Web/Views/QRS/QRS015.cshtml @@ -72,14 +72,14 @@ laydate.render({ elem: '#dateStart' , trigger: 'click' - , format: 'yyyy/MM/dd' + , format: 'yyyy-MM-dd' , theme: 'grid' }); laydate.render({ elem: '#dateEnd' , trigger: 'click' - , format: 'yyyy/MM/dd' + , format: 'yyyy-MM-dd' , theme: 'grid' }); }); diff --git a/AMESCoreStudio.Web/Views/QRS/QRS015A.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS015A.cshtml index aef3e29f..b843ae23 100644 --- a/AMESCoreStudio.Web/Views/QRS/QRS015A.cshtml +++ b/AMESCoreStudio.Web/Views/QRS/QRS015A.cshtml @@ -16,6 +16,7 @@
+
@Html.Raw(ViewData["IPQCDataList"])
@@ -27,7 +28,61 @@ diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultMastersController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultMastersController.cs index a368f9f0..92c15470 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultMastersController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/InspectionResultMastersController.cs @@ -137,17 +137,21 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES public async Task> GetIPQCHeaderData4QRS015(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd) { ResultModel result = new ResultModel(); - var q = from q1 in _context.InspectionResultMasters - join q2 in _context.WipAtts on q1.WipNo equals q2.WipNO - join q3 in _context.CalendarTables on q1.CreateDate.Date equals q3.TimeID + var q = from q1 in _context.InspectionForms + join q2 in _context.InspectionItems on q1.InspectionFormID equals q2.InspectionFormID + join q3 in _context.InspectionResultDetails on q2.InspectionItemID equals q3.InspectionItemID + join q4 in _context.InspectionResultMasters on q1.InspectionFormID equals q4.InspectionFormID + join q5 in _context.WipAtts on q4.WipNo equals q5.WipNO + join q6 in _context.CalendarTables on q1.CreateDate.Date equals q6.TimeID select new { q1.InspectionFormID, q1.CreateDate, - q1.WipNo, - q2.ItemNO, - q2.ModelNO, - IPQCWeek = q3.WeekOfYear + q4.WipNo, + q5.ItemNO, + q5.ModelNO, + q3.Result, + IPQCWeek = q6.WeekOfYear }; if (wipNO != null && wipNO != "") @@ -158,7 +162,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { q = q.Where(w => w.ItemNO == itemNO); } - if (modelNO != "*") + if (modelNO != null && modelNO != "") { q = q.Where(w => w.ModelNO == modelNO); } @@ -173,9 +177,13 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES var g = q.GroupBy(x => new { x.IPQCWeek }).Select(x => new { IPQCWeek = x.Key.IPQCWeek, - IPQCCnt = x.Count() + IPQCCnt = x.Count(), + PassCnt = x.Count(i => i.Result == "P"), + FailCnt = x.Count(i => i.Result == "F") }); + g = g.OrderBy(y => y.IPQCWeek); + //紀錄筆數 result.DataTotal = g.Count(); @@ -193,6 +201,83 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + + /// + /// 查詢IPQC明細資料 + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetIPQCDetailData(string wipNO, string itemNO, string modelNO, string dateStart, string dateEnd, string weekCode, int page = 0, int limit = 10) + { + ResultModel result = new ResultModel(); + var q = from q1 in _context.InspectionForms + join q2 in _context.InspectionItems on q1.InspectionFormID equals q2.InspectionFormID + join q3 in _context.InspectionResultDetails on q2.InspectionItemID equals q3.InspectionItemID + join q4 in _context.InspectionResultMasters on q1.InspectionFormID equals q4.InspectionFormID + join q5 in _context.WipAtts on q4.WipNo equals q5.WipNO + join q6 in _context.CalendarTables on q1.CreateDate.Date equals q6.TimeID + join q7 in _context.LineInfoes on q3.LineID equals q7.LineID + select new + { + q1.InspectionFormID, + q1.InspectionNo, + q1.CreateDate, + q4.WipNo, + q5.ItemNO, + q5.ModelNO, + q7.LineDesc, + StationName = q3.Stations.StationName, + q4.BarcodeNo, + q3.Result, + IPQCWeek = q6.WeekOfYear + }; + + if (wipNO != null && wipNO != "") + { + q = q.Where(w => w.WipNo == wipNO); + } + if (itemNO != null && itemNO != "") + { + q = q.Where(w => w.ItemNO == itemNO); + } + if (modelNO != null && modelNO != "") + { + q = q.Where(w => w.ModelNO == modelNO); + } + if (dateStart != null && dateStart != "" && dateEnd != null && dateEnd != "") + { + q = q.Where(w => w.CreateDate >= DateTime.Parse(dateStart) && w.CreateDate <= DateTime.Parse(dateEnd)); + } + if (weekCode != null && weekCode != "") + { + q = q.Where(w => w.IPQCWeek.Equals(int.Parse(weekCode))); + } + + //紀錄筆數 + result.DataTotal = q.Count(); + + //Table 頁數 + if (page > 0) + { + q = q.Skip((page - 1) * limit).Take(limit); + } + + result.Data = await q.ToListAsync(); + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + + /// /// 用FormID获取该巡檢結果资料 ///