From 520c7d294556e80537e4851165eb64edda54527d Mon Sep 17 00:00:00 2001 From: Marvin Date: Fri, 29 Apr 2022 16:35:28 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E7=94=9F=E7=94=A2=E9=80=B2?= =?UTF-8?q?=E5=BA=A6=E6=9F=A5=E8=A9=A2(=E8=A3=BD=E7=A8=8B+=E6=96=99?= =?UTF-8?q?=E8=99=9F+=E5=B7=A5=E5=96=AE=E8=99=9F=E7=A2=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/QRSController.cs | 200 ++++++++++++++++++ AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 13 +- AMESCoreStudio.Web/Views/QRS/QRS011.cshtml | 75 +++++++ AMESCoreStudio.Web/Views/QRS/QRS011A.cshtml | 17 ++ .../Controllers/AMES/WipInfosController.cs | 60 ++++++ .../SYS/ProgramInfoesController.cs | 9 +- 6 files changed, 372 insertions(+), 2 deletions(-) create mode 100644 AMESCoreStudio.Web/Views/QRS/QRS011.cshtml create mode 100644 AMESCoreStudio.Web/Views/QRS/QRS011A.cshtml diff --git a/AMESCoreStudio.Web/Controllers/QRSController.cs b/AMESCoreStudio.Web/Controllers/QRSController.cs index 4bffbf6f..2e12fdee 100644 --- a/AMESCoreStudio.Web/Controllers/QRSController.cs +++ b/AMESCoreStudio.Web/Controllers/QRSController.cs @@ -332,6 +332,206 @@ namespace AMESCoreStudio.Web.Controllers return View(); } + public async Task QRS011() + { + await GetUnitList(); + + return View(); + } + + public async Task QRS011AAsync(string unitNo, string itemNO, string wipNO) + { + ViewData["Title"] = "查詢條件 - 製程代碼 : " + unitNo + "; 料號 : " + itemNO + "; 工單號碼 : " + wipNO; + + IResultModel result = await _pcsApi.GetWipInfo4QRS011(unitNo, itemNO, wipNO); + + string wipDataList = ""; + if (result.DataTotal > 0) + { + foreach (var item in result.Data) + { + JObject jo = JObject.Parse(item.ToString()); + int wip_id = int.Parse(jo["wipID"].ToString()); + int flow_rule_id = int.Parse(jo["flowRuleID"].ToString()); + int line_id = int.Parse(jo["lineID"].ToString()); + string item_no = jo["itemNO"].ToString(); + string unit_name = jo["unitName"].ToString(); + string line_desc = jo["lineDesc"].ToString(); + string wip_no = jo["wipNO"].ToString(); + int plan_qty = int.Parse(jo["planQTY"].ToString()); + int input_qty = int.Parse(jo["completeQTY"].ToString()); + int output_qty = 0; + + var cycle_time = await _ppsApi.GetCycleTime(item_no + "," + line_id); + + string ct1 = ""; + if (cycle_time.Count > 0) + { + ct1 = cycle_time[0].CT1.ToString() + "s"; + } + + wipDataList = wipDataList + "" + unit_name + " - " + line_desc + "" + " - " + "" + wip_no + "" + "" + "(" + item_no + ")" + "" + " - " + "" + plan_qty + " / " + input_qty + " / " + output_qty + "" + " | " + "" + "標準工時: " + "" + ct1 + "
"; + + var rule_sation = await _basApi.GetRuleStationsByFlow(flow_rule_id); + wipDataList = wipDataList + ""; + + string stationQty = "
"; + string stationRate = "
過站數量
"; + string stationWip = "
良率
"; + + string stationList = ""; + for (int j = 0; j < rule_sation.Count; j++) + { + if (rule_sation[j].StationID != 1000 && rule_sation[j].StationType == "M") + { + stationList = stationList + rule_sation[j].RuleStationID + ","; + + wipDataList = wipDataList + ""; + + var wip_station = await _pcsApi.GetWipStation4QRS009Group(wip_id, rule_sation[j].RuleStationID); + + int okQty = 0, ngQty = 0; + if (wip_station.DataTotal > 0) + { + foreach (var data in wip_station.Data) + { + JObject j0 = JObject.Parse(data.ToString()); + if (j0["ruleStatus"].ToString() == "P") + { + okQty = int.Parse(j0["firstCnt"].ToString()); + } + else + { + ngQty = int.Parse(j0["firstCnt"].ToString()); + } + } + } + + //stationQty = stationQty + ""; + stationQty = stationQty + ""; + + double rate = ((okQty * 1.0) / (okQty + ngQty)) * 100; + + if (j == rule_sation.Count - 2) + { + if (rate <= 90) + { + stationRate = stationRate + ""; + } + else if (rate >= 95 && rate <= 97) + { + stationRate = stationRate + ""; + } + else if (rate >= 98) + { + stationRate = stationRate + ""; + } + else + { + stationRate = stationRate + ""; + } + //stationRate = stationRate + ""; + } + else + { + //stationRate = stationRate + ""; + if (rate <= 90) + { + stationRate = stationRate + ""; + } + else if (rate >= 95 && rate <= 97) + { + stationRate = stationRate + ""; + } + else if (rate >= 98) + { + stationRate = stationRate + ""; + } + else + { + stationRate = stationRate + ""; + } + stationRate = stationRate + ""; + } + } + } + stationQty = stationQty + "
WIP" + rule_sation[j].StationDesc + "" + okQty + "/" + ngQty + "" + okQty + "/" + ngQty + "" + rate.ToString("0.00") + "%" + "" + rate.ToString("0.00") + "%" + "" + rate.ToString("0.00") + "%" + "" + rate.ToString("0.00") + "%" + "" + rate.ToString("0.00") + "%" + "" + rate.ToString("0.00") + "%" + "" + rate.ToString("0.00") + "%" + "" + rate.ToString("0.00") + "%" + "" + rate.ToString("0.00") + "%" + "" + rate.ToString("0.00") + "%" + "" + "" + " >> " + "" + "
"; + + stationRate = stationRate + ""; + + string[] station_list = stationList.Split(","); + + for (int j = 0; j < station_list.Length - 1; j++) + { + var wip_station1 = await _pcsApi.GetWipStation4QRS009Group(wip_id, int.Parse(station_list[j])); + + int okQty1 = 0, ngQty1 = 0; + + if (wip_station1.DataTotal > 0) + { + foreach (var data in wip_station1.Data) + { + JObject j1 = JObject.Parse(data.ToString()); + if (j1["ruleStatus"].ToString() == "P") + { + okQty1 = int.Parse(j1["firstCnt"].ToString()); + } + else + { + ngQty1 = int.Parse(j1["firstCnt"].ToString()); + } + } + } + + int okQty2 = 0, ngQty2 = 0; + //计算WIP + if (j < station_list.Length - 2) + { + var wip_station2 = await _pcsApi.GetWipStation4QRS009Group(wip_id, int.Parse(station_list[j + 1])); + + if (wip_station2.DataTotal > 0) + { + foreach (var data in wip_station2.Data) + { + JObject j2 = JObject.Parse(data.ToString()); + if (j2["ruleStatus"].ToString() == "P") + { + okQty2 = int.Parse(j2["firstCnt"].ToString()); + } + else + { + ngQty2 = int.Parse(j2["firstCnt"].ToString()); + } + } + } + } + int wip_qty = okQty1 + ngQty1 - okQty2 - ngQty2; + if (wip_qty < 0) + { + wip_qty = 0; + } + stationWip = stationWip + "" + wip_qty + ""; + } + + stationWip = stationWip + "
"; + + wipDataList = wipDataList + ""; + + wipDataList = wipDataList + stationQty; + wipDataList = wipDataList + stationRate; + wipDataList = wipDataList + stationWip; + + } + } + else + { + wipDataList = wipDataList + "查无资料"; + } + wipDataList = wipDataList + "
"; + ViewData["WipDataList"] = wipDataList; + return View(); + } + [ResponseCache(Duration = 0)] [HttpGet] public async Task GetWipStationPassBarcode(string id, int page = 0, int limit = 10) diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 4ba2a43b..e23b8151 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -892,7 +892,7 @@ namespace AMESCoreStudio.Web #endregion - #region QRS010 + #region QRS010 良率 /// /// 良率查詢QRS010 @@ -910,6 +910,17 @@ namespace AMESCoreStudio.Web #endregion + #region QRS011 生產進度查詢 + + /// + /// 查詢工單基本資料QRS011 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WipInfos/GetWipInfo4QRS011")] + ITask> GetWipInfo4QRS011(string unitNo, string itemNO, string wipNO); + + #endregion + #region WipKp 工單KP資訊資料檔 /// /// 查詢工單號碼 對應 WipKp diff --git a/AMESCoreStudio.Web/Views/QRS/QRS011.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS011.cshtml new file mode 100644 index 00000000..19e564f1 --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS011.cshtml @@ -0,0 +1,75 @@ +@{ + ViewData["Title"] = "生產進度查詢"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+ +
+
+
+
+
+
+
+ +
+ +
+ +
+
+
+
+ +
+ +
+
+
+
+
+ +
+ +
+
+
+
+
+ +
+
+
+
+
+
+@section Scripts{ + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); + await Html.RenderPartialAsync("_FileinputScriptsPartial"); } + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/QRS/QRS011A.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS011A.cshtml new file mode 100644 index 00000000..42ec4686 --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS011A.cshtml @@ -0,0 +1,17 @@ +@{ + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+ +
+
+
+ @Html.Raw(ViewData["WipDataList"]) +
+
diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs index e162e2de..21babf79 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs @@ -99,6 +99,66 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return result; } + /// + /// 查詢工單資料QRS011 + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetWipInfo4QRS011(string unitNo, string itemNO, string wipNO) + { + ResultModel result = new ResultModel(); + var q = from q1 in _context.WipInfos + join q2 in _context.WipAtts on q1.WipNO equals q2.WipNO + join q3 in _context.LineInfoes on q1.LineID equals q3.LineID + join q4 in _context.FactoryUnits on q1.UnitNO equals q4.UnitNo + select new + { + q1.WipID, + q1.WipNO, + q1.PlanQTY, + q1.CompleteQTY, + q1.UnitNO, + q1.LineID, + q1.FlowRuleID, + q1.StatusNO, + q1.CreateDate, + q2.ItemNO, + q3.LineDesc, + q4.UnitName + }; + + q = q.Where(w => w.StatusNO == "A"); + if (unitNo != "*") + { + q = q.Where(w => w.UnitNO == unitNo); + } + if (itemNO != null && itemNO != "") + { + q = q.Where(w => w.ItemNO == itemNO); + } + if (wipNO != null && wipNO != "") + { + q = q.Where(w => w.WipNO == wipNO); + } + + //紀錄筆數 + result.DataTotal = q.Count(); + + result.Data = await q.ToListAsync(); + + if (result == null) + { + result.Msg = "查無資料"; + result.Success = false; + return result; + } + + result.Success = true; + result.Msg = "OK"; + return result; + } + /// /// 查詢工單資料 by SelectParameter /// diff --git a/AMESCoreStudio.WebApi/Controllers/SYS/ProgramInfoesController.cs b/AMESCoreStudio.WebApi/Controllers/SYS/ProgramInfoesController.cs index 0fa1b20f..02cd8bdb 100644 --- a/AMESCoreStudio.WebApi/Controllers/SYS/ProgramInfoesController.cs +++ b/AMESCoreStudio.WebApi/Controllers/SYS/ProgramInfoesController.cs @@ -35,7 +35,14 @@ namespace AMESCoreStudio.WebApi.Controllers.SYS [HttpGet] public async Task>> GetProgramInfo() { - return await _context.ProgramInfoes.ToListAsync(); + IQueryable q = _context.ProgramInfoes; + + q = q.OrderBy(p => p.ProgramNo); + + var programInfo = await q.ToListAsync(); + + return programInfo; + //return await _context.ProgramInfoes.ToListAsync(); } ///