#
whycq
2023-05-16 6274f4380453d9e2855f5e13645877852f020600
#
8个文件已修改
128 ■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/model/MatDto.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/ServerBootstrap.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/command/LedCommand.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LedThread.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensCrnThread.java 73 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/views/console.html 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -121,11 +121,11 @@
                    }
                } else {
                    // led 异常显示
                    LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                    if (ledThread != null) {
                        String errorMsg = "扫码失败,请重试";
                        MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                    }
//                    LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
//                    if (ledThread != null) {
//                        String errorMsg = "扫码失败,请重试";
//                        MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
//                    }
                    continue;
                }
@@ -199,7 +199,7 @@
                                .build()
                                .doPost();
                        JSONObject jsonObject = JSON.parseObject(response);
//                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
//                        Integer code = jsonObject.getInteger("code");
                        if (jsonObject.getInteger("code").equals(200)) {
                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
@@ -208,6 +208,7 @@
                            staProtocol.setWorkNo(dto.getWorkNo().shortValue());
                            staProtocol.setStaNo(dto.getStaNo().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            ledThread.errorReset();
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                throw new CoolException("更新plc站点信息失败");
@@ -1486,6 +1487,7 @@
                }
                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 -> {
@@ -1561,7 +1563,7 @@
            // led显示默认内容
            if (reset) {
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
                    News.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    News.error("{}号LED命令下发失败1565!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                }
            }
        }
src/main/java/com/zy/common/model/MatDto.java
@@ -9,7 +9,7 @@
public class MatDto {
    // 物料编号
    private String matNo;
    private String matnr;
    // 物料名称
    private String maknx;
@@ -20,8 +20,8 @@
    public MatDto() {
    }
    public MatDto(String matNo, String maknx, Double count) {
        this.matNo = matNo;
    public MatDto(String matnr, String maknx, Double count) {
        this.matnr = matnr;
        this.maknx = maknx;
        this.count = count;
    }
src/main/java/com/zy/core/ServerBootstrap.java
@@ -92,12 +92,17 @@
        log.info("初始化条码扫描仪线程...................................................");
        for (Slave barcode : slaveProperties.getBarcode()) {
            BarcodeThread barcodeThread = new BarcodeThread(barcode);
            if(barcode.getId() > 6)
            {//1到6号扫码器数据从PLC中获取,无需start
                new Thread(barcodeThread).start();
            }
            new Thread(barcodeThread).start();
            SlaveConnection.put(SlaveType.Barcode, barcode.getId(), barcodeThread);
        }
//        for (Slave barcode : slaveProperties.getBarcode()) {
//            BarcodeThread barcodeThread = new BarcodeThread(barcode);
//            if(barcode.getId() > 6)
//            {//1到6号扫码器数据从PLC中获取,无需start
//                new Thread(barcodeThread).start();
//            }
//            SlaveConnection.put(SlaveType.Barcode, barcode.getId(), barcodeThread);
//        }
        // 初始化LED线程
        log.info("初始化LED线程...................................................");
        for (LedSlave led : slaveProperties.getLed()) {
src/main/java/com/zy/core/model/command/LedCommand.java
@@ -25,6 +25,8 @@
    private String sourceLocNo;
    private String barcode;
    private List<MatDto> matDtos = new ArrayList<>();
    private boolean emptyMk = false;
src/main/java/com/zy/core/thread/LedThread.java
@@ -85,7 +85,7 @@
            sb.append("目标站:").append(command.getStaNo()).append("\n");
            if (!command.isEmptyMk()) {
                for (MatDto matDto : command.getMatDtos()) {
                    sb.append(matDto.getMatNo()).append("-").append(matDto.getMaknx()).append("\n");
                    sb.append(matDto.getMatnr()).append("-").append(matDto.getMaknx()).append("\n");
                }
            }
            sb.append("\n");
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -232,6 +232,37 @@
            log.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())
                ){
                    log.error("下发前:[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
                    log.error("堆垛机命令回读失败后,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(command));
                    MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command));
                    Thread.sleep(100);
                    readStatus();
                    return false;
                } else {
                    log.info("下发前:[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
                }
            }
        }catch (Exception e){
            log.error("堆垛机命令地址写入后回读出错");
        }
//        convertRow(command);
        command.setCrnNo(slave.getId());
//        short[] array = new short[10];
@@ -248,6 +279,48 @@
        array[9] = command.getCommand();
        array[10] = command.getLocType1();   //新增货物类型下发
        OperateResult result = siemensNet.Write("DB100.0", array);
        log.info("堆垛机命令下发[id:{}] >>>>> {}", slave.getId(), array);
        if(!result.IsSuccess){
            log.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) 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())
                ){
                    log.error("堆垛机命令地址写入后回读失败[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
                    log.error("堆垛机命令回读失败后,重新添加任务到队列 ===>> [id:{}],{}", slave.getId(), JSON.toJSON(command));
                    MessageQueue.offer(SlaveType.Crn, slave.getId(), new Task(2, command));
                    Thread.sleep(100);
                    readStatus();
                    return false;
                } else {
                    log.info("堆垛机命令地址写入后回读成功[id:{}] >>>>> 写入[{}],===>>回读[{}]", slave.getId(), JSON.toJSON(command),JSON.toJSON(one));
                }
            }
        }catch (Exception e){
            log.error("堆垛机命令地址写入后回读出错");
        }
        if (command.getAckFinish() == 0) {
            short commandFinish = 1;
src/main/resources/application.yml
@@ -139,14 +139,14 @@
  # LED1
  led[0]:
    id: 1
    ip: 10.10.10.221
    ip: 10.10.10.220
    port: 5005
    devpPlcId: ${wcs-slave.devp[0].id}
    staArr: 100
  # LED2
  led[1]:
    id: 2
    ip: 10.10.10.222
    ip: 10.10.10.221
    port: 5005
    devpPlcId: ${wcs-slave.devp[0].id}
    staArr: 103
src/main/webapp/views/console.html
@@ -607,12 +607,12 @@
                        offSet = 1710; //145
                        crnEl.animate({left: offSet + 'px'}, 1000);
                        // if(crns[i].bay === 1){
                        //     crnEl.animate({left: offSet + 'px'}, 1000);
                        // } else {
                        //     crnEl.animate({left: (offSet - unit + (crns[i].bay * unit)) + 'px'}, 1000);
                        // }
                        // crnEl.animate({left: offSet + 'px'}, 1000);
                        if(crns[i].bay === 1){
                            crnEl.animate({left: offSet + 'px'}, 1000);
                        } else {
                            crnEl.animate({left: (offSet - unit + (crns[i].bay * unit)) + 'px'}, 1000);
                        }
                    }
                } else if (res.code === 403) {