#
whycq
2024-01-10 5687b706d02e1d3bbaa6863d51b5803944b3af05
#
6个文件已修改
543 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 230 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/protocol/CrnProtocol.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensCrnThread.java 178 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/js/console.map.js 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -19,6 +19,7 @@
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;
@@ -152,6 +153,8 @@
                // 退回
                if (back) {
//                        News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg);
                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
                    if (!staProtocol.isLoading()){
                        continue;
                    }
@@ -170,12 +173,11 @@
                        && staProtocol.isLoading()
                        && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk()
                        && (staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9997 || staProtocol.getWorkNo() == 9995)
                        && staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) {
//                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode)) {
//                        News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
//                        //条码为空或者不符合,退库到172站点
                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
                        News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
                        //条码为空或者不符合,退库到172站点
//                        staProtocol.setWorkNo((short)9999);
//                        staProtocol.setStaNo((short)172);
//                        devpThread.setPakMk(staProtocol.getSiteId(), false);
@@ -183,8 +185,8 @@
//                        if (!result) {
//                            throw new CoolException("更新plc站点信息失败");
//                        }
//                        continue;
//                    }
                        continue;
                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
@@ -199,7 +201,7 @@
                    WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
                            .eq("barcode", barcode)
                            .eq("io_type", 103));
                            .in("io_type", 107,103));
                    if (!Cools.isEmpty(checkPick)) {
                        continue;
                    }
@@ -236,8 +238,9 @@
                        } else {
                            staProtocol.setWorkNo((short) 9998);
                            staProtocol.setStaNo((short) 14);
                            staProtocol.setWorkNo(wrkNo);
                            wrkNo++;
                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -409,11 +412,21 @@
                }
                String barcode = barcodeThread.getBarcode();
                if (!Cools.isEmpty(barcode) && (staProtocol.getWorkNo() != 9998 || staProtocol.getWorkNo() != 9996)) {
                if (!Cools.isEmpty(barcode)) {
//                    log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
                        staProtocol.setWorkNo((short) 9998);
                        staProtocol.setStaNo((short) 14);
                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
                        if (!staProtocol.isLoading()) {
                            continue;
                        }
                        if (!staProtocol.isPakMk()) {
                            continue;
                        }
                        if(staProtocol.getWorkNo() != 0) {
                            continue;
                        }
                        staProtocol.setWorkNo(wrkNo);
                        wrkNo++;
                        staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        // led 异常显示
@@ -436,7 +449,7 @@
                        && staProtocol.isLoading()
                        && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk()
                        && (staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9997 || staProtocol.getWorkNo() == 9995)
//                        && (staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9997 || staProtocol.getWorkNo() == 9995)
                        && staProtocol.isPakMk()) {
                    WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
@@ -462,8 +475,7 @@
                    // 获取目标站
                    Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                            .eq("type_no", wrkMast.getIoType() - 50)
                            //速腾特有捡料, 11站是出库站, 然后手动走到15站进行再入库
                            .eq("stn_no", 15) // 作业站点 = 拣料出库的目标站
                            .eq("stn_no", pickSta.getStaNo()) // 作业站点 = 拣料出库的目标站
                            .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号
                    StaDesc staDesc = staDescService.selectOne(wrapper);
                    if (Cools.isEmpty(staDesc)) {
@@ -1746,145 +1758,103 @@
     * 出库  ===>> 工作档信息写入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());
//            // 命令集合
//            List<LedCommand> commands = new ArrayList<>();
//            // 工作档集合
//            List<WrkMast> wrkMasts = new ArrayList<>();
            // 命令集合
            List<LedCommand> commands = new ArrayList<>();
            // 工作档集合
            List<WrkMast> wrkMasts = new ArrayList<>();
            for (Integer staNo : led.getStaArr()) {
                // 获取叉车站点
                StaProtocol staProtocol = devpThread.getStation().get(staNo);
                if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) {
                    MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, ""));
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                // 获取工作档数据
                WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
                if (null == wrkMast) {
                    MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, ""));
                    continue;
                }
                ArrayList<MatDto> matDtos = new ArrayList<>();
                Wrapper<WrkDetl> detlWrapper = new EntityWrapper<WrkDetl>()
                        .eq("wrk_no", wrkMast.getWrkNo());
                if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; }
                wrkMasts.add(wrkMast);
                // 组装命令
                LedCommand ledCommand = new LedCommand();
                ledCommand.setWorkNo(wrkMast.getWrkNo());
                ledCommand.setStaNo(wrkMast.getStaNo());
                ledCommand.setSourceStaNo(wrkMast.getSourceStaNo());
                ledCommand.setLocNo(wrkMast.getLocNo());
                ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
                ledCommand.setIoType(wrkMast.getIoType());
                ledCommand.setTitle(wrkMast.getIoType$());
                // 出库模式
                switch (wrkMast.getIoType()) {
                    case 10:
                    case 101:
                        ledCommand.setTitle("全板出库");
                        break;
                    case 103:
                        ledCommand.setTitle("拣料出库");
                        break;
                    case 104:
                        ledCommand.setTitle("并板出库");
                        break;
                    case 107:
                        ledCommand.setTitle("盘点出库");
                        break;
                    case 110:
                        ledCommand.setTitle("空板出库");
                        ledCommand.setEmptyMk(true);
                        break;
                    default:
                        ledCommand.setBarcode(wrkMast.getBarcode());
                        List<WrkDetl> wrkDetls = wrkDetlService.selectList(detlWrapper);
                        for (WrkDetl wrkDetl : wrkDetls) {
                            MatDto matDto = new MatDto();
                            matDto.setMaknx(wrkDetl.getMaktx());
                            matDto.setMatNo(wrkDetl.getMatnr());
                            matDto.setCount(wrkDetl.getAnfme());
                            matDtos.add(matDto);
                        }
                        News.error("任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
                        break;
                }
                ledCommand.setMatDtos(matDtos);
                MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, ledCommand.toString()));
