mes集成增加MesCallResult
This commit is contained in:
@@ -12,6 +12,7 @@ using JY.Inspection.Frm;
|
||||
using JY.Inspection.Mes;
|
||||
using JY.MES;
|
||||
using JY.MES.Entity;
|
||||
using JY.MES.Enum;
|
||||
using JY.MES.MES;
|
||||
using JY.Model;
|
||||
using JY.Model.Excel;
|
||||
@@ -2434,17 +2435,17 @@ namespace JY.Inspection
|
||||
if (m != null)
|
||||
{
|
||||
#region 3、产品结果加工参数
|
||||
MesResponse resMes = ToMesData.ProductResultParameters(m);
|
||||
if (!resMes.success)
|
||||
MesCallResult<RespProductResult> resMes = ToMesData.ProductResultParameters(m);
|
||||
if (!resMes.IsSuccess)
|
||||
{
|
||||
if (resMes.error == 99)
|
||||
if (resMes.ErrorType == MesErrorType.NetworkError || resMes.ErrorType == MesErrorType.NetworkTimeout)
|
||||
{
|
||||
omronPLCCom.lstMcUI[0].WriteDReg("W249", (short)1);//MES网络异常
|
||||
LogManagerControl.AddLog("结果数据上传MES超时或无法访问MES服务器", LogAddtype.local, Logtype.Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogManagerControl.AddLog("结果数据上传MES失败NG" + resMes.message, LogAddtype.local, Logtype.Error);
|
||||
LogManagerControl.AddLog("结果数据上传MES失败NG" + resMes.OriResponse.Message, LogAddtype.local, Logtype.Error);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -2469,7 +2470,7 @@ namespace JY.Inspection
|
||||
}
|
||||
}
|
||||
};
|
||||
RespArrivalStation resp = ToMesData.PostProductExitStationData(req);
|
||||
RespExitStation resp = ToMesData.PostProductExitStationData(req);
|
||||
|
||||
if (resp == null || !resp.Success)
|
||||
{
|
||||
|
||||
@@ -487,6 +487,8 @@
|
||||
<None Include="Resources\设备报警.png" />
|
||||
<None Include="Resources\报警记录.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<Folder Include="Exceptions\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
@@ -1,4 +1,7 @@
|
||||
using JY.MES;
|
||||
using JY.MES.Entity;
|
||||
using JY.MES.Enum;
|
||||
using JY.MES.Exceptions;
|
||||
using JY.MES.MES;
|
||||
using JY.Model;
|
||||
using JY.Utility;
|
||||
@@ -7,6 +10,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
|
||||
namespace JY.Inspection.Mes
|
||||
{
|
||||
@@ -25,7 +29,7 @@ namespace JY.Inspection.Mes
|
||||
/// </summary>
|
||||
/// <param name="m"></param>
|
||||
/// <returns></returns>
|
||||
MesResponse ProductResultParameters(BlankingData m);
|
||||
MesCallResult<RespProductResult> ProductResultParameters(BlankingData m);
|
||||
|
||||
/// <summary>
|
||||
/// 产品进站(包装)
|
||||
@@ -131,9 +135,9 @@ namespace JY.Inspection.Mes
|
||||
#endregion
|
||||
|
||||
#region 2、结果加工参数
|
||||
public MesResponse ProductResultParameters(BlankingData m)
|
||||
public MesCallResult<RespProductResult> ProductResultParameters(BlankingData m)
|
||||
{
|
||||
MesResponse mesResponse = new MesResponse();
|
||||
MesCallResult<RespProductResult> resp = new MesCallResult<RespProductResult>();
|
||||
DateTime nowTime = DateTime.Now;
|
||||
string josnTxtMsg = string.Empty;
|
||||
try
|
||||
@@ -184,7 +188,8 @@ namespace JY.Inspection.Mes
|
||||
}
|
||||
|
||||
// 生成TagDataVoListItem
|
||||
tdvls.Add(new TagDataVOListItem() {
|
||||
tdvls.Add(new TagDataVOListItem()
|
||||
{
|
||||
tagCode = cfgItem.MesItemCode,
|
||||
tagValue = item.Value,
|
||||
tagTime = m.OutTime,
|
||||
@@ -209,30 +214,25 @@ namespace JY.Inspection.Mes
|
||||
|
||||
var sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string mesRes = MESApiHelper.HttpPostJsonAPI(Global.systemConfig.ResultProcessMesUrl, p, Global.systemConfig.MesRequestTime);
|
||||
var mesCallResult = MESApiHelper.HttpPostJsonAPI<RespProductResult>(Global.systemConfig.ResultProcessMesUrl, p, Global.systemConfig.MesRequestTime);
|
||||
sw.Stop();
|
||||
|
||||
var res = JsonConvert.DeserializeObject<dynamic>(mesRes);
|
||||
mesResponse.success = res.success.Value;
|
||||
if (!res.success.Value)
|
||||
if (mesCallResult?.OriResponse?.Success != true)
|
||||
{
|
||||
mesResponse.code = res.code.Value;
|
||||
mesResponse.message = res.message.Value;
|
||||
if (mesRes.Contains("category"))
|
||||
mesResponse.category = res.category.Value;
|
||||
if (res.error != null)
|
||||
mesResponse.error = (int)res.error.Value;
|
||||
resp.IsSuccess = false;
|
||||
resp.ErrorType = MesErrorType.BusinessError;
|
||||
resp.ErrorMessage = mesCallResult?.OriResponse.Message ?? "MES业务处理失败";
|
||||
}
|
||||
|
||||
new MesLog().LogProductResult(nowTime, p, mesRes, sw.ElapsedMilliseconds);
|
||||
new MesLog().LogProductResult(nowTime, p, mesCallResult.OriRespJsonStr, sw.ElapsedMilliseconds);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
mesResponse.success = false;
|
||||
mesResponse.error = 9;
|
||||
mesResponse.message = "结果加工参数上传异常:" + ex.Message;
|
||||
resp.IsSuccess = false;
|
||||
resp.ErrorType = MesErrorType.ClientError;
|
||||
resp.ErrorMessage = "结果加工参数上传异常:" + ex.Message;
|
||||
}
|
||||
return mesResponse;
|
||||
return resp;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user