BasicMethod.java
4.7 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
package com.neotel.webbox.capacity.method;
import com.neotel.webbox.capacity.bean.BoxData;
import com.neotel.webbox.capacity.bean.BoxResult;
import com.neotel.webbox.capacity.bean.ReelData;
import com.neotel.webbox.capacity.bean.RequestItem;
import com.neotel.webbox.capacity.box.Box;
import com.neotel.webbox.capacity.box.Column;
import com.neotel.webbox.capacity.box.SlotUnit;
import java.util.ArrayList;
import java.util.List;
public class BasicMethod {
protected static SlotUnit getValidSlotUnit(int requestReelCount, ReelData reelData, int validHeight){
if(requestReelCount <=0){
return null;
}
//剩余空间可放多少层料格
int slotCount = validHeight/reelData.getReelSlotHeight();
if(slotCount < reelData.getMinUnit()){
//可放料格层数不到一个模组
return null;
}
int validReelCount = slotCount;
if(reelData.is7Reel()){
validReelCount = validReelCount * 2;
}
if(validReelCount >= requestReelCount){
//可以全部放下
return new SlotUnit(reelData,requestReelCount);
}
//只可以放下部分
return new SlotUnit(reelData,validReelCount);
}
protected static int fillToColumn(Column column, int remainCount, ReelData reelData){
if(remainCount > 0 || remainCount == -1){
//剩余空间可放多少层料格
int slotCount = column.getRemainHeight()/reelData.getReelSlotHeight();
if(remainCount!= -1 && slotCount > remainCount){
slotCount = remainCount;
}
SlotUnit existSlotUnit = column.getSlotUnit(reelData);
int existCount = 0;
if(existSlotUnit == null){
//不存在同尺寸料格,需要判断最小模组
if(slotCount < reelData.getMinUnit()){
//可放料格层数不到一个模组,尝试扩展已存在的料盘
return 0;
}
}else{
existCount = existSlotUnit.getReelCount();
}
int reelCount = slotCount;
if(reelData.is7Reel()){
reelCount = reelCount * 2;
}
SlotUnit newSlotUnit = new SlotUnit(reelData, reelCount);
SlotUnit mergeSlotUnit = column.mergeSlotUnit(newSlotUnit);
if(mergeSlotUnit != null){
int addCount = mergeSlotUnit.getReelCount() - existCount;
return addCount;
}
}
return 0;
}
protected static Column getPureColumn(int validHeight, BoxData boxData, ReelData reelData,int pureCapacity){
Column column = new Column(validHeight);
column.setRemainHeight(0);
List<SlotUnit> slotUnitList = new ArrayList<>();
SlotUnit unit = new SlotUnit(reelData,pureCapacity);
slotUnitList.add(unit);
column.setSlotUnitList(slotUnitList);
return column;
}
protected static BoxResult getBoxResult(List<RequestItem> requestList, BoxData boxData, List<Box> mixBoxList){
List<Box> boxes = new ArrayList<>();
for (RequestItem requestItem : requestList){
ReelData reelData = requestItem.getReelData();
int pressHeight = reelData.getPressHeight();
for (int i = 0; i < requestItem.getPureBoxCount(); i++) {
Box box = new Box();
box.setColumnCount(boxData.getColumnCount());
int standColumnValidHeight = boxData.getColumnValidHeight(pressHeight);
int pureColumnCapacity = boxData.getColumnPureSizeCapacity(reelData.getPressHeight(), reelData);
Column standColumn = getPureColumn(standColumnValidHeight,boxData,reelData,pureColumnCapacity);
box.setColumn(standColumn);
int doorDownValidHeight = boxData.getDoorDownValidHeight(pressHeight);
int pureDoorDownCapacity = boxData.getDoorDownCapacity(reelData.getPressHeight(), reelData);
Column doorDown = getPureColumn(doorDownValidHeight,boxData,reelData,pureDoorDownCapacity);
box.setDoorDown(doorDown);
int doorUpValidHeight = boxData.getDoorUpValidHeight(pressHeight);
int pureDoorUpCapacity = boxData.getDoorUpCapacity(reelData.getPressHeight(), reelData);
Column doorUp = getPureColumn(doorUpValidHeight,boxData,reelData,pureDoorUpCapacity);
box.setDoorUp(doorUp);
boxes.add(box);
}
}
for (Box box : mixBoxList) {
boxes.add(box);
}
BoxResult boxResult = new BoxResult();
boxResult.setBoxList(boxes);
boxResult.setRequestList(requestList);
return boxResult;
}
}