#
Junjie
2025-04-03 ac09ee9c9f39cb9d452b57504e5c79321e0371eb
#
10个文件已修改
199 ■■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCommandModeType.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/FyxcDevpThread.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java 36 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/AnalyzeService.java
@@ -119,11 +119,6 @@
                return motionList;
            }
            BasConveyorSta basConveyorStaDest = basConveyorStaService.selectBySiteNo(task.getDestSite());
            if (basConveyorStaDest == null) {
                return motionList;
            }
            //检测穿梭车是否有任务绑定
            boolean shuttleResult = Utils.checkShuttleHasBinding(shuttleDevice, task.getTaskNo());
            if (shuttleResult) {
@@ -158,7 +153,6 @@
                            dto.setLiftNo(transferLiftDevice.getId().intValue());
                            dto.setLev(Utils.getLev(task.getDestLoc()));
                            dto.setStaNo(Integer.parseInt(task.getDestSite()));
                            dto.setDevpNo(basConveyorStaDest.getConveyorDeviceId().intValue());
                            dto.setReleaseLift(1);//执行完成后释放提升机
                        }))
                ));
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/KernelService.java
@@ -95,11 +95,13 @@
            motion.setMotionCtg(MotionCtgType.LIFT_WITH_GOODS.val());
            if (null != origin) {
                motion.setOrigin(String.valueOf(liftDispatcher.getLiftLevOffset(target.getLiftNo(), origin.getLev())));
                motion.setOriDrt(origin.getStaNo());//源站
//                motion.setOrigin(String.valueOf(liftDispatcher.getLiftLevOffset(target.getLiftNo(), origin.getLev())));
//                motion.setOriDrt(origin.getStaNo());//源站
                motion.setOrigin(String.valueOf(origin.getStaNo()));
            }
            motion.setTarget(String.valueOf(liftDispatcher.getLiftLevOffset(target.getLiftNo(), target.getLev())));
            motion.setTarDrt(target.getStaNo());//目标站
//            motion.setTarget(String.valueOf(liftDispatcher.getLiftLevOffset(target.getLiftNo(), target.getLev())));
//            motion.setTarDrt(target.getStaNo());//目标站
            motion.setTarget(String.valueOf(target.getStaNo()));
            if (target.getDevpNo() != null) {
                motion.setDockNo(String.valueOf(target.getDevpNo()));//输送线ID
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/kernel/command/LiftCommandService.java
@@ -113,12 +113,6 @@
//                    return false;
//                }
                //判断目标站是否有托盘
                Integer conveyorDeviceId = Integer.parseInt(motion.getDockNo());
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, conveyorDeviceId);
                if (devpThread == null) {
                    return false;
                }
//                //*************标准系统代码********************
//                StaProtocol staProtocol = devpThread.getStation().get(motion.getTarDrt());
//                if (staProtocol == null) {
@@ -135,29 +129,7 @@
//                }
//                //*************************************************
                //*************此代码为光泰定制代码********************
                Integer tarDrt = motion.getTarDrt();
                if (tarDrt == 31001) {
                    tarDrt = 31004;
                }
                StaProtocol staProtocol = devpThread.getStation().get(tarDrt);
                if (staProtocol == null) {
                    return false;
                }
                if (!staProtocol.isAutoing()) {
                    return false;
                }
                if (staProtocol.isLoading()) {
                    return false;
                }
                if (staProtocol.getWorkNo().intValue() != 0) {
                    return false;
                }
                //*************************************************
                command = liftThread.getPalletInOutCommand(assignCommand.getDeviceTaskNo(), Integer.parseInt(motion.getOrigin()), Integer.parseInt(motion.getTarget()), motion.getOriDrt(), motion.getTarDrt(), LiftCommandModeType.PALLET_INOUT);
                command = liftThread.getPalletInOutCommand(assignCommand.getDeviceTaskNo(), Integer.parseInt(motion.getOrigin()), Integer.parseInt(motion.getTarget()), motion.getOriDrt(), motion.getTarDrt(), task.getTaskSts() < 100 ? LiftCommandModeType.PALLET_IN : LiftCommandModeType.PALLET_OUT);
                list.addAll(command);
                motion.setTemp(String.valueOf(assignCommand.getDeviceTaskNo()));
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/LiftCommandModeType.java
@@ -4,11 +4,13 @@
    NONE(-1, "未知类型"),
    MOVE(1, "提升机升降"),
    PALLET_INOUT(2, "托盘出入"),
