From 3d7c5a7c0f2f1642b228263867bcd4fa113bf5b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=B1=9F=E7=8E=AE?= Date: Wed, 11 Oct 2023 09:22:32 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E8=AF=B7=E6=B1=82=E5=8F=96=E6=94=BE?= =?UTF-8?q?=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/nl/acs/agv/server/AgvWaitUtil.java | 26 +----- .../acs/agv/server/impl/AgvServiceImpl.java | 40 ++++---- .../service/impl/InstructionServiceImpl.java | 18 ++-- .../quartz/task/QueryXZAgvTaskStatus.java | 93 ++++++++++--------- .../resources/config/application-prod.yml | 2 +- 5 files changed, 87 insertions(+), 92 deletions(-) diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java index d5a1275..b6fe091 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java @@ -23,9 +23,6 @@ import org.springframework.stereotype.Service; @RequiredArgsConstructor @Slf4j public class AgvWaitUtil { - private final DeviceAppService deviceAppService; - private final AcsToWmsZDServiceImpl acsToWmsZDService; - private final InstructionService instructionService; private final AcsToWmsService acsToWmsService; @Autowired LogServer logServer; @@ -107,23 +104,10 @@ public class AgvWaitUtil { public JSONObject waitOutPut(String endDeviceCode, Instruction inst) { log.info("仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode); - JSONObject responseBody = acsToWmsService.gccQueryStationState(inst); - - if (ObjectUtil.isNotEmpty(responseBody) && 200 == responseBody.optInt("status")) { - JSONArray data = responseBody.optJSONArray("data"); - for (int i = 0; i < data.size(); i++) { - JSONObject datum = data.getJSONObject(i); - if (endDeviceCode.equals(datum.optString("Station_Code")) - && datum.optBoolean("IsHasGoods")) { - JSONObject map = new JSONObject(); - map.put("status", 200); - map.put("message", "允许离开!"); - log.info("允许仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode); - return map; - } - } - } - - throw new BadRequestException("请求失败!"); + JSONObject map = new JSONObject(); + map.put("status", 200); + map.put("message", "允许离开!"); + log.info("允许仙工AGV放货完成后请求离开,设备号 - {}", endDeviceCode); + return map; } } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java index 16cf76e..4ba7d66 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java @@ -2181,26 +2181,26 @@ public class AgvServiceImpl implements AgvService { jo4.put("operation", "JackUnload"); ja.add(jo4); -// if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) { -// //放货完成等待 -// com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject(); -// jo5.put("blockId", IdUtil.simpleUUID()); -// jo5.put("location", inst.getNext_point_code() + "OUTPUT"); -// jo5.put("operation", "script"); -// jo5.put("id", inst.getNext_point_code() + "OUTPUT"); -// jo5.put("script_name", "userpy/interact.py"); -// com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject(); -// script_args5.put("addr", addr); -// com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject(); -// com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject(); -// reach5.put("task_code", inst.getInstruction_code()); -// reach5.put("address", inst.getNext_point_code() + "OUTPUT"); -// data5.put("reach", reach5); -// script_args5.put("data", data5); -// script_args5.put("protocol", "HTTP"); -// jo5.put("script_args", script_args5); -// ja.add(jo5); -// } + if ("true".equals(nextDevice.getExtraValue().get("ignore_release_check"))) { + //放货完成等待 + com.alibaba.fastjson.JSONObject jo5 = new com.alibaba.fastjson.JSONObject(); + jo5.put("blockId", IdUtil.simpleUUID()); + jo5.put("location", inst.getNext_point_code() + "OUTPUT"); + jo5.put("operation", "script"); + jo5.put("id", inst.getNext_point_code() + "OUTPUT"); + jo5.put("script_name", "userpy/interact.py"); + com.alibaba.fastjson.JSONObject script_args5 = new com.alibaba.fastjson.JSONObject(); + script_args5.put("addr", addr); + com.alibaba.fastjson.JSONObject data5 = new com.alibaba.fastjson.JSONObject(); + com.alibaba.fastjson.JSONObject reach5 = new com.alibaba.fastjson.JSONObject(); + reach5.put("task_code", inst.getInstruction_code()); + reach5.put("address", inst.getNext_point_code() + "OUTPUT"); + data5.put("reach", reach5); + script_args5.put("data", data5); + script_args5.put("protocol", "HTTP"); + jo5.put("script_args", script_args5); + ja.add(jo5); + } return ja; } diff --git a/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 9304df6..a4c35d5 100644 --- a/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/hd/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -53,6 +53,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.*; import java.util.regex.Pattern; +import java.util.stream.Collectors; /** * @author ldjun @@ -64,7 +65,7 @@ import java.util.regex.Pattern; @Slf4j public class InstructionServiceImpl implements InstructionService, ApplicationAutoInitial { - List instructions = new ArrayList(); + List instructions = new ArrayList<>(); @Autowired DeviceAppService deviceAppService; @@ -1212,12 +1213,15 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu @Override public Instruction findByInstCodeFromCache(String inst_code) { - for (int i = 0; i < this.instructions.size(); i++) { - Instruction inst = instructions.get(i); - if (StrUtil.equals(inst_code, inst.getInstruction_code())) { - return inst; - } + if (StrUtil.isBlank(inst_code)) { + return null; + } + + List list = this.instructions.stream().filter(i -> inst_code.equals(i.getInstruction_code())).collect(Collectors.toList()); + if (list.isEmpty()) { + return null; + } else { + return list.get(0); } - return null; } } diff --git a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java index 1a0d644..34f5cd6 100644 --- a/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java +++ b/hd/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvTaskStatus.java @@ -1,6 +1,5 @@ package org.nl.modules.quartz.task; -import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpResponse; @@ -15,8 +14,6 @@ import org.nl.acs.task.service.TaskService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import java.util.List; - /** * 查询AGV任务状态 */ @@ -36,33 +33,39 @@ public class QueryXZAgvTaskStatus { @Autowired TaskService taskService; - public void run() throws Exception { + private boolean lock = false; - HttpResponse response = agvService.queryXZAgvInstStatus(); - com.alibaba.fastjson.JSONObject jo = JSONArray.parseObject(response.body()); + public void run() throws Exception { - JSONArray ja = JSONArray.parseArray(jo.getString("list")); - for (int i = 0; i < ja.size(); i++) { - com.alibaba.fastjson.JSONObject one = (com.alibaba.fastjson.JSONObject) ja.get(i); - String inst_code = one.getString("id"); - Instruction inst = instructionService.findByInstCodeFromCache(inst_code); - if (ObjectUtil.isEmpty(inst)) - continue; - //子任务状态 待以后处理 - JSONArray blocks = JSONArray.parseArray(one.getString("blocks")); - for(int j=0;j