SemiFinishedManager.cs
3.9 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using AGVLib;
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CtuDeviceLib.manager
{
public class SemiFinishedManager
{
static string packLineServer { get { return ConfigAppSettings.GetValue("packLineServer", "http://10.68.52.23:8081"); } }
//10.68.52.23:8081
//HsdServer/StorageStatus/InStorage
//POST
//
/// <summary>
/// 请求是否可以放料
/// </summary>
/// <returns></returns>
public static bool CanPut()
{
bool enable = ConfigAppSettings.GetValue("Enable_InlineComm", true);
if (!enable) return true;
try
{
string server = packLineServer+"/HsdServer/StorageStatus/InStorage";
string content = JsonHelper.SerializeObject(new clsRequest());
string json = HttpHelper.Post(server, content);
clsRtn rtnData = JsonHelper.DeserializeJsonToObject<clsRtn>(json);
if (string.IsNullOrEmpty(json))
{
LogUtil.error($"请求入料线体是否放料异常【{content}】【{json}】");
}
if (rtnData != null && rtnData.code == 0)
{
return true;
}
}
catch (Exception ex)
{
LogUtil.error("请求入料线体是否放料异常", ex);
}
return false;
}
public static bool PutOK()
{
bool enable = ConfigAppSettings.GetValue("Enable_InlineComm", true);
if (!enable) return true;
try
{
string server = packLineServer+"/HsdServer/StorageStatus/InStorage";
string content = JsonHelper.SerializeObject(new clsRequest2());
string json = HttpHelper.Post(server, content);
clsRtn rtnData = JsonHelper.DeserializeJsonToObject<clsRtn>(json);
if (string.IsNullOrEmpty(json))
{
LogUtil.error($"入料线体放料完成通知异常【{content}】【{json}】");
}
if (rtnData != null && rtnData.code == 0)
{
return true;
}
}
catch (Exception ex)
{
LogUtil.error("入料线体放料完成通知异常", ex);
}
return false;
}
/// <summary>
///
/// </summary>
/// <returns></returns>
public static bool CheckCarton(out clsCarton carton)
{
carton = null;
bool enable = ConfigAppSettings.GetValue("Enable_InlineComm", true);
if (!enable) return false;
try
{
string server = packLineServer+"/HsdServer/StorageStatus/CheckCarton";
string content = JsonHelper.SerializeObject(new clsRequest());
string json = HttpHelper.Post(server, content);
carton = JsonHelper.DeserializeJsonToObject<clsCarton>(json);
if (carton != null && carton.cartonCode == 0)
{
return true;
}
}
catch (Exception ex)
{
LogUtil.error("CheckCarton error", ex);
}
return false;
}
}
public class clsCarton
{
public int cartonCode { get; set; }
public string cartonID { get; set; }
}
class clsRtn
{
/// <summary>
/// 0允许
/// -1,不允许
/// </summary>
public int code { get; set; }
}
class clsRequest
{
public string RequestCode { get; set; } = "1";
}
class clsRequest2
{
public string Finish { get; set; } = "1";
}
}