From 93053fd08626c3ab9439c858e09babab7b93fe86 Mon Sep 17 00:00:00 2001 From: "USER-20220102CG\\noblelift" <546428999@qq.com> Date: Fri, 11 Nov 2022 08:50:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agv/server/impl/ZheDaAgvServiceImpl.java | 29 +++--- .../service/impl/InstructionServiceImpl.java | 15 ++- ...atus.java => QueryOneZDAgvTaskStatus.java} | 67 +------------ .../quartz/task/QueryTwoZDAgvTaskStatus.java | 95 +++++++++++++++++++ .../src/main/resources/logback-spring.xml | 2 +- acs/nladmin-ui/.env.production | 4 +- acs/nladmin-ui/public/config.js | 4 +- 7 files changed, 127 insertions(+), 89 deletions(-) rename acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/{QueryZDAgvTaskStatus.java => QueryOneZDAgvTaskStatus.java} (55%) create mode 100644 acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryTwoZDAgvTaskStatus.java diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java index 8787ab4..e712b1d 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ZheDaAgvServiceImpl.java @@ -77,9 +77,9 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService { //不同楼层下发不同的agv系统 if (task_type.equals("1")) { - agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst.getInstruction_code(); + agvurl = agvurl + ":" + agvport + "/rmds/v1/transportOrders/" + inst.getInstruction_code(); } else { - agvurl = agvurl2 + ":" + agvport2 + "/v1/transportOrders/" + inst.getInstruction_code(); + agvurl = agvurl2 + ":" + agvport2 + "/rmds/v1/transportOrders/" + inst.getInstruction_code(); } log.info("下发agv任务请求:{}", agvurl); log.info("下发agv任务参数:{}", jo.toString()); @@ -111,8 +111,9 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService { agvport = paramService.findByCode(AcsConfig.AGVPORT2).getValue(); } - agvurl = agvurl + ":" + agvport + "/v1/transportOrders"; - HttpResponse result = HttpRequest.get(agvurl) + agvurl = agvurl + ":" + agvport + "/rmds/v1/transportOrders/query"; + HttpResponse result = HttpRequest.post(agvurl) + .body("{}") .timeout(20000)//超时,毫秒 .execute(); @@ -283,7 +284,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService { String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - String url = agvurl + ":" + agvport + "/addDestinations"; + String url = agvurl + ":" + agvport + "/rmds/addDestinations"; log.info("下发agv任务请求:{}", url); HttpResponse result = HttpRequest.post(url) @@ -425,7 +426,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService { String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); - agvurl = agvurl + ":" + agvport + "/v1/" + code + "/markComplete"; + agvurl = agvurl + ":" + agvport + "/rmds/v1/" + code + "/markComplete"; log.info("关闭agv运单序列请求:{}", agvurl); HttpResponse result = HttpRequest.post(agvurl) @@ -473,7 +474,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService { properties.add(pro1); JSONObject pro2 = new JSONObject(); pro2.put("key", "PauseOnStation"); - pro2.put("value", "True"); + pro2.put("value", "true"); properties.add(pro2); destinationOrder.put("properties", properties); //进入等待 离开不等待 @@ -481,11 +482,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService { JSONArray properties = new JSONArray(); JSONObject pro1 = new JSONObject(); pro1.put("key", "EntryRequired"); - pro1.put("value", "True"); + pro1.put("value", "true"); properties.add(pro1); JSONObject pro2 = new JSONObject(); pro2.put("key", "PauseOnStation"); - pro2.put("value", "False"); + pro2.put("value", "false"); properties.add(pro2); destinationOrder.put("properties", properties); //进入不等待 离开等待 @@ -493,11 +494,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService { JSONArray properties = new JSONArray(); JSONObject pro1 = new JSONObject(); pro1.put("key", "EntryRequired"); - pro1.put("value", "False"); + pro1.put("value", "false"); properties.add(pro1); JSONObject pro2 = new JSONObject(); pro2.put("key", "PauseOnStation"); - pro2.put("value", "True"); + pro2.put("value", "true"); properties.add(pro2); destinationOrder.put("properties", properties); //不等待 @@ -505,11 +506,11 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService { JSONArray properties = new JSONArray(); JSONObject pro1 = new JSONObject(); pro1.put("key", "EntryRequired"); - pro1.put("value", "False"); + pro1.put("value", "false"); properties.add(pro1); JSONObject pro2 = new JSONObject(); pro2.put("key", "PauseOnStation"); - pro2.put("value", "False"); + pro2.put("value", "false"); properties.add(pro2); destinationOrder.put("properties", properties); } @@ -547,7 +548,7 @@ public class ZheDaAgvServiceImpl implements ZheDaAgvService { JSONArray properties = new JSONArray(); JSONObject pro1 = new JSONObject(); pro1.put("key", "Wait"); - pro1.put("value", "True"); + pro1.put("value", "true"); properties.add(pro1); destinationOrder.put("properties", properties); } diff --git a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java index 4fc1598..dfcd21a 100644 --- a/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java +++ b/acs/nladmin-system/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java @@ -7,6 +7,7 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import lombok.RequiredArgsConstructor; @@ -378,13 +379,17 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu if (StrUtil.equals(route.getType(), "1")) { ZheDaAgvService zheDaAgvService = SpringContextHolder.getBean(ZheDaAgvService.class); HttpResponse result = zheDaAgvService.sendAgvInstToAgv(dto); - if (ObjectUtils.isEmpty(result) || result.getStatus() != 200) { - dto.setSend_status("2"); + if (!ObjectUtils.isEmpty(result)) { + JSONObject jo = JSON.parseObject(result.body()); + if(jo.getInteger("status") != 200){ + dto.setSend_status("2"); + } else { + dto.setSend_status("1"); + } } else { - dto.setSend_status("1"); + dto.setSend_status("2"); } } - } catch (Exception e) { dto.setSend_status("2"); e.printStackTrace(); @@ -942,6 +947,8 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu } else { flag = true; } + } else { + flag = true; } if (flag) { diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryZDAgvTaskStatus.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryOneZDAgvTaskStatus.java similarity index 55% rename from acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryZDAgvTaskStatus.java rename to acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryOneZDAgvTaskStatus.java index 668a57c..13e762b 100644 --- a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryZDAgvTaskStatus.java +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryOneZDAgvTaskStatus.java @@ -21,7 +21,7 @@ import java.util.List; */ @Slf4j @Component -public class QueryZDAgvTaskStatus { +public class QueryOneZDAgvTaskStatus { @Autowired InstructionService instructionService; @@ -58,71 +58,6 @@ public class QueryZDAgvTaskStatus { // WITHDRAWN:业务订单已被撤销 // FINISHED:业务订单已完成 // FAILED:业务订单已失败 -// UNROUTABLE:无法规划该业务订单的执行路线 - - //执行中 - if ("BEING_PROCESSED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("1"); - instructionService.update(inst); - } - } else if ("FINISHED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("2"); - instructionService.finish(inst); - } - } else if ("WITHDRAWN".equals(state) || "FAILED".equals(state)) { - if (inst != null) { - inst.setInstruction_status("3"); - instructionService.update(inst); - instructionService.removeByCodeFromCache(inst_jo.getString("task_code")); - } - } - JSONArray ja = inst_jo.getJSONArray("destinations"); - for (int j = 0; j < ja.size(); j++) { - JSONObject jo = ja.getJSONObject(j); - JSONArray pro_rows = jo.getJSONArray("properties"); - //Load 取货动作 Unload放货动作 Wait等待 - String operation = jo.getString("operation"); - String device = jo.getString("locationName"); - for (int k = 0; k < pro_rows.size(); k++) { - JSONObject item = pro_rows.getJSONObject(k); - if ("True".equals(item.get("value"))) { - String param = item.get("key").toString(); - //EntryRequired是否进入前等待 PauseOnStation是否离开等待 Wait在该点进行等待 - agvService.process(inst_code, param, device, operation, vehicle); - } - } - } - } - - HttpResponse response2 = agvService.queryAgvInstStatus("2"); - //查询AGV指令列表 - JSONArray inst_rows2 = JSONArray.parseArray(response2.body()); - for (int i = 0; i < inst_rows2.size(); i++) { - JSONObject inst_jo = inst_rows2.getJSONObject(i); - String inst_code = inst_jo.getString("task_code"); - Instruction inst = instructionService.findByCodeFromCache(inst_code); - if (ObjectUtil.isEmpty(inst)){ - continue; - } - //反馈结果状态 - log.info("instcode:" + inst_code + "," + inst_jo.toString()); - - String state = inst_jo.getString("state"); - String vehicle = ""; - //正在执行指令agv车号 - if (!StrUtil.isEmpty(inst_jo.getString("vehicle"))) { - vehicle = inst_jo.getString("vehicle"); - inst.setCarno(vehicle); - } -// RAW:初始状态 -// ACTIVE:业务订单已激活 -// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行 -// BEING_PROCESSED:业务订单正在被执行 -// WITHDRAWN:业务订单已被撤销 -// FINISHED:业务订单已完成 -// FAILED:业务订单已失败 // UNROUTABLE:无法规划该业务订单的执行路线 //执行中 diff --git a/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryTwoZDAgvTaskStatus.java b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryTwoZDAgvTaskStatus.java new file mode 100644 index 0000000..cffc142 --- /dev/null +++ b/acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryTwoZDAgvTaskStatus.java @@ -0,0 +1,95 @@ +package org.nl.modules.quartz.task; + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpResponse; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.agv.server.ZheDaAgvService; +import org.nl.acs.instruction.service.InstructionService; +import org.nl.acs.instruction.service.dto.Instruction; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * 查询AGV任务状态 + */ +@Slf4j +@Component +public class QueryTwoZDAgvTaskStatus { + + @Autowired + InstructionService instructionService; + + @Autowired + ZheDaAgvService agvService; + + + public void run() throws Exception { + HttpResponse response2 = agvService.queryAgvInstStatus("2"); + //查询AGV指令列表 + JSONArray inst_rows2 = JSONArray.parseArray(response2.body()); + for (int i = 0; i < inst_rows2.size(); i++) { + JSONObject inst_jo = inst_rows2.getJSONObject(i); + String inst_code = inst_jo.getString("task_code"); + Instruction inst = instructionService.findByCodeFromCache(inst_code); + if (ObjectUtil.isEmpty(inst)){ + continue; + } + //反馈结果状态 + log.info("instcode:" + inst_code + "," + inst_jo.toString()); + + String status = inst_jo.getString("status"); + String vehicle = ""; + //正在执行指令agv车号 + if (!StrUtil.isEmpty(inst_jo.getString("vehicle"))) { + vehicle = inst_jo.getString("vehicle"); + inst.setCarno(vehicle); + } +// RAW:初始状态 +// ACTIVE:业务订单已激活 +// DISPATCHABLE:业务订单已通过系统验证,等待被调度执行 +// BEING_PROCESSED:业务订单正在被执行 +// WITHDRAWN:业务订单已被撤销 +// FINISHED:业务订单已完成 +// FAILED:业务订单已失败 +// UNROUTABLE:无法规划该业务订单的执行路线 + + //执行中 + if ("BEING_PROCESSED".equals(status) || "ACTIVE".equals(status)) { + if (inst != null) { + inst.setInstruction_status("1"); + instructionService.update(inst); + } + } else if ("FINISHED".equals(status)) { + if (inst != null) { + inst.setInstruction_status("2"); + instructionService.finish(inst); + } + } else if ("WITHDRAWN".equals(status) || "FAILED".equals(status)) { + if (inst != null) { + inst.setInstruction_status("3"); + instructionService.update(inst); + instructionService.removeByCodeFromCache(inst_jo.getString("task_code")); + } + } + JSONArray ja = inst_jo.getJSONArray("destinations"); + for (int j = 0; j < ja.size(); j++) { + JSONObject jo = ja.getJSONObject(j); + JSONArray pro_rows = jo.getJSONArray("properties"); + //Load 取货动作 Unload放货动作 Wait等待 + String operation = jo.getString("operation"); + String device = jo.getString("locationName"); + for (int k = 0; k < pro_rows.size(); k++) { + JSONObject item = pro_rows.getJSONObject(k); + if ("True".equals(item.get("value"))) { + String param = item.get("key").toString(); + //EntryRequired是否进入前等待 PauseOnStation是否离开等待 Wait在该点进行等待 + agvService.process(inst_code, param, device, operation, vehicle); + } + } + } + } + } +} diff --git a/acs/nladmin-system/src/main/resources/logback-spring.xml b/acs/nladmin-system/src/main/resources/logback-spring.xml index 4edd8e5..141fb0f 100644 --- a/acs/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs/nladmin-system/src/main/resources/logback-spring.xml @@ -136,7 +136,7 @@ https://juejin.cn/post/6844903775631572999 - + diff --git a/acs/nladmin-ui/.env.production b/acs/nladmin-ui/.env.production index 786bd42..c9271ca 100644 --- a/acs/nladmin-ui/.env.production +++ b/acs/nladmin-ui/.env.production @@ -2,6 +2,6 @@ ENV = 'production' # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置 # 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http -VUE_APP_BASE_API = 'http://47.97.157.227:8010' +VUE_APP_BASE_API = 'http://192.168.4.116:8010' # 如果接口是 http 形式, wss 需要改为 ws -VUE_APP_WS_API = 'ws://47.97.157.227:8010' +VUE_APP_WS_API = 'ws://192.168.4.116:8010' diff --git a/acs/nladmin-ui/public/config.js b/acs/nladmin-ui/public/config.js index c4d32ea..02064e3 100644 --- a/acs/nladmin-ui/public/config.js +++ b/acs/nladmin-ui/public/config.js @@ -1,9 +1,9 @@ window.g = { dev: { - VUE_APP_BASE_API: 'http://127.0.0.1:8010' + VUE_APP_BASE_API: 'http://192.168.4.116:8010' }, prod: { - VUE_APP_BASE_API: 'http://127.0.0.1:8010' + VUE_APP_BASE_API: 'http://192.168.4.1168010' }