//                wrkMasts.add(wrkMast);
//                // 组装命令
//                LedCommand ledCommand = new LedCommand();
//                ledCommand.setWorkNo(wrkMast.getWrkNo());
//                ledCommand.setIoType(wrkMast.getIoType());
//                // 出库模式
//                switch (wrkMast.getIoType()) {
//                    case -1:
//                        ledCommand.setTitle("全板入库");
//                        break;
//                    case 10:
//                        ledCommand.setTitle("空板入库");
//                        break;
//                    case 10-1:
//                        ledCommand.setTitle("全板出库");
//                        break;
//                    case 103:
//                        ledCommand.setTitle("拣料出库");
//                        break;
//                    case 104:
//                        ledCommand.setTitle("并板出库");
//                        break;
//                    case 107:
//                        ledCommand.setTitle("盘点出库");
//                        break;
//                    case 110:
//                        ledCommand.setTitle("空板出库");
//                        ledCommand.setEmptyMk(true);
//                        break;
//                    default:
//                        News.error(methodName + ":任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
//                        break;
//                }
//                ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
//                ledCommand.setLocNo(wrkMast.getLocNo());
//                ledCommand.setStaNo(wrkMast.getStaNo());
////                ledCommand.setSourceStaNo(wrkMast.getSourceStaNo());
//                if (wrkMast.getIoType() != 110 && wrkMast.getIoType() != 10) {
//                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
//                    wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme())));
//                }
//                commands.add(ledCommand);
//            }
//            Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());
//            // 获取LED线程
//            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
//            // 相同工作号集合则过滤
////            if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
////                continue;
////            }
//            // 命令下发 -------------------------------------------------------------------------------
//            if (!commands.isEmpty()) {
//                String errMsg = "";
//                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(3, commands))) {
//                    News.error(methodName + ":{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
//                    continue;
//                } else {
//                    ledThread.setLedMk(false);
//                }
//
//
                ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
                ledCommand.setStaNo(wrkMast.getStaNo());
                ledCommand.setBarcode(wrkMast.getBarcode());
                if (wrkMast.getIoType() != 110) {
                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
                    wrkDetls.forEach(wrkDetl -> {
                        if (wrkMast.getIoType() == 101) {
                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme()));
                        }
                        if (wrkMast.getIoType() == 103 && (null == wrkDetl.getInspect() || 0 == wrkDetl.getInspect())) {
                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(),  wrkDetl.getAnfme()));
                        }
                        if (wrkMast.getIoType() == 107) {
                            ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMaktx(), wrkDetl.getAnfme()));
                        }
                    });
                }
                commands.add(ledCommand);
            }
