自动化立体仓库 - WMS系统
luxiaotao1123
2020-07-30 a47fcd804f2c590a8e5e2c08a1d506b665411aa9
#当前本版十分完美、冻结
2个文件已修改
89 ■■■■■ 已修改文件
src/main/java/com/zy/common/model/StartupDto.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/CommonService.java 79 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/model/StartupDto.java
@@ -5,8 +5,6 @@
 */
public class StartupDto {
    private Shelves shelves;
    private Integer sourceStaNo;
    private Integer staNo;
@@ -14,14 +12,6 @@
    private Integer crnNo;
    private String locNo;
    public Shelves getShelves() {
        return shelves;
    }
    public void setShelves(Shelves shelves) {
        this.shelves = shelves;
    }
    public Integer getSourceStaNo() {
        return sourceStaNo;
src/main/java/com/zy/common/service/CommonService.java
@@ -99,40 +99,55 @@
            int eRow = rowLastno.geteRow();
            int crn_qty = rowLastno.getCrnQty();
            int rowCount = eRow - sRow + 1;
            // 目标堆垛机号
            int crnNo = 0;
            // 目标库位
            LocMast locMast = null;
            // 同一天同规格货物靠近摆法规则 todo
            // 同一天同规格货物靠近摆法规则
            List<String> locNos = locDetlService.getSameDetlToday("X004073XX");
            for (String locNo : locNos) {
                // 获取排
                int row = Integer.parseInt(locNo.substring(0, 2));
                // 判断是否为深库位
                double remainder = Arith.remainder(row, rowCount / crn_qty);
                int targetRow;
                if (remainder == 1) {
                    // 得到当前库位的外围库位
                    targetRow =  row + 1;
                } else if (remainder == 0) {
                    // 得到当前库位的内围库位
                    targetRow =  row - 1;
                } else {
                    continue;
                }
            }
            // 获取目标站所在货架排号
            Shelves shelves = new Shelves(rowCount, crn_qty);
            curRow = shelves.start(curRow);
            if (curRow < 0) {
                throw new CoolException("检索库位失败,请联系管理员");
            }
            // 堆垛机号
            int crnNo = 0;
            for (List<Integer> node : shelves.nodes){
                if (node.contains(curRow)) {
                    crnNo = shelves.nodes.indexOf(node) + 1;
                String targetLocNo = zerofill(String.valueOf(targetRow), 2)+locNo.substring(2);
                // 检测目标库位是否为空库位
                LocMast targetLocMast = locMastService.selectById(targetLocNo);
                if (targetLocMast != null && !targetLocMast.getLocSts().equals("O")) {
                    locMast = targetLocMast;
                    crnNo = locMast.getCrnNo();
                    break;
                }
            }
            // 如果没有相近物料,则按规则轮询货架
            if (null == locMast) {
                // 获取目标站所在货架排号
                Shelves shelves = new Shelves(rowCount, crn_qty);
                curRow = shelves.start(curRow);
                if (curRow < 0) {
                    throw new CoolException("检索库位失败,请联系管理员");
                }
                for (List<Integer> node : shelves.nodes){
                    if (node.contains(curRow)) {
                        crnNo = shelves.nodes.indexOf(node) + 1;
                        break;
                    }
                }
            }
            basCrnpService.checkSiteStatus(crnNo);
            // 获取目标站
            Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
@@ -147,7 +162,9 @@
            int inQty = staNo.getInQty()==null?0:staNo.getInQty();
            if (staNo.getInEnable().equals("Y") && staNo.getAutoing().equals("Y") && inQty<2) {
                // 查找库位
                LocMast locMast = locMastService.queryFreeLocMast(curRow);
                if (locMast == null) {
                    locMast = locMastService.queryFreeLocMast(curRow);
                }
                if (Cools.isEmpty(locMast)) {
                    throw new CoolException("没有空库位");
                }
@@ -159,7 +176,6 @@
                // 返回dto
                startupDto.setCrnNo(crnNo);
                startupDto.setShelves(shelves);
                startupDto.setSourceStaNo(sourceStaNo);
                startupDto.setStaNo(staNo.getDevNo());
                startupDto.setLocNo(locNo);
@@ -175,17 +191,34 @@
    public static void main(String[] args) {
        System.out.println(Arith.remainder(1, 4));
        System.out.println("0200201".substring(0, 2));
        String locNo = "0100201";
        String locNo = "0800201";
        int row = Integer.parseInt(locNo.substring(0, 2));
        double remainder = Arith.remainder(row, 4);
        int targetRow;
        if (remainder == 1) {
            // 得到当前库位的外围库位
            int targetRow =  row + 1;
            targetRow =  row + 1;
        } else if (remainder == 0) {
            // 得到当前库位的内围库位
            targetRow =  row - 1;
        } else {
            return;
        }
        String zerofill = zerofill(String.valueOf(targetRow), 2)+locNo.substring(2);
        System.out.println(zerofill);
    }
    public static String zerofill(String msg, Integer count) {
        if (msg.length() == count) {
            return msg;
        } else if (msg.length() > count) {
            return msg.substring(0, 16);
        } else {
            StringBuilder msgBuilder = new StringBuilder(msg);
            for(int i = 0; i < count - msg.length(); ++i) {
                msgBuilder.insert(0, "0");
            }
            return msgBuilder.toString();
        }
    }