#
gtsxc
2024-11-25 d8b1f82c07cf723b2590cae5a432ff78a514b05e
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/service/impl/MainServiceImpl.java
@@ -255,7 +255,32 @@
                                R result = openUtils.createInTask(createInTaskParam);
                                News.info("创建入库任务,任务数据={},WMS响应={},请求响应={}", JSON.toJSON(param), JSON.toJSON(jsonObject), JSON.toJSON(result));
                                try{
                                    String msg = "";
                                    HashMap<String, String> hashMap = new HashMap<>();
                                    hashMap.put("msg", msg);
                                    hashMap.put("sta", "31001");
                                    new HttpHandler.Builder()
                                            .setUri(wmsUrl)
                                            .setPath("/rpc/led/getError")
                                            .setJson(JSON.toJSONString(hashMap))
                                            .build()
                                            .doPost();
                                }catch (Exception e){
                                }
                            }else {
                                String msg = jsonObject.getString("msg");
                                HashMap<String, String> hashMap = new HashMap<>();
                                hashMap.put("msg", msg);
                                hashMap.put("sta", "31001");
                                new HttpHandler.Builder()
                                        .setUri(wmsUrl)
                                        .setPath("/rpc/led/getError")
                                        .setJson(JSON.toJSONString(hashMap))
                                        .build()
                                        .doPost();
                                News.error("入库申请失败,任务数据={},请求响应={}", JSON.toJSON(param), JSON.toJSON(jsonObject));
                            }
                        } catch (Exception e) {
@@ -905,7 +930,7 @@
                    .eq(BasLed::getDeviceId, ledDevice.getId()));
            List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class);
            BasConveyor basConveyor = basConveyorService.getById(new LambdaQueryWrapper<BasConveyor>()
            BasConveyor basConveyor = basConveyorService.getOne(new LambdaQueryWrapper<BasConveyor>()
                    .eq(BasConveyor::getDeviceId, led.getConveyorId().intValue()));
            if (basConveyor == null) {
                continue;
@@ -920,27 +945,24 @@
            for (Integer staNo : staArr) {
                // 获取叉车站点
                StaProtocol staProtocol = devpThread.getStation().get(staNo);
                if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) {
                if (null == staProtocol || null == staProtocol.getWorkNo()) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                // 获取工作档数据
                Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, staProtocol.getWorkNo()));
                if (null == task) {
                if (!staProtocol.isOutEnable()){
                    continue;
                }
                tasks.add(task);
                // 组装命令
                LedCommand ledCommand = new LedCommand();
                ledCommand.setWorkNo(task.getTaskNo());
                ledCommand.setIoType(task.getTaskCtg().intValue());
                ledCommand.setTitle(task.getTaskCtg$());
                ledCommand.setSourceLocNo(task.getOriginLoc());
                ledCommand.setLocNo(task.getDestLoc());
                ledCommand.setStaNo(Integer.parseInt(task.getDestSite()));
                String taskNo = "0";
                if (0 != staProtocol.getWorkNo()){
                    Motion motion = motionService.getOne(new LambdaQueryWrapper<Motion>().eq(Motion::getMotionCtg, 9).eq(Motion::getTemp, staProtocol.getWorkNo()));
                    // 获取工作档数据
                    Task task = taskService.getOne(new LambdaQueryWrapper<Task>().eq(Task::getTaskNo, motion.getTaskNo()));
                    if (null == task) {
                        continue;
                    }
                    taskNo = task.getWmsTaskNo();
                }
                try {
                    //获取WMS地址
                    Dict dict = dictService.getOne(new LambdaQueryWrapper<Dict>().eq(Dict::getFlag, "WMS_URL").eq(Dict::getStatus, 1));
@@ -948,32 +970,23 @@
                        String wmsUrl = dict.getValue();
                        HashMap<String, Object> param = new HashMap<>();
                        param.put("taskNo", task.getTaskNo());
                        param.put("taskNo", taskNo);
                        param.put("sta",staNo);
                        String response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath("/queryTask")
                                .setPath("/rpc/led/getTask")
                                .setJson(JSON.toJSONString(param))
                                .build()
                                .doPost();
                        JSONObject jsonObject = JSON.parseObject(response);
                        Integer code = jsonObject.getInteger("code");
                        if (code.equals(200)) {
                            List<MatDto> matDtos = JSON.parseArray(jsonObject.getString("data"), MatDto.class);
                            ledCommand.setMatDtos(matDtos);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                commands.add(ledCommand);
            }
            // 获取LED线程
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, ledDevice.getId().intValue());
            // 命令下发 -------------------------------------------------------------------------------
            if (!commands.isEmpty()) {
                ledThread.write(commands);
                ledThread.setLedMk(false);
            }
        }
    }