From f7b4193f3a35bf1f410f0ac7c3df57e5aa19bead Mon Sep 17 00:00:00 2001 From: Marvin Date: Tue, 15 Mar 2022 22:26:41 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E8=89=AF=E7=8E=87=E6=9F=A5?= =?UTF-8?q?=E8=A9=A2QRS010?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/QRSController.cs | 143 ++++++++ AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 11 + AMESCoreStudio.Web/Views/QRS/QRS010.cshtml | 343 ++++++++++++++++++ .../Controllers/AMES/NgRepairsController.cs | 2 +- .../Controllers/AMES/WipClassController.cs | 132 +++++++ 5 files changed, 630 insertions(+), 1 deletion(-) create mode 100644 AMESCoreStudio.Web/Views/QRS/QRS010.cshtml diff --git a/AMESCoreStudio.Web/Controllers/QRSController.cs b/AMESCoreStudio.Web/Controllers/QRSController.cs index b95b5d33..a126cc8b 100644 --- a/AMESCoreStudio.Web/Controllers/QRSController.cs +++ b/AMESCoreStudio.Web/Controllers/QRSController.cs @@ -5,6 +5,8 @@ using AMESCoreStudio.CommonTools.Result; using Microsoft.AspNetCore.Hosting; using Newtonsoft.Json.Linq; using AMESCoreStudio.Web.Models; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc.Rendering; namespace AMESCoreStudio.Web.Controllers { @@ -333,5 +335,146 @@ namespace AMESCoreStudio.Web.Controllers return Json(new Table() { count = 0, data = null }); } + + private async Task GetProductTypeList() + { + var result = await _pcsApi.GetProductTypes(); + + var ProductTypes = new List(); + for (int i = 0; i < result.Count; i++) + { + ProductTypes.Add(new SelectListItem(result[i].ProductTypeName, result[i].ProductTypeID.ToString())); + } + + ViewBag.ProductTypeList = ProductTypes; + } + + private async Task GetMFGTypeList() + { + var result = await _pcsApi.GetMFGTypes(); + + var MFGTypes = new List(); + for (int i = 0; i < result.Count; i++) + { + MFGTypes.Add(new SelectListItem(result[i].MFGTypeName, result[i].MFGTypeNO.ToString())); + } + + ViewBag.MFGTypeList = MFGTypes; + } + + private async Task GetTestTypeList() + { + var result = await _basApi.GetTestTypes(); + + var TestTypeItems = new List(); + for (int i = 0; i < result.Count; i++) + { + TestTypeItems.Add(new SelectListItem(result[i].TypeName, result[i].TypeNo.ToString())); + } + ViewBag.TestTypeList = TestTypeItems; + } + + + private async Task GetUnitList() + { + var result = await _basApi.GetFactoryUnits(); + + var UnitItems = new List(); + for (int i = 0; i < result.Count; i++) + { + UnitItems.Add(new SelectListItem(result[i].UnitName, result[i].UnitNo.ToString())); + } + ViewBag.UnitList = UnitItems; + } + + private async Task GetLineInfoList() + { + var result = await _basApi.GetLineInfoes(); + + var LineItems = new List(); + for (int i = 0; i < result.Count; i++) + { + LineItems.Add(new SelectListItem(result[i].LineDesc, result[i].LineID.ToString())); + } + ViewBag.LineList = LineItems; + } + + [HttpPost] + public async Task GetUnitLineJson(string unit_no) + { + var result = await _basApi.GetLineInfoByUnit(unit_no); + + var item = new List(); + + for (int i = 0; i < result.Count; i++) + { + item.Add(new SelectListItem(result[i].LineDesc, result[i].LineID.ToString())); + } + + if (item.Count == 0) + { + item.Add(new SelectListItem("全部", "*")); + } + + //将数据Json化并传到前台视图 + return Json(new { data = item }); + } + + private async Task GetStationList() + { + var result = await _basApi.GetStationses(); + + var StationItems = new List(); + for (int i = 0; i < result.Count; i++) + { + StationItems.Add(new SelectListItem(result[i].StationName, result[i].StationID.ToString())); + } + ViewBag.StationList = StationItems; + } + + [HttpPost] + public async Task GetUnitStationJson(string unit_no) + { + var result = await _basApi.GetStationsByUnit(unit_no); + + var item = new List(); + + for (int i = 0; i < result.Count; i++) + { + item.Add(new SelectListItem(result[i].StationName, result[i].StationID.ToString())); + } + + if (item.Count == 0) + { + item.Add(new SelectListItem("全部", "*")); + } + + //将数据Json化并传到前台视图 + return Json(new { data = item }); + } + + public async Task QRS010() + { + await GetProductTypeList(); + await GetTestTypeList(); + await GetUnitList(); + await GetLineInfoList(); + await GetStationList(); + await GetMFGTypeList(); + + return View(); + } + + public async Task QRS010QueryAsync(string unitNo, string lineID, string stationID, string wipNO, string itemNO, string mfgTypeNo, string dateStart, string dateEnd, int page = 0, int limit = 10) + { + + var result = await _pcsApi.GetYieldData4QRS010(unitNo, lineID, stationID, wipNO, itemNO, mfgTypeNo, dateStart, dateEnd, 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 }); + } } } diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 4ee026bf..422b8db5 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -871,5 +871,16 @@ namespace AMESCoreStudio.Web ITask> GetBarcodeOutfitByBarcodeNo(string id); #endregion + #region QRS010 + + /// + /// 良率查詢QRS010 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WipClass/GetYieldData4QRS010")] + ITask> GetYieldData4QRS010(string unitNo, string lineID, string stationID, string wipNo, string itemNo, string mfgTypeNo, string dateStart, string dateEnd, int page, int limit); + + #endregion + } } diff --git a/AMESCoreStudio.Web/Views/QRS/QRS010.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS010.cshtml new file mode 100644 index 00000000..90f28a95 --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS010.cshtml @@ -0,0 +1,343 @@ +@{ + ViewData["Title"] = "良率查詢"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + + + + +
+
+
+
+
@ViewBag.Title
+
+
+
+
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+ +
+
+
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+
+ +
+ +
+
+
+ +
+
+
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+ +@section Scripts{ + + +} diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs index 03ee3bc1..6afd0900 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/NgRepairsController.cs @@ -209,7 +209,7 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { if (stationID != "0") { - q = q.Where(w => w.StationId == int.Parse(lineID)); + q = q.Where(w => w.StationId == int.Parse(stationID)); } } if (wipNo != null) diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipClassController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipClassController.cs index ceba418a..10f89279 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipClassController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipClassController.cs @@ -140,5 +140,137 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES { return _context.WipClass.Any(e => e.WipID == id); } + + /// + /// 良率查詢 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetYieldData4QRS010(string unitNo, string lineID, string stationID, string mfgTypeNo, string wipNo, string itemNo, string dateStart, string dateEnd, int page = 0, int limit = 10) + { + ResultModel result = new ResultModel(); + var q = from a in _context.WipClass + join b in _context.RuleStations on a.RuleStationID equals b.RuleStationID + join c in _context.WipInfos on a.WipID equals c.WipID + join d in _context.WipAtts on c.WipNO equals d.WipNO + join e in _context.LineInfoes on c.LineID equals e.LineID + select new + { + a.WipID, + c.WipNO, + d.ItemNO, + c.PlanQTY, + d.ModelNO, + e.LineDesc, + a.RuleStationID, + b.StationID, + b.StationDesc, + a.RuleStatus, + a.FirstCnt, + a.PassCnt, + c.UnitNO, + c.LineID, + a.CreateDate + }; + + if (unitNo != null) + { + if (unitNo != "*") + { + q = q.Where(w => w.UnitNO == unitNo); + } + } + + if (lineID != null) + { + if (lineID != "0") + { + q = q.Where(w => w.LineID == int.Parse(lineID)); + } + } + + if (stationID != null) + { + if (stationID != "0") + { + q = q.Where(w => w.StationID == int.Parse(stationID)); + } + } + if (wipNo != null) + { + if (wipNo != "") + { + q = q.Where(w => w.WipNO == wipNo); + } + } + + if (itemNo != null) + { + if (itemNo != "") + { + q = q.Where(w => w.ItemNO == itemNo); + } + } + + if (dateStart != null && dateEnd != null) + { + if (dateStart != "" && dateEnd != "") + { + q = q.Where(w => w.CreateDate >= DateTime.Parse(dateStart) && w.CreateDate <= DateTime.Parse(dateEnd)); + } + } + + q = q.OrderBy(w => w.RuleStationID); + + var g = q.GroupBy(x => new { x.WipID, x.WipNO, x.PlanQTY, x.RuleStationID, x.StationID, x.StationDesc, x.RuleStatus, x.ItemNO, x.LineDesc, x.ModelNO }).Select(y => new + { + WipID = y.Key.WipID, + WipNO = y.Key.WipNO, + PlanQTY = y.Key.PlanQTY, + RuleStationID = y.Key.RuleStationID, + StationID = y.Key.StationID, + StationDesc = y.Key.StationDesc, + RuleStatus = y.Key.RuleStatus, + ItemNO = y.Key.ItemNO, + LineDesc = y.Key.LineDesc, + ModelNO = y.Key.ModelNO, + FirstCnt = y.Sum(x => x.FirstCnt), + PassCnt = y.Sum(x => x.PassCnt), + Yield = (y.Sum(x => x.FirstCnt) / y.Sum(x => x.PassCnt) * 100) + }); + + //紀錄筆數 + result.DataTotal = g.Count(); + + //Table 頁數 + if (page > 0) + { + g = g.Skip((page - 1) * limit).Take(limit); + } + + result.Data = await g.ToListAsync(); + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } } }