whycq
2024-06-30 f884d266dce2295e75462e931f7fb60eb2c23c80
Merge remote-tracking branch 'origin/sxjzwcs' into sxjzwcs
7个文件已修改
316 ■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 146 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/common/model/MatDto.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/LedThread.java 74 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensCrnThread.java 87 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/webapp/static/images/zy-logo.png 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -96,7 +96,7 @@
     * 组托
     * 入库站,根据条码扫描生成入库工作档,工作状态 2
     */
    public synchronized void generateStoreWrkFile(Integer mark) {
    public synchronized void generateStoreWrkFile(Integer mark) throws InterruptedException {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) { //遍历输送线
            // 遍历入库口
@@ -125,10 +125,7 @@
                  是2号输送线9995拣料任务
                 */
                String barcode = barcodeThread.getBarcode();
                if (Cools.isEmpty(barcode) || !staProtocol.isInEnable() || staProtocol.isEmptyMk()
                || !staProtocol.isFullPlt() || (staProtocol.getWorkNo() == 9995 && devp.getId() == 2)) {
                    continue;
                }
                // 尺寸检测异常
                boolean back = false;
@@ -192,6 +189,12 @@
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errMsg));
                    Thread.sleep(500);
                }
                if (Cools.isEmpty(barcode) || !staProtocol.isInEnable() || staProtocol.isEmptyMk()
                        || !staProtocol.isFullPlt() || (staProtocol.getWorkNo() <= 9000 && devp.getId() == 2)) {
                    continue;
                }
                if (staProtocol.isAutoing() && staProtocol.isInEnable()
@@ -206,21 +209,23 @@
                            continue;
                        }
                    }
                    if (wrkMast != null && devp.getId() == 2) {
                        News.warn(""+mark+" - 4"+" - 工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        staProtocol.setWorkNo((short)9999);
                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            throw new CoolException("更新plc站点信息失败");
                        }
                        // led 异常显示
                        if (ledThread != null) {
                            String errorMsg = "工作档已存在该条码号===>>" + barcode;
                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
                        }
                    if (wrkMast != null) {
//                        News.warn(""+mark+" - 4"+" - 工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
//                        if (devp.getId() == 2) {
//                            staProtocol.setWorkNo((short)9999);
//                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
//                            devpThread.setPakMk(staProtocol.getSiteId(), false);
//                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                            if (!result) {
//                                throw new CoolException("更新plc站点信息失败");
//                            }
//                        }
//
//                        // led 异常显示
//                        if (ledThread != null) {
//                            String errorMsg = "工作档已存在该条码号===>>" + barcode;
//                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errorMsg));
//                        }
                        continue;
                    }
@@ -262,9 +267,22 @@
                                ledCommand.setTitle("全板入库");
                                ledCommand.setLocNo(dto.getLocNo());
                                ledCommand.setStaNo(dto.getStaNo());
                                ArrayList<MatDto> matDtos = new ArrayList<>();
                                MatDto matDto = new MatDto();
                                matDto.setLocNo(dto.getLocNo());
                                matDtos.add(matDto);
                                ledCommand.setMatDtos(matDtos);
                                ledCommand.setBarcode(barcode);
                                commands.add(ledCommand);
                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands));
                                if (devp.getId() == 1) {
                                     if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(1, commands))){
                                         ledThread.setLedMk(false);
                                     }
                                } else {
                                    if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands))){
                                        ledThread.setLedMk(false);
                                    }
                                }
//                                ledThread.errorReset();
                            }
                        } else {
@@ -445,14 +463,17 @@
                            .eq("stn_no", stnNo) // 作业站点 = 拣料出库的目标站
                            .eq("crn_no", wrkMast.getCrnNo()); // 堆垛机号
                    StaDesc staDesc = staDescService.selectOne(wrapper);
                    //LED
                    LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
                    if (Cools.isEmpty(staDesc)) {
                        News.error(""+mark+" - 2"+" - 入库路径不存在!type_no={},stn_no={},crn_no={}", wrkMast.getIoType(), pickSta.getStaNo(), wrkMast.getCrnNo());
                        staProtocol.setWorkNo((short) 9999);
                        staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        //LED
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
                        if (devp.getId() == 2) {
                            staProtocol.setWorkNo((short) 9999);
                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        }
                        // led 异常显示
                        if (ledThread != null) {
                            String errorMsg = "此为拣料、并板、盘点再入库.请放在"+pickSta.getBackSta().shortValue()+"站点";
@@ -499,6 +520,29 @@
                        e.printStackTrace();
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        continue;
                    }
                    List<LedCommand> commands = new ArrayList<>();
                    LedCommand ledCommand = new LedCommand();
                    ledCommand.setWorkNo(wrkMast.getWrkNo());
                    ledCommand.setIoType(wrkMast.getIoType());
                    ledCommand.setTitle(wrkMast.getIoType() == 53 ? "拣料再入库" : "盘点再入库");
                    ledCommand.setLocNo(wrkMast.getLocNo());
                    ledCommand.setStaNo(wrkMast.getStaNo());
                    ledCommand.setBarcode(barcode);
                    ArrayList<MatDto> matDtos = new ArrayList<>();
                    MatDto matDto = new MatDto();
                    matDto.setLocNo(wrkMast.getLocNo());
                    matDtos.add(matDto);
                    ledCommand.setMatDtos(matDtos);
                    commands.add(ledCommand);
                    if (devp.getId() == 1) {
                        if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(1, commands))) {
                            ledThread.setLedMk(false);
                        }
                    } else {
                        if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, commands))){
                            ledThread.setLedMk(false);
                        }
                    }
                    // 更新站点信息 且 下发plc命令
