自动化立体仓库 - WMS系统
zwl
1 天以前 8728a2be61d93b538599e634bba9eaad5ad1a969
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
package com.zy.asrs.task;
 
import com.zy.asrs.entity.WrkMast;
import com.zy.common.properties.SlaveProperties;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.test.util.ReflectionTestUtils;
 
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
 
import static org.junit.jupiter.api.Assertions.assertEquals;
 
class WorkMastSchedulerTest {
 
    private WorkMastScheduler scheduler;
 
    @BeforeEach
    void setUp() {
        scheduler = new WorkMastScheduler();
        SlaveProperties slaveProperties = new SlaveProperties();
        slaveProperties.setDoubleDeep(true);
        slaveProperties.setDoubleLocs(Arrays.asList(1, 4, 5, 8, 9, 12, 13, 16, 17, 20));
        slaveProperties.setDoubleLocsLeft(Arrays.asList(1, 5, 9, 13, 17));
        slaveProperties.setDoubleLocsRight(Arrays.asList(4, 8, 12, 16, 20));
        ReflectionTestUtils.setField(scheduler, "slaveProperties", slaveProperties);
    }
 
    @Test
    void selectOutboundBatchMasts_unorderedDoubleExtension_shouldPreferShallowThenDeep() {
        List<WrkMast> candidates = new ArrayList<>();
        for (int i = 0; i < 20; i++) {
            candidates.add(outboundMast(1000 + i, 19, 0, "0100101"));
        }
        for (int i = 0; i < 5; i++) {
            candidates.add(outboundMast(2000 + i, 19, 0, "0200101"));
        }
 
        List<WrkMast> result = selectOutboundBatchMasts(candidates);
 
        assertEquals(25, result.size());
        for (int i = 0; i < 5; i++) {
            assertEquals("0200101", result.get(i).getSourceLocNo());
        }
        for (int i = 5; i < 20; i++) {
            assertEquals("0100101", result.get(i).getSourceLocNo());
        }
    }
 
    @Test
    void selectOutboundBatchMasts_orderedDoubleExtension_shouldKeepOutboundSeqOrder() {
        List<WrkMast> candidates = Arrays.asList(
                outboundMast(1002, 19, 2, "0200101"),
                outboundMast(1001, 19, 1, "0100101"),
                outboundMast(1003, 19, 3, "0200101")
        );
 
        List<WrkMast> result = selectOutboundBatchMasts(candidates);
 
        assertEquals(Integer.valueOf(1), result.get(0).getPltType());
        assertEquals(Integer.valueOf(2), result.get(1).getPltType());
        assertEquals(Integer.valueOf(3), result.get(2).getPltType());
    }
 
    @SuppressWarnings("unchecked")
    private List<WrkMast> selectOutboundBatchMasts(List<WrkMast> candidates) {
        return ReflectionTestUtils.invokeMethod(scheduler, "selectOutboundBatchMasts", candidates);
    }
 
    private static WrkMast outboundMast(Integer wrkNo, Integer crnNo, Integer outboundSeq, String sourceLocNo) {
        WrkMast mast = new WrkMast();
        mast.setWrkNo(wrkNo);
        mast.setIoType(101);
        mast.setCrnNo(crnNo);
        mast.setPltType(outboundSeq);
        mast.setSourceLocNo(sourceLocNo);
        return mast;
    }
}