自动化立体仓库 - WCS系统
#
luxiaotao1123
2022-01-05 8066494f23f6820d326a4d8e56f579bc3eed6774
#
1个文件已修改
110 ■■■■■ 已修改文件
src/main/java/com/zy/core/thread/CrnThread.java 110 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/CrnThread.java
@@ -184,82 +184,48 @@
            return;
        }
        command.setCrnNo(slave.getId());
        /* 方法 1 */
        do {
            if (command.getDestinationPosZ() != null) {
                if (!melsecMcNet.Write("D2202", command.getDestinationPosZ()).IsSuccess) { break; }
            }
            if (command.getDestinationPosY() != null) {
                if (!melsecMcNet.Write("D2204", command.getDestinationPosY()).IsSuccess) { break; }
            }
            if (command.getDestinationPosX() != null) {
                if (!melsecMcNet.Write("D2208", command.getDestinationPosX()).IsSuccess) { break; }
            }
            if (command.getSourcePosZ() != null) {
                if (!melsecMcNet.Write("D2210", command.getSourcePosZ()).IsSuccess) { break; }
            }
            if (command.getSourcePosY() != null) {
                if (!melsecMcNet.Write("D2212", command.getSourcePosY()).IsSuccess) { break; }
            }
            if (command.getDestinationPosX() != null) {
                if (!melsecMcNet.Write("D2214", command.getSourcePosX()).IsSuccess) { break; }
            }
            if (command.getTaskMode() != null) {
                if (!melsecMcNet.Write("D2216", command.getTaskMode()).IsSuccess) { break; }
            }
            if (command.getTaskNo() != null) {
                if (!melsecMcNet.Write("D2217", command.getTaskNo()).IsSuccess) { break; }
            }
            if (command.getAckFinish() != null) {
                if (!melsecMcNet.Write("D2218", command.getAckFinish()).IsSuccess) { break; }
            }
        short[] array = new short[9];
        array[0] = command.getStatus();
        array[1] = command.getSourceRow(); // 排
        array[2] = command.getSourceBay(); // 列
        array[3] = command.getSourceLev(); // 层
        array[4] = command.getSourceSta(); // 站号
        array[5] = command.getDestinationPosRow(); // 排
        array[6] = command.getDestinationPosBay(); // 列
        array[7] = command.getDestinationPosLev(); // 层
        array[8] = command.getDestinationSta();  // 目标位置站号
            try {
                // 日志记录
                BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class);
                BasCrnOpt basCrnOpt = new BasCrnOpt(
                        command.getTaskNo().intValue(),    // 任务号
                        command.getCrnNo(),    // 堆垛机[非空]
                        new Date(),    // 下发时间
                        command.getTaskModeType().toString(),    // 模式
                        command.getSourcePosX().intValue(),    // 源排
                        command.getSourcePosY().intValue(),    // 源列
                        command.getSourcePosZ().intValue(),    // 源层
                        null,    // 源站
                        command.getDestinationPosX().intValue(),    // 目标排
                        command.getDestinationPosY().intValue(),    // 目标列
                        command.getDestinationPosZ().intValue(),    // 目标层
                        null,    // 目标站
                        null,    // 响应结果
                        null,    // 修改时间
                        null    // 修改人员
                );
                bean.insert(basCrnOpt);
            } catch (Exception ignore) {}
        try {
            // 日志记录
            BasCrnOptService bean = SpringUtils.getBean(BasCrnOptService.class);
            BasCrnOpt basCrnOpt = new BasCrnOpt(
                    command.getTaskNo().intValue(),    // 任务号
                    command.getCrnNo(),    // 堆垛机[非空]
                    new Date(),    // 下发时间
                    command.getTaskModeType().toString(),    // 模式
                    command.getSourcePosX().intValue(),    // 源排
                    command.getSourcePosY().intValue(),    // 源列
                    command.getSourcePosZ().intValue(),    // 源层
                    null,    // 源站
                    command.getDestinationPosX().intValue(),    // 目标排
                    command.getDestinationPosY().intValue(),    // 目标列
                    command.getDestinationPosZ().intValue(),    // 目标层
                    null,    // 目标站
                    null,    // 响应结果
                    null,    // 修改时间
                    null    // 修改人员
            );
            bean.insert(basCrnOpt);
        } catch (Exception ignore) {}
        OperateResult result = melsecMcNet.Write("100", array);
        if (result.IsSuccess) {
            log.info("堆垛机命令下发[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;
        } while (false);
        System.out.println(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
        OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
        log.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
        /* 方法 2 */
//        melsecMcNet.Write("D2218", command.getAckFinish());
//        melsecMcNet.Write("D2217", command.getTaskNo());
//        melsecMcNet.Write("D2216", command.getTaskMode());
//        melsecMcNet.Write("D2214", command.getSourcePosX());
//        melsecMcNet.Write("D2212", command.getSourcePosY());
//        melsecMcNet.Write("D2210", command.getSourcePosZ());
//        melsecMcNet.Write("D2208", command.getDestinationPosX());
//        melsecMcNet.Write("D2204", command.getDestinationPosY());
//        melsecMcNet.Write("D2202", command.getDestinationPosZ());
        } else {
            OutputQueue.CRN.offer(MessageFormat.format("【{0}】写入堆垛机plc数据失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
            log.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
        }
    }