自动化立体仓库 - WMS系统
zwl
昨天 8728a2be61d93b538599e634bba9eaad5ad1a969
创建出库任务时修改任务优先级
2个文件已添加
85 ■■■■■ 已修改文件
src/main/resources/sql/20260429_out_order_batch_priority_threshold.sql 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/test/java/com/zy/asrs/task/WorkMastSchedulerTest.java 80 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/sql/20260429_out_order_batch_priority_threshold.sql
New file
@@ -0,0 +1,5 @@
IF NOT EXISTS (SELECT 1 FROM sys_config WHERE code = N'outOrderBatchPriorityThreshold')
BEGIN
    INSERT INTO sys_config (name, code, value, type, status)
    VALUES (N'出库批量建任务优先级递减计数阀值', N'outOrderBatchPriorityThreshold', N'1', 1, 1);
END;
src/test/java/com/zy/asrs/task/WorkMastSchedulerTest.java
New file
@@ -0,0 +1,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;
    }
}