mes集成增加MesCallResult

This commit is contained in:
liming 蔡
2026-07-14 16:09:25 +08:00
parent 5d2c7afb9c
commit 2ecfd549b3
12 changed files with 198 additions and 49 deletions
+19 -19
View File
@@ -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