ProcessRouteUpMom.cs
2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using Hh.Mes.Common.config;
using Hh.Mes.Common.log;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.Pojo.System;
using Newtonsoft.Json;
using Hh.Mes.POJO.ApiEntity;
using Hh.Mes.Service.Logs;
using Hh.Mes.POJO.Response;
namespace Hh.Mes.Service.ApiService
{
public partial class UpstreamService
{
/// <summary>
/// 工序执行反馈
/// </summary>
/// <remarks>
/// <para><a href="https://kdocs.cn/l/caBR6DBb2LpP">MOM-产线中控接口文档</a></para>
/// <para><a href="https://www.bejson.com/">Josn在线解析工具</a></para>
/// </remarks>
/// <returns><see cref="Response"/></returns>
public Response ProcessRouteUpMom(ProcessRouteUpMomEntity entity)
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var resultToken = GetMomToken();
if (!resultToken.Item1)
{
QueueInterLog.GetInstance.EnqueueInterLog(null, null, EnumLog.报工至MOM失败.ToString(), response.Message, 0, user: "AOP", sysTitle: EnumLog.MOM业务问题.ToString());
return response.ResponseError(resultToken.Item2);
}
var urlDic = "UrlProcessRouteUpMom" + ConfigRead.GetInstance.GetAppsetConnection().AppCustomExtend1;
var url = GetDictionaryDictValue(urlDic, "GetUrl");
var json = JsonConvert.SerializeObject(entity);
response = HttpMan(url, json, EnumLog.工序执行反馈.ToString(), token: resultToken.Item2);
if (response.Status)
{
return response.ResponseSuccess();
}
Log4NetHelper.Instance.Error($"【MOM工序执行反馈--返回结果】" + response.Result);
MOMResult momResult = JsonConvert.DeserializeObject<MOMResult>(response.Result);
if (momResult.MSG.Contains("作业工单数据已完成"))
{
return response.ResponseSuccess("作业工单数据在MOM系统中已经完成");
}
else
{
QueueInterLog.GetInstance.EnqueueInterLog(null, null, EnumLog.报工至MOM失败.ToString(), response.Message, 0, user: "AOP", sysTitle: EnumLog.MOM业务问题.ToString());
}
response.Message = $"【MOM】PLMEID:{momResult.PLMEID},生产计划号:{entity.plan_code},工序编码:{entity.proced_code},错误原因:{momResult.MSG},STATUS:{momResult.STATUS}";
response.Result = "";
return response;
});
}
}
}