Basket.cs
6.1 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
using CtuDeviceLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
namespace Mushiny
{
/// <summary>
/// ctu背篓
/// </summary>
public class Basket
{
/// <summary>
/// 是否是货叉
/// </summary>
public bool IsFork { get; set; }
/// <summary>
/// 所在层
/// 1--10
/// </summary>
public byte Row { get; set; }
/// <summary>
/// 料箱码
/// </summary>
public string BoxCode { get; set; }
/// <summary>
/// 料箱定位码
/// </summary>
public string LocateCode { get; set; } = "";
/// <summary>
/// 更新时间
/// </summary>
public DateTime UpdateTime { get; set; }
/// <summary>
/// 屏蔽
/// </summary>
public bool Shield { get; set; }
/// <summary>
/// 目的地
/// </summary>
public string DstName { get; set; }
/// <summary>
/// 是否有料箱
/// </summary>
public bool IsPutted { get; set; }
/// <summary>
/// 检查半成品料箱是否相同
/// </summary>
/// <returns></returns>
public bool CheckCodeEquals()
{
if (string.IsNullOrEmpty(BoxCode) || string.IsNullOrEmpty(LocateCode)) return true;
//D00314
string str1 = "";
string str2 = "";
if (BoxCode.Length == 6)
{
str1 = BoxCode.Substring(1);
}
//S000000 00159
if (LocateCode.Length == 12)
{
str2 = LocateCode.Substring(7);
}
if (str1.Equals(str2))
{
return true;
}
return false;
}
/// <summary>
/// 检查料箱是否一致
/// </summary>
/// <returns></returns>
public bool CheckCodeIsSame()
{
if (string.IsNullOrEmpty(BoxCode) || string.IsNullOrEmpty(LocateCode)) return true;
//C07 00314
string str1 = "";
string pre1 = "";
string pre2 = "";
string str2 = "";
if (BoxCode.Length == 8)
{
str1 = BoxCode.Substring(3);
pre1 = BoxCode.Substring(0, 3);
}
//S000000 00159
if (LocateCode.Length == 12)
{
str2 = LocateCode.Substring(7);
pre2 = LocateCode.Substring(0, 1);
}
if (str1.Equals(str2))
{
if ("C07".Equals(pre1) && "S".Equals(pre2))
{
return true;
}
if ("C13".Equals(pre1) && "M".Equals(pre2))
{
return true;
}
if ("C15".Equals(pre1) && "P".Equals(pre2))
{
return true;
}
}
return false;
}
/// <summary>
/// 料箱码转为定位码
/// </summary>
/// <param name="boxCode"></param>
/// <returns></returns>
public static string BoxCodeToLocateCode(string boxCode)
{
if (string.IsNullOrEmpty(boxCode)) return "";
if (boxCode.StartsWith("D") && boxCode.Length == 6)//半成品料箱
{
//D00314
return $"T000000{boxCode.Substring(1)}";
}
else if (boxCode.StartsWith("C") && boxCode.Length == 8)//原材料料箱
{
string prefix = boxCode.Substring(0, 3);
if ("C07".Equals(prefix))
{
//C07 00314
return $"S000000{boxCode.Substring(3)}";
}
else if ("C13".Equals(prefix))
{
return $"M000000{boxCode.Substring(3)}";
}
else if ("C15".Equals(prefix))
{
return $"P000000{boxCode.Substring(3)}";
}
}
return "";
}
/// <summary>
/// 料箱码转为定位码
/// </summary>
/// <param name="boxCode"></param>
/// <returns></returns>
public static string LocateCodeToBoxCode(string locateCode)
{
if (string.IsNullOrEmpty(locateCode)) return "";
if (locateCode.StartsWith("T"))//半成品
{
//T000000 00314
return $"D{locateCode.Substring(7)}";
}
else if (locateCode.StartsWith("S"))
{
return $"C07{locateCode.Substring(7)}";
}
else if (locateCode.StartsWith("M"))
{
return $"C13{locateCode.Substring(7)}";
}
else if (locateCode.StartsWith("P"))
{
return $"C15{locateCode.Substring(7)}";
}
return "";
}
public string GetLocateCodeByContainerCode()
{
if (string.IsNullOrEmpty(BoxCode)) return "";
if (BoxCode.StartsWith("D") && BoxCode.Length == 6)//半成品料箱
{
//D00314
return $"T000000{BoxCode.Substring(1)}";
}
else if (BoxCode.StartsWith("C") && BoxCode.Length == 8)//原材料料箱
{
string prefix = BoxCode.Substring(0, 3);
if ("C07".Equals(prefix))
{
//C07 00314
return $"S000000{BoxCode.Substring(3)}";
}
else if ("C13".Equals(prefix))
{
return $"M000000{BoxCode.Substring(3)}";
}
else if ("C15".Equals(prefix))
{
return $"P000000{BoxCode.Substring(3)}";
}
}
return "";
}
}
}