//
//            try {
//                // 修改主档led标记
//                for (WrkMast wrkMast : wrkMasts) {
//                    wrkMast.setOveMk("Y");
//                    wrkMast.setModiTime(new Date());
//                    if (wrkMastMapper.updateById(wrkMast) == 0) {
//                        throw new CoolException("更新工作档失败");
//                    }
//                }
//
//                // 更新线程当前工作号集合
//                ledThread.setWorkNos(workNos);
//
//            } catch (Exception e) {
//                e.printStackTrace();
//                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//            }
            Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());
            // 获取LED线程
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
            // 相同工作号集合则过滤
            if (CollectionUtils.equals(ledThread.getWorkNos(), workNos)) {
                continue;
            }
            // 命令下发 -------------------------------------------------------------------------------
            if (!commands.isEmpty()) {
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
                    News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    continue;
                }
            }
            try {
                // 修改主档led标记
                for (WrkMast wrkMast : wrkMasts) {
                    wrkMast.setOveMk("Y");
                    wrkMast.setModiTime(new Date());
                    if (wrkMastMapper.updateById(wrkMast) == 0) {
                        throw new CoolException("更新工作档失败");
                    }
                }
                // 更新线程当前工作号集合
                ledThread.setWorkNos(workNos);
            } catch (Exception e) {
                e.printStackTrace();
                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
            }
        }
    }
