自动化立体仓库 - WMS系统
Junjie
2023-05-13 8c3714822ea0223ae42bd5c08dbbc872fffee9d5
库位规则
9个文件已修改
200 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/LocRuleController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/LocRuleMapper.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/LocRuleService.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/LocMastServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/LocRuleServiceImpl.java 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/service/CommonService.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/LocRuleMapper.xml 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/locRule/locRule.js 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/locRule/locRule.html 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/LocRuleController.java
@@ -76,6 +76,10 @@
        locRule.setCreateTime(now);
        locRule.setUpdateBy(getUserId());
        locRule.setUpdateTime(now);
        if (locRule.getMixed() == 1) {
            //混载
            locRule.setMatnr("00000000");
        }
        locRuleService.insert(locRule);
        return R.ok();
    }
@@ -98,6 +102,11 @@
        locRule.setUpdateBy(getUserId());
        locRule.setUpdateTime(new Date());
        locRuleService.updateById(locRule);
        if (locRule.getMixed() == 0) {
            locRuleService.updateKeepGoByMatnr(locRule.getMatnr(), locRule.getKeepGo());
        }else {//混载
            locRuleService.updateKeepGoByMixed(locRule.getKeepGo());
        }
        return R.ok();
    }
src/main/java/com/zy/asrs/mapper/LocRuleMapper.java
@@ -11,8 +11,12 @@
@Repository
public interface LocRuleMapper extends BaseMapper<LocRule> {
    LocRule selectByMatnr(String matnr);
    List<LocRule> selectByMatnr(String matnr);
    LocRule selectByMixed(Integer mixed);
    List<LocRule> selectByMixed(Integer mixed);
    int updateKeepGoByMatnr(String matnr, Integer keepGo);
    int updateKeepGoByMixed(Integer keepGo);
}
src/main/java/com/zy/asrs/service/LocRuleService.java
@@ -8,12 +8,16 @@
public interface LocRuleService extends IService<LocRule> {
    LocRule find(String matnr);
    List<LocRule> find(String matnr);
    //找混载库位规则
    LocRule findMixed();
    List<LocRule> findMixed();
    //将库位规则组转换为库位组
    List<LocMast> locRuleToLocNos(LocRule locRule);
    int updateKeepGoByMatnr(String matnr, Integer keepGo);
    int updateKeepGoByMixed(Integer keepGo);
}
src/main/java/com/zy/asrs/service/impl/LocMastServiceImpl.java
@@ -84,7 +84,7 @@
        int row = Utils.getRow(locNo);
        List<String> locNos = Utils.getGroupLoc(locNo);
        if (CommonService.FIRST_GROUP_ROW_LIST.contains(row)) {
        } else if (CommonService.SECOND_GROUP_ROW_LIST.contains(row)) {
        } else if (CommonService.SECOND_GROUP_ROW_LIST.contains(row) || CommonService.THIRD_GROUP_ROW_LIST.contains(row)) {
            Collections.reverse(locNos);
        } else {
            throw new RuntimeException("库位解析异常");
src/main/java/com/zy/asrs/service/impl/LocRuleServiceImpl.java
@@ -26,7 +26,7 @@
    private LocMastService locMastService;
    @Override
    public LocRule find(String matnr) {
    public List<LocRule> find(String matnr) {
        if (Cools.isEmpty(matnr)) {
            return null;
        }
@@ -40,33 +40,23 @@
    //找混载库位规则
    @Override
    public LocRule findMixed() {
    public List<LocRule> findMixed() {
        return this.baseMapper.selectByMixed(1);//搜索混载库位规则
    }
    //将库位规则转换为库位组
    //将库位规则转换为库位组(能查出来的都是空库位)
    @Override
    public List<LocMast> locRuleToLocNos(LocRule locRule) {
        ArrayList<String> locNos = new ArrayList<>();
        //将所有符合混载规则的库位号进行存储
        Integer rowBeg = locRule.getRowBeg();
        Integer rowEnd = locRule.getRowEnd();
        return locMastService.queryFreeLocMast2(null, locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
    }
        Integer bayBeg = locRule.getBayBeg();
        Integer bayEnd = locRule.getBayEnd();
    @Override
    public int updateKeepGoByMatnr(String matnr, Integer keepGo) {
        return this.baseMapper.updateKeepGoByMatnr(matnr, keepGo);
    }
        Integer levBeg = locRule.getLevBeg();
        Integer levEnd = locRule.getLevEnd();
        for (int i = rowBeg; i <= rowEnd; i++) {
            for (int j = bayBeg; j <= bayEnd; j++) {
                for (int k = levBeg; k <= levEnd; k++) {
                    String locNo = Utils.getLocNo(i, j, k);
                    locNos.add(locNo);
                }
            }
        }
        return locMastService.selectEmptyByLocNos(locNos);
    @Override
    public int updateKeepGoByMixed(Integer keepGo) {
        return this.baseMapper.updateKeepGoByMixed(keepGo);
    }
}
src/main/java/com/zy/common/service/CommonService.java
@@ -161,8 +161,6 @@
     * 混载找库位
     */
    private LocMast getLocNoStep1(List<String> matNos, LocTypeDto locTypeDto) {
        LocMast locMast = null;
        //判断当前货物是否为混载货物
        String firstMatNos = matNos.get(0);
        boolean mixed = false;//默认不是混载货物
@@ -174,41 +172,44 @@
        }
        if (!mixed) {
            return locMast;//不是混载货物,直接跳出当前任务
            return null;//不是混载货物,直接跳出当前任务
        }
        // 找混载库位规则
        LocRule locRule = locRuleService.findMixed();
        if (locRule == null) {
            return locMast;//没有混载规则,跳出当前任务
        List<LocRule> locRules = locRuleService.findMixed();
        if (locRules == null || locRules.size() == 0) {
            return null;//没有混载规则,跳出当前任务
        }
        //将库位规则组转换为库位组
        List<LocMast> locMasts = locRuleService.locRuleToLocNos(locRule);
        if (locMasts == null || locMasts.size() == 0) {
            if (locRule.getKeepGo() == 0) {
                //找不到空库位,且禁止继续寻找其他非混载区域库位
                //找不到库位,抛出异常
                throw new CoolException("混载区域没有空库位");
        for (LocRule locRule : locRules) {
            if (locRule == null) {
                continue;
            }
            return locMast;//没有混载规则,跳出当前任务
        }
        for (LocMast one : locMasts) {
            LocMast locMast0 = locMastService.findOutMost(one.getLocNo());
            if (null != locMast0) {
                // 浅库位符合尺寸检测
                if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
                    // 因库位移转、需预留空库位
                    if (locMastService.checkEmptyCount(locMast0, 10)) {
                        locMast = locMast0;
                        break;
            List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
            for (LocMast one : locMasts) {
                LocMast locMast0 = locMastService.findOutMost(one.getLocNo());
                if (null != locMast0) {
                    // 浅库位符合尺寸检测
                    if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
                        // 因库位移转、需预留空库位
                        if (locMastService.checkEmptyCount(locMast0, 10)) {
                            return locMast0;//找到空余的混载库位
                        }
                    }
                }
            }
        }
        return locMast;
        if (locRules.get(0).getKeepGo() == 0) {
            //找不到空库位,且禁止继续寻找其他非混载区域库位
            //找不到库位,抛出异常
            throw new CoolException("混载区域没有空库位");
        }
        return null;
    }
    /**
@@ -217,8 +218,16 @@
    private LocMast getLocNoStep2(List<String> matNos, LocTypeDto locTypeDto) {
        LocMast locMast = null;
        // 库区锁定
        LocRule locRule = locRuleService.find(Cools.isEmpty(matNos) ? null : matNos.get(0));
        if (!Cools.isEmpty(locRule)) {
        List<LocRule> locRules = locRuleService.find(Cools.isEmpty(matNos) ? null : matNos.get(0));
        if (locRules == null || locRules.size() == 0) {
            return null;//没有库位规则,跳出当前任务
        }
        for (LocRule locRule : locRules) {
            if (locRule == null) {
                continue;
            }
            List<LocMast> locMasts = locMastService.queryFreeLocMast2(locTypeDto.getLocType1(), locRule.getRowBeg(), locRule.getRowEnd(), locRule.getBayBeg(), locRule.getBayEnd(), locRule.getLevBeg(), locRule.getLevEnd());
            for (LocMast one : locMasts) {
                LocMast locMast0 = locMastService.findOutMost(one.getLocNo());
@@ -227,13 +236,19 @@
                    if (VersionUtils.locMoveCheckLocType(locMast0, locTypeDto)) {
                        // 因库位移转、需预留空库位
                        if (locMastService.checkEmptyCount(locMast0, 10)) {
                            locMast = locMast0;
                            break;
                            return locMast0;
                        }
                    }
                }
            }
        }
        if (locRules.get(0).getKeepGo() == 0) {
            //找不到空库位,且禁止继续寻找其他非混载区域库位
            //找不到库位,抛出异常
            throw new CoolException("规则区域没有空库位");
        }
        return locMast;
    }
src/main/resources/mapper/LocRuleMapper.xml
@@ -37,9 +37,17 @@
    </select>
    <select id="selectByMixed" resultMap="BaseResultMap">
        select top 1 * from asr_loc_rule
        select * from asr_loc_rule
        where mixed = #{mixed}
        and status = 1
    </select>
    <update id="updateKeepGoByMatnr">
        update asr_loc_rule set keep_go = #{keepGo} where matnr = #{matnr}
    </update>
    <update id="updateKeepGoByMixed">
        update asr_loc_rule set keep_go = #{keepGo} where mixed = 1
    </update>
</mapper>
src/main/webapp/static/js/locRule/locRule.js
@@ -24,9 +24,9 @@
            {type: 'checkbox'}
            // ,{field: 'id', align: 'center',title: 'ID'}
            ,{field: 'matnr', align: 'center',title: '商品编号'}
            ,{field: 'specs', align: 'center',title: '规格'}
            ,{field: 'model', align: 'center',title: '型号'}
            ,{field: 'cstmr', align: 'center',title: '客户'}
            ,{field: 'specs', align: 'center',title: '规格', hide: true}
            ,{field: 'model', align: 'center',title: '型号', hide: true}
            ,{field: 'cstmr', align: 'center',title: '客户', hide: true}
            ,{field: 'batch', align: 'center',title: '批号'}
            ,{field: 'other', align: 'center',title: '其他', hide: true}
            ,{field: 'rowBeg', align: 'center',title: '开始排'}
@@ -35,7 +35,7 @@
            ,{field: 'bayEnd', align: 'center',title: '结束列'}
            ,{field: 'levBeg', align: 'center',title: '开始层'}
            ,{field: 'levEnd', align: 'center',title: '结束层'}
            ,{field: 'limit', align: 'center',title: '上限'}
            ,{field: 'limit', align: 'center',title: '上限', hide: true}
            ,{field: 'status$', align: 'center',title: '状态', hide: true}
            ,{field: 'createBy$', align: 'center',title: '添加人员', hide: true}
            ,{field: 'createTime$', align: 'center',title: '添加时间', hide: true}
src/main/webapp/views/locRule/locRule.html
@@ -78,24 +78,24 @@
                        <input class="layui-input" name="matnr" placeholder="请输入商品编号">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">规格: </label>
                    <div class="layui-input-block">
                        <input class="layui-input" name="specs" placeholder="请输入规格">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">型号: </label>
                    <div class="layui-input-block">
                        <input class="layui-input" name="model" placeholder="请输入型号">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">客户: </label>
                    <div class="layui-input-block">
                        <input class="layui-input" name="cstmr" placeholder="请输入客户">
                    </div>
                </div>
<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label">规格: </label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <input class="layui-input" name="specs" placeholder="请输入规格">-->
<!--                    </div>-->
<!--                </div>-->
<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label">型号: </label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <input class="layui-input" name="model" placeholder="请输入型号">-->
<!--                    </div>-->
<!--                </div>-->
<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label">客户: </label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <input class="layui-input" name="cstmr" placeholder="请输入客户">-->
<!--                    </div>-->
<!--                </div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label">批号: </label>
                    <div class="layui-input-block">
@@ -108,12 +108,12 @@
<!--                        <input class="layui-input" name="other" placeholder="请输入其他">-->
<!--                    </div>-->
<!--                </div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label">上限: </label>
                    <div class="layui-input-block">
                        <input class="layui-input" name="limit" placeholder="请输入上限">
                    </div>
                </div>
<!--                <div class="layui-form-item">-->
<!--                    <label class="layui-form-label">上限: </label>-->
<!--                    <div class="layui-input-block">-->
<!--                        <input class="layui-input" name="limit" placeholder="请输入上限">-->
<!--                    </div>-->
<!--                </div>-->
                <div class="layui-form-item">
                    <label class="layui-form-label">混载: </label>
                    <div class="layui-input-block">