AutoInoutInfo.cs
5.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
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
using OnlineStore.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnlineStore.DeviceLibrary
{
public class AutoInoutInfo
{
/// <summary>
/// 入库完成后自动出库,出库完成后自动入库
/// </summary>
public bool autoNext = false;
/// <summary>
/// 自动出入库间隔
/// </summary>
private int Jiange = 3;
private int positionIndex = 0;
public string autoMsg = "";
private int startIndex = -1;
private string shelfPosId = "";
#region 出入库参数
/// <summary>
/// 当前出入库的次数,超过配置的数量时,需要自动重置一下,再进行出入库
/// </summary>
internal int CurrInOutCount = 0;
internal int CurrInOutACount = 0;
#endregion
public void StartAuto(int jiange, int currIndex, string shelfPosId)
{
autoNext = true;
Jiange = jiange;
positionIndex = currIndex;
startIndex = currIndex;
this.shelfPosId = shelfPosId;
}
public void StopAuto()
{
autoNext = false;
}
internal void InOutEndProcess(BoxEquip boxBean, MoveType storeMoveType)
{
try
{
//是否自动进入出库状态
if (!autoNext)
{
return;
}
if (storeMoveType.Equals(MoveType.InStore))
{
int newIndex = positionIndex - 1;
if (newIndex < 0)
{
if (startIndex >= 0 && startIndex < boxBean.PositionNumList.Count)
{
newIndex = startIndex;
boxBean.LogInfo("下一个索引不存在,重新开始自动出入库,索引【" + startIndex + "】");
}
else
{
autoNext = false;
autoMsg = "自动出入库结束!";
boxBean.LogInfo("下一个索引不存在,自动 出入库结束!");
}
}
else
{
positionIndex = newIndex;
string posid = boxBean.PositionNumList[positionIndex];
InOutParam param = new InOutParam(new InOutPosInfo("AAAA", posid));
//param.NeedOutShelf = false;
//param.NeedEnterShelf = false;
//判断是否需要重置
//if (CurrInOutACount >= boxBean.Config.Box_ResetACount)
//{
// boxBean.LogInfo("自动进入下一个出库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把出库信息存入排队列表中");
// boxBean.Reset(false);
// autoMsg = "自动出库:" + posid;
// boxBean.waitOutStoreList.Enqueue(param);
//}
//else
{
boxBean.LogInfo("自动进入下一个出库:posid=" + posid);
autoMsg = "自动出库:" + posid;
boxBean.StartOutstore(param);
}
}
}
else if (storeMoveType.Equals(MoveType.OutStore))
{
int newIndex = positionIndex - Jiange;
if (newIndex < 0)
{
if (startIndex >= 0 && startIndex < boxBean.PositionNumList.Count)
{
newIndex = startIndex;
boxBean.LogInfo("下一个索引不存在,重新开始自动出入库,索引【" + startIndex + "】");
}
else
{
autoNext = false;
autoMsg = "自动出入库结束!";
boxBean.LogInfo("下一个索引不存在,自动 出入库结束!");
}
}
else
{
string posid = boxBean.PositionNumList[newIndex];
InOutParam param = new InOutParam(new InOutPosInfo("AAAA", posid));
// param.NeedOutShelf = false;
//判断是否需要重置
//if (CurrInOutACount >= boxBean.Config.Box_ResetACount)
//{
// boxBean.LogInfo("自动进入下一个入库:posid=" + posid + ",当时已经出入库" + CurrInOutACount + "次,需要重置BOX,先把入库信息存入排队列表中");
// boxBean.Reset(false);
// autoMsg = "自动入库:" + posid;
// boxBean.waitOutStoreList.Enqueue(param);
//}
//else
{
boxBean.LogInfo("自动进入下一个入库:posid=" + posid);
autoMsg = "自动入库:" + posid;
boxBean.StartInstore(param);
}
}
}
}
catch (Exception ex)
{
LogUtil.error(boxBean.Name + "InOutEndProcess ERROR:" + ex.ToString());
}
}
internal void ClearCount()
{
CurrInOutACount = 0;
CurrInOutCount = 0;
}
}
}