src/main/java/com/zy/core/model/protocol/CrnProtocol.java
@@ -187,6 +187,11 @@
     */
    public Float yDuration;
    /**
     * 堆垛机所在巷道
     */
    private Integer crnLane = 1;
    public void setMode(Short mode) {
        this.mode = mode;
        this.modeType = CrnModeType.get(mode);
@@ -251,32 +256,32 @@
        return basCrnp;
    }
    public void setxSpeed(Short xSpeed) {
        this.xSpeed = Float.valueOf(xSpeed);
    public void setxSpeed(float xSpeed) {
        this.xSpeed = xSpeed;
    }
    public void setySpeed(Short ySpeed) {
        this.ySpeed = Float.valueOf(ySpeed);
    public void setySpeed(float ySpeed) {
        this.ySpeed = ySpeed;
    }
    public void setzSpeed(Short zSpeed) {
        this.zSpeed = Float.valueOf(zSpeed);
    public void setzSpeed(float zSpeed) {
        this.zSpeed = zSpeed;
    }
    public void setxDistance(Short xDistance) {
        this.xDistance = Float.valueOf(xDistance);
    public void setxDistance(float xDistance) {
        this.xDistance = xDistance;
    }
    public void setyDistance(Short yDistance) {
        this.yDistance = Float.valueOf(yDistance);
    public void setyDistance(float yDistance) {
        this.yDistance = yDistance;
    }
    public void setxDuration(Short xDuration) {
        this.xDuration = Float.valueOf(xDuration);
    public void setxDuration(float xDuration) {
        this.xDuration = xDuration;
    }
    public void setyDuration(Short yDuration) {
        this.yDuration = Float.valueOf(yDuration);
    public void setyDuration(float yDuration) {
        this.yDuration = yDuration;
    }
}
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -44,6 +44,8 @@
     */
    private boolean backHpFlag = false;
    private boolean cmdFlag = true;
    public SiemensCrnThread(CrnSlave slave) {
        this.slave = slave;
    }
@@ -147,10 +149,10 @@
     * 读取状态
     */
    private void readStatus(){
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        short len = 56;
        len = slave.getId() == 1 ? (short) 56 : (short) 58;
        try {
            OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short) 56);
            OperateResultExOne<byte[]> result = siemensNet.Read("DB101.0", (short)56);
            if (result.IsSuccess) {
                if (null == crnProtocol) {
                    crnProtocol = new CrnProtocol();
@@ -170,26 +172,24 @@
                crnProtocol.setTemp2(siemensNet.getByteTransform().TransInt16(result.Content, 22));
                crnProtocol.setTemp3(siemensNet.getByteTransform().TransInt16(result.Content, 24));
                crnProtocol.setTemp4(siemensNet.getByteTransform().TransInt16(result.Content, 26));
                crnProtocol.setxSpeed(siemensNet.getByteTransform().TransInt16(result.Content, 28));
                crnProtocol.setySpeed(siemensNet.getByteTransform().TransInt16(result.Content, 32));
                crnProtocol.setzSpeed(siemensNet.getByteTransform().TransInt16(result.Content, 36));
                crnProtocol.setxDistance(siemensNet.getByteTransform().TransInt16(result.Content, 40));
                crnProtocol.setyDistance(siemensNet.getByteTransform().TransInt16(result.Content, 44));
                crnProtocol.setxDuration(siemensNet.getByteTransform().TransInt16(result.Content, 48));
                crnProtocol.setyDuration(siemensNet.getByteTransform().TransInt16(result.Content, 52));
                crnProtocol.setxSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 28));
                crnProtocol.setySpeed(siemensNet.getByteTransform().TransSingle(result.Content, 32));
                crnProtocol.setzSpeed(siemensNet.getByteTransform().TransSingle(result.Content, 36));
                crnProtocol.setxDistance(siemensNet.getByteTransform().TransSingle(result.Content, 40));
                crnProtocol.setyDistance(siemensNet.getByteTransform().TransSingle(result.Content, 44));
                crnProtocol.setxDuration(siemensNet.getByteTransform().TransSingle(result.Content, 48));
                crnProtocol.setyDuration(siemensNet.getByteTransform().TransSingle(result.Content, 52));
                OutputQueue.CRN.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), slave.getId()));
                // 复位信号
                if (crnProtocol.getStatusType().equals(CrnStatusType.WAITING)) {
                    if (resetFlag) {
                        if(crnProtocol.getTaskNo()==9999){
                            backHpFlag = false;
                        }
                        CrnCommand crnCommand = new CrnCommand();
                        crnCommand.setAckFinish((short)1);
                        if (write(crnCommand)) {
                            resetFlag = false;
                            cmdFlag = true;
                        }
                    }
                }
@@ -201,19 +201,19 @@
                    basCrnp.setCrnNo(slave.getId());
                    basCrnp.setCrnSts((int)crnProtocol.getMode());
                    if (!basCrnpService.updateById(crnProtocol.toSqlModel(basCrnp))){
                        News.error(methodName + ":堆垛机plc数据库更新失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", 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());
                    }
                } 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(methodName + ":读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", 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());
            }
        } 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(methodName + ":读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.error("读取堆垛机plc状态信息失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            initCrn();
        }
    }
@@ -231,34 +231,144 @@
     * 写入数据
     */
    private boolean write(CrnCommand command) throws InterruptedException {
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        if (null == command) {
            News.error("堆垛机写入命令为空");
            return false;
        }
        // 向堆垛机发任务前的堆垛机状态
        try{
            OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 24);
            if (resultRead.IsSuccess) {
                CrnCommand one = new CrnCommand();
                one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2));
                one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4));
                one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6));
                one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8));
                one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10));
                one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12));
                one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14));
                one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16));
                if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode())
                        || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY())
                        || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX())
                        || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ())
                ){
                    News.error("下发前:[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
                } else {
                    News.info("下发前:[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
                }
            }
        }catch (Exception e){
            News.error("堆垛机命令地址写入后回读出错");
        }
//        convertRow(command);
        command.setCrnNo(slave.getId());
//        short[] array = new short[10];
        short[] array = new short[10];
        array[0] = command.getAckFinish();
        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.getSourceStaNo();
//        array[10] = command.getDestinationStaNo();
        array[0] = command.getAckFinish(); // 任务完成确认位
        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();
