From 0c8d272ad9b6ccddb74cb96253eb9bafc4f4a01f Mon Sep 17 00:00:00 2001 From: Marvin Date: Wed, 9 Feb 2022 11:17:51 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=96=B0=E5=A2=9E=E5=9C=A8=E5=88=B6=E5=88=86?= =?UTF-8?q?=E5=B8=83=E5=9B=BEQRS009?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/QRSController.cs | 223 ++++++++++++++++++ AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs | 19 ++ AMESCoreStudio.Web/Views/QRS/QRS009.cshtml | 18 ++ .../Controllers/AMES/WipInfosController.cs | 49 ++++ .../Controllers/AMES/WipStationController.cs | 24 ++ 5 files changed, 333 insertions(+) create mode 100644 AMESCoreStudio.Web/Controllers/QRSController.cs create mode 100644 AMESCoreStudio.Web/Views/QRS/QRS009.cshtml diff --git a/AMESCoreStudio.Web/Controllers/QRSController.cs b/AMESCoreStudio.Web/Controllers/QRSController.cs new file mode 100644 index 00000000..2444b457 --- /dev/null +++ b/AMESCoreStudio.Web/Controllers/QRSController.cs @@ -0,0 +1,223 @@ +using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Microsoft.Extensions.Logging; +using AMESCoreStudio.CommonTools.Result; +using Microsoft.AspNetCore.Hosting; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace AMESCoreStudio.Web.Controllers +{ + public class QRSController : Controller + { + private readonly ILogger _logger; + public readonly IREP _repApi; + public readonly IPPS _ppsApi; + public readonly IBAS _basApi; + public readonly IPCS _pcsApi; + private readonly IWebHostEnvironment _env; + + public QRSController(ILogger logger, IREP repApi, IPPS ppsApi, IBAS basApi, IPCS pcsApi, IWebHostEnvironment env) + { + _logger = logger; + _repApi = repApi; + _ppsApi = ppsApi; + _basApi = basApi; + _pcsApi = pcsApi; + _env = env; + } + + public async Task QRS009() + { + IResultModel result = await _pcsApi.GetWipInfo4QRS009(); + + 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.GetWipStation4QRS009(wip_id, rule_sation[j].RuleStationID); + + int okQty = 0, ngQty = 0; + if (wip_station.Count > 0) + { + for (int k = 0; k < wip_station.Count; k++) + { + if (wip_station[k].RuleStatus == "P") + { + okQty = wip_station[k].FirstCnt; + } + else + { + ngQty = wip_station[k].FirstCnt; + } + } + } + + stationQty = stationQty + ""; + + double rate = ((okQty * 1.0) / (okQty + ngQty)) * 100; + + if (j == rule_sation.Count - 2) + { + stationRate = stationRate + ""; + } + else + { + stationRate = stationRate + ""; + stationRate = stationRate + ""; + } + } + } + stationQty = stationQty + "
WIP" + rule_sation[j].StationDesc + "" + okQty + "/" + ngQty + "" + 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.GetWipStation4QRS009(wip_id, int.Parse(station_list[j])); + + int okQty1 = 0, ngQty1 = 0; + + if (wip_station1.Count > 0) + { + for (int k = 0; k < wip_station1.Count; k++) + { + if (wip_station1[k].RuleStatus == "P") + { + okQty1 = wip_station1[k].FirstCnt; + } + else + { + ngQty1 = wip_station1[k].FirstCnt; + } + } + } + + int okQty2 = 0, ngQty2 = 0; + //计算WIP + if (j < station_list.Length - 2) + { + var wip_station2 = await _pcsApi.GetWipStation4QRS009(wip_id, int.Parse(station_list[j+1])); + + if (wip_station2.Count > 0) + { + for (int k = 0; k < wip_station2.Count; k++) + { + if (wip_station2[k].RuleStatus == "P") + { + okQty2 = wip_station2[k].FirstCnt; + } + else + { + ngQty2 = wip_station2[k].FirstCnt; + } + } + } + } + stationWip = stationWip + "" + (okQty1 + ngQty1 - okQty2 - ngQty2) + ""; + } + + stationWip = stationWip + "
"; + + wipDataList = wipDataList + ""; + + wipDataList = wipDataList + stationQty; + wipDataList = wipDataList + stationRate; + wipDataList = wipDataList + stationWip; + + /* + wipDataList = wipDataList + ""; + for (int j = 0; j < rule_sation.Count; j++) + { + if (rule_sation[j].StationID != 1000 && rule_sation[j].StationType == "M") + { + wipDataList = wipDataList + ""; + } + } + wipDataList = wipDataList + "
過站數量" + "0/0" + "
"; + */ + + /* + wipDataList = wipDataList + ""; + for (int j = 0; j < rule_sation.Count; j++) + { + if (rule_sation[j].StationID != 1000 && rule_sation[j].StationType == "M") + { + if (j == rule_sation.Count - 2) + { + wipDataList = wipDataList + ""; + } + else + { + wipDataList = wipDataList + ""; + wipDataList = wipDataList + ""; + } + } + } + wipDataList = wipDataList + "
良率" + "100%" + "" + "100%" + "" + "" + " >> " + "" + "
"; + */ + + /* + wipDataList = wipDataList + ""; + for (int j = 0; j < rule_sation.Count; j++) + { + if (rule_sation[j].StationID != 1000 && rule_sation[j].StationType == "M") + { + wipDataList = wipDataList + ""; + } + } + wipDataList = wipDataList + "
WIP" + "0" + "

"; + */ + } + } + else + { + wipDataList = wipDataList + "查无资料"; + } + wipDataList = wipDataList + "
"; + ViewData["WipDataList"] = wipDataList; + return View(); + } + } +} diff --git a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs index 4c9e2174..9c08f3e1 100644 --- a/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs +++ b/AMESCoreStudio.Web/HttpApis/AMES/IPCS.cs @@ -722,6 +722,25 @@ namespace AMESCoreStudio.Web #endregion + #region QRS009 + + /// + /// 查詢工單基本資料QRS009 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WipInfos/GetWipInfo4QRS009")] + ITask> GetWipInfo4QRS009(); + + + /// + /// 查詢工單站别资料 + /// + /// + [WebApiClient.Attributes.HttpGet("api/WipStation/GetWipStation4QRS009")] + ITask> GetWipStation4QRS009(int wipID,int ruleStationID); + + #endregion + diff --git a/AMESCoreStudio.Web/Views/QRS/QRS009.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS009.cshtml new file mode 100644 index 00000000..370be687 --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS009.cshtml @@ -0,0 +1,18 @@ +@{ + ViewData["Title"] = "在製分布圖"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+
+
+ +
+ @Html.Raw(ViewData["WipDataList"]) +
+
\ No newline at end of file diff --git a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs index e0e8b8bd..52f9b70a 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipInfosController.cs @@ -50,6 +50,55 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return WipInfo; } + /// + /// 查詢工單資料QRS009 + /// + /// + [Route("[action]")] + [HttpGet] + public async Task> GetWipInfo4QRS009() + { + 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"); + + + //紀錄筆數 + 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/AMES/WipStationController.cs b/AMESCoreStudio.WebApi/Controllers/AMES/WipStationController.cs index 35ca62ab..8d400f41 100644 --- a/AMESCoreStudio.WebApi/Controllers/AMES/WipStationController.cs +++ b/AMESCoreStudio.WebApi/Controllers/AMES/WipStationController.cs @@ -47,6 +47,30 @@ namespace AMESCoreStudio.WebApi.Controllers.AMES return wipStation; } + /// + /// 基本查詢 + /// + /// 工單ID + /// 流程ID + /// + [HttpGet("GetWipStation4QRS009")] + public async Task>> GetWipStation4QRS009(int wipID, int ruleStationID) + { + IQueryable q = _context.WipStations; + + + if (wipID != 0) + q = q.Where(w => w.WipID == wipID); + + + if (ruleStationID != 0) + q = q.Where(w => w.RuleStationID == ruleStationID); + + var result = await q.ToListAsync(); + + return result; + } + /// /// 基本查詢 ///