BoxData.java
13.6 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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
package com.neotel.webbox.capacitynew.bean;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.util.NumberUtils;
import com.neotel.webbox.util.NumberUtil;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Setter
@Getter
public class BoxData {
/**
* 料仓名称
*/
@ExcelProperty("料仓名称")
private String boxName;
/**
* 料仓高度
*/
@ExcelProperty("料仓高度")
private int boxHeight;
/**
* 料仓不可用高度
*/
@ExcelProperty("不可用高度")
private int boxInvalidHeight;
/**
* 列数
*/
@ExcelProperty("标准列数")
private int columnCount;
/**
* 料仓特殊列
*/
@ExcelIgnore
private Map<String, List<BoxSpecialColumnContent>> boxSpecialColumnMap;
/**
* 是否有效
*
* @return
*/
public boolean isValid() {
return !boxName.isEmpty()
&& boxHeight >= 1000
&& boxInvalidHeight >= 100
&& columnCount >= 1;
}
public int getBoxPureSizeCapacity(ReelData reelData) {
//每一列可放料盘数量
int columnPureSizeCapacity = getColumnPureSizeCapacity(reelData.getPressHeight(), reelData);
//特殊列上部可放料盘数量
int boxSpecialColumnUpCapacityTotal = getBoxSpecialColumnUpCapacityTotal(getBoxSpecialColumnMap(), reelData.getPressHeight(), reelData);
//特殊列下部可放料盘数量
int boxSpecialColumnCapacityTotal = getBoxSpecialColumnCapacityTotal(getBoxSpecialColumnMap(), reelData);
int total = getColumnCount() * columnPureSizeCapacity + boxSpecialColumnUpCapacityTotal + boxSpecialColumnCapacityTotal;
return total;
}
/**
* 获取特殊列上部可放入料盘大小
*
* @param pressHeight
* @param reelData
* @return
*/
public int getBoxSpecialColumnUpCapacityTotal(Map<String, List<BoxSpecialColumnContent>> boxSpecialColumnMap, int pressHeight, ReelData reelData) {
int boxSpecialColumnUpCapacity = 0;
if (boxSpecialColumnMap != null && boxSpecialColumnMap.size() > 0) {
boxFillSpecialColumnHeight(boxSpecialColumnMap, reelData);
for (Map.Entry<String, List<BoxSpecialColumnContent>> entry : boxSpecialColumnMap.entrySet()) {
List<BoxSpecialColumnContent> boxSpecialColumnContentList = entry.getValue();
if (boxSpecialColumnContentList != null && boxSpecialColumnContentList.size() > 0) {
//减去(可用+不可用的),得到可用高度,取放入的数量
int boxSpecialColumnHeightTotal = boxSpecialColumnContentList.stream().mapToInt(BoxSpecialColumnContent::getHeight).sum();
int boxSpecialColumnUpHeight = getBoxSpecialColumnUpHeightTotal(boxSpecialColumnHeightTotal, pressHeight);
boxSpecialColumnUpCapacity += getColumnPureSizeCapacity(boxSpecialColumnUpHeight, reelData.getReelSize(), reelData.getReelSlotHeight());
}
}
}
return boxSpecialColumnUpCapacity;
}
/**
* 特殊列上方可用空间(总高度 - 特殊列可用不可用高度 - 下方高度 - 压紧高度)
*/
public int getBoxSpecialColumnUpHeightTotal(int boxSpecialColumnHeightTotal, int pressHeight) {
int columnValidHeight = getBoxHeight() - boxSpecialColumnHeightTotal - getBoxInvalidHeight() - pressHeight;
return columnValidHeight;
}
/**
* 获取特殊列可用高度,所能放的数量
*
* @param boxSpecialColumnMap
* @param reelData
* @return
*/
public int getBoxSpecialColumnCapacityTotal(Map<String, List<BoxSpecialColumnContent>> boxSpecialColumnMap, ReelData reelData) {
int boxSpecialColumnCapacity = 0;
if (boxSpecialColumnMap != null && boxSpecialColumnMap.size() > 0) {
//加载料仓与料盘之间的数据
boxSpecialColumnMap = boxFillSpecialColumnHeight(boxSpecialColumnMap, reelData);
//循环每列可以放下的高度
for (Map.Entry<String, List<BoxSpecialColumnContent>> entry : boxSpecialColumnMap.entrySet()) {
List<BoxSpecialColumnContent> boxSpecialColumnContentList = entry.getValue();
if (boxSpecialColumnContentList != null && boxSpecialColumnContentList.size() > 0) {
for (BoxSpecialColumnContent boxSpecialColumnContent : boxSpecialColumnContentList) {
if ("可用".equals(boxSpecialColumnContent.getTitle())) {
boxSpecialColumnCapacity += getColumnPureSizeCapacity(boxSpecialColumnContent.getHeight(), reelData.getReelSize(), reelData.getReelSlotHeight());
}
}
}
}
}
return boxSpecialColumnCapacity;
}
/**
* 获取特殊列可用高度,所能放的数量(单个)
*
* @param boxSpecialColumnContentList
* @param reelData
* @return
*/
public int getBoxSingleSpecialColumnCapacity(List<BoxSpecialColumnContent> boxSpecialColumnContentList, ReelData reelData) {
int boxSingleSpecialColumnCapacity = 0;
//循环每列可以放下的高度
if (boxSpecialColumnContentList != null && boxSpecialColumnContentList.size() > 0) {
for (BoxSpecialColumnContent boxSpecialColumnContent : boxSpecialColumnContentList) {
if ("可用".equals(boxSpecialColumnContent.getTitle())) {
boxSingleSpecialColumnCapacity += getColumnPureSizeCapacity(boxSpecialColumnContent.getHeight(), reelData.getReelSize(), reelData.getReelSlotHeight());
}
}
}
return boxSingleSpecialColumnCapacity;
}
/**
* 获取到特殊列(单列)可用的总高度
*
* @param boxSpecialColumnContentList
* @return
*/
public int getBoxSingleSpecialColumnHeight(List<BoxSpecialColumnContent> boxSpecialColumnContentList) {
return boxSpecialColumnContentList.stream().filter(boxSpecialColumnContent -> boxSpecialColumnContent.getTitle().equals("可用")).mapToInt(BoxSpecialColumnContent::getHeight).sum();
}
/**
* 料仓特殊列取值 与 料盘关联
*
* @param boxSpecialColumnMap
* @param reelData
* @return
*/
public static Map<String, List<BoxSpecialColumnContent>> boxFillSpecialColumnHeight(Map<String, List<BoxSpecialColumnContent>> boxSpecialColumnMap, ReelData reelData) {
if (boxSpecialColumnMap != null && boxSpecialColumnMap.size() > 0) {
for (Map.Entry<String, List<BoxSpecialColumnContent>> entry : boxSpecialColumnMap.entrySet()) {
String boxSpecialColumnTitle = entry.getKey();
//获取到特殊列的值
List<BoxSpecialColumnContent> boxSpecialColumnContentList = entry.getValue();
if (boxSpecialColumnContentList != null && boxSpecialColumnContentList.size() > 0) {
for (BoxSpecialColumnContent boxSpecialColumnContent : boxSpecialColumnContentList) {
getBoxSpecialColumnHeight(boxSpecialColumnContent, reelData);
}
}
}
}
return boxSpecialColumnMap;
}
/**
* 特殊列进行转换,文本的转成数值
*
* @param boxSpecialColumnContent
* @return
*/
public static BoxSpecialColumnContent getBoxSpecialColumnHeight(BoxSpecialColumnContent boxSpecialColumnContent, ReelData reelData) {
//先看料仓里是否配置,如果没有配置的话 就取料盘数据
int height = 0;
if (NumberUtil.isInteger(boxSpecialColumnContent.getValue())) {
height = (int) Double.parseDouble(boxSpecialColumnContent.getValue());
} else {
Map<String, Integer> boxSpecialColumn = reelData.getBoxSpecialColumn();
Integer boxSpecialColumnHeight = boxSpecialColumn.get(boxSpecialColumnContent.getValue());
if (boxSpecialColumnHeight != null) {
height = boxSpecialColumnHeight;
}
}
boxSpecialColumnContent.setHeight(height);
return boxSpecialColumnContent;
}
/**
* 获取标准列可放入料盘数量
*
* @param pressHeight
* @param reelData
* @return
*/
public int getColumnPureSizeCapacity(int pressHeight, ReelData reelData) {
//标准列可用高度
int columnValidHeight = getColumnValidHeight(pressHeight);
return getColumnPureSizeCapacity(columnValidHeight, reelData.getReelSize(), reelData.getReelSlotHeight()/*, false*/);
}
/**
* 根据可用空间和料盘尺寸计算料盘容量
*
* @param reelSize 料盘尺寸
* @param validHeight 可用高度
* @param reelSpaceHeight 单个格子占用高度
* @return 容量
*/
public int getColumnPureSizeCapacity(int validHeight, int reelSize, int reelSpaceHeight/*, boolean isDoorDown*/) {
int countPerColumn = validHeight / reelSpaceHeight;
//如果不是入料口下方,每一列上部可多放一盘
//if (!isDoorDown) {
if (reelSize == 7 || validHeight % reelSpaceHeight != 0) {
//如果有空余可以再放一盘,7寸盘可以多放一盘
countPerColumn = countPerColumn + 1;
}
// }
//每个格子可放料盘数,7寸盘为2盘,其他为1
int countPerUnit = 1;
if (reelSize == 7) {
countPerUnit = 2;
}
int capacity = countPerColumn * countPerUnit;
return capacity;
}
/**
* 料仓列可用高度,总高-不可用高度(下方电气板) - 压紧轴占用高度
*/
public int getColumnValidHeight(int pressHeight) {
return getBoxHeight() - getBoxInvalidHeight() - pressHeight;
}
/**
* 获取到料仓总可用高度
*
* @param maxPressHeight
* @param requestList
* @return
*/
public int getTotalValidHeight(int maxPressHeight, List<RequestItem> requestList) {
return this.getColumnCount() * getColumnValidHeight(maxPressHeight) + getBoxSpecialColumnValidHeightTotal(getBoxSpecialColumnMap(),requestList) + getBoxSpecialColumnUpValidHeightTotal(getBoxSpecialColumnMap(), requestList, maxPressHeight);
}
/**
* 获取特殊列上部有效高度
*
* @param boxSpecialColumnMap
* @return
*/
public int getBoxSpecialColumnUpValidHeightTotal(Map<String, List<BoxSpecialColumnContent>> boxSpecialColumnMap, List<RequestItem> requestList, int maxPressHeight) {
int boxSpecialColumnUpHeightTotal = 0;
if (boxSpecialColumnMap != null && boxSpecialColumnMap.size() > 0) {
//循环特殊列
for (Map.Entry<String, List<BoxSpecialColumnContent>> map : boxSpecialColumnMap.entrySet()) {
int singleBoxSpecialColumnUpValidHeight = getBoxHeight();
List<BoxSpecialColumnContent> boxSpecialColumnContentList = map.getValue();
int tempValidHeight = 0;
for (RequestItem requestItem : requestList) {
for (BoxSpecialColumnContent boxSpecialColumnContent : boxSpecialColumnContentList) {
getBoxSpecialColumnHeight(boxSpecialColumnContent, requestItem.getReelData());
}
int specialColumnValidHeight = boxSpecialColumnContentList.stream().mapToInt(BoxSpecialColumnContent::getHeight).sum();
tempValidHeight = getBoxSpecialColumnUpHeightTotal(specialColumnValidHeight, maxPressHeight);
if (tempValidHeight < singleBoxSpecialColumnUpValidHeight) {
singleBoxSpecialColumnUpValidHeight = tempValidHeight;
}
}
boxSpecialColumnUpHeightTotal += singleBoxSpecialColumnUpValidHeight;
}
}
return boxSpecialColumnUpHeightTotal;
}
/**
* 获取特殊列上部有效高度(单列)
*
* @param boxSpecialColumnContentList
* @param maxPressHeight
* @return
*/
public int getBoxSingleSpecialColumnUpValidHeight(List<BoxSpecialColumnContent> boxSpecialColumnContentList, int maxPressHeight) {
int specialColumnHeight = boxSpecialColumnContentList.stream().mapToInt(BoxSpecialColumnContent::getHeight).sum();
return getBoxSpecialColumnUpHeightTotal(specialColumnHeight, maxPressHeight);
}
/**
* 获取特殊列可用总高度
*
* @param boxSpecialColumnMap
* @return
*/
public int getBoxSpecialColumnValidHeightTotal(Map<String, List<BoxSpecialColumnContent>> boxSpecialColumnMap,List<RequestItem> requestList) {
//获取到可用高度
int specialColumnValidHeight = 0;
if (boxSpecialColumnMap != null && boxSpecialColumnMap.size() > 0) {
//每个料仓可用高度是一样的,在这里只取第一个
boxSpecialColumnMap = boxFillSpecialColumnHeight(boxSpecialColumnMap,requestList.get(0).getReelData());
for (Map.Entry<String, List<BoxSpecialColumnContent>> entry : boxSpecialColumnMap.entrySet()) {
List<BoxSpecialColumnContent> specialColumnContentList = entry.getValue();
specialColumnValidHeight += specialColumnContentList.stream().filter(boxSpecialColumnContent -> boxSpecialColumnContent.getTitle().equals("可用")).mapToInt(BoxSpecialColumnContent::getHeight).sum();
}
}
return specialColumnValidHeight;
}
}