//        array[10] = command.getLocType1();   //新增货物类型下发
        OperateResult result = siemensNet.Write("DB100.0", array);
        News.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), array);
        if(!result.IsSuccess){
            News.error("写入堆垛机plc数据失败,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(command));
            MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command));
            Thread.sleep(100);
            readStatus();
            return false;
        }
        //堆垛机任务写入后,回读一次,看是否成功
        Thread.sleep(200);
        try{
            OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.0", (short) 18);
            if (resultRead.IsSuccess) {
                CrnCommand one = new CrnCommand();
                one.setTaskNo(siemensNet.getByteTransform().TransInt16(resultRead.Content, 2));
                one.setTaskMode(siemensNet.getByteTransform().TransInt16(resultRead.Content, 4));
                one.setSourcePosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 6));
                one.setSourcePosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 8));
                one.setSourcePosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 10));
                one.setDestinationPosX(siemensNet.getByteTransform().TransInt16(resultRead.Content, 12));
                one.setDestinationPosY(siemensNet.getByteTransform().TransInt16(resultRead.Content, 14));
                one.setDestinationPosZ(siemensNet.getByteTransform().TransInt16(resultRead.Content, 16));
                if (!command.getTaskNo().equals(one.getTaskNo()) || !command.getTaskMode().equals(one.getTaskMode())
                        || !command.getSourcePosX().equals(one.getSourcePosX()) || !command.getSourcePosY().equals(one.getSourcePosY())
                        || !command.getSourcePosZ().equals(one.getSourcePosZ()) || !command.getDestinationPosX().equals(one.getDestinationPosX())
                        || !command.getDestinationPosY().equals(one.getDestinationPosY()) || !command.getDestinationPosZ().equals(one.getDestinationPosZ())
                ){
                    try{
                        News.error("堆垛机命令地址写入后回读失败[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
                    }catch (Exception e){
                        try{
                            News.error("日志打印失败:===>>参数one报错 [id:{}],{}", slave.getId(), JSON.toJSON(command),JSON.toJSON(resultRead));
                        }catch (Exception e1){
                            News.error("日志打印失败:===>> [id:{}],{}", slave.getId(), JSON.toJSON(command));
                        }
                    }
                    News.error("堆垛机命令回读失败后,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(command));
                    MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command));
                    Thread.sleep(100);
                    readStatus();
                    return false;
                } else {
                    News.info("堆垛机命令地址写入后回读成功[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
                }
            }
        }catch (Exception e){
            News.error("堆垛机命令地址写入后回读出错");
        }
        if (command.getAckFinish() == 0) {
            short commandFinish = 1;
            Thread.sleep(100L);
            result = siemensNet.Write("DB100.18", commandFinish);
            if (result.IsSuccess) {
                Thread.sleep(300);
                //任务下发次数
                int writeCount2 = 0;
                do {
                    writeCount2++;
                    short commandFinish = (short) 1;
                    result = siemensNet.Write("DB100.18", commandFinish);
                    if(result.IsSuccess){
                        //堆垛机任务写入后,回读一次,看是否成功
                        Thread.sleep(200);
                        OperateResultExOne<byte[]> resultRead = siemensNet.Read("DB100.18", (short) 2);
                        if (resultRead.IsSuccess) {
                            commandFinish=siemensNet.getByteTransform().TransInt16(resultRead.Content, 0);
                            if (commandFinish != 1){
                                News.error("堆垛机任务确认位"+commandFinish+"写入数据与回读数据不一致!"+"循环执行次数:"+writeCount2+"次");
                            }else{
                                //任务命令写入成功
                                News.info("堆垛机任务确认位"+commandFinish+"回读成功!"+"循环执行次数:"+writeCount2+"次");
                                break;
                            }
                        }else {
                            News.error("堆垛机任务确认位"+commandFinish+"回读失败!"+"循环执行次数:"+writeCount2+"次");
                        }
                    } else {
                        News.error("堆垛机任务确认位"+commandFinish+"写入失败!"+"循环执行次数:"+writeCount2+"次");
                    }
                }while (writeCount2<5);
            }
        }