@@ -1546,12 +1590,22 @@
                                // 组装命令
                                LedCommand ledCommand = new LedCommand();
                                ledCommand.setWorkNo(dto.getWorkNo());
                                ledCommand.setIoType(1);
                                ledCommand.setTitle("全板入库");
                                ledCommand.setIoType(10);
                                ledCommand.setTitle("空板入库");
                                ledCommand.setLocNo(dto.getLocNo());
                                ledCommand.setStaNo(dto.getStaNo());
                                ledCommand.setBarcode("");
                                ArrayList<MatDto> matDtos = new ArrayList<>();
                                MatDto matDto = new MatDto();
                                matDto.setLocNo(dto.getLocNo());
                                matDtos.add(matDto);
                                ledCommand.setMatDtos(matDtos);
                                commands.add(ledCommand);
                                MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, commands));
                                if (devp.getId() == 1) {
                                    MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(1, commands));
                                } else {
                                    MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(3, commands));
                                }
//                                ledThread.errorReset();
                            }
                        } else {
@@ -1600,6 +1654,9 @@
            // 工作档集合
            List<WrkMast> wrkMasts = new ArrayList<>();
            for (Integer staNo : led.getStaArr()) {
                if (staNo == 104 || staNo == 204 || staNo == 304) {
                    continue;
                }
                // 获取叉车站点
                StaProtocol staProtocol = devpThread.getStation().get(staNo);
                if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) {
@@ -1674,7 +1731,7 @@
                    } else {
                        ledThread.setLedMk(false);
                    }
                } else {
                } else if(led.getId() == 1 || led.getId() == 2){
                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
                        News.error(""+mark+" - 3"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                        continue;
@@ -1745,11 +1802,20 @@
            // led显示默认内容
            if (reset && !ledThread.isLedMk()) {
                ledThread.setLedMk(true);
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) {
                    News.error(""+mark+" - 1"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                } else {
                if (led.getId() <=2 ) {
                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
                        News.error(""+mark+" - 1"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    } else {
                    }
                } else {
                    if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(4, new ArrayList<>()))) {
                        News.error(""+mark+" - 1"+" - {}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    } else {
                    }
                }
            }
        }
        News.infoNoLog(""+mark+" - 0"+" - 执行完成:其他  ===>> LED显示器复位,显示默认信息");
@@ -2325,4 +2391,16 @@
        }
    }
    public void resetOneLed() {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) { //遍历输送线
            if (devp.getId() == 1) {
                // 遍历入库口
                for (DevpSlave.Sta inSta : devp.getInSta()) {  // 遍历入库口
                    SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                    StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                }
            }
        }
    }
}
src/main/java/com/zy/common/model/MatDto.java
@@ -27,6 +27,8 @@
    // 批次
    private String batch;
    private String locNo;
    public MatDto() {
    }
src/main/java/com/zy/core/MainProcess.java
@@ -70,6 +70,9 @@
                    mainService.outOfDevp(11);
                    // 复位一期led入库后显示默认信息
//                    mainService.resetOneLed();
                    //mainService.DevpCallThePolice(12);
