InOutParam.cs
5.5 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
using log4net;
using OnlineStore.Common;
using OnlineStore.LoadCSVLibrary;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
namespace OnlineStore.DeviceLibrary
{
using crc = CodeResourceControl;
public class InOutParam
{
/// <summary>
/// 创建新出入库信息
/// </summary>
/// <param name="type">出入库类型</param>
/// <param name="wareNo">二维码内容</param>
/// <param name="posId">库位号</param>
/// <param name="platew">宽度</param>
/// <param name="plateh">高度</param>
/// <param name="targetP">出入库目标位置, 0=出库表示批量出料,入库表示目标库位 。 1=紧急出料到NG口,入库NG送到NG口</param>
/// <param name="shefNum">料架编号</param>
/// <param name="IsNg">是否是入库NG料</param>
/// <param name="ngMsg">NG消息</param>
public InOutParam(MoveType type, string wareNo = "", string posId = "", int platew = 0, int plateh = 0, int targetP = 0, int shefNum=0, bool IsNg = false, string ngMsg = "")
{
WareCode = wareNo;
PosID = posId;
MoveP = null;
this.PlateW = platew;
this.PlateH = plateh;
this.TargetPosition = targetP;
this.shelfNum = shefNum;
this.InStoreNg = IsNg;
this.NgMsg = ngMsg;
this.moveType = type;
}
public InOutParam(MoveType type, string wareNo, string posId, LineMoveP linePosition, int targetP = 0)
{
WareCode = wareNo;
PosID = posId;
MoveP = linePosition;
this.TargetPosition = targetP;
this.moveType = type;
}
public MoveType moveType = MoveType.None;
/// <summary>
/// 物品二维码信息
/// </summary>
public string WareCode { get; set; }
/// <summary>
/// 位置坐标名(对应配置表的位置)
/// </summary>
public string PosID { get; set; }
public LineMoveP MoveP { get; set; }
/// <summary>
/// 料盘高度
/// </summary>
public int PlateH { get; set; }
/// <summary>
/// 料盘宽度
/// </summary>
public int PlateW { get; set; }
/// <summary>
/// 是否是入料NG料
/// </summary>
public bool InStoreNg = false;
/// <summary>
/// 入料NG消息
/// </summary>
public string NgMsg = "";
/// <summary>
/// 料架编号
/// </summary>
public int shelfNum = 0;
/// <summary>
/// 出入库目标位置,
/// 0=出库表示批量出料,入库表示目标库位
/// 1=紧急出料到NG口,入库NG送到NG口
/// </summary>
public int TargetPosition = 0;
/// <summary>
/// 目标料仓,1=左侧,2=右侧
/// </summary>
public int TargetBox = 0;
/// <summary>
/// 根据PosId获取对应的料仓ID,若PosId=="",返回-1
/// </summary>
/// <returns></returns>
public int GetStoreId()
{
return GetPosStoreId(PosID);
}
public static int GetPosStoreId(string posId)
{
if (!posId.Equals(""))
{
try
{
string[] arr = posId.Split('#');
if (arr.Length >= 2)
{
var p = int.Parse(arr[1].Substring(2, 1));
switch (p) {
case 3:
return 1;
case 4:
return 2;
default:
return p;
}
}
}
catch (Exception ex)
{
}
}
return -1;
}
public string ToStr()
{
if (InStoreNg)
{
return crc.GetString("instore_fail"," 入库失败")+"[BOX_" + TargetBox + "] [" + WareCode + "], [" + PlateW + "x" + PlateH + "] ";
}
else
{
if (moveType.Equals(MoveType.InStore))
{
return crc.GetString("instore"," 入库")+ "[" + PosID + "] [" + WareCode + "], [" + PlateW + "x" + PlateH + "] ";
}
else
{
if (TargetPosition.Equals(0))
{
return crc.GetString("batch_outstore"," 批量出库")+"[" + PosID + "] [" + WareCode + "], [" + PlateW + "x" + PlateH + "] ";
}
else
{
return crc.GetString("single_outstore"," 单盘出库")+ "[" + PosID + "] [" + WareCode + "], [" + PlateW + "x" + PlateH + "] ";
}
}
}
}
public InOutParam clone()
{
return (InOutParam)this.MemberwiseClone();/*
MemoryStream stream = new MemoryStream();
BinaryFormatter formatter = new BinaryFormatter();
formatter.Serialize(stream, this);
stream.Position = 0;
return formatter.Deserialize(stream) as InOutParam;*/
}
}
}