//        if (command.getAckFinish() == 0) {
//            short commandFinish = 1;
//            Thread.sleep(200L);
//            result = siemensNet.Write("DB100.18", commandFinish);
//            log.info("堆垛机commandFinish下发[id:{}] >>>>> {}", slave.getId(), commandFinish);
////            result = siemensNet.Write("DB100.22", commandFinish);
//        }
        try {
            // 日志记录
@@ -286,12 +396,12 @@
        if (result != null && result.IsSuccess) {
            Thread.sleep(200);
            this.readStatus();
            News.info(methodName + ":堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), JSON.toJSON(command));
            News.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 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(methodName + ":写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            News.error("写入堆垛机plc数据失败 ===>> [id:{}] [ip:{}] [port:{}]", slave.getId(), slave.getIp(), slave.getPort());
            return false;
        }
    }
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -72,6 +72,17 @@
    public static final ArrayList<Integer> staNosErr3 = new ArrayList<Integer>() {{
        add(301); add(303); add(305);
    }};
    public static final ArrayList<Integer> barcode1 = new ArrayList<Integer>() {{
        add(0); add(1); add(2);
    }};
    public static final ArrayList<Integer> barcode2 = new ArrayList<Integer>() {{
        add(3); add(4); add(5);
    }};
    public static final ArrayList<Integer> barcode3 = new ArrayList<Integer>() {{
        add(6); add(7); add(8);
    }};
    private ArrayList<Integer> getStaNo() {
        switch (slave.getId()) {
            case 1:
@@ -84,6 +95,19 @@
                throw new CoolException("获取站点失败!");
        }
    }
    private ArrayList<Integer> getBarcodeList() {
        switch (slave.getId()) {
            case 1:
                return barcode1;
            case 2:
                return barcode2;
            case 3:
                return barcode3;
            default:
                throw new CoolException("获取站点失败!");
        }
    }
    private ArrayList<Integer> getStaNoErr() {
        switch (slave.getId()) {
            case 1:
@@ -219,6 +243,24 @@
                    staProtocol.setPakMk(true);
                }
            }
            // 根据实时信息更新数据库
            try {
                List<BasDevp> basDevps = new ArrayList<>();
                for (Integer siteId : staNos) {
                    StaProtocol staProtocol = station.get(siteId);
                    basDevps.add(staProtocol.toSqlModel());
                }
                BasDevpService basDevpService = SpringUtils.getBean(BasDevpService.class);
                if (null != basDevpService && !basDevpService.updateBatchById(basDevps)) {
                    throw new Exception("更新数据库数据失败");
                }
            } 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(methodName + ":更新数据库数据失败 ===>> [id:{}] [ip:{}] [port:{}] [rack:{}] [slot:{}]", slave.getId(), slave.getIp(), slave.getPort(), slave.getRack(), slave.getSlot());
            }
        }
        //外形检测
        ArrayList<Integer> staNoErrs = getStaNoErr();
@@ -241,17 +283,30 @@
        //条码扫描器
//        Thread.sleep(200);
        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840",(short)(barcodeSize*10));
//        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840",(short)(barcodeSize*8));
//        if (result2.IsSuccess) {
//            for (int i = 0; i < barcodeSize; i++) {
//                String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8");
//                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
//                if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
//                    barcodeThread.setBarcode(barcode);
//                }
//            }
//        }
        ArrayList<Integer> barcodeList = getBarcodeList();
        OperateResultExOne<byte[]> result2 = siemensS7Net.Read("DB101.840", (short) (barcodeList.size() * 8));
        if (result2.IsSuccess) {
            for (int i = 0; i < barcodeSize; i++) {
            for (int i = 0; i < barcodeList.size(); i++) {
                Integer barcodeId = barcodeList.get(i);
                String barcode = siemensS7Net.getByteTransform().TransString(result2.Content,i*8,8, "UTF-8");
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, i + 1);
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, barcodeId + 1);
                if(!Cools.isEmpty(barcodeThread) && !barcodeThread.getBarcode().equals(barcode)) {
                    barcodeThread.setBarcode(barcode);
                }
            }
        }
        //RGV小车
//        Thread.sleep(200);
        OperateResultExOne<byte[]> result3 = siemensS7Net.Read("DB100.160",(short)2);
