diff --git a/AMESCoreStudio.Web/Controllers/QRSController.cs b/AMESCoreStudio.Web/Controllers/QRSController.cs index c26c83b4..00a1ad86 100644 --- a/AMESCoreStudio.Web/Controllers/QRSController.cs +++ b/AMESCoreStudio.Web/Controllers/QRSController.cs @@ -29,9 +29,11 @@ namespace AMESCoreStudio.Web.Controllers public readonly ISYS _sysApi; public readonly IKCS _kcsApi; public readonly IQRS _qrsApi; + public readonly IESUN _esunApi; + private readonly IWebHostEnvironment _env; - public QRSController(ILogger logger, IREP repApi, IPPS ppsApi, IBAS basApi, IPCS pcsApi, ISYS sysApi, IKCS kcsApi, IWebHostEnvironment env, IQRS qrsApi) + public QRSController(ILogger logger, IREP repApi, IPPS ppsApi, IBAS basApi, IPCS pcsApi, ISYS sysApi, IKCS kcsApi, IWebHostEnvironment env, IQRS qrsApi,IESUN esunApi) { _logger = logger; _repApi = repApi; @@ -41,6 +43,8 @@ namespace AMESCoreStudio.Web.Controllers _sysApi = sysApi; _kcsApi = kcsApi; _qrsApi = qrsApi; + _esunApi = esunApi; + _env = env; } @@ -775,6 +779,18 @@ namespace AMESCoreStudio.Web.Controllers ViewBag.UnitList = UnitItems; } + private async Task GetUnitList4ESUN() + { + var result = await _esunApi.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; + } + /// /// 線別 預設帶全部 /// @@ -10784,5 +10800,292 @@ namespace AMESCoreStudio.Web.Controllers return factoryNo; } + + public async Task QRS025() + { + await GetUnitList4ESUN(); + + return View(); + } + + /// + /// 生產進度查詢 + /// + /// 生產製程 + /// 料號 + /// 工單號碼 + /// 工單狀態:N(未完工) E(已完工) + /// + public async Task QRS025AAsync(string unitNo, string itemNO, string wipNO, string wipStatus) + { + ViewData["Title"] = "查詢條件 - 製程代碼 : " + unitNo + "; 料號 : " + itemNO + "; 工單號碼 : " + wipNO; + + string esun_wip_no = wipNO; + + if (wipNO != null) + { + var esun_wip = await _esunApi.GetWipInfoByRelatedWoNo(wipNO); + if (esun_wip.Count > 0) + { + esun_wip_no = esun_wip[0].WipNO; + } + } + + IResultModel result = await _esunApi.GetWipInfo4QRS011(unitNo, itemNO, esun_wip_no, wipStatus); + + 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 _esunApi.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 _esunApi.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") + if (rule_sation[j].StationType == "M") + { + stationList = stationList + rule_sation[j].StationID + ","; + + wipDataList = wipDataList + ""; + + var wip_station = await _esunApi.GetWipStation4QRS009Group(wip_id, rule_sation[j].StationID); + + 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()); + } + } + } + + // 完工站(1000)PASS資料 抓上一站PASS數 + if (rule_sation[j].StationID == 1000) + { + wip_station = await _esunApi.GetWipStation4QRS009Group(wip_id, rule_sation[j - 1].StationID); + 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()); + } + } + } + } + + stationQty = stationQty + ""; + + double rate = ((okQty * 1.0) / (okQty + ngQty)) * 100; + + if (okQty + ngQty == 0) + { + rate = 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].Station.StationName + "" + 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++) + { + int wip_qty = 0; + var wip_station1 = await _esunApi.GetWipBarcode4QRS009(wip_id, int.Parse(station_list[j]), 0, 10); + + if (wip_station1.DataTotal > 0) + { + wip_qty = wip_station1.DataTotal; + } + + 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(); + } + + public IActionResult QRS025P(string id) + { + string[] param = id.Split("_"); + ViewBag.WIP_ID = param[0]; + ViewBag.STATION_ID = param[1]; + + return View(); + } + + public IActionResult QRS025F(string id) + { + string[] param = id.Split("_"); + ViewBag.WIP_ID = param[0]; + ViewBag.STATION_ID = param[1]; + + return View(); + } + + public IActionResult QRS025W(string id) + { + string[] param = id.Split("_"); + ViewBag.WIP_ID = param[0]; + ViewBag.STATION_ID = param[1]; + + return View(); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWipStationPassBarcode4ESUN(string id, int page = 0, int limit = 10) + { + string[] param = id.Split("_"); + int wip_id = int.Parse(param[0]); + int station_id = int.Parse(param[1]); + + var result = await _esunApi.GetWipStationBarcode4QRS009(wip_id, station_id, "P", 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 }); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWipStationFailBarcode4ESUN(string id, int page = 0, int limit = 10) + { + string[] param = id.Split("_"); + int wip_id = int.Parse(param[0]); + int station_id = int.Parse(param[1]); + + var result = await _esunApi.GetWipStationBarcode4QRS009(wip_id, station_id, "F", 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 }); + } + + [ResponseCache(Duration = 0)] + [HttpGet] + public async Task GetWipStationBarcode4ESUN(string id, int page = 0, int limit = 10) + { + string[] param = id.Split("_"); + int wip_id = int.Parse(param[0]); + int station_id = int.Parse(param[1]); + + var result = await _esunApi.GetWipBarcode4QRS009(wip_id, station_id, 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/IESUN.cs b/AMESCoreStudio.Web/HttpApis/AMES/IESUN.cs new file mode 100644 index 00000000..ec2465c3 --- /dev/null +++ b/AMESCoreStudio.Web/HttpApis/AMES/IESUN.cs @@ -0,0 +1,72 @@ +using System.Collections.Generic; +using WebApiClient; +using WebApiClient.Attributes; +using AMESCoreStudio.WebApi; +using Microsoft.AspNetCore.Mvc; +using AMESCoreStudio.WebApi.Models.AMES; +using AMESCoreStudio.WebApi.Models.BAS; +using AMESCoreStudio.WebApi.DTO.AMES; +using AMESCoreStudio.CommonTools.Result; + +namespace AMESCoreStudio.Web +{ + [JsonReturn] + public interface IESUN:IHttpApi + { + /// + /// 獲取生產製程單位 + /// + /// + [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/FactoryUnits")] + ITask> GetFactoryUnits(); + + /// + /// 查詢工單資料Info By RelatedWONO + /// + /// + [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/WipInfos/WipInfoByRelatedWoNo/{RelatedWoNo}")] + ITask> GetWipInfoByRelatedWoNo(string RelatedWoNo); + + /// + /// 根据流程ID獲取流程站別資料 + /// + /// + [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/RuleStations/Flow/{id}")] + ITask> GetRuleStationsByFlow(int id, int page = 0, int limit = 10); + + /// + /// 查詢工單基本資料QRS011 + /// + /// + [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/WipInfos/GetWipInfo4QRS011")] + ITask> GetWipInfo4QRS011(string unitNo, string itemNO, string wipNO, string wipStatus); + + /// + /// 根據ID獲取指定機種C/T資料資料 + /// + /// + [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/CycleTimes/{id}")] + ITask> GetCycleTime(string id); + + /// + /// 查詢工單站别资料 + /// + /// + [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/WipStation/GetWipStation4QRS009Group")] + ITask> GetWipStation4QRS009Group(int wipID, int stationID); + + /// + /// 查詢工單站別在製條碼資料 + /// + /// + [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/BarcodeInfoes/GetWipBarcode4QRS009")] + ITask> GetWipBarcode4QRS009(int wipID, int stationID, int page, int limit); + + /// + /// 查詢工單站別條碼資料 + /// + /// + [WebApiClient.Attributes.HttpGet("http://192.168.4.109:5088/api/BarcodeStation/GetWipStationBarcode4QRS009")] + ITask> GetWipStationBarcode4QRS009(int wipID, int stationID, string ruleStatus, int page, int limit); + } +} diff --git a/AMESCoreStudio.Web/Views/QRS/QRS025.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS025.cshtml new file mode 100644 index 00000000..f429701b --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS025.cshtml @@ -0,0 +1,96 @@ +@{ + 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/QRS025A.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS025A.cshtml new file mode 100644 index 00000000..42ec4686 --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS025A.cshtml @@ -0,0 +1,17 @@ +@{ + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+
+
+
@ViewBag.Title
+
+ +
+
+
+ @Html.Raw(ViewData["WipDataList"]) +
+
diff --git a/AMESCoreStudio.Web/Views/QRS/QRS025F.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS025F.cshtml new file mode 100644 index 00000000..60de10c7 --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS025F.cshtml @@ -0,0 +1,53 @@ +@{ + ViewData["Title"] = "在製分布圖-過站FAIL條碼資料"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+ + +
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/QRS/QRS025P.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS025P.cshtml new file mode 100644 index 00000000..bae7a4f4 --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS025P.cshtml @@ -0,0 +1,53 @@ +@{ + ViewData["Title"] = "在製分布圖-過站PASS條碼資料"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+ + +
+
+
+ +@section Scripts{ + +} \ No newline at end of file diff --git a/AMESCoreStudio.Web/Views/QRS/QRS025W.cshtml b/AMESCoreStudio.Web/Views/QRS/QRS025W.cshtml new file mode 100644 index 00000000..9ecd8b73 --- /dev/null +++ b/AMESCoreStudio.Web/Views/QRS/QRS025W.cshtml @@ -0,0 +1,53 @@ +@{ + ViewData["Title"] = "在製分布圖-在製條碼資料"; + Layout = "~/Views/Shared/_AMESLayout.cshtml"; +} + +
+
+ + +
+
+
+ +@section Scripts{ + +} \ No newline at end of file