pjb
2024-06-30 cd18df2ff664883dc2ded7b14d1d0f78b9c136a6
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()
@@ -207,10 +210,12 @@
                        }
                    }
                    if (wrkMast != null) {
                        News.warn(""+mark+" - 4"+" - 工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        News.warn(""+mark+" - 4"+" - 满托盘入库工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        if (devp.getId() == 2) {
                            staProtocol.setWorkNo((short)9999);
                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
//                            staProtocol.setWorkNo((short)9999);
//                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
                            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
                            staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
@@ -264,17 +269,26 @@
                                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);
                                if (devp.getId() == 1) {
                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(1, commands));
                                     if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(1, commands))){
                                         ledThread.setLedMk(false);
                                     }
                                } else {
                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands));
                                    if (MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, commands))){
                                        ledThread.setLedMk(false);
                                    }
                                }
//                                ledThread.errorReset();
                            }
                        } else {
                            News.error(""+mark+" - 5"+" - 请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                            News.error(""+mark+" - 5"+" - 满板入库请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                            if(devp.getId() == 2) {
                                staProtocol.setWorkNo((short)9999);
                                staProtocol.setStaNo(inSta.getBackSta().shortValue());
@@ -451,6 +465,8 @@
                            .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());
                        if (devp.getId() == 2) {
@@ -459,8 +475,7 @@
                            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());
                        // led 异常显示
                        if (ledThread != null) {
                            String errorMsg = "此为拣料、并板、盘点再入库.请放在"+pickSta.getBackSta().shortValue()+"站点";
@@ -516,11 +531,20 @@
                    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) {
                        MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(1, commands));
                        if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(1, commands))) {
                            ledThread.setLedMk(false);
                        }
                    } else {
                        MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, commands));
                        if (MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, commands))){
                            ledThread.setLedMk(false);
                        }
                    }
                    // 更新站点信息 且 下发plc命令
@@ -1573,6 +1597,11 @@
                                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);
                                if (devp.getId() == 1) {
                                    MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(1, commands));
@@ -1581,6 +1610,7 @@
                                }
//                                ledThread.errorReset();
                            }
                            Thread.sleep(500);
                        } else {
                            staProtocol.setWorkNo((short)9991);
                            staProtocol.setStaNo((short)100);
@@ -1597,7 +1627,7 @@
                                    MessageQueue.offer(SlaveType.Led, emptyInSta.getLed(), new Task(5, errorMsg));
                                }
                            }
                            News.error(""+mark+" - 3"+" - 请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                            News.error(""+mark+" - 3"+" - 空板入库请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
@@ -1627,7 +1657,7 @@
            // 工作档集合
            List<WrkMast> wrkMasts = new ArrayList<>();
            for (Integer staNo : led.getStaArr()) {
                if (staNo == 104 || staNo == 204) {
                if (staNo == 104 || staNo == 204 || staNo == 304) {
                    continue;
                }
                // 获取叉车站点
@@ -1704,7 +1734,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;