src/main/resources/application.yml
@@ -248,14 +248,17 @@
    pickSta[0]:
      staNo: 101
      barcode: ${wcs-slave.barcode[0].id}
      backSta: 100
    # 拣料入库口2
    pickSta[1]:
      staNo: 103
      barcode: ${wcs-slave.barcode[1].id}
      backSta: 102
    # 拣料入库口3
    pickSta[2]:
      staNo: 105
      barcode: ${wcs-slave.barcode[2].id}
      backSta: 104
  # 输送线2楼
  devp[1]:
    id: 2
@@ -303,14 +306,17 @@
    pickSta[0]:
      staNo: 201
      barcode: ${wcs-slave.barcode[3].id}
      backSta: 200
    # 拣料入库口2
    pickSta[1]:
      staNo: 203
      barcode: ${wcs-slave.barcode[4].id}
      backSta: 202
    # 拣料入库口3
    pickSta[2]:
      staNo: 205
      barcode: ${wcs-slave.barcode[5].id}
      backSta: 204
  # 输送线3楼
  devp[2]:
    id: 3
@@ -358,14 +364,17 @@
    pickSta[0]:
      staNo: 301
      barcode: ${wcs-slave.barcode[6].id}
      backSta: 300
    # 拣料入库口2
    pickSta[1]:
      staNo: 303
      barcode: ${wcs-slave.barcode[7].id}
      backSta: 302
    # 拣料入库口3
    pickSta[2]:
      staNo: 305
      barcode: ${wcs-slave.barcode[8].id}
      backSta: 304
  # 条码扫描仪1
  barcode[0]:
    id: 1
@@ -417,60 +426,60 @@
    ip: 10.10.10.81
    port: 5005
    devpPlcId: ${wcs-slave.devp[0].id}
    staArr: 101
    staArr: 100
  # LED2
  led[1]:
    id: 2
    ip: 10.10.10.202
    port: 5005
    devpPlcId: ${wcs-slave.devp[0].id}
    staArr: 103
    staArr: 102
    # LED3
  led[2]:
    id: 1
    ip: 10.10.10.81
    port: 5005
    devpPlcId: ${wcs-slave.devp[0].id}
    staArr: 105
    staArr: 104
  # LED4
  led[3]:
    id: 2
    ip: 10.10.10.202
    port: 5005
    devpPlcId: ${wcs-slave.devp[1].id}
    staArr: 201
    staArr: 200
    # LED5
  led[4]:
    id: 1
    ip: 10.10.10.81
    port: 5005
    devpPlcId: ${wcs-slave.devp[1].id}
    staArr: 203
    staArr: 202
  # LED6
  led[5]:
    id: 2
    ip: 10.10.10.202
    port: 5005
    devpPlcId: ${wcs-slave.devp[1].id}
    staArr: 205
    staArr: 204
  # LED7
  led[6]:
    id: 1
    ip: 10.10.10.81
    port: 5005
    devpPlcId: ${wcs-slave.devp[2].id}
    staArr: 301
    staArr: 300
  # LED8
  led[7]:
    id: 2
    ip: 10.10.10.202
    port: 5005
    devpPlcId: ${wcs-slave.devp[2].id}
    staArr: 303
    staArr: 302
  # LED9
  led[8]:
    id: 1
    ip: 10.10.10.81
    port: 5005
    devpPlcId: ${wcs-slave.devp[2].id}
    staArr: 305
    staArr: 304
src/main/webapp/static/js/console.map.js
@@ -64,7 +64,7 @@
    "rackDescs": [{
        "type": "rackDescs",
        "id": "lb_desc17",
        "text": "#1",
        "text": "#6",
        "top": 119,
        "left": 157,
        "width": 30,
@@ -72,7 +72,7 @@
    }, {
        "type": "rackDescs",
        "id": "lb_desc16",
        "text": "#6",
        "text": "#1",
        "top": 344,
        "left": 154,
        "width": 33,
@@ -96,8 +96,8 @@
        "height": 290
    }, {
        "type": "crane",
        "id": "crn-3",
        "text": "3",
        "id": "crn-1",
        "text": "1",
        "top": 316,
        "left": 466,
        "width": 93,
@@ -136,8 +136,8 @@
        "height": 2
    }, {
        "type": "crane",
        "id": "crn-1",
        "text": "1",
        "id": "crn-3",
        "text": "3",
        "top": 151,
        "left": 471,
        "width": 93,