5 changed files with 333 additions and 0 deletions
@ -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<QRSController> _logger; |
||||
|
public readonly IREP _repApi; |
||||
|
public readonly IPPS _ppsApi; |
||||
|
public readonly IBAS _basApi; |
||||
|
public readonly IPCS _pcsApi; |
||||
|
private readonly IWebHostEnvironment _env; |
||||
|
|
||||
|
public QRSController(ILogger<QRSController> 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<IActionResult> QRS009() |
||||
|
{ |
||||
|
IResultModel<dynamic> result = await _pcsApi.GetWipInfo4QRS009(); |
||||
|
|
||||
|
string wipDataList = "<font size='3'>"; |
||||
|
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 + "<font color='#FF80FF'>" + unit_name + " - " + line_desc + "</font>" + " - " + "<font color='#0080FF'>" + wip_no + "</font>" + "<font color='#FFC90E'>" + "(" + item_no + ")" + "</font>" + " - " + "<font color='#0080FF'>" + plan_qty + " / " + input_qty + " / " + output_qty + "</font>" +" | "+ "<font color='#0080FF'>" + "標準工時: " + "</font>" + ct1 + "<br/>"; |
||||
|
|
||||
|
var rule_sation = await _basApi.GetRuleStationsByFlow(flow_rule_id); |
||||
|
wipDataList = wipDataList + "<table><tr><td width='120'></td>"; |
||||
|
|
||||
|
string stationQty = "<table><tr><td width='120'>過站數量</td>"; |
||||
|
string stationRate = "<table><tr><td width='120'>良率</td>"; |
||||
|
string stationWip = "<table><tr><td width='120'>WIP</td>"; |
||||
|
|
||||
|
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 + "<td width='150' style='text-align:left'>" + rule_sation[j].StationDesc + "</td>"; |
||||
|
|
||||
|
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 + "<td width='150' style='text-align:left'>" + okQty + "/" + ngQty + "</td>"; |
||||
|
|
||||
|
double rate = ((okQty * 1.0) / (okQty + ngQty)) * 100; |
||||
|
|
||||
|
if (j == rule_sation.Count - 2) |
||||
|
{ |
||||
|
stationRate = stationRate + "<td width='150' style='text-align:left'>" + rate.ToString("0.00") + "%" + "</td>"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
stationRate = stationRate + "<td width='90' style='text-align:left'>" + rate.ToString("0.00") + "%" + "</td>"; |
||||
|
stationRate = stationRate + "<td width='60' style='text-align:left'>" + "<font color='#FF80FF'>" + " >> " + "</font>" + "</td>"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
stationQty = stationQty + "</tr></table>"; |
||||
|
|
||||
|
stationRate = stationRate + "</tr></table>"; |
||||
|
|
||||
|
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 + "<td width='150' style='text-align:left'>" + (okQty1 + ngQty1 - okQty2 - ngQty2) + "</td>"; |
||||
|
} |
||||
|
|
||||
|
stationWip = stationWip + "</tr></table><br/>"; |
||||
|
|
||||
|
wipDataList = wipDataList + "</tr></table>"; |
||||
|
|
||||
|
wipDataList = wipDataList + stationQty; |
||||
|
wipDataList = wipDataList + stationRate; |
||||
|
wipDataList = wipDataList + stationWip; |
||||
|
|
||||
|
/* |
||||
|
wipDataList = wipDataList + "<table><tr><td width='120'>過站數量</td>"; |
||||
|
for (int j = 0; j < rule_sation.Count; j++) |
||||
|
{ |
||||
|
if (rule_sation[j].StationID != 1000 && rule_sation[j].StationType == "M") |
||||
|
{ |
||||
|
wipDataList = wipDataList + "<td width='150' style='text-align:left'>" + "0/0" + "</td>"; |
||||
|
} |
||||
|
} |
||||
|
wipDataList = wipDataList + "</tr></table>"; |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
wipDataList = wipDataList + "<table><tr><td width='120'>良率</td>"; |
||||
|
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 + "<td width='150' style='text-align:left'>" + "100%" + "</td>"; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
wipDataList = wipDataList + "<td width='90' style='text-align:left'>" + "100%" + "</td>"; |
||||
|
wipDataList = wipDataList + "<td width='60' style='text-align:left'>" + "<font color='#FF80FF'>" + " >> " + "</font>" + "</td>"; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
wipDataList = wipDataList + "</tr></table>"; |
||||
|
*/ |
||||
|
|
||||
|
/* |
||||
|
wipDataList = wipDataList + "<table><tr><td width='120'>WIP</td>"; |
||||
|
for (int j = 0; j < rule_sation.Count; j++) |
||||
|
{ |
||||
|
if (rule_sation[j].StationID != 1000 && rule_sation[j].StationType == "M") |
||||
|
{ |
||||
|
wipDataList = wipDataList + "<td width='150' style='text-align:left'>" + "0" + "</td>"; |
||||
|
} |
||||
|
} |
||||
|
wipDataList = wipDataList + "</tr></table><br/>"; |
||||
|
*/ |
||||
|
} |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
wipDataList = wipDataList + "查无资料"; |
||||
|
} |
||||
|
wipDataList = wipDataList + "</font>"; |
||||
|
ViewData["WipDataList"] = wipDataList; |
||||
|
return View(); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
@{ |
||||
|
ViewData["Title"] = "在製分布圖"; |
||||
|
Layout = "~/Views/Shared/_AMESLayout.cshtml"; |
||||
|
} |
||||
|
|
||||
|
<div class="layui-card"> |
||||
|
<div class="layui-card-header"> |
||||
|
<div class="layui-form"> |
||||
|
<div class="layui-form-item "> |
||||
|
<div class="layui-inline"><i class="fa fa-file-text-o fa-fw"></i> @ViewBag.Title</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<div class="layui-card-body"> |
||||
|
@Html.Raw(ViewData["WipDataList"]) |
||||
|
</div> |
||||
|
</div> |
Loading…
Reference in new issue