#
Junjie
2024-12-23 a4d9d3f23e44099972ea6de8af35152ed96ae8ae
#
5个文件已修改
8个文件已删除
2282 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/controller/AgvController.java 49 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/RobotController.java 91 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/entity/AgvBasDevp.java 309 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/mapper/AgvBasDevpMapper.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/AgvBasDevpService.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/AgvBasDevpServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 549 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/ServerBootstrap.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/BarcodeThread.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread2.java 319 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread3.java 275 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 487 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/controller/AgvController.java
File was deleted
src/main/java/com/zy/asrs/controller/RobotController.java
File was deleted
src/main/java/com/zy/asrs/entity/AgvBasDevp.java
File was deleted
src/main/java/com/zy/asrs/mapper/AgvBasDevpMapper.java
File was deleted
src/main/java/com/zy/asrs/service/AgvBasDevpService.java
File was deleted
src/main/java/com/zy/asrs/service/impl/AgvBasDevpServiceImpl.java
File was deleted
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -311,105 +311,6 @@
    }
    /**
     * wms入库
     * 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2
     */
    @Deprecated
    public void generateStoreWrkFile0() {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历入库口
            for (DevpSlave.Sta inSta : devp.getInSta()) {
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                Short workNo = staProtocol.getWorkNo();
                // 判断是否满足入库条件
                if (staProtocol.isAutoing() && staProtocol.isLoading()
                        && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999))
                        && staProtocol.isPakMk()) {
                    // 尺寸检测异常
                    boolean back = false;
                    String errMsg = "";
                    if (staProtocol.isFrontErr()) {
                        errMsg = "前超限";
                        back = true;
                    }
                    if (!back && staProtocol.isBackErr()) {
                        errMsg = "后超限";
                        back = true;
                    }
                    if (!back && staProtocol.isHighErr()) {
                        errMsg = "高超限";
                        back = true;
                    }
                    if (!back && staProtocol.isLeftErr()) {
                        errMsg = "左超限";
                        back = true;
                    }
                    if (!back && staProtocol.isRightErr()) {
                        errMsg = "右超限";
                        back = true;
                    }
                    if (!back && staProtocol.isWeightErr()) {
                        errMsg = "超重";
                        back = true;
                    }
                    if (!back && staProtocol.isBarcodeErr()) {
                        errMsg = "扫码失败";
                        back = true;
                    }
                    // 退回
                    if (back) {
                        News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg);
                        staProtocol.setWorkNo((short) 32002);
                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        // led 异常显示
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                        if (ledThread != null) {
                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
                        }
                        continue;
                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo());
                    if (wrkMast == null) { continue; }
                    // 命令下发区 --------------------------------------------------------------------------
                    // 更新站点信息 且 下发plc命令
                    staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
                    staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    if (result) {
                        // 更新工作主档
                        wrkMast.setWrkSts(2L); // 工作状态:2.设备上走
                        wrkMast.setModiTime(new Date());
                        if (wrkMastMapper.updateById(wrkMast) == 0) {
                            News.error("更新工作档失败!!! [工作号:{}]", wrkMast.getWrkNo());
                        }
                    } else {
                        News.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
                    }
                }
            }
        }
    }
    /**
     * 拣料、并板再入库
     */
    @Transactional
