自动化立体仓库 - WMS系统
#
LSH
2023-06-07 1af3b14449eb33792e606185c55643bca53efbb7
src/main/java/com/zy/asrs/utils/Utils.java
@@ -6,6 +6,7 @@
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.service.BasCrnpService;
import com.zy.asrs.service.LocMastService;
import com.zy.common.properties.SlaveProperties;
@@ -730,6 +731,29 @@
        return false;
    }
    /**
     * 随机获取可用且有空库位的堆垛机号
     */
    public static Integer getRandomCrnNo(List<Integer> crnNos, Short locType1) {
        BasCrnpService basCrnpService = SpringUtils.getBean(BasCrnpService.class);
        LocMastService locMastService = SpringUtils.getBean(LocMastService.class);
        Random random = new Random();
        //可用堆垛机list
        ArrayList<Integer> normalCrnNos = new ArrayList<>();
        for (Integer crnNo : crnNos) {
            List<LocMast> emptyLocMast = locMastService.findEmptyLocMast(locType1, crnNo);
            if (basCrnpService.checkSiteError(crnNo, true) && emptyLocMast.size() > 0) {
                normalCrnNos.add(crnNo);
            }
        }
        if (normalCrnNos.size() == 0) {
            throw new CoolException("没有可用堆垛机");
        }
        //随机可用堆垛机号
        Integer randomCrnNo = normalCrnNos.get(random.nextInt(normalCrnNos.size()));
        return randomCrnNo;
    }
    public static void main(String[] args) {
        List<String> groupLoc = Utils.getGroupLoc("1300801");
        System.out.println(groupLoc);