//    PALLET_INOUT(2, "托盘出入"),
    LOCK(3, "锁定提升机"),
    UNLOCK(4, "解锁提升机"),
    RESET(5, "复位"),
    MOVE_CAR(6, "提升机升降小车"),
    PALLET_IN(7, "托盘入"),
    PALLET_OUT(8, "托盘出"),
    ;
    public Integer id;
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
@@ -170,18 +170,23 @@
                            continue;
                        }
                        // 获取条码扫描仪信息
                        DeviceBarcode deviceBarcode = deviceBarcodeService.getById(basConveyorSta.getBarcodeId());
                        if(deviceBarcode == null) {
                            continue;
                        }
                        BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, Integer.parseInt(deviceBarcode.getDeviceId()));
                        if (barcodeThread == null) {
                            continue;
                        }
                        String barcode = barcodeThread.getBarcode();
//                        // 获取条码扫描仪信息
//                        DeviceBarcode deviceBarcode = deviceBarcodeService.getById(basConveyorSta.getBarcodeId());
//                        if(deviceBarcode == null) {
//                            continue;
//                        }
//                        BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, Integer.parseInt(deviceBarcode.getDeviceId()));
//                        if (barcodeThread == null) {
//                            continue;
//                        }
//                        String barcode = barcodeThread.getBarcode();
//                        if (!Cools.isEmpty(barcode)) {
//                            News.info("{}号条码扫描器检测条码信息:{}", deviceBarcode.getId(), barcode);
//                        }
                        String barcode = staProtocol.getBarcode();
                        if (!Cools.isEmpty(barcode)) {
                            News.info("{}号条码扫描器检测条码信息:{}", deviceBarcode.getId(), barcode);
                            News.info("条码扫描器检测条码信息:{}", barcode);
                        }
                        // 判断重复工作档
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/LiftDispatcher.java
@@ -78,6 +78,13 @@
            }
            String liftLocNo = Utils.getLocNo(Utils.getRow(standby.getDeviceStandbyLoc()), Utils.getBay(standby.getDeviceStandbyLoc()), Utils.getLev(locNo));
            if (locNo.equals(liftLocNo)) {
                finalDistance = 100;
                recentLiftThread = liftThread;
                continue;
            }
            List<NavigateNode> nodeList = navigateUtils.calc(locNo, liftLocNo, NavigationMapType.NONE.id, null);
            if (nodeList == null) {
                continue;
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
@@ -84,6 +84,10 @@
                continue;
            }
            if (shuttleProtocol.getCurrentLocNo() == null) {
                continue;
            }
            int shuttleLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());
            if (shuttleLev == lev) {
                currentLevDevices.add(device);
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/FyxcDevpThread.java
@@ -158,9 +158,8 @@
//                staProtocol.setWorkMode((int) siemensS7Net.getByteTransform().TransInt16(result.Content, i * 40 + 8));// 工作模式
                staProtocol.setWorkNo((short) siemensS7Net.getByteTransform().TransInt32(result.Content, i * 18 + 10));     // 工作号
                staProtocol.setStaNo((short) siemensS7Net.getByteTransform().TransInt32(result.Content, i * 18 + 14));   // 目标站
                staProtocol.setWorkNo((short) siemensS7Net.getByteTransform().TransInt16(result.Content, i * 18 + 10));     // 工作号
                staProtocol.setStaNo((short) siemensS7Net.getByteTransform().TransInt16(result.Content, i * 18 + 12));   // 目标站
                if (!staProtocol.isPakMk() && !staProtocol.isLoading()) {
                    staProtocol.setPakMk(true);
@@ -245,6 +244,7 @@
    @Override
    public boolean writeWorkNo(int siteId, short workNo) {
        int index = staNos1.indexOf(siteId);
        index += 1;
        OperateResult write = siemensS7Net.Write("DB83." + (index *8+6),(int) workNo);    // 工作号
@@ -266,6 +266,7 @@
    @Override
    public boolean writeStaNo(int siteId,short staNo) {
        int index = staNos1.indexOf(siteId);
        index += 1;
        OperateResult write = siemensS7Net.Write("DB101." + (index * 8 + 4),(int) staNo);    // 目标站
@@ -287,27 +288,27 @@
    @Override
    public boolean writeWorkSta(int siteId, short workNo, short staNo) {
        int index = staNos1.indexOf(siteId);
        index += 1;
        short[] array = new short[2];
        array[0] = workNo;
        array[1] = staNo;
        String workNoAddress = "DB101." + (index * 8 + 6);
        String staNoAddress = "DB101." + (index * 8 + 4);
        String workNoAddress = "DB83." + (index * 8 + 6);
        String staNoAddress = "DB83." + (index * 8 + 4);
        OperateResult write1 = null;    // 工作号
        OperateResult write2 = null;     // 目标站
        //任务下发次数
        int writeCount = 0;
        do {
            write1 = siemensS7Net.Write(workNoAddress, (int) workNo);    // 工作号
            write2 = siemensS7Net.Write(staNoAddress, (int) staNo);
            write1 = siemensS7Net.Write(workNoAddress,  workNo);    // 工作号
            write2 = siemensS7Net.Write(staNoAddress, staNo);
            if ((write1.IsSuccess && write2.IsSuccess)) {
                OperateResultExOne<byte[]> readResult = siemensS7Net.Read(staNoAddress, (short) 8);
                if (readResult.IsSuccess) {
                    int staNo2 = siemensS7Net.getByteTransform().TransInt32(readResult.Content, 0);
                    int workNo2 = siemensS7Net.getByteTransform().TransInt32(readResult.Content, 4);
                    int staNo2 = siemensS7Net.getByteTransform().TransInt16(readResult.Content, 0);
                    int workNo2 = siemensS7Net.getByteTransform().TransInt16(readResult.Content, 4);
                    if (workNo == workNo2 && staNo == staNo2) {
                        //任务命令写入成功
                        log.info("写入输送线命令后返回成功,并且回读成功。输送线plc编号={},{},{},写入次数={}", siteId, JSON.toJSON(workNo), JSON.toJSON(staNo), writeCount);
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyLiftThread.java
@@ -286,20 +286,16 @@
        }
        LiftDispatcher liftDispatcher = SpringUtils.getBean(LiftDispatcher.class);
        Integer lev = liftDispatcher.getLiftLevOffset(this.device.getId().intValue(), liftProtocol.getLev());
        if (null == lev){
            News.error("提升机获取当前层为空");
            response.setMessage("提升机获取当前层为空");
            return response;
        Integer origin = command.getOriginLev();
        Integer target = command.getTargetLev();
        if (command.getMode() == 2) {
            origin = liftDispatcher.getLiftLevOffset(this.device.getId().intValue(), liftProtocol.getLev());
            target = liftDispatcher.getLiftLevOffset(this.device.getId().intValue(), command.getTargetLev());
        }
        array[1] = lev.shortValue();
        Integer targetLev = liftDispatcher.getLiftLevOffset(this.device.getId().intValue(), command.getTargetLev());
        if (null == targetLev){
            News.error("提升机获取目标层为空");
            response.setMessage("提升机获取目标层为空");
            return response;
        }
        array[2] = targetLev.shortValue();
        array[1] = origin.shortValue();
        array[2] = target.shortValue();
        OperateResult result = siemensS7Net.Write("DB83.0", array);
        if (result != null && result.IsSuccess) {
@@ -413,12 +409,16 @@
    public List<LiftCommand> getMoveCommand(Integer taskNo, Integer sourceLev, Integer targetLev, LiftCommandModeType mode) {
        /**
         * 任务类型
         * 1=移托盘;升降机将源站台托盘移到目标站台
         * 2=移小车,升降机移到目标层,等待
         1=移托盘;升降机将源站台托盘移到目标站台
         2=换层,升降机移到目标层,等待
         3=入库托盘,升降机将源站台托盘移到目标层数;
         4=出库托盘,升降机将源站台托盘移到目标站台
         */
        short taskMode = 2;
        if (mode.equals(LiftCommandModeType.PALLET_INOUT)) {
            taskMode = 1;
        if (mode.equals(LiftCommandModeType.PALLET_IN)) {
            taskMode = 3;
        } else if (mode.equals(LiftCommandModeType.PALLET_OUT)) {
            taskMode = 4;
        }
        // 开始任务
@@ -435,7 +435,7 @@
        LiftCommand command = new LiftCommand();
        command.setLiftNo(Integer.valueOf(this.device.getDeviceNo()));
        command.setBody(JSON.toJSONString(array));
        command.setMode(LiftCommandModeType.MOVE.id);
        command.setMode(mode.id);
        command.setOriginLev(sourceLev);
        command.setTargetLev(targetLev);
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/rcs/thread/impl/NyShuttleThread.java
@@ -62,6 +62,7 @@
    private static final boolean DEBUG = false;//调试模式
    private List<JSONObject> socketReadResults = new ArrayList<>();
    private List<JSONObject> socketResults = new ArrayList<>();
    //原始设备数据
@@ -82,6 +83,7 @@
            while (true) {
                try {
                    listenSocketMessage();
                    listenInit();//监听初始化事件
                } catch (Exception e) {
                    e.printStackTrace();
                }
@@ -137,7 +139,6 @@
        Thread otherThread = new Thread(() -> {
            while (true) {
                try {
                    listenInit();//监听初始化事件
                    saveLog();//保存数据
                } catch (Exception e) {
                    e.printStackTrace();
@@ -223,7 +224,19 @@
            }
            JSONObject result = JSON.parseObject(sb.toString());//得到响应结果集
            if (!socketResults.isEmpty() && socketResults.size() >= 5) {
            String msgType = result.getString("msgType");
            if ("responseMsg".equals(msgType)) {
                JSONObject response = result.getJSONObject("response");
                JSONObject body = response.getJSONObject("body");
                if (body.containsKey("workingMode")) {
                    //read
                    socketReadResults.add(body);
                    return;
                }
            }
            if (!socketResults.isEmpty() && socketResults.size() >= 20) {
                socketResults.remove(0);//清理头节点
            }
            socketResults.add(result);//添加数据
@@ -307,7 +320,18 @@
            //----------读取四向穿梭车状态-----------
            NyShuttleHttpCommand readStatusCommand = getReadStatusCommand(Integer.parseInt(device.getDeviceNo()));
            JSONObject data = requestCommand(readStatusCommand);
            requestCommandAsync(readStatusCommand);//请求状态
            if (this.socketReadResults.isEmpty()) {
                if (System.currentTimeMillis() - shuttleProtocol.getLastOnlineTime() > 1000 * 60) {
                    //最后一次上线时间超过60s,认定离线
                    this.shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.OFFLINE);
                }
                return;
            }
            JSONObject data = this.socketReadResults.get(0);
            this.socketReadResults.remove(0);
            if (data == null) {
                if (System.currentTimeMillis() - shuttleProtocol.getLastOnlineTime() > 1000 * 60) {
                    //最后一次上线时间超过60s,认定离线
@@ -356,13 +380,17 @@
                ///读取四向穿梭车状态-end
                //小车处于运行中,将标记置为true
                if (shuttleProtocol.getDeviceStatus() == 1) {
                if (shuttleProtocol.getDeviceStatus() == 0) {
                    shuttleProtocol.setPakMk(true);
                }
                if (shuttleProtocol.getProtocolStatusType() == null && shuttleProtocol.getDeviceStatus().intValue() == 0) {
                if (shuttleProtocol.getProtocolStatusType() == null && shuttleProtocol.getDeviceStatus().intValue() == 1) {
                    //小车空闲状态、小车任务状态为未知,认定曾离线过,需要复位成空闲
                    shuttleProtocol.setProtocolStatusType(ShuttleProtocolStatusType.IDLE);
                }
                if (shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.OFFLINE) && shuttleProtocol.getDeviceStatus().intValue() == 1) {
                    this.shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE);
                }
                this.originDeviceData = data;
@@ -1109,6 +1137,22 @@
        return result;//返回Body结果集
    }
    private void requestCommandAsync(NyShuttleHttpCommand httpCommand) throws IOException {
        if (this.socket == null) {
            return;
        }
        //压缩数据包
        JSONObject data = JSON.parseObject(JSON.toJSONString(httpCommand));
        data.remove("nodes");
        // 获取输出流
        OutputStreamWriter writer = new OutputStreamWriter(this.socket.getOutputStream());
        writer.write(JSON.toJSONString(data) + "\r\n");
        writer.flush();
//            System.out.println("Sent message to server: " + JSON.toJSONString(httpCommand));
    }
    private JSONObject filterBodyData(JSONObject data) {
        Object response = data.get("response");
        if (response == null) {