1
zhang
2025-06-05 c48d0150aa9f6b297671f28adb6b9dc95b529cfc
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -95,6 +95,8 @@
    @Autowired
    private WaitPakinMapper waitPakinMapper;
    private Map<String, Integer> flagData = new HashMap<>();
    /**
     * 组托
     * 入库站,根据条码扫描生成入库工作档,工作状态 2
@@ -225,6 +227,7 @@
                        JSONObject jsonObject = JSON.parseObject(response);
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                        Integer code = jsonObject.getInteger("code");
                        Object redata = jsonObject.get("data");
                        if (code.equals(200)) {
                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                            // plc 处理
@@ -258,40 +261,82 @@
                                String errorMsg = barcode + "托盘识别异常,请先进行组托!";
                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                            }
                        } else if (code == 500 || code == 1000) {
                            if (inSta.getStaNo().equals(103)) {
                                staProtocol.setWorkNo((short) 9996);
                                staProtocol.setStaNo((short) 203);
                            }
                            if (inSta.getStaNo().equals(203)) {
                                staProtocol.setWorkNo((short) 9996);
                                staProtocol.setStaNo((short) 103);
                            }
                            if (inSta.getStaNo().equals(113)) {
                                staProtocol.setWorkNo((short) 9995);
                                staProtocol.setStaNo((short) 114);
                            } else if (inSta.getStaNo().equals(213)) {
                                staProtocol.setWorkNo((short) 9995);
                                staProtocol.setStaNo((short) 214);
                            }
                        } else if (redata.toString().contains("物料类型和实际种类不一致")||redata.toString().contains("混放物料类型不一致")) {
                            staProtocol.setWorkNo((short) 9995);
                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            String data = jsonObject.getString("data");
                            String msg = jsonObject.getString("msg");
                            if (code == 500) {
                                // led 异常显示
                                if (ledThread != null) {
                                    String errorMsg = "入库站:" + staProtocol.getStaNo() + "---" + barcode + "检索库位失败,请检查库存剩余。===>>" + data + "--" + msg;
                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                                }
                            } else if (code == 1000) {
                                // led 异常显示
                                if (ledThread != null) {
                                    String errorMsg = "入库站:" + staProtocol.getStaNo() + "---" + barcode + "需要换入库站。";
                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                            // led 异常显示
                            if (ledThread != null) {
                                String errorMsg = barcode + redata.toString();
                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                            }
                        }else if (redata.toString().startsWith("800")){
                            staProtocol.setWorkNo((short) 9995);
                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            // led 异常显示
                            if (ledThread != null) {
                                String errorMsg = barcode + "库位不足";
                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                            }
                        } else if ((code == 500 || code == 1000)) {
                            if (redata != null && redata.toString().startsWith("800")) {
                                Integer num = flagData.get(param.getBarcode());
                                if (num != null) {
                                    flagData.put(param.getBarcode(), num + 1);
                                } else {
                                    flagData.put(param.getBarcode(), 1);
                                }
                            }
                            if (flagData.get(param.getBarcode()) != null && flagData.get(param.getBarcode()) >= 2) {
                                staProtocol.setWorkNo((short) 9995);
                                staProtocol.setStaNo(inSta.getBackSta().shortValue());
                                devpThread.setPakMk(staProtocol.getSiteId(), false);
                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                                // led 异常显示
                                if (ledThread != null && redata != null) {
                                    String errorMsg = barcode + redata.toString();
                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                                }
                            } else {
                                if (inSta.getStaNo().equals(103)) {
                                    staProtocol.setWorkNo((short) 9998);
                                    staProtocol.setStaNo((short) 203);
                                }
                                if (inSta.getStaNo().equals(203)) {
                                    staProtocol.setWorkNo((short) 9996);
                                    staProtocol.setStaNo((short) 103);
                                }
                                if (inSta.getStaNo().equals(113)) {
                                    staProtocol.setWorkNo((short) 9995);
                                    staProtocol.setStaNo((short) 114);
                                } else if (inSta.getStaNo().equals(213)) {
                                    staProtocol.setWorkNo((short) 9995);
                                    staProtocol.setStaNo((short) 214);
                                }
                                devpThread.setPakMk(staProtocol.getSiteId(), false);
                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                                String data = jsonObject.getString("data");
                                String msg = jsonObject.getString("msg");
                                if (code == 500) {
                                    // led 异常显示
                                    if (ledThread != null) {
                                        String errorMsg = "入库站:" + staProtocol.getStaNo() + "---" + barcode + "检索库位失败,请检查库存剩余。===>>" + data + "--" + msg;
                                        MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                                    }
                                } else if (code == 1000) {
                                    // led 异常显示
                                    if (ledThread != null) {
                                        String errorMsg = "入库站:" + staProtocol.getStaNo() + "---" + barcode + "需要换入库站。";
                                        MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                                    }
                                }
                            }
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
@@ -1195,7 +1240,8 @@
                                    // 没有作业中的入库任务时,才能生成移库任务
                                    WrkMast one2 = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
                                            .eq("crn_no", slave.getId())
                                            .last(" and wrk_sts in (3,4,5,6,7,8)"));
                                            .eq("source_loc_no", shallowLocNo));
                                            //.last(" and wrk_sts in (3,4,5,6,7,8)"));
                                    if (one2 == null) {
                                        moveLocForDeepLoc(slave, shallowLoc);
                                        // 置顶任务
@@ -2809,7 +2855,7 @@
    /**
     * 让小车从 远点 ====>> 待机
     *  等待堆垛机搬运
     * 等待堆垛机搬运
     */
    public synchronized void letCarBeWaiting(WrkMast wrkMast, Integer steNo, String locNo) {
        // 获取穿梭车信息
@@ -2893,7 +2939,7 @@
    /**
     * 让小车从 远点 ====>> 移动到近点
     *  等待堆垛机搬运
     * 等待堆垛机搬运
     */
    public synchronized void letCarBeReady(WrkMast wrkMast, Integer steNo, String locNo) {
        // 获取穿梭车信息
@@ -2937,7 +2983,7 @@
    /**
     * 让小车从 远点 ====>> 移动到近点
     *  等待堆垛机搬运
     * 等待堆垛机搬运
     */
    public synchronized void letCarBeReady(WrkCharge wrkCharge, Integer steNo) {
        // 获取穿梭车信息