|
|
using Microsoft.AspNetCore.Http;
|
|
|
using Sln.Iot.PLC;
|
|
|
using Sln.Iot.Serilog;
|
|
|
using Sln.Iot.Socket;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Net.NetworkInformation;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace Sln.Iot.Business
|
|
|
{
|
|
|
public class MesReportBusiness
|
|
|
{
|
|
|
private Timer _timer;
|
|
|
private readonly SerilogHelper _log = SerilogHelper.Instance;
|
|
|
private readonly DeltaHttpClient _deltaHttpClient = DeltaHttpClient.Instance;
|
|
|
|
|
|
public string InterfaceID;
|
|
|
public string Status = "0";
|
|
|
public string StatusCode = "0";
|
|
|
|
|
|
public int PassQuantity = 0;
|
|
|
public int FailQuantity = 0;
|
|
|
public string ErrorCount = "0";
|
|
|
public string ErrorTime = "0";
|
|
|
public double CycleTime = 0;
|
|
|
public double RunningTime = 0;
|
|
|
public double WaitingTime = 0;
|
|
|
public int InputQuantity = 0;
|
|
|
public string Barcode = "0";
|
|
|
public int Cya = 0;
|
|
|
|
|
|
public MesReportBusiness()
|
|
|
{
|
|
|
_deltaHttpClient.Init();
|
|
|
_timer = new Timer(TimerCallback, null, 0, 1000*15);
|
|
|
}
|
|
|
|
|
|
public void TimerCallback(object? state)
|
|
|
{
|
|
|
_deltaHttpClient.PostRequestSend(tranter());
|
|
|
}
|
|
|
|
|
|
private string tranter()
|
|
|
{
|
|
|
|
|
|
#region 傳送字的資料
|
|
|
string strSendData;
|
|
|
strSendData = "[{";
|
|
|
// strSendData += "\"factory\":\"" + "DG5" + "\",";
|
|
|
strSendData += "\"interfaceID\":\"" + InterfaceID + "\",";
|
|
|
// strSendData += "\"EquipType\":" + EquipType + ",";
|
|
|
strSendData += "\"status\":" + Status + ",";
|
|
|
strSendData += "\"statusCode\":\"" + StatusCode + "\",";
|
|
|
strSendData += "\"passQty\":" + PassQuantity + ",";
|
|
|
strSendData += "\"failQty\":" + FailQuantity + ",";
|
|
|
strSendData += "\"errorCnt\":" + ErrorCount + ",";
|
|
|
strSendData += "\"errorTimes\":" + ErrorTime + ",";
|
|
|
strSendData += "\"cycleTime\":" + CycleTime + ",";
|
|
|
strSendData += "\"runningTime\":" + RunningTime + ",";
|
|
|
strSendData += "\"waitingTime\":" + WaitingTime + ",";
|
|
|
// strSendData += "\"selfCheck\":" + (SELFCHECK ? "1" : "0") + ",";
|
|
|
strSendData += "\"selfCheck\":" + "1" + ",";
|
|
|
strSendData += "\"inputQty\":" + InputQuantity + ",";
|
|
|
strSendData += "\"barcode\":\"" + Barcode + "\",";
|
|
|
strSendData += "\"model\":\"" + Cya + "\",";
|
|
|
|
|
|
//端子壽命
|
|
|
strSendData += "\"paramList\":[";
|
|
|
// strSendData += "{\"paramCode\":\"" + Key1 + "\",";
|
|
|
// strSendData += "\"paramValue\":\"" + Value1 + "\"},";
|
|
|
// strSendData += "{\"paramCode\":\"" + Key2 + "\",";
|
|
|
// strSendData += "\"paramValue\":\"" + Value2 + "\"},";
|
|
|
// strSendData += "{\"paramCode\":\"" + Key3 + "\",";
|
|
|
// strSendData += "\"paramValue\":\"" + Value3 + "\"},";
|
|
|
//因为我们的数据此部分没有,如果再remove,将删除[,导致格式错误
|
|
|
// strSendData = strSendData.Remove(strSendData.Length - 1);//20170525 Tim 修改最後一個,沒刪除的bug
|
|
|
strSendData += "]";
|
|
|
strSendData += "}]";
|
|
|
|
|
|
#endregion
|
|
|
return strSendData;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|