#
luxiaotao1123
2022-03-14 a87d3006efd604c576a39bfaff2d21379143ada5
src/main/java/com/zy/core/thread/SteThread.java
@@ -219,23 +219,30 @@
            return false;
        }
        command.setSteNo(slave.getId());
        short[] array = new short[10];
//        array[0] = command.getAckFinish();
//        array[1] = command.getTaskNo();
//        array[2] = command.getTaskMode();
//        array[3] = command.getSourcePosX();
        OperateResult result = null;
        // 开始任务
        if (!command.getWaiting()) {
            OperateResult result0 = siemensS7Net.Write("D0", command.getTaskNo());
            short[] array = new short[10];
            array[0] = command.getTaskMode();
//            array[1] = command.getTaskNo();
//            array[2] = command.getTaskMode();
//            array[3] = command.getSourcePosX();
//        array[4] = command.getSourcePosY();
//        array[5] = command.getSourcePosZ();
//        array[6] = command.getDestinationPosX();
//        array[7] = command.getDestinationPosY();
//        array[8] = command.getDestinationPosZ();
//        array[9] = command.getCommand();
        OperateResult result = siemensS7Net.Write("D0", array);
//        if (command.getAckFinish() == 0) {
//            short commandFinish = 1;
//            result = siemensS7Net.Write("D9", commandFinish);
//        }
            OperateResult result1 = siemensS7Net.Write("D0", array);
            // 确认开始任务
            if (result0.IsSuccess) {
                result = siemensS7Net.Write("D0", true);
            }
        // 任务完成
        } else {
            result = siemensS7Net.Write("D0", true);
        }
        try {
            // 日志记录
@@ -260,9 +267,14 @@
//            bean.insert(basSteOpt);
        } catch (Exception ignore) {}
        if (result.IsSuccess) {
        if (result != null && result.IsSuccess) {
            // 维护数据库排列层
//            this.modifyPos();
            if (!steProtocol.getWaiting()) {
                this.lastRow = command.getRow().intValue();
                this.lastBay = command.getBay().intValue();
                this.lastLev = command.getLev().intValue();
            }
            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)));
@@ -287,10 +299,19 @@
                    BasSteService service = SpringUtils.getBean(BasSteService.class);
                    BasSte basSte = service.selectById(slave.getId());
                    if (basSte != null) {
                        if (service.updatePos(this.lastRow, this.lastBay, this.lastLev) > 0) {
                            return true;
                        } else {
                            log.error("{}号穿梭车修改数据库定位失败!!!", slave.getId());
                        // 更新plc数据块
                        short[] arr = new short[] {this.lastRow.shortValue(), this.lastBay.shortValue(), this.lastLev.shortValue()};
                        OperateResult result = siemensS7Net.Write("D0", arr);
                        if (result.IsSuccess) {
                            // 更新数据库
                            if (service.updatePos(this.lastRow, this.lastBay, this.lastLev) > 0) {
                                this.lastRow = null;
                                this.lastBay = null;
                                this.lastLev = null;
                                return true;
                            } else {
                                log.error("{}号穿梭车修改数据库定位失败!!!", slave.getId());
                            }
                        }
                    }