AndonUpMom.cs
3.04 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
61
62
63
64
65
66
67
68
69
70
using Hh.Mes.Common.config;
using Hh.Mes.Common.log;
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.ApiEntity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Newtonsoft.Json;
namespace Hh.Mes.Service.ApiService
{
public partial class UpstreamService
{
/// <summary>
/// ANDON信息反馈
/// </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 AndonUpMom(AndonUpMomEntity andonUpMomEntity)
{
var response = new Response();
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var resultToken = GetMomToken();
if (!resultToken.Item1) return response.ResponseError(resultToken.Item2);
var urlDic = "UrlAndonUpMom" + ConfigRead.GetInstance.GetAppsetConnection().AppCustomExtend1;
var url = GetDictionaryDictValue(urlDic, "GetUrl");
//var url = "http://10.77.101.247:51001/mom/intf/intfMbosLineTaskAndon/receive";
#region 测试数据
//var sendData = new AndonUpMomEntity();
//var item = new AndonUpMomDetail()
//{
// id = "01",
// line_code = "TZTTHW",
// device_information = "xxx",
// device_fault_type = "xxx",
// device_fault_description = "xxx",
// device_status = "1",
// start_time = DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd HH:mm:ss"),
// end_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
// ylzd1 = "1",
// type = EnumAction.I.ToString()
//};
//sendData.andon_list.Add(item);
#endregion
var json = JsonConvert.SerializeObject(andonUpMomEntity);
//var json = "{\"andon_list\":[{\"id\":\"01\",\"line_code\":\"zjqzzz\",\"device_information\":\"xxx\",\"device_fault_type\":\"xxx\",\"device_fault_description\":\"xxx\",\"device_status\":\"1\",\"start_time\":\"2008-02-21 12:00:00\",\"end_time\":\"2014-02-21 12:00:00\",\"ylzd1\":\"1\",\"type\":\"i\"}]}";
response = HttpMan(url, json, EnumLog.ANDON报警.ToString(), token: resultToken.Item2);
if (response.Code == 200)
{
return response.ResponseSuccess();
}
//Log4NetHelper.Instance.Error($"【MOM返回结果】" + response.Result);
MOMResult momResult = JsonConvert.DeserializeObject<MOMResult>(response.Result);
response.Message = $"【MOM】PLMEID:{momResult.PLMEID},错误原因:{momResult.MSG},STATUS:{momResult.STATUS}";
response.Result = "";
return response;
});
}
}
}