@@ -529,49 +430,6 @@
                        } catch (Exception e) {
                            e.printStackTrace();
                            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 拣料、并板再入库(325、331、333、339)
     */
    @Transactional
    public synchronized void stnToCrnStnPick2(){
        try {
            for (DevpSlave devp : slaveProperties.getDevp()) {
                // 遍历拣料入库口
                for (DevpSlave.Sta pickSta : devp.getPickInSta2()) {
                    // 获取拣料入库站信息
                    DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                    StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
                    if (staProtocol == null) {
                        continue;
                    } else {
                        staProtocol = staProtocol.clone();
                    }
                    if (staProtocol.isAutoing()
                            && staProtocol.isLoading()
                            && staProtocol.isInEnable()
                            && (staProtocol.getWorkNo() > 0)
                            && staProtocol.isPakMk()) {
                        WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue());
                        if (wrkMast == null) {
                            continue;
                        }
                        if (wrkMast.getSteNo() == null) {
                            wrkMast.setSteNo(1);
                            wrkMastMapper.updateById(wrkMast);
                            staProtocol.setStaNo((short) 341);//写入目标站
                            staProtocol.setPakMk(false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        }
                    }
                }
@@ -2506,413 +2364,6 @@
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * AGV补货 => 生成入库通知档
     */
    public synchronized void robotGenerateAgvTask() {
        try {
            //检测300站是否自动、有物、工作号
            for (DevpSlave devp : slaveProperties.getDevp()) {
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(300);
                if (staProtocol == null) {
                    continue;
                }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) {
                    //查询是否有工作档
                    WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue());
                    if (wrkMast == null) {
                        continue;
                    }
                    if (wrkMast.getWrkSts() != 25) {//25.提升机搬运完成
                        continue;
                    }
                    if (wrkMast.getMk() != null && wrkMast.getMk().equals("Y")) {//标记为Y表示需要用到机械臂拣料
                        Short targetSta = null;//目标站
                        //判断机械臂拣料站是否空闲
                        StaProtocol staProtocol303 = devpThread.getStation().get(303);
                        StaProtocol staProtocol317 = devpThread.getStation().get(317);
                        List<WrkMast> wrkMasts303 = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 25).eq("sta_no", 303));
                        List<WrkMast> wrkMasts317 = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", 25).eq("sta_no", 317));
                        if (staProtocol303.isAutoing() && !staProtocol303.isLoading() && wrkMasts303.isEmpty()) {
                            //自动、无物
                            targetSta = (short) 303;
                        } else if (staProtocol317.isAutoing() && !staProtocol317.isLoading() && wrkMasts317.isEmpty()) {
                            //自动、无物
                            targetSta = (short) 317;
                        } else {
                            continue;//没有空闲站点
                        }
                        if (wrkMast.getStaNo() != 303 && wrkMast.getStaNo() != 317) {
                            //向AGV发起组托请求
                            try {
                                HashMap<String, Object> param = new HashMap<>();
                                param.put("wrkNo", wrkMast.getWrkNo());
                                String response = new HttpHandler.Builder()
                                        .setUri(wmsUrl)
                                        .setPath("/rpc/replenishment")
                                        .setJson(JSON.toJSONString(param))
                                        .build()
                                        .doPost();
                                JSONObject jsonObject = JSON.parseObject(response);
                                Integer code = jsonObject.getInteger("code");
                                if (code.equals(200)) {//AGV组托成功
                                    //覆盖工作档目标站
                                    wrkMast.setStaNo(targetSta.intValue());
                                    wrkMast.setShuttleNo(null);//释放小车
                                    wrkMast.setLiftNo(null);//释放提升机
                                    if (wrkMastMapper.updateById(wrkMast) > 0) {
                                        //向300站写入目标站
                                        staProtocol = staProtocol.clone();
                                        staProtocol.setStaNo(targetSta);//移动到目标站
                                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                                        try {
                                            Thread.sleep(500);
                                        } catch (Exception e) {
                                            e.printStackTrace();
                                        }
                                        continue;
                                    }
                                }
                            } catch (Exception e) {
//                                e.printStackTrace();
                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                            }
//                        //覆盖工作档目标站
//                        wrkMast.setStaNo(targetSta.intValue());
//                        wrkMast.setShuttleNo(null);//释放小车
//                        wrkMast.setLiftNo(null);//释放提升机
//                        if (wrkMastMapper.updateById(wrkMast) > 0) {
//                            //向300站写入目标站
//                            staProtocol = staProtocol.clone();
//                            staProtocol.setStaNo(targetSta);//移动到目标站
//                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                            try {
//                                Thread.sleep(500);
//                            } catch (Exception e) {
//                                e.printStackTrace();
//                            }
//                            continue;
//                        }
                        }
                    }
                }
            }
        } catch (Exception e) {
//            e.printStackTrace();
        }
    }
    /**
     * AGV补货 => 机械臂拣料
     */
    public synchronized void agvRestockByRobot() {
        try {
            //检测300站是否自动、有物、工作号
            for (DevpSlave devp : slaveProperties.getDevp()) {
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol303 = devpThread.getStation().get(303);
                StaProtocol staProtocol317 = devpThread.getStation().get(317);
                if (staProtocol303 == null || staProtocol317 == null) {
                    continue;
                }
                if (staProtocol303.isAutoing() && staProtocol303.isLoading() && staProtocol303.getWorkNo() != 0) {
                    //调度机械臂
                    //查询是否有工作档
                    WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol303.getWorkNo().intValue());
                    if (wrkMast == null) {
                        continue;
                    }
                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
                    if (wrkDetls.isEmpty()) {
                        continue;
                    }
                    if (wrkMast.getInvWh() == null) {
                        boolean result = RobotUtils.sendTask(staProtocol303.getWorkNo().toString(), wrkDetls.size(), "303");
                        if (result) {
                            wrkMast.setInvWh("Y");//标记已经下发机械臂任务
                            wrkMastMapper.updateById(wrkMast);
                        }
                    }
                }
                if (staProtocol317.isAutoing() && staProtocol317.isLoading() && staProtocol317.getWorkNo() != 0) {
                    //调度机械臂
                    //查询是否有工作档
                    WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol317.getWorkNo().intValue());
                    if (wrkMast == null) {
                        continue;
                    }
                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
                    if (wrkDetls.isEmpty()) {
                        continue;
                    }
                    if (wrkMast.getInvWh() == null) {
                        boolean result = RobotUtils.sendTask(staProtocol317.getWorkNo().toString(), wrkDetls.size(), "317");
                        if (result) {
                            wrkMast.setInvWh("Y");//标记已经下发机械臂任务
                            wrkMastMapper.updateById(wrkMast);
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * AGV补货(通知AGV取货)
     */
    public synchronized void agvRestockInto() {
        try {
            //检测309和312站是否自动、有物
            for (DevpSlave devp : slaveProperties.getDevp()) {
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol309 = devpThread.getStation().get(309);
                StaProtocol staProtocol312 = devpThread.getStation().get(312);
                if (staProtocol309 == null || staProtocol312 == null) {
                    continue;
                }
                if (staProtocol309.isAutoing() && staProtocol309.isLoading() && staProtocol309.isInEnable()) {
                    // 获取条码扫描仪信息
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 9);//308站条码器
                    if (barcodeThread == null) {
                        continue;
                    }
                    String barcode = barcodeThread.getBarcode();
                    if (!Cools.isEmpty(barcode)) {
                        //通知AGV取货
                        boolean result = agvRestockCall("301-1", barcode);
                        log.info("机械臂通知AGV取货,条码号:" + barcode);
                        if (result) {
                            barcodeThread.setBarcode("");
                        }
                    }
                }
                if (staProtocol312.isAutoing() && staProtocol312.isLoading() && staProtocol312.isInEnable()) {
                    // 获取条码扫描仪信息
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, 10);//311站条码器
                    if (barcodeThread == null) {
                        continue;
                    }
                    String barcode = barcodeThread.getBarcode();
                    if (!Cools.isEmpty(barcode)) {
                        //通知AGV取货
                        boolean result = agvRestockCall("302-1", barcode);
                        log.info("机械臂通知AGV取货,条码号:" + barcode);
                        if (result) {
                            barcodeThread.setBarcode("");
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //通知AGV取货
    private boolean agvRestockCall(String staNo, String barcode) {
        try {
            HashMap<String, Object> param = new HashMap<>();
            param.put("devNo", staNo);
            param.put("containerCode", barcode);
            String response = new HttpHandler.Builder()
                    .setUri(wmsUrl)
                    .setPath("/rpc/start")
                    .setJson(JSON.toJSONString(param))
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            News.info("悬挂线,WMS返回结果:" + jsonObject);
            Integer code = jsonObject.getInteger("code");
            if (code.equals(200)) {//呼叫AGV
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        return false;
    }
    //通知WMS当前拣料站点信息
    private boolean agvCureentCall(String staNo, String barcode) {
        try {
            HashMap<String, Object> param = new HashMap<>();
            param.put("devNo", staNo);
            param.put("containerCode", barcode);
            String response = new HttpHandler.Builder()
                    .setUri(wmsUrl)
                    .setPath("/rpc/current/containerCode")
                    .setJson(JSON.toJSONString(param))
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            News.info("悬挂线,WMS返回结果:" + jsonObject);
            Integer code = jsonObject.getInteger("code");
            if (code.equals(200)) {//呼叫AGV
                return true;
            }
        } catch (Exception e) {
            e.printStackTrace();
            TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
        }
        return false;
    }
    /**
     * AGV补货(悬挂线通知AGV取货)
     */
    public synchronized void agvRestockIntoByHangingWire() {
        try {
            //检测350和351扫码器
            int[] barcodeStaNo = {11, 12,14,16,18,20};//11 => 350站扫码器,12 => 351站扫码器
            for (int staNo : barcodeStaNo) {
                // 获取条码扫描仪信息
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo);
                if (barcodeThread == null) {
                    continue;
                }
                String barcode = barcodeThread.getBarcode();
                if (!Cools.isEmpty(barcode)) {
                    if (barcode.contains("NoRead")) {
                        continue;
                    }
                    String agvStaNo = null;
                    if (staNo == 11) {
                        agvStaNo = "303-1";
                    } else if(staNo == 12){
                        agvStaNo = "304-1";
                    } else if(staNo == 14){
                        agvStaNo = "311-1";
                    } else if(staNo == 16){
                        agvStaNo = "313-1";
                    } else if(staNo == 18){
                        agvStaNo = "315-1";
                    } else if(staNo == 20){
                        agvStaNo = "317-1";
                    }
                    //通知AGV取货
                    boolean result = agvRestockCall(agvStaNo, barcode);
                    if (result) {
                        barcodeThread.setBarcode("");
                    }
                    log.info(barcodeThread.getSlave().getId() + "号扫码器,通知AGV取货,条码号:" + barcode);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * AGV拣料站点信息
     */
    public synchronized void agvCurrentContainerCodeInfoWire() {
        try {
            //检测350和351扫码器
            int[] barcodeStaNo = {13, 15,17,19};//11 => 350站扫码器,12 => 351站扫码器
            for (int staNo : barcodeStaNo) {
                // 获取条码扫描仪信息
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, staNo);
                if (barcodeThread == null) {
                    continue;
                }
                String barcode = barcodeThread.getBarcode();
                if (!Cools.isEmpty(barcode)) {
                    if (barcode.contains("NoRead")) {
                        continue;
                    }
                    String agvStaNo = null;
                    if (staNo == 13) {
                        agvStaNo = "CS-310";
                    } else if(staNo == 15){
                        agvStaNo = "CS-311";
                    } else if(staNo == 17){
                        agvStaNo = "CS-312";
                    } else if(staNo == 19){
                        agvStaNo = "CS-313";
                    }
                    //通知WMS当前容器码
                    boolean result = agvCureentCall(agvStaNo, barcode);
                    if (result) {
                        barcodeThread.setBarcode("");
                    }
                    log.info(barcodeThread.getSlave().getId() + "号扫码器,通知AGV取货,条码号:" + barcode);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    // 300站拣料
    public void pick300() {
        try {
            //检测300站是否自动、有物、工作号
            for (DevpSlave devp : slaveProperties.getDevp()) {
                // 获取入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(300);
                if (staProtocol == null) {
                    continue;
                }else {
                    staProtocol = staProtocol.clone();
                }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() != 0) {
                    //查询是否有工作档
                    WrkMast wrkMast = wrkMastMapper.selectByWorkNo(staProtocol.getWorkNo().intValue());
                    if (wrkMast == null) {
                        continue;
                    }
                    if (wrkMast.getWrkSts() != 29) {//29.出库完成
                        continue;
                    }
                    if (wrkMast.getMk() == null) {
                        Integer sourceStaNo = wrkMast.getSourceStaNo();//源站
                        Integer staNo = wrkMast.getStaNo();//目标站
                        //覆盖工作档目标站
                        wrkMast.setStaNo(sourceStaNo);
                        wrkMast.setSourceStaNo(staNo);
                        wrkMast.setMk("N");
                        if (wrkMastMapper.updateById(wrkMast) > 0) {
                            //向300站写入目标站
                            staProtocol = staProtocol.clone();
                            staProtocol.setStaNo(wrkMast.getStaNo().shortValue());//移动到目标站
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            try {
                                Thread.sleep(500);
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
src/main/java/com/zy/core/MainProcess.java
@@ -22,8 +22,6 @@
    private MainServiceImpl mainService;
    // 所属线程
    private Thread thread;
    // 所属线程
    private Thread agvThread;
    // 频率
    private int i = 0;
@@ -45,17 +43,11 @@
                    // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
                    mainService.generateStoreWrkFile(); // 组托
//                    mainService.generateStoreWrkFile0(); // WMS入库
                    // 间隔
                    Thread.sleep(500);
                    //初始化实时地图
                    mainService.initRealtimeBasMap();
                    // 拣料、并板再入库
                    mainService.stnToCrnStnPick();
//                    // 拣料、并板再入库(325、331、333、339)
//                    mainService.stnToCrnStnPick2();
                    // 盘点再入库
                    mainService.stnToCrnStnPlate();
                    // 入库  ===>>  四向穿梭车入库作业下发
@@ -76,18 +68,6 @@
                    mainService.recErr();
                    // 入库  ===>> 空栈板初始化入库,叉车入库站放货
                    mainService.storeEmptyPlt();
//                    // AGV补货 => 生成入库通知档
//                    mainService.robotGenerateAgvTask();
//                    // AGV补货(机械臂拣料)
//                    mainService.agvRestockByRobot();
//                    // AGV补货(通知AGV取货)
//                    mainService.agvRestockInto();
//                    // AGV补货(悬挂线通知AGV取货)
//                    mainService.agvRestockIntoByHangingWire();
//                    // AGV信息更新
//                    mainService.agvCurrentContainerCodeInfoWire();
                    // 300站拣料
                    mainService.pick300();
                    // 出库  ===>> 工作档信息写入led显示器
                    mainService.ledExecute();
                    // 其他  ===>> LED显示器复位,显示默认信息
@@ -109,40 +89,9 @@
        thread.start();
    }
    public void agvStart(){
        agvThread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    // 间隔
                    Thread.sleep(300);
                    // AGV补货 => 生成入库通知档
                    mainService.robotGenerateAgvTask();
                    // AGV补货(机械臂拣料)
                    mainService.agvRestockByRobot();
                    // AGV补货(通知AGV取货)
                    mainService.agvRestockInto();
                    // AGV补货(悬挂线通知AGV取货)
                    mainService.agvRestockIntoByHangingWire();
                    // AGV信息更新
                    mainService.agvCurrentContainerCodeInfoWire();
                    // 间隔
                    Thread.sleep(200);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        agvThread.start();
    }
    @PreDestroy
    public void shutDown(){
        if (thread != null) thread.interrupt();
        if (agvThread != null) agvThread.interrupt();
    }
}
src/main/java/com/zy/core/ServerBootstrap.java
@@ -41,7 +41,6 @@
        initThread();
        // 开始主流程进程
        mainProcess.start();
        mainProcess.agvStart();
        News.info("核心控制层已启动...............................................");
    }
@@ -89,16 +88,6 @@
            DevpThread devpThread = new SiemensDevpThread(devp);
            new Thread((Runnable) devpThread).start();
            SlaveConnection.put(SlaveType.Devp, devp.getId(), devpThread);
        }
        for (Devp2Slave devp2 : slaveProperties.getDevp2()) {
            SiemensDevpThread2 siemensDevpThread2 = new SiemensDevpThread2(devp2);
            new Thread(siemensDevpThread2).start();
            SlaveConnection.put(SlaveType.Devp2, devp2.getId(), siemensDevpThread2);
        }
        for (Devp2Slave devp3 : slaveProperties.getDevp3()) {
            SiemensDevpThread3 siemensDevpThread3 = new SiemensDevpThread3(devp3);
            new Thread(siemensDevpThread3).start();
            SlaveConnection.put(SlaveType.Devp3, devp3.getId(), siemensDevpThread3);
        }
        // 初始化提升机
        News.info("初始化提升机........................................................");
src/main/java/com/zy/core/thread/BarcodeThread.java
@@ -3,24 +3,12 @@
import com.alibaba.fastjson.JSONObject;
import com.core.common.Cools;
import com.core.common.DateUtils;
import com.core.common.SpringUtils;
import com.zy.asrs.service.AgvBasDevpService;
import com.zy.asrs.service.BasDevpService;
import com.zy.core.News;
import com.zy.core.Slave;
import com.zy.core.ThreadHandler;
import com.zy.core.cache.OutputQueue;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;
import java.net.SocketTimeoutException;
import java.util.Date;
/**
@@ -33,10 +21,6 @@
    private Slave slave;
    private StringBuffer barcode = new StringBuffer();
    private Socket socket;
    private DataOutputStream dataOutputStream;
    private DataInputStream dataInputStream;
    public Integer connCount = 0;
    public BarcodeThread(Slave slave) {
        this.slave = slave;
@@ -50,18 +34,8 @@
        this.barcode.delete(0, this.barcode.length());
        this.barcode.append(barcode);
        if(!Cools.isEmpty(barcode)) {
            AgvBasDevpService agvBasDevpService = SpringUtils.getBean(AgvBasDevpService.class);
            News.info("{}号条码器,检索数据:{}", slave.getId(), this.barcode);
            String devNo = slave.getId() == 13 ? "310-1" : slave.getId() == 15 ? "312-2" : slave.getId() == 17 ? "314-1" : slave.getId() == 19 ? "316-1" : null;
            if(!Cools.isEmpty(devNo)){
                barcode = barcode.substring(3,barcode.length());
                int updateBarcode = agvBasDevpService.updateBarcode(devNo, barcode);
                if (updateBarcode <= 0) {
                    News.info("{}号条码器,检索数据:{},更新站点条码失败", slave.getId(), this.barcode);
                }
            }
            News.info("{}号条码器,更新成功", slave.getId());
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("time", DateUtils.convert(new Date(), DateUtils.yyyyMMddHHmmss_F));
            jsonObject.put("barcode", barcode);
@@ -70,90 +44,21 @@
                OutputQueue.BARCODE.poll();
            }
            OutputQueue.BARCODE.offer(jsonObject);
        }
    }
    @Override
    public boolean connect() {
        try {
            close();  //1.主动释放连接 //2.某些服务器对指定ip有链路数限制
            socket = new Socket();
            SocketAddress socketAddress = new InetSocketAddress(slave.getIp(), slave.getPort());
            socket.connect(socketAddress, 10000); //某些服务器ping延迟高时要增加,否则会报错connect timeout
            dataOutputStream = new DataOutputStream(socket.getOutputStream());
            dataInputStream = new DataInputStream(socket.getInputStream());
//            log.info("条码扫描仪连接成功 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
        } catch (Exception e) {
            socket = null;
            log.error("条码扫描仪连接失败!!! ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            return false;
        }
        return true;
    }
    @Override
    public void close() {
        try {
            if (null != dataOutputStream) {
                dataOutputStream.close();
            }
            if (null != dataInputStream) {
                dataInputStream.close();
            }
            if (null != socket){
                socket.close();
            }
            socket = null;
        } catch (IOException e) {
            log.error("SocketClient close Exception:" + e.getMessage());
        }
    }
    @Override
    @SuppressWarnings("InfiniteLoopStatement")
    public void run() {
        connect();
        while (true) {
            try {
                byte[] read = read(14, 3 * 60 * 1000);
                if (null != read) {
                    String s = new String(read);
                    log.warn("ip:{},id:{},读取到条码:{}",slave.getIp(),slave.getId(),s);
                    if (!Cools.isEmpty(s)) {
                        setBarcode(new String(read));
                    }
                }
                Thread.sleep(50);
            }catch (Exception e) {
                log.warn("ip:{},id:{},读取条码异常:{}",slave.getIp(),slave.getId(),e);
                setBarcode("");
                log.error("run" + e);
//                e.printStackTrace();
                connect();
            }
        }
    }
    public byte[] read(int bufferSize, int timeOut) throws IOException {
        if (socket == null || !socket.isConnected() || socket.isClosed() || connCount > 120) {
            connect();
            connCount = 0;
            return null;
        }
        socket.setSoTimeout(timeOut);
        byte[] bytes = new byte[bufferSize];
        int len = dataInputStream.read(bytes);
        byte[] tempBytes = null;
        if (len > 0) {
            tempBytes = new byte[len];
            System.arraycopy(bytes, 0, tempBytes, 0, len);
        } else {
            connect();
        }
        return tempBytes;
    }
}
src/main/java/com/zy/core/thread/SiemensDevpThread2.java
File was deleted
src/main/java/com/zy/core/thread/SiemensDevpThread3.java
File was deleted
src/main/resources/application.yml
@@ -8,7 +8,7 @@
    name: @pom.build.finalName@
  datasource:
    driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    url: jdbc:sqlserver://10.10.10.40:1433;databasename=tzskasrs
    url: jdbc:sqlserver://192.168.4.125:1433;databasename=tzskasrs
    username: sa
#    password: Zoneyung@zy56$
    password: sa@123
@@ -29,7 +29,7 @@
logging:
  path: /stock/out/@pom.build.finalName@/logs
  path: ./stock/out/@pom.build.finalName@/logs
super:
  pwd: xltys1995
@@ -40,22 +40,8 @@
wms:
  url: 10.10.10.40:8080/tzskwms
robot:
  url: http://10.10.10.41:7002
erp:
  db:
    driver_class_name: com.microsoft.sqlserver.jdbc.SQLServerDriver
    ur: jdbc:sqlserver://10.10.10.209:1433;databasename=POY_ASRS
    username: poy-asrs
    password: Poy@2022
# 下位机配置
wcs-slave:
  # 双深
  doubleDeep: true
  # 双深库位排号
  doubleLocs: 32
  # 输送线
  devp[0]:
@@ -77,49 +63,7 @@
      backSta: 102
      barcode: ${wcs-slave.barcode[1].id}
      led: ${wcs-slave.led[2].id}
      liftNo: ${wcs-slave.lift[1].id}
    # 入库口3
    inSta[2]:
      staNo: 105
      backSta: 104
      barcode: ${wcs-slave.barcode[2].id}
      led: ${wcs-slave.led[3].id}
      liftNo: ${wcs-slave.lift[2].id}
    # 入库口4
    inSta[3]:
      staNo: 200
      backSta: 201
      barcode: ${wcs-slave.barcode[3].id}
      led: ${wcs-slave.led[4].id}
      liftNo: ${wcs-slave.lift[0].id}
    # 入库口5
    inSta[4]:
      staNo: 203
      backSta: 202
      barcode: ${wcs-slave.barcode[4].id}
      led: ${wcs-slave.led[5].id}
      liftNo: ${wcs-slave.lift[1].id}
    # 入库口6
    inSta[5]:
      staNo: 205
      backSta: 204
      barcode: ${wcs-slave.barcode[5].id}
      led: ${wcs-slave.led[6].id}
      liftNo: ${wcs-slave.lift[2].id}
    # 入库口7
    inSta[6]:
      staNo: 341
      backSta: 340
      barcode: ${wcs-slave.barcode[7].id}
      led: ${wcs-slave.led[0].id}
      liftNo: ${wcs-slave.lift[1].id}
    # 入库口8
    inSta[7]:
      staNo: 346
      backSta: 345
      barcode: ${wcs-slave.barcode[6].id}
      led: ${wcs-slave.led[11].id}
      liftNo: ${wcs-slave.lift[2].id}
    # 空板入库口1
    emptyInSta[0]:
      staNo: 100
@@ -133,42 +77,7 @@
      backSta: 102
      barcode: ${wcs-slave.barcode[1].id}
      led: ${wcs-slave.led[2].id}
      liftNo: ${wcs-slave.lift[1].id}
    # 空板入库口3
    emptyInSta[2]:
      staNo: 105
      backSta: 104
      barcode: ${wcs-slave.barcode[2].id}
      led: ${wcs-slave.led[3].id}
      liftNo: ${wcs-slave.lift[2].id}
    # 空板入库口4
    emptyInSta[3]:
      staNo: 200
      backSta: 201
      barcode: ${wcs-slave.barcode[3].id}
      led: ${wcs-slave.led[4].id}
      liftNo: ${wcs-slave.lift[0].id}
    # 空板入库口5
    emptyInSta[4]:
      staNo: 203
      backSta: 202
      barcode: ${wcs-slave.barcode[4].id}
      led: ${wcs-slave.led[5].id}
      liftNo: ${wcs-slave.lift[1].id}
    # 空板入库口6
    emptyInSta[5]:
      staNo: 205
      backSta: 204
      barcode: ${wcs-slave.barcode[5].id}
      led: ${wcs-slave.led[6].id}
      liftNo: ${wcs-slave.lift[2].id}
    # 空板入库口7
    emptyInSta[6]:
      staNo: 346
      backSta: 345
      barcode: ${wcs-slave.barcode[6].id}
      led: ${wcs-slave.led[11].id}
      liftNo: ${wcs-slave.lift[2].id}
    # 出库口1
    outSta[0]:
      staNo: 100
@@ -176,26 +85,6 @@
    # 出库口2
    outSta[1]:
      staNo: 103
      led: ${wcs-slave.led[0].id}
    # 出库口3
    outSta[2]:
      staNo: 105
      led: ${wcs-slave.led[0].id}
    # 出库口4
    outSta[3]:
      staNo: 200
      led: ${wcs-slave.led[0].id}
    # 出库口5
    outSta[4]:
      staNo: 203
      led: ${wcs-slave.led[0].id}
    # 出库口6
    outSta[5]:
      staNo: 205
      led: ${wcs-slave.led[0].id}
    # 出库口7
    outSta[6]:
      staNo: 346
      led: ${wcs-slave.led[0].id}
    # 拣料入库口
    pickInSta[0]:
@@ -209,137 +98,7 @@
      backSta: 103
      barcode: ${wcs-slave.barcode[1].id}
      led: ${wcs-slave.led[2].id}
      liftNo: ${wcs-slave.lift[1].id}
    pickInSta[2]:
      staNo: 105
      backSta: 105
      barcode: ${wcs-slave.barcode[2].id}
      led: ${wcs-slave.led[3].id}
      liftNo: ${wcs-slave.lift[2].id}
    pickInSta[3]:
      staNo: 200
      backSta: 200
      barcode: ${wcs-slave.barcode[3].id}
      led: ${wcs-slave.led[4].id}
      liftNo: ${wcs-slave.lift[0].id}
    pickInSta[4]:
      staNo: 203
      backSta: 203
      barcode: ${wcs-slave.barcode[4].id}
      led: ${wcs-slave.led[5].id}
      liftNo: ${wcs-slave.lift[1].id}
    pickInSta[5]:
      staNo: 205
      backSta: 205
      barcode: ${wcs-slave.barcode[5].id}
      led: ${wcs-slave.led[6].id}
      liftNo: ${wcs-slave.lift[2].id}
    pickInSta[6]:
      staNo: 346
      backSta: 346
      barcode: ${wcs-slave.barcode[6].id}
      led: ${wcs-slave.led[11].id}
      liftNo: ${wcs-slave.lift[2].id}
    pickInSta[7]:
      staNo: 341
      backSta: 341
      barcode: ${wcs-slave.barcode[7].id}
      led: ${wcs-slave.led[7].id}
      liftNo: ${wcs-slave.lift[1].id}
    pickInSta2[0]:
      staNo: 325
      backSta: 341
      barcode: ${wcs-slave.barcode[7].id}
      led: ${wcs-slave.led[8].id}
      liftNo: ${wcs-slave.lift[1].id}
    pickInSta2[1]:
      staNo: 331
      backSta: 341
      barcode: ${wcs-slave.barcode[7].id}
      led: ${wcs-slave.led[8].id}
      liftNo: ${wcs-slave.lift[1].id}
    pickInSta2[2]:
      staNo: 333
      backSta: 341
      barcode: ${wcs-slave.barcode[7].id}
      led: ${wcs-slave.led[9].id}
      liftNo: ${wcs-slave.lift[1].id}
    pickInSta2[3]:
      staNo: 339
      backSta: 341
      barcode: ${wcs-slave.barcode[7].id}
      led: ${wcs-slave.led[10].id}
      liftNo: ${wcs-slave.lift[1].id}
#    # 货架入库站点
#    rackInStn[0]:
#      devpPlcId: ${wcs-slave.devp[0].id}
#      staNo: 105
#      row: 4
#      bay: 6
#      lev: 1
#    # 货架入库站点
#    rackInStn[1]:
#      devpPlcId: ${wcs-slave.devp[0].id}
#      staNo: 106
#      row: 4
#      bay: 6
#      lev: 3
#    # 货架入库站点
#    rackInStn[2]:
#      devpPlcId: ${wcs-slave.devp[0].id}
#      staNo: 107
#      row: 4
#      bay: 6
#      lev: 6
#    # 货架入库站点
#    rackInStn[3]:
#      devpPlcId: ${wcs-slave.devp[0].id}
#      staNo: 108
#      row: 4
#      bay: 6
#      lev: 6
#    # 货架出库站点
#    rackOutStn[0]:
#      devpPlcId: ${wcs-slave.devp[0].id}
#      staNo: 100
#      row: 15
#      bay: 2
#      lev: 1
#    # 货架出库站点
#    rackOutStn[1]:
#      devpPlcId: ${wcs-slave.devp[0].id}
#      staNo: 104
#      row: 4
#      bay: 6
#      lev: 1
#    # 货架出库站点
#    rackOutStn[2]:
#      devpPlcId: ${wcs-slave.devp[0].id}
#      staNo: 105
#      row: 4
#      bay: 6
#      lev: 3
#    # 货架出库站点
#    rackOutStn[3]:
#      devpPlcId: ${wcs-slave.devp[0].id}
#      staNo: 108
#      row: 4
#      bay: 6
#      lev: 6
  # 输送线2
  devp2[0]:
    id: 1
    ip: 10.10.10.58
    port: 102
    rack: 0
    slot: 0
  # 输送线2
  devp3[0]:
    id: 1
    ip: 10.10.10.239
    port: 102
    rack: 0
    slot: 0
  # 条码扫描仪
  barcode[0]:
@@ -351,96 +110,6 @@
    id: 2
    ip: 10.10.10.102
    port: 51236
  # 条码扫描仪
  barcode[2]:
    id: 3
    ip: 10.10.10.102
    port: 51236
  # 条码扫描仪
  barcode[3]:
    id: 4
    ip: 10.10.10.102
    port: 51236
  # 条码扫描仪
  barcode[4]:
    id: 5
    ip: 10.10.10.102
    port: 51236
  # 条码扫描仪
  barcode[5]:
    id: 6
    ip: 10.10.10.102
    port: 51236
  # 条码扫描仪
  barcode[6]:
    id: 7
    ip: 10.10.10.102
    port: 51236
  # 条码扫描仪
  barcode[7]:
    id: 8
    ip: 10.10.10.102
    port: 51236
  # 条码扫描仪
  barcode[8]:
    id: 9
    ip: 10.10.10.102
    port: 51236
  # 条码扫描仪
  barcode[9]:
    id: 10
    ip: 10.10.10.102
    port: 2002
  # 条码扫描仪
  barcode[10]:
    id: 11
    ip: 10.10.10.225
    port: 2002
  # 条码扫描仪310
  barcode[11]:
    id: 12
    ip: 10.10.10.224
    port: 2002
  # 条码扫描仪
  barcode[12]:
    id: 13
    ip: 10.10.10.233
    port: 2002
  # 条码扫描仪
  barcode[13]:
    id: 14
    ip: 10.10.10.232
    port: 2002
  # 条码扫描仪
  barcode[14]:
    id: 15
    ip: 10.10.10.231
    port: 2002
  # 条码扫描仪
  barcode[15]:
    id: 16
    ip: 10.10.10.230
    port: 2002
  # 条码扫描仪
  barcode[16]:
    id: 17
    ip: 10.10.10.229
    port: 2002
  # 条码扫描仪
  barcode[17]:
    id: 18
    ip: 10.10.10.228
    port: 2002
  # 条码扫描仪
  barcode[18]:
    id: 19
    ip: 10.10.10.235
    port: 2002
  # 条码扫描仪
  barcode[19]:
    id: 20
    ip: 10.10.10.234
    port: 2002
   # LED1
  led[0]:
@@ -541,62 +210,6 @@
    port: 8888
    rack: 0
    slot: 0
  # 四向穿梭车3
  shuttle[2]:
    id: 3
    ip: 10.10.10.103
    port: 8888
    rack: 0
    slot: 0
  # 四向穿梭车4
  shuttle[3]:
    id: 4
    ip: 10.10.10.104
    port: 8888
    rack: 0
    slot: 0
  # 四向穿梭车5
  shuttle[4]:
    id: 5
    ip: 10.10.10.105
    port: 8888
    rack: 0
    slot: 0
  # 四向穿梭车6
  shuttle[5]:
    id: 6
    ip: 10.10.10.106
    port: 8888
    rack: 0
    slot: 0
  # 四向穿梭车7
  shuttle[6]:
    id: 7
    ip: 10.10.10.107
    port: 8888
    rack: 0
    slot: 0
  # 四向穿梭车8
  shuttle[7]:
    id: 8
    ip: 10.10.10.108
    port: 8888
    rack: 0
    slot: 0
  # 四向穿梭车9
  shuttle[8]:
    id: 9
    ip: 10.10.10.109
    port: 8888
    rack: 0
    slot: 0
  # 四向穿梭车10
  shuttle[9]:
    id: 10
    ip: 10.10.10.110
    port: 8888
    rack: 0
    slot: 0
  # 提升机1
  lift[0]:
    id: 1
@@ -643,98 +256,4 @@
    sta[9]:
      staNo: 110
      lev: 10
      liftNo: ${wcs-slave.lift[0].id}
  # 提升机2
  lift[1]:
    id: 2
    ip: 10.10.10.132
    port: 102
    staRow: 13
    staBay: 38
    sta[0]:
      staNo: 201
      lev: 1
      liftNo: ${wcs-slave.lift[1].id}
    sta[1]:
      staNo: 202
      lev: 2
      liftNo: ${wcs-slave.lift[1].id}
    sta[2]:
      staNo: 203
      lev: 3
      liftNo: ${wcs-slave.lift[1].id}
    sta[3]:
      staNo: 204
      lev: 4
      liftNo: ${wcs-slave.lift[1].id}
    sta[4]:
      staNo: 205
      lev: 5
      liftNo: ${wcs-slave.lift[1].id}
    sta[5]:
      staNo: 206
      lev: 6
      liftNo: ${wcs-slave.lift[1].id}
    sta[6]:
      staNo: 207
      lev: 7
      liftNo: ${wcs-slave.lift[1].id}
    sta[7]:
      staNo: 208
      lev: 8
      liftNo: ${wcs-slave.lift[1].id}
    sta[8]:
      staNo: 209
      lev: 9
      liftNo: ${wcs-slave.lift[1].id}
    sta[9]:
      staNo: 210
      lev: 10
      liftNo: ${wcs-slave.lift[1].id}
  # 提升机3
  lift[2]:
    id: 3
    ip: 10.10.10.133
    port: 102
    staRow: 13
    staBay: 57
    sta[0]:
      staNo: 301
      lev: 1
      liftNo: ${wcs-slave.lift[2].id}
    sta[1]:
      staNo: 302
      lev: 2
      liftNo: ${wcs-slave.lift[2].id}
    sta[2]:
      staNo: 303
      lev: 3
      liftNo: ${wcs-slave.lift[2].id}
    sta[3]:
      staNo: 304
      lev: 4
      liftNo: ${wcs-slave.lift[2].id}
    sta[4]:
      staNo: 305
      lev: 5
      liftNo: ${wcs-slave.lift[2].id}
    sta[5]:
      staNo: 306
      lev: 6
      liftNo: ${wcs-slave.lift[2].id}
    sta[6]:
      staNo: 307
      lev: 7
      liftNo: ${wcs-slave.lift[2].id}
    sta[7]:
      staNo: 308
      lev: 8
      liftNo: ${wcs-slave.lift[2].id}
    sta[8]:
      staNo: 309
      lev: 9
      liftNo: ${wcs-slave.lift[2].id}
    sta[9]:
      staNo: 310
      lev: 10
      liftNo: ${wcs-slave.lift[2].id}
      liftNo: ${wcs-slave.lift[0].id}