src/main/java/com/zy/core/thread/LedThread.java
@@ -113,25 +113,31 @@
        // 创建一个数据页
        TextBxPage page = new TextBxPage();
        for (LedCommand command : list) {
            page.newLine(command.getTitle() +"("+command.getWorkNo()+")");
            if (!command.isEmptyMk()) {
                for (MatDto matDto : command.getMatDtos()) {
                    //去掉小数点
                    String strQty = matDto.getCount().toString();
                    int idx = strQty.lastIndexOf(".");
                    if(idx >= 0){
                        strQty = strQty.substring(0,idx);
                    }
                    page.newLine(matDto.getMatnr());
                    page.newLine(matDto.getMaknx());
                    page.newLine("[数量:" + strQty +  "/" +  matDto.getTotal().intValue()+"]");
            if (command.getIoType() < 100) {
                page.newLine(command.getTitle());
                page.newLine("任务号:" + command.getWorkNo());
                page.newLine("库位号:" + command.getLocNo());
                page.newLine("条码:" + command.getBarcode());
            } else {
                page.newLine(command.getTitle() + "(" + command.getWorkNo() + ")");
                if (!command.isEmptyMk()) {
                    for (MatDto matDto : command.getMatDtos()) {
                        //去掉小数点
                        String strQty = matDto.getCount().toString();
                        int idx = strQty.lastIndexOf(".");
                        if (idx >= 0) {
                            strQty = strQty.substring(0, idx);
                        }
                        page.newLine(matDto.getMatnr());
                        page.newLine(matDto.getMaknx());
                        page.newLine("[数量:" + strQty + "/" + matDto.getTotal().intValue() + "]");
//                    page.newLine(matDto.getMaknx() + "[数量" + strQty +"]");
//                    page.newLine(matDto.getMaknx() + "【数量" + matDto.getCount() +"】");
                    }
                }
                page.newLine("\n");
            }
            page.newLine("\n");
        }
        // 设置字体
        page.setFont(new Font("宋体",Font.PLAIN,12));
        // 设置文本颜色
@@ -179,7 +185,7 @@
//            page.newLine("自动化立体仓库");
//            page.newLine("西格迈股份有限公司");
//        }
        page.newLine("力源智能仓储");
        page.newLine("捷众智能仓储");
        // 设置字体
        page.setFont(new Font("宋体",Font.PLAIN,13));
@@ -232,9 +238,41 @@
    }
    private void error(String msg) {
        errorMsg.delete(0, errorMsg.length());
        errorMsg.append(msg);
    private void error(String msg) throws Bx5GException {
        if (slave.getId() <= 2) {
            if (!connect()) {
                return;
            }
            pf = new ProgramBxFile( 0, screen.getProfile());
            pf.setFrameShow(false);
            // 分别输入X,Y,width,height
            area = new TextCaptionBxArea( 0,0,96,48, screen.getProfile());
            // 创建一个数据页
            TextBxPage page = new TextBxPage();
            page.newLine(msg);
            // 设置字体
            page.setFont(new Font("宋体",Font.PLAIN,12));
            // 设置文本颜色
            page.setForeground(Color.red);
            // 设置显示特技为快速打出
            page.setDisplayStyle(styles[6]);
            area.clearPages();
            area.addPage(page);
            pf.addArea(area);
            if (pf.validate() != null) {
                News.info("Led"+" - 2"+" - pf out of range");
            } else {
                // 更新节目
                screen.writeProgram(pf);
//            resetStatus = false;
            }
            close();
        } else {
            errorMsg.delete(0, errorMsg.length());
            errorMsg.append(msg);
        }
    }
    public void errorReset() {
src/main/java/com/zy/core/thread/SiemensCrnThread.java
@@ -256,6 +256,49 @@
                array[8] = command.getDestinationPosZ();
                array[9] = command.getCommand();
                result = siemensNet.Write("DB100.0", array);
                //堆垛机任务写入后,回读一次,看是否成功
                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));
                                }
                            }
                            if(!resetFlag){
                                News.error("堆垛机命令回读失败后,重新添加任务到队列2 ===>> [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("堆垛机命令地址写入后回读出错");
                }
            }
        } else {
            // 写任务完成确认
@@ -275,6 +318,50 @@
                array[8] = command.getDestinationPosZ();
                array[9] = command.getCommand();
                result = siemensNet.Write("DB100.0", array);
                log.info(JSON.toJSONString(array));
                //堆垛机任务写入后,回读一次,看是否成功
                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));
                                }
                            }
                            if(!resetFlag){
                                News.error("堆垛机命令回读失败后,重新添加任务到队列2 ===>> [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("堆垛机命令地址写入后回读出错");
                }
            }
        }
src/main/resources/application.yml
@@ -205,14 +205,14 @@
    ip: 10.10.10.107
    port: 5005
    devpPlcId: ${wcs-slave.devp[0].id}
    staArr: 101
    staArr: 101,104
  # LED2
  led[1]:
    id: 2
    ip: 10.10.10.105
    port: 5005
    devpPlcId: ${wcs-slave.devp[0].id}
    staArr: 201
    staArr: 201,204
  # LED3
  led[2]:
    id: 3
src/main/webapp/static/images/zy-logo.png