#
mrzhssss
2023-01-29 7548c795ec26a13bf295f5bec4f3005e4476ade5
#
9个文件已修改
188 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 138 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/utils/Utils.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/BarcodeThread.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LedThread.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/MelsecCrnThread.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/ScaleThread.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensCrnThread.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -19,7 +19,6 @@
import com.zy.common.model.SearchLocParam;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
import com.zy.common.utils.CollectionUtils;
import com.zy.common.utils.HttpHandler;
import com.zy.common.utils.News;
import com.zy.core.CrnThread;
@@ -98,6 +97,8 @@
     * 入库站,根据条码扫描生成入库工作档,工作状态 2
     */
    public synchronized void generateStoreWrkFile() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库口
@@ -128,6 +129,7 @@
                        // led 异常显示
                        if (ledThread != null) {
                            String errorMsg = "扫码失败,请重试";
                            News.error(methodName +  ":扫码失败,请重试");
                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                        }
                        continue;
@@ -170,7 +172,7 @@
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
                    if (wrkMast != null) {
                        News.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        News.error(methodName + ":工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        continue;
                    }
@@ -206,6 +208,8 @@
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                News.error(methodName  + ":更新plc站点信息失败");
                                throw new CoolException("更新plc站点信息失败");
                            }
                            String successMsg = "入库工作档--工作号:" + dto.getWorkNo() + " 目标库位:" + dto.getLocNo();
