自动化立体仓库 - WCS系统
#
luxiaotao1123
2022-08-26 deeea3d8de2d09fbeef300fcb6a790d72cfee42e
#
12个文件已修改
178 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/SteController.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/domain/vo/SteDataVo.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/domain/vo/SteMsgTableVo.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/BasSteMapper.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/BasSteService.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/BasSteServiceImpl.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/protocol/SteProtocol.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SteThread.java 65 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/BasSteMapper.xml 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/pipeline.html 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/ste.html 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/SteController.java
@@ -134,6 +134,7 @@
            }
            vo.setSpeed(steProtocol.getSpeed());  // 速度
            vo.setCloser(steProtocol.getCloser());  // 近点距离
            vo.setPakMk(steProtocol.getPakMk());    // 作业标记
        }
        return R.ok().add(list);
    }
@@ -164,6 +165,7 @@
                    vo.setLev(basSte.getLev());
                    vo.setCrnNo(basSte.getCrnNo());
                    vo.setWorkNo(basSte.getWrkNo());
                    vo.setPakMk(basSte.getPakMk());
                }
                break;
            }
@@ -178,7 +180,18 @@
        if (basSte == null) {
            return R.error();
        }
        // 获取穿梭车信息
        SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, vo.getSteNo());
        SteProtocol steProtocol = steThread.getSteProtocol();
        if (steProtocol != null) {
           throw new CoolException(vo.getSteNo() + "号穿梭车不在线,无法保存");
        }
        if (!Cools.isEmpty(vo.getRow(), vo.getBay(), vo.getLev())) {
            if (!steThread.modifyPosHandle(vo.getRow(), vo.getBay(), vo.getLev())) {
                throw new CoolException("服务器错误");
            }
        }
        basSte.setPakMk(vo.getPakMk());
        basSte.setWrkNo(vo.getWorkNo());
        basSte.setCrnNo(vo.getCrnNo());
        basSte.setUpdateTime(new Date());
src/main/java/com/zy/asrs/domain/vo/SteDataVo.java
@@ -22,4 +22,6 @@
    private Integer crnNo;
    private String pakMk;
}
src/main/java/com/zy/asrs/domain/vo/SteMsgTableVo.java
@@ -44,5 +44,7 @@
    // 近点距离
    public Double closer = 0.0D;
    // 作业标记
    private String pakMk = "-";
}
src/main/java/com/zy/asrs/mapper/BasSteMapper.java
@@ -10,6 +10,8 @@
@Repository
public interface BasSteMapper extends BaseMapper<BasSte> {
    int updatePos(@Param("row")Integer row, @Param("bay")Integer bay, @Param("lev")Integer lev);
    int updatePos(@Param("steNo")Integer steNo, @Param("row")Integer row, @Param("bay")Integer bay, @Param("lev")Integer lev);
    int updatePakMk(@Param("steNo")Integer steNo, @Param("pakMk")String pakMk);
}
src/main/java/com/zy/asrs/service/BasSteService.java
@@ -7,6 +7,8 @@
    BasSte findByCrnNo(Integer crnNo);
    int updatePos(Integer row, Integer bay, Integer lev);
    Boolean updatePos(Integer steNo, Integer row, Integer bay, Integer lev);
    Boolean updatePakMk(Integer steNo, String pakMk);
}
src/main/java/com/zy/asrs/service/impl/BasSteServiceImpl.java
@@ -28,8 +28,13 @@
    }
    @Override
    public int updatePos(Integer row, Integer bay, Integer lev) {
        return this.baseMapper.updatePos(row, bay, lev);
    public Boolean updatePos(Integer steNo, Integer row, Integer bay, Integer lev) {
        return this.baseMapper.updatePos(steNo, row, bay, lev) > 0;
    }
    @Override
    public Boolean updatePakMk(Integer steNo, String pakMk) {
        return this.baseMapper.updatePakMk(steNo, pakMk) > 0;
    }
}
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -547,7 +547,7 @@
                        SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
                        SteProtocol steProtocol = steThread.getSteProtocol();
                        if (steProtocol == null) { continue; }
                        if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) {
                        if (steProtocol.isIdle()) {
                            // 已经存在吊车执行任务时,则过滤
                            if (wrkMastMapper.selectWorking(slave.getId()) != null) {
@@ -690,7 +690,7 @@
                            SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
                            SteProtocol steProtocol = steThread.getSteProtocol();
                            if (steProtocol == null) { continue; }
                            if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) {
                            if (steProtocol.isIdle()) {
                                // 命令下发区 --------------------------------------------------------------------------
                                SteCommand steCommand = new SteCommand();
@@ -781,7 +781,7 @@
            SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, ste.getId());
            SteProtocol steProtocol = steThread.getSteProtocol();
            if (steProtocol == null) { continue; }
            if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) {
            if (steProtocol.isIdle()) {
                if (Utils.getGroupRow(locNo).equals(Utils.getGroupRow(steProtocol.getRow().intValue())) && steProtocol.getBay() == Utils.getBay(locNo) && steProtocol.getLev() == Utils.getLev(locNo)) {
                    return steProtocol.getSteNo().intValue();
                }
@@ -800,7 +800,7 @@
        SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, basSte.getSteNo());
        SteProtocol steProtocol = steThread.getSteProtocol();
        if (steProtocol != null) {
            if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) {
            if (steProtocol.isIdle()) {
                return steThread;
            }
        }
@@ -816,7 +816,7 @@
        SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
        SteProtocol steProtocol = steThread.getSteProtocol();
        if (steProtocol == null) { return; }
        if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) {
        if (steProtocol.isIdle()) {
            // 命令下发区 --------------------------------------------------------------------------
            SteCommand steCommand = new SteCommand();
@@ -849,7 +849,7 @@
        SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
        SteProtocol steProtocol = steThread.getSteProtocol();
        if (steProtocol == null) { return; }
        if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) {
        if (steProtocol.isIdle()) {
            // 堆垛机空闲
            if (crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() == 0) {
                LocMast locMast;
@@ -926,7 +926,7 @@
        SteProtocol steProtocol = steThread.getSteProtocol();
        if (steProtocol == null) { return; }
        // 穿梭车空闲
        if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) {
        if (steProtocol.isIdle()) {
            // 堆垛机空闲
            if (crnProtocol.getStatusType().equals(CrnStatusType.IDLE) || crnProtocol.getTaskNo() == 0) {
@@ -1009,7 +1009,7 @@
                        SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
                        SteProtocol steProtocol = steThread.getSteProtocol();
                        if (steProtocol == null) { continue; }
                        if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) {
                        if (steProtocol.isIdle()) {
                            // 命令下发区 --------------------------------------------------------------------------
                            SteCommand steCommand = new SteCommand();
                            steCommand.setSteNo(steNo); // 穿梭车编号
@@ -1078,7 +1078,7 @@
                    SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo);
                    SteProtocol steProtocol = steThread.getSteProtocol();
                    if (steProtocol == null) { continue; }
                    if (steProtocol.getStatusType().equals(SteStatusType.IDLE)) {
                    if (steProtocol.isIdle()) {
                        // 穿梭车重新定位排列层
                        if (!steThread.confirmPos()) {
                            log.error("{}号穿梭车重新定位失败!作业工作档任务号:{}", wrkMast.getSteNo(), wrkMast.getWrkNo());
src/main/java/com/zy/core/model/protocol/SteProtocol.java
@@ -217,6 +217,7 @@
     */
    private String lastIo = "I";
    private String pakMk = "-";
    public BasSte toSqlModel(BasSte basSte){
        if (alarm!=null) {
@@ -225,4 +226,10 @@
        basSte.setWrkNo(taskNo);
        return basSte;
    }
    // 是否处于空闲待命状态
    public Boolean isIdle() {
        return getStatusType().equals(SteStatusType.IDLE) && pakMk.equals("N");
    }
}
src/main/java/com/zy/core/thread/SteThread.java
@@ -42,10 +42,6 @@
    private short heartBeatVal = 1;
    private boolean resetFlag = false;
    private Integer lastRow;
    private Integer lastBay;
    private Integer lastLev;
    public SteThread(SteSlave slave) {
        this.slave = slave;
    }
@@ -186,6 +182,12 @@
                // 根据实时信息更新数据库
                BasSteService service = SpringUtils.getBean(BasSteService.class);
                if (null != service) {
                    // 同步pakMk
                    BasSte one = service.selectById(slave.getId());
                    if (one != null) {
                        steProtocol.setPakMk(one.getPakMk());
                    }
                    BasSte basSte = new BasSte();
                    basSte.setSteNo(slave.getId());
                    if (!service.updateById(steProtocol.toSqlModel(basSte))){
@@ -306,40 +308,45 @@
    }
    public void modifyPos(Integer row, Integer bay, Integer lev) {
        this.lastRow = row;
        this.lastBay = bay;
        this.lastLev = lev;
        BasSteService service = SpringUtils.getBean(BasSteService.class);
        if (!service.updatePos(this.slave.getId(), row, bay, lev)) {
            log.error("更新{}号穿梭车定位失败 ===>> 排:【{}】, 列:【{}】,层:【{}】", this.slave.getId(), row, bay, lev);
        }
    }
    public boolean confirmPos() {
        if (this.lastRow != null && this.lastRow != 0) {
            if (this.lastBay != null && this.lastBay != 0) {
                if (this.lastLev != null && this.lastLev != 0) {
                    BasSteService service = SpringUtils.getBean(BasSteService.class);
                    BasSte basSte = service.selectById(slave.getId());
                    if (basSte != null) {
                        // 更新plc数据块
                        short[] arr = new short[] {this.lastRow.shortValue(), this.lastBay.shortValue(), this.lastLev.shortValue()};
                        OperateResult result = siemensS7Net.Write("V1002", arr);
                        if (result.IsSuccess) {
                            // 更新数据库
                            if (service.updatePos(this.lastRow, this.lastBay, this.lastLev) > 0) {
                                this.lastRow = null;
                                this.lastBay = null;
                                this.lastLev = null;
                                return true;
                            } else {
                                log.error("{}号穿梭车修改数据库定位失败!!!", slave.getId());
                            }
                        }
                    }
        BasSteService service = SpringUtils.getBean(BasSteService.class);
        BasSte basSte = service.selectById(slave.getId());
        if (basSte != null) {
            // 更新plc数据块
            short[] arr = new short[] {basSte.getRow().shortValue(), basSte.getBay().shortValue(), basSte.getLev().shortValue()};
            OperateResult result = siemensS7Net.Write("V1002", arr);
            if (result.IsSuccess) {
                // 更新数据库
                if (service.updatePakMk(this.slave.getId(), "N")) {
                    return true;
                } else {
                    log.error("{}号穿梭车修改数据库定位失败!!!", slave.getId());
                }
            }
        }
        return false;
    }
    public boolean modifyPosHandle(Integer row, Integer bay, Integer lev) {
        short[] arr = new short[] {row.shortValue(), bay.shortValue(), lev.shortValue()};
        OperateResult result = siemensS7Net.Write("V1002", arr);
        if (!result.IsSuccess) {
            return false;
        }
        BasSteService service = SpringUtils.getBean(BasSteService.class);
        if (!service.updatePos(this.slave.getId(), row, bay, lev)) {
            log.error("更新{}号穿梭车定位失败 ===>> 排:【{}】, 列:【{}】,层:【{}】", this.slave.getId(), row, bay, lev);
            return false;
        }
        return true;
    }
    @Override
    public void close() {
        siemensS7Net.ConnectClose();
src/main/resources/mapper/BasSteMapper.xml
@@ -31,7 +31,17 @@
    <update id="updatePos">
        update asr_bas_ste
        set his_row = row, his_bay = bay,his_lev = lev,
        row = #{row}, bay = #{bay}, lev = #{lev}
        row = #{row}, bay = #{bay}, lev = #{lev},
        pak_mk = 'Y'
        where 1=1
        and ste_no = #{steNo}
    </update>
    <update id="updatePakMk">
        update asr_bas_ste
        set pak_mk = #{pakMk}
        where 1=1
        and ste_no = #{steNo}
    </update>
</mapper>
src/main/webapp/views/pipeline.html
@@ -84,7 +84,7 @@
        </footer>
        <div id="site-detl" style="display: none">
            <form>
            <div>
                <div class="form-item">
                    <label class="form-label">站号:</label>
                    <div class="form-input">
@@ -113,7 +113,7 @@
                    <button class="form-button" id="save">保存</button>
                    <button class="form-button" id="cancel" style="background-color: #D0D0D0">取消</button>
                </div>
            </form>
            </div>
        </div>
    </div>
@@ -326,6 +326,7 @@
            staNo:  $('#staNo').val(),
            pakMk: $('#pakMk').val()
        }, function (res) {
            layer.close(layerDetl);
            layer.msg("修改成功",{icon: 1,});
        })
    })
@@ -338,4 +339,4 @@
    })
</script>
</html>
</html>
src/main/webapp/views/ste.html
@@ -73,6 +73,7 @@
                            <th>目标库位</th>
                            <th>速度</th>
                            <th>近点距离</th>
                            <th>作业标记</th>
                        </tr>
                    </thead>
                    <tbody>
@@ -133,7 +134,7 @@
    </div>
    <div id="ste-detl" style="display: none">
        <form>
        <div>
            <div class="form-item">
                <label class="form-label">穿梭车号:</label>
                <div class="form-input">
@@ -155,26 +156,32 @@
            <div class="form-item">
                <label class="form-label">列:</label>
                <div class="form-input">
                    <input id="bay" name="bay" type="text" class="layui-input" autocomplete="off">
                    <input id="bay" name="bay" type="number" class="layui-input" autocomplete="off">
                </div>
            </div>
            <div class="form-item">
                <label class="form-label">层:</label>
                <div class="form-input">
                    <input id="lev" name="lev" type="text" class="layui-input" autocomplete="off">
                    <input id="lev" name="lev" type="number" class="layui-input" autocomplete="off">
                </div>
            </div>
            <div class="form-item">
                <label class="form-label">堆垛机:</label>
                <div class="form-input">
                    <input id="crnNo" name="crnNo" type="text" class="layui-input" autocomplete="off">
                    <input id="crnNo" name="crnNo" type="number" class="layui-input" autocomplete="off">
                </div>
            </div>
            <div class="form-item">
                <label class="form-label">作业标记:</label>
                <div class="form-input">
                    <input id="pakMk" name="pakMk" type="text" class="layui-input" autocomplete="off">
                </div>
            </div>
            <div class="form-item form-button-container">
                <button class="form-button" id="save">保存</button>
                <button class="form-button" id="cancel" style="background-color: #D0D0D0">取消</button>
            </div>
        </form>
        </di>
    </div>
</body>
</html>
@@ -217,16 +224,17 @@
        }
    }
    var layerIdx;
    $(document).on('click ','.pos-btn', function () {
        let steNo = Number($(this).parent().attr("data-steNo"));
        layerDetl = layer.open({
        layerIdx = layer.open({
            type: 1,
            title: false,
            shadeClose: true,
            offset: [$(this).offset().top + 30 + 'px', $(this).offset().left + 'px'],
            anim: 5,
            shade: [0],
            area: ['310px', '340px'],
            area: ['310px', '370px'],
            closeBtn: 0,
            content: $("#ste-detl"),
            success: function(layero, index){
@@ -237,6 +245,7 @@
                    $('#bay').val(res.data.bay);
                    $('#lev').val(res.data.lev);
                    $('#crnNo').val(res.data.crnNo);
                    $('#pakMk').val(res.data.pakMk);
                })
            },
            end: function () {
@@ -246,6 +255,7 @@
                $('#bay').val("");
                $('#lev').val("");
                $('#crnNo').val("");
                $('#pakMk').val("");
            }
        })
    })
@@ -258,9 +268,15 @@
            bay: $('#bay').val(),
            lev:  $('#lev').val(),
            crnNo: $('#crnNo').val(),
            pakMk: $('#pakMk').val(),
        }, function (res) {
            layer.msg("修改成功",{icon: 1,});
            layer.msg("修改成功", {icon: 1,});
            layer.close(layerIdx);
        })
    })
    $(document).on('click ','#cancel', function () {
        layer.close(layerIdx);
    })
    // 穿梭车信息表获取 ---- 表一
@@ -327,6 +343,7 @@
                        setVal(tr.children("td").eq(6), table[i-1].locNo);
                        setVal(tr.children("td").eq(7), table[i-1].speed);
                        setVal(tr.children("td").eq(8), table[i-1].closer);
                        setVal(tr.children("td").eq(9), table[i-1].pakMk);
                    }
                } else if (res.code === 403){
                    window.location.href = baseUrl+"/login";