@@ -221,7 +225,7 @@
                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                                }
                            }
                            News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                            News.error(methodName  +":请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                        }
@@ -301,6 +305,8 @@
     * 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2
     */
    public synchronized void generateStoreWrkFile0() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库口
@@ -341,10 +347,10 @@
                        wrkMast.setWrkSts(2L); // 工作状态:2.设备上走
                        wrkMast.setModiTime(new Date());
                        if (wrkMastMapper.updateById(wrkMast) == 0) {
                            News.error("更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo());
                            News.error(methodName + ":更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo());
                        }
                    } else {
                        News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
                        News.error(methodName +":发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
                    }
                }
@@ -359,6 +365,8 @@
     * 拣料、并板、盘点再入库
     */
    public synchronized void stnToCrnStnPick() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历拣料入库口
            for (DevpSlave.Sta pickSta : devp.getPickSta()) {
@@ -389,6 +397,7 @@
                        // led 异常显示
                        if (ledThread != null) {
                            String errorMsg = "扫码失败,请重试";
                            News.error(methodName + ":扫码失败,请重试");
                            MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                        }
                        continue;
@@ -436,17 +445,22 @@
                            .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号
                    StaDesc staDesc = staDescService.selectOne(wrapper);
                    if (Cools.isEmpty(staDesc)) {
                        News.error("入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
                        News.error(methodName + ":入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
                        continue;
                    }
                    try {
                        // 保存工作明细档历史档
                        if (wrkMastMapper.saveWrkDetlLog(wrkMast.getWrkNo()) == 0) {
                            News.error(methodName + ":保存工作明细档历史档失败");
                            throw new CoolException("保存工作明细档历史档失败");
                        }
                        // 保存工作主档历史档
                        if (wrkMastMapper.saveWrkMastLog(wrkMast.getWrkNo()) == 0) {
                            News.error(methodName + "-1:" + "保存工作主档历史档失败");
                            throw new CoolException("保存工作主档历史档失败");
                        }
@@ -463,6 +477,8 @@
                        wrkMast.setSourceLocNo(""); // 源库位清空
                        wrkMast.setModiTime(now);
                        if (wrkMastMapper.updateById(wrkMast) == 0) {
                            News.error(methodName + ":更新工作档数据状态失败");
                            throw new CoolException("更新工作档数据状态失败");
                        }
                        // 更新明细档io_time (历史档关联使用)
@@ -472,6 +488,8 @@
                        locMast.setLocSts("Q");
                        locMast.setModiTime(new Date());
                        if (!locMastService.updateById(locMast)) {
                            News.error(methodName+ ":修改库位状态失败");
                            throw new CoolException("修改库位状态失败");
                        }
                    } catch (Exception e) {
@@ -486,7 +504,9 @@
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    if (!result) {
                        News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
                        News.error(methodName + ":发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
                        News.error(methodName + ":发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
                    }
                }
@@ -500,6 +520,8 @@
     * 堆垛机站出库到出库站
     */
    public synchronized void crnStnToOutStn() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
            // 遍历堆垛机出库站
            for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) {
@@ -549,7 +571,7 @@
                            // 复位堆垛机
                            crnThread.setResetFlag(true);
                        } else {
                            News.error("更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo());
                            News.error(methodName + ":更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo());
                        }
                    }
@@ -563,6 +585,8 @@
     * 入出库  ===>>  堆垛机入出库作业下发
     */
    public synchronized void crnIoExecute() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
@@ -572,7 +596,7 @@
            }
            BasCrnp basCrnp = basCrnpService.selectById(crn.getId());
            if (basCrnp == null) {
                News.error("{}号堆垛机尚未在数据库进行维护!", crn.getId());
                News.error(methodName + ":{}号堆垛机尚未在数据库进行维护!", crn.getId());
                continue;
            }
@@ -675,6 +699,8 @@
     * 入库  ===>>  堆垛机站到库位
     */
    public synchronized void crnStnToLoc(CrnSlave slave, CrnProtocol crnProtocol) {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        for (CrnSlave.CrnStn crnStn : slave.getCrnInStn()) {
            boolean flag = false;
            // 获取堆垛机入库站信息
@@ -688,7 +714,7 @@
            // 查询站点详细信息
            BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
            if (staDetl == null) {
                News.error("入库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo());
                News.error(methodName + ":入库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo());
                continue;
            }
            if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
@@ -707,11 +733,11 @@
            // 获取库位信息
            LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
            if (locMast == null) {
                News.error("查询库存无数据--库位号{}", wrkMast.getLocNo());
                News.error(methodName + ":查询库存无数据--库位号{}", wrkMast.getLocNo());
                continue;
            }
            if (!locMast.getLocSts().equals("S") && !locMast.getLocSts().equals("Q")) {
                News.error("入库操作库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), locMast.getLocSts());
                News.error(methodName + ":入库操作库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), locMast.getLocSts());
                continue;
            }
@@ -733,12 +759,12 @@
                if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) {
                    WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
                    if (null == waitWrkMast) {
                        News.error("{}库位异常,未检索到相应工作档!", shallowLocNo);
                        News.error(methodName + ":{}库位异常,未检索到相应工作档!", shallowLocNo);
                    } else {
                        waitWrkMast.setIoPri(15D);
                        waitWrkMast.setModiTime(new Date());
                        if (wrkMastMapper.updateById(waitWrkMast) == 0) {
                            News.error("调整工作档优先级失败!工作号={}", waitWrkMast.getWrkNo());
                            News.error(methodName + ":调整工作档优先级失败!工作号={}", waitWrkMast.getWrkNo());
                        }
                        continue;
                    }
@@ -776,7 +802,7 @@
            crnCommand.setDestinationPosY(locMast.getBay1().shortValue());     // 目标库位列
            crnCommand.setDestinationPosZ(locMast.getLev1().shortValue());     // 目标库位层
            if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
                News.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
                News.error(methodName + ":堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
            } else {
//                long startTime = System.currentTimeMillis();
@@ -797,7 +823,7 @@
                wrkMast.setCrnStrTime(now);
                wrkMast.setModiTime(now);
                if (wrkMastMapper.updateById(wrkMast) == 0) {
                    News.error("修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo());
                    News.error(methodName + ":修改工作档状态 2.设备上走 => 3.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo());
                }
            }
        }
@@ -808,6 +834,8 @@
     * 2022-06-09 TQS修改,查询工作档LIST,遍历下发,防止第一个任务堵塞出库
     */
    public synchronized void locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol) {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
            // 获取工作状态为11(生成出库ID)的出库工作档
//            WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId(), crnStn.getStaNo());
@@ -818,13 +846,13 @@
                }
                // 工作档状态判断
                if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null) {
                    News.error("查询工作档数据不符合条件--入出类型/站点, 工作号={},源库位={},入出类型={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType());
                    News.error(methodName + ":查询工作档数据不符合条件--入出类型/站点, 工作号={},源库位={},入出类型={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType());
                    continue;
                }
                // 获取源库位信息
                LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
                if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) {
                    News.error("出库操作库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), sourceSta.getLocSts());
                    News.error(methodName + ":出库操作库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), sourceSta.getLocSts());
                    continue;
                }
                // 获取堆垛机出库站信息
@@ -846,7 +874,7 @@
                // 查询站点详细信息
                BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
                if (staDetl == null) {
                    News.error("出库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo());
                    News.error(methodName + ":出库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo());
                    break;
//                    continue;
                }
@@ -869,13 +897,13 @@
                        if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) {
                            WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
                            if (null == waitWrkMast) {
                                News.error("{}库位异常,未检索到相应工作档!", shallowLocNo);
                                News.error(methodName + ":{}库位异常,未检索到相应工作档!", shallowLocNo);
                            } else {
                                if (waitWrkMast.getWrkSts() == 11) {
                                    waitWrkMast.setIoPri(15D);
                                    waitWrkMast.setModiTime(new Date());
                                    if (wrkMastMapper.updateById(waitWrkMast) == 0) {
                                        News.error("调整工作档优先级失败!工作号={}", waitWrkMast.getWrkNo());
                                        News.error(methodName + ":调整工作档优先级失败!工作号={}", waitWrkMast.getWrkNo());
                                    }
                                    continue;
                                } else {
@@ -895,7 +923,7 @@
                                // 生成工作档,将浅库位移转到新的库位中
                                moveLocForDeepLoc(slave, shallowLoc);
                            }
                            News.error("{}任务出库失败,浅库位堵塞!浅库位号:{}", wrkMast.getWrkNo(), shallowLocNo);
                            News.error(methodName + ": {}任务出库失败,浅库位堵塞!浅库位号:{}", wrkMast.getWrkNo(), shallowLocNo);
                            continue;
                        } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) {
                            WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo);
@@ -924,7 +952,7 @@
                    crnCommand.setDestinationPosY(crnStn.getBay().shortValue());     // 目标库位列
                    crnCommand.setDestinationPosZ(crnStn.getLev().shortValue());     // 目标库位层
                    if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
                        News.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
                        News.error(methodName + ":堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
                    } else {
                        // 修改工作档状态 11.生成出库ID => 12.吊车出库中
                        Date now = new Date();
@@ -932,7 +960,7 @@
                        wrkMast.setCrnStrTime(now);
                        wrkMast.setModiTime(now);
                        if (wrkMastMapper.updateById(wrkMast) == 0) {
                            News.error("修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo());
                            News.error(methodName + ":修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo());
                        }
                        break;
                    }
@@ -1062,6 +1090,8 @@
     * 库位移转
     */
    public synchronized void locToLoc(CrnSlave slave, CrnProtocol crnProtocol) {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        // 获取工作档信息
        WrkMast wrkMast = wrkMastMapper.selectLocMove(slave.getId());
        if (null == wrkMast) {
@@ -1070,7 +1100,7 @@
        // 获取源库位信息
        LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
        if (null == sourceSta) {
            News.error("工作档库位移转失败,原因:检索源库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
            News.error(methodName + "工作档库位移转失败,原因:检索源库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo());
            return;
        }
        // 源库位  库位状态判断
@@ -1080,7 +1110,7 @@
        // 获取目标库位信息
        LocMast sta = locMastService.selectById(wrkMast.getLocNo());
        if (null == sta) {
            News.error("工作档库位移转失败,原因:检索目标库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getLocNo());
            News.error(methodName  + ":工作档库位移转失败,原因:检索目标库位失败!工作号={},源库位={}", wrkMast.getWrkNo(), wrkMast.getLocNo());
            return;
        }
        // 获取堆垛机信息 并 判断是否可入出
@@ -1102,13 +1132,13 @@
            if (shallowLoc.getLocSts().equals("P") || shallowLoc.getLocSts().equals("R")) {
                WrkMast waitWrkMast = wrkMastMapper.selectByLocNo(shallowLocNo);
                if (null == waitWrkMast) {
                    News.error("{}库位异常,未检索到相应工作档!", shallowLocNo);
                    News.error(methodName + ":{}库位异常,未检索到相应工作档!", shallowLocNo);
                } else {
                    if (waitWrkMast.getWrkSts() == 11) {
                        waitWrkMast.setIoPri(15D);
                        waitWrkMast.setModiTime(new Date());
                        if (wrkMastMapper.updateById(waitWrkMast) == 0) {
                            News.error("调整工作档优先级失败!工作号={}", waitWrkMast.getWrkNo());
                            News.error(methodName + ":调整工作档优先级失败!工作号={}", waitWrkMast.getWrkNo());
                        }
                        return;
                    } else {
@@ -1128,7 +1158,7 @@
                    // 生成工作档,将浅库位移转到新的库位中
                    moveLocForDeepLoc(slave, shallowLoc);
                }
                News.error("{}任务出库失败,浅库位堵塞!浅库位号:{}", wrkMast.getWrkNo(), shallowLocNo);
                News.error(methodName + ":{}任务出库失败,浅库位堵塞!浅库位号:{}", wrkMast.getWrkNo(), shallowLocNo);
                return;
            } else if (shallowLoc.getLocSts().equals("Q") || shallowLoc.getLocSts().equals("S")) {
                WrkMast waitWrkMast = wrkMastMapper.selectByLocNo1(shallowLocNo);
@@ -1156,7 +1186,7 @@
        crnCommand.setDestinationPosY(sta.getBay1().shortValue());     // 目标库位列
        crnCommand.setDestinationPosZ(sta.getLev1().shortValue());     // 目标库位层
        if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task(2, crnCommand))) {
            News.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
            News.error(methodName + ":堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
        } else {
            // 修改工作档状态 11.生成出库ID => 12.吊车出库中
            Date now = new Date();
@@ -1164,7 +1194,7 @@
            wrkMast.setCrnStrTime(now);
            wrkMast.setModiTime(now);
            if (wrkMastMapper.updateById(wrkMast) == 0) {
                News.error("【库位移转】 修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo());
                News.error(methodName + ":【库位移转】 修改工作档状态 11.生成出库ID => 12.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo());
            }
        }
@@ -1174,6 +1204,8 @@
     * 执行对工作档的完成操作
     */
    public synchronized void storeFinished() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crn.getId());
@@ -1190,7 +1222,7 @@
                    // 获取入库待确认工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue());
                    if (wrkMast == null) {
                        News.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo());
                        News.error(methodName + ":堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo());
                        continue;
                    }
                    // 入库 + 库位转移  ==> 4.入库完成
@@ -1217,6 +1249,8 @@
     * 堆垛机异常信息记录
     */
    public synchronized void recCrnErr() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        Date now = new Date();
        for (CrnSlave crn : slaveProperties.getCrn()) {
            // 获取堆垛机信息
@@ -1263,7 +1297,7 @@
                                    "任务中异常"    // 备注
                            );
                            if (!basErrLogService.insert(basErrLog)) {
                                News.error("堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", crn.getId(), errName);
                                News.error(methodName + ":堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", crn.getId(), errName);
                            }
                        }
                    } else {
@@ -1273,7 +1307,7 @@
                            latest.setUpdateTime(now);
                            latest.setStatus(2);
                            if (!basErrLogService.updateById(latest)) {
                                News.error("堆垛机plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
                                News.error(methodName + ":堆垛机plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
                            }
                        }
                    }
@@ -1310,7 +1344,7 @@
                                    "无任务异常"    // 备注
                            );
                            if (!basErrLogService.insert(basErrLog)) {
                                News.error("堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", crn.getId(), errName);
                                News.error(methodName + ":堆垛机plc异常记录失败 ===>> [id:{}] [error:{}]", crn.getId(), errName);
                            }
                        }
                        // 无异常
@@ -1321,7 +1355,7 @@
                            latest.setUpdateTime(now);
                            latest.setStatus(2);
                            if (!basErrLogService.updateById(latest)) {
                                News.error("堆垛机plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
                                News.error(methodName + ":堆垛机plc异常记录修复失败 ===>> [id:{}] [errLogId:{}]", crn.getId(), latest.getId());
                            }
                        }
                    }
@@ -1338,6 +1372,8 @@
     * 空栈板初始化入库,叉车入库站放货
     */
    public synchronized void storeEmptyPlt() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历空板入库口
            for (DevpSlave.Sta emptyInSta : devp.getEmptyInSta()) {
@@ -1381,10 +1417,12 @@
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                News.error(methodName + "更新plc站点信息失败");
                                throw new CoolException("更新plc站点信息失败");
                            }
                        } else {
                            News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                            News.error(methodName + ":请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
@@ -1456,6 +1494,8 @@
     * 出库  ===>> 工作档信息写入led显示器
     */
    public synchronized void ledExecute() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        for (LedSlave led : slaveProperties.getLed()) {
            // 获取输送线plc线程
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
@@ -1484,13 +1524,13 @@
                ledCommand.setIoType(wrkMast.getIoType());
                // 出库模式
                switch (wrkMast.getIoType()) {
                    case 1:
                    case -1:
                        ledCommand.setTitle("全板入库");
                        break;
                    case 10:
                        ledCommand.setTitle("空板入库");
                        break;
                    case 101:
                    case 10-1:
                        ledCommand.setTitle("全板出库");
                        break;
                    case 103:
@@ -1507,7 +1547,7 @@
                        ledCommand.setEmptyMk(true);
                        break;
                    default:
                        News.error("任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
                        News.error(methodName + ":任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
                        break;
                }
                ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
@@ -1531,7 +1571,7 @@
            if (!commands.isEmpty()) {
                String errMsg = "";
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
                    News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    News.error(methodName + ":{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    continue;
                } else {
                    ledThread.setLedMk(false);
@@ -1829,6 +1869,7 @@
     * 堆垛机演示  ===>> 库位移转
     */
    public synchronized void crnDemoOfLocMove1() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        try {
            for (CrnSlave crn : slaveProperties.getCrn()) {
                if (!crn.getDemo()) {
@@ -1880,6 +1921,7 @@
                    wrkMast.setModiTime(new Date());
                    int res = wrkMastMapper.insert(wrkMast);
                    if (res == 0) {
                        News.error(methodName + ":保存工作档失败");
                        throw new CoolException("保存工作档失败");
                    }
                    // 工作档明细保存
@@ -1901,9 +1943,13 @@
                        sourceLoc.setLocSts("R"); // R.出库预约
                        sourceLoc.setModiTime(new Date());
                        if (!locMastService.updateById(sourceLoc)) {
                            News.error(methodName + ":更新源库位状态失败");
                            throw new CoolException("更新源库位状态失败");
                        }
                    } else {
                        News.error(methodName + ":源库位出库失败");
                        throw new CoolException("源库位出库失败");
                    }
                    // 修改目标库位状态
@@ -1911,16 +1957,20 @@
                        loc.setLocSts("S"); // S.入库预约
                        loc.setModiTime(new Date());
                        if (!locMastService.updateById(loc)) {
                            News.error(methodName + ":更新目标库位状态失败");
                            throw new CoolException("更新目标库位状态失败");
                        }
                    } else {
                        News.error(methodName + ":移转失败");
                        throw new CoolException("移转失败");
                    }
                }
            }
        } catch (Exception e) {
            News.error("堆垛机演示  ===>> 库位移转失败", e);
            News.error(methodName + ":堆垛机演示  ===>> 库位移转失败", e);
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
@@ -2055,6 +2105,8 @@
    public synchronized void autoEmptyOut() {
        DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        Integer autoOutSite = 12;
        //如果站点可出禁用,则不生成空盘出库任务
        StaProtocol staProtocol = devpThread.getStation().get(autoOutSite);
@@ -2083,7 +2135,7 @@
                    JSONObject data = (JSONObject) jsonObject.get("data");
                    News.info((String) data.get("msg"));
                } else {
                    News.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/auto/emptyOut/v1", "", response);
                    News.error(methodName + ":请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/auto/emptyOut/v1", "", response);
                }
            } catch (Exception e) {
                e.printStackTrace();
src/main/java/com/zy/asrs/utils/Utils.java
@@ -36,6 +36,8 @@
        }
    }
    /**
     * 判断是否为深库位
     */
src/main/java/com/zy/core/thread/BarcodeThread.java
@@ -32,10 +32,12 @@
    }
    public void setBarcode(String barcode) {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        this.barcode.delete(0, this.barcode.length());
        this.barcode.append(barcode);
        if(!Cools.isEmpty(barcode)) {
            News.info("{}号条码器,检索数据:{}", slave.getId(), this.barcode);
            News.info(methodName + ":{}号条码器,检索数据:{}", slave.getId(), this.barcode);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("time", DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss_F));
            jsonObject.put("barcode", barcode);
src/main/java/com/zy/core/thread/LedThread.java
@@ -246,6 +246,8 @@
    @Override
    public boolean connect() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        boolean connRes = false;
        try {
            connRes = screen.connect(slave.getIp(),slave.getPort());
@@ -253,9 +255,9 @@
        } catch (Exception ignore) {
        }
        if (connRes) {
            News.info("led连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.info(methodName + ":led连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
        } else {
            News.error("led连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.error(methodName + ":led连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
        }
        return connRes;
    }
src/main/java/com/zy/core/thread/MelsecCrnThread.java
@@ -234,6 +234,8 @@
     * 写入数据
     */
    private boolean write(CrnCommand command){
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        if (null == command) {
            News.error("堆垛机写入命令为空");
            return false;
@@ -330,12 +332,12 @@
        } catch (Exception ignore) {}
        if (result != null && result.IsSuccess) {
            News.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            News.info(methodName + ":堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
            return true;
        } else {
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
            News.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.error(methodName + ":写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            return false;
        }
    }
src/main/java/com/zy/core/thread/ScaleThread.java
@@ -56,6 +56,8 @@
    @Override
    public boolean connect() {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        try {
            close();  //1.主动释放连接 //2.某些服务器对指定ip有链路数限制
            socket = new Socket();
@@ -67,7 +69,7 @@
//            News.info("条码扫描仪连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
        } catch (Exception e) {
            socket = null;
            News.error("条码扫描仪连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.error(methodName + ":条码扫描仪连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            return false;
        }
        return true;
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -147,6 +147,8 @@
     * 读取状态
     */
    private void readStatus(){
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        try {
            OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56);
            if (result.IsSuccess) {
@@ -199,19 +201,19 @@
                    basCrnp.setCrnNo(slave.getId());
                    basCrnp.setCrnSts((int)crnProtocol.getMode());
                    if (!basCrnpService.updateById(crnProtocol.toSqlModel(basCrnp))){
                        News.error("堆垛机plc数据库更新失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
                        News.error(methodName + ":堆垛机plc数据库更新失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
                    }
                } catch (Exception ignore){}
            } else {
                initCrn();
                OutputQueue.CRN.offer(MessageFormat.format("【{0}】读取堆垛机plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
                News.error("读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
                News.error(methodName + ":读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            }
        } catch (Exception e) {
            e.printStackTrace();
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】读取堆垛机plc状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
            News.error("读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.error(methodName + ":读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            initCrn();
        }
    }
@@ -229,6 +231,8 @@
     * 写入数据
     */
    private boolean write(CrnCommand command) throws InterruptedException {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        if (null == command) {
            News.error("堆垛机写入命令为空");
            return false;
@@ -282,12 +286,12 @@
        if (result != null && result.IsSuccess) {
            Thread.sleep(200);
            this.readStatus();
            News.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            News.info(methodName + ":堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] >>>>> 命令下发: {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(command)));
            return true;
        } else {
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
            News.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.error(methodName + ":写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            return false;
        }
    }
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -131,6 +131,8 @@
     * 读取状态 ====> 整块plc
     */
    private void read() throws InterruptedException {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
//        // 更新入出库模式
//        updateIoMode();
        int staNoSize = staNos.size();
@@ -249,7 +251,7 @@
            } catch (Exception e) {
                e.printStackTrace();
                OutputQueue.DEVP.offer(MessageFormat.format("【{0}】更新数据库数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}] [rack:{4}] [slot:{5}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot()));
                News.error("更新数据库数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
                News.error(methodName + ":更新数据库数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            }
        } else {
@@ -262,6 +264,8 @@
     * 写入 ID+目标站 =====> 单站点写入
     */
    private void write(StaProtocol staProtocol) throws InterruptedException {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        if (null == staProtocol) {
            return;
        }
@@ -281,10 +285,10 @@
                staProtocol.setPakMk(true);
            }
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】写入输送线站点数据失败。输送线plc编号={1},站点数据={2}", slave.getId(), JSON.toJSON(staProtocol)));
            News.error("写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol));
            News.error(methodName + ":写入输送线站点数据失败。输送线plc编号={},站点数据={}", slave.getId(), JSON.toJSON(staProtocol));
        } else {
            OutputQueue.DEVP.offer(MessageFormat.format("【{0}】 输送线命令下发 [id:{1}] >>>>> {2}", DateUtils.convert(new Date()), slave.getId(), JSON.toJSON(staProtocol)));
            News.info("输送线命令下发 [id:{}] >>>>> 命令下发: {}",  slave.getId(), JSON.toJSON(staProtocol));
            News.info(methodName + ":输送线命令下发 [id:{}] >>>>> 命令下发: {}",  slave.getId(), JSON.toJSON(staProtocol));
        }
    }
src/main/resources/application.yml
@@ -8,8 +8,8 @@
    name: @pom.build.finalName@
  datasource:
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    url: jdbc:sqlserver://10.10.10.100:1433;databasename=stasrs
#    url: jdbc:sqlserver://192.168.4.15:1433;databasename=stasrs
#    url: jdbc:sqlserver://10.10.10.100:1433;databasename=stasrs
    url: jdbc:sqlserver://192.168.4.15:1433;databasename=stasrs
    username: sa
    password: sa@123
  mvc: