From 61573ae778feadd0f8ea122fd5b17c1c3b0a9f91 Mon Sep 17 00:00:00 2001 From: liuxy Date: Fri, 8 Nov 2024 17:21:53 +0800 Subject: [PATCH] =?UTF-8?q?rev=EF=BC=9A=E8=BE=93=E9=80=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/nl/acs/agv/XgAgvEnum.java | 2 + .../org/nl/acs/agv/server/AgvWaitUtil.java | 105 ++++++++++-------- .../nl/acs/agv/server/ConveyorService.java | 21 ++++ .../agv/server/impl/ConveyorServiceImpl.java | 48 ++++++++ .../server/impl/XianGongAgvServiceImpl.java | 11 +- .../java/org/nl/acs/config/AcsConfig.java | 8 ++ .../src/main/resources/log/AcsToConveyor.xml | 33 ++++++ .../src/main/resources/logback-spring.xml | 1 + .../src/main/java/org/nl/AppRun.java | 1 - lms/nladmin-ui/.env.production | 4 +- 10 files changed, 184 insertions(+), 50 deletions(-) create mode 100644 acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/ConveyorService.java create mode 100644 acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ConveyorServiceImpl.java create mode 100644 acs2/nladmin-system/src/main/resources/log/AcsToConveyor.xml diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/agv/XgAgvEnum.java b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/XgAgvEnum.java index c236972..c6b6f6c 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/acs/agv/XgAgvEnum.java +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/XgAgvEnum.java @@ -17,6 +17,8 @@ public enum XgAgvEnum { SSX_ACTION_NOT_GET_PUT(0,"不允许取放"), SSX_ACTION_GET(1,"允许取货"), SSX_ACTION_PUT(2,"允许放货"), + SSX_ACTION_GET_MOVE(3,"允许取货完成离开"), + SSX_ACTION_PUT_MOVE(4,"允许放货完成离开"), GS_ACTION_YES(1,"允许"), GS_ACTION_NOT(0,"不允许"), diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java index d86f3b9..9049d8a 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java @@ -14,6 +14,7 @@ import org.nl.acs.opc.DeviceAppService; import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.wql.core.bean.WQLObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -31,31 +32,39 @@ public class AgvWaitUtil { private DeviceExecuteLogService deviceExecuteLogService; @Autowired private TaskService taskService; + @Autowired + private ConveyorService conveyorService; + + private final String code = "BZXXL,CPJSSX"; //取货前等待 public JSONObject waitInGet(String deviceCode) { log.info("仙工AGV请求取货,设备号 - {}", deviceCode); boolean flag = false; + JSONObject jsonDevice = WQLObject.getWQLObject("acs_storage_cell").query("storage_code = '" + deviceCode + "'").uniqueResult(0); Device device = this.deviceAppService.findDeviceByCode(deviceCode); - if (ObjectUtil.isEmpty(device)) { + if (ObjectUtil.isEmpty(device) && ObjectUtil.isEmpty(jsonDevice)) { throw new BadRequestException("请求失败,未找到设备!"); } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - // 标准版输送线驱动 - StandardCoveyorControlDeviceDriver driver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); + if (code.contains(deviceCode)) { // 通知输送线申请取货-1 - driver.writing("toCommand",XgAgvEnum.APPLY_GET.getCode()); - // 判断是否满足条件:action = 1(允许取货) && move = 1(有货) - if (driver.getMove() == XgAgvEnum.SSX_ACTION_GET.getCode() && driver.getAction() == XgAgvEnum.SSX_MOVE_NO.getCode()) { + JSONObject param = new JSONObject(); + param.put("toCommand",XgAgvEnum.APPLY_GET.getCode()); + param.put("deviceCode",deviceCode); + + // 调用接口 + JSONObject result = conveyorService.applyPutAndGet(param); + + if (result.getIntValue("action") == XgAgvEnum.SSX_ACTION_GET.getCode()) { String message = "允许AGV取货。"; - driver.setMessage(message); this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); flag = true; } else { - this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", "光电信号为:" + driver.getMove()); + this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", result.getString("massage")); } + } else { flag = true; } @@ -76,26 +85,29 @@ public class AgvWaitUtil { log.info("仙工AGV取货完成后请求离开,设备号 - {}", deviceCode); boolean flag = false; + JSONObject jsonDevice = WQLObject.getWQLObject("acs_storage_cell").query("storage_code = '" + deviceCode + "'").uniqueResult(0); Device device = this.deviceAppService.findDeviceByCode(deviceCode); - if (ObjectUtil.isEmpty(device)) { + if (ObjectUtil.isEmpty(device) && ObjectUtil.isEmpty(jsonDevice)) { throw new BadRequestException("请求失败,未找到设备!"); } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - // 标准版输送线驱动 - StandardCoveyorControlDeviceDriver driver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); + if (code.contains(deviceCode)) { // 通知输送线取货完成-2 - driver.writing("toCommand",XgAgvEnum.APPLY_GET_SUCCESS.getCode()); - if (driver.getMove() == XgAgvEnum.SSX_MOVE_YES.getCode()) { + JSONObject param = new JSONObject(); + param.put("toCommand",XgAgvEnum.APPLY_GET_SUCCESS.getCode()); + param.put("deviceCode",deviceCode); + + // 调用接口 + JSONObject result = conveyorService.applyPutAndGet(param); + + if (result.getIntValue("action") == XgAgvEnum.SSX_ACTION_GET_MOVE.getCode()) { String message = "允许AGV取货后离开。"; - driver.setMessage(message); this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); flag = true; } else { - String message = "光电信号有货,不允许AGV取货后离开。"; - driver.setMessage(message); - this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); + this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", result.getString("massage")); } + } else { flag = true; } @@ -116,32 +128,34 @@ public class AgvWaitUtil { log.info("仙工AGV请求放货,设备号 - {}", deviceCode); boolean flag = false; + JSONObject jsonDevice = WQLObject.getWQLObject("acs_storage_cell").query("storage_code = '" + deviceCode + "'").uniqueResult(0); Device device = this.deviceAppService.findDeviceByCode(deviceCode); - if (ObjectUtil.isEmpty(device)) { + if (ObjectUtil.isEmpty(device) && ObjectUtil.isEmpty(jsonDevice)) { throw new BadRequestException("请求失败,未找到设备!"); } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - // 标准版输送线驱动 - StandardCoveyorControlDeviceDriver driver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); + if (code.contains(deviceCode)) { // 通知输送线申请放货-3 - driver.writing("toCommand",XgAgvEnum.APPLY_PUT.getCode()); - // 判断是否满足条件:action = 2(允许放货) && move = 0(无货) - if (driver.getMove() == XgAgvEnum.SSX_MOVE_YES.getCode() && driver.getAction() == XgAgvEnum.SSX_ACTION_PUT.getCode()) { - String message = "允许AGV放货。"; - driver.setMessage(message); - this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); - flag = true; + JSONObject param = new JSONObject(); + param.put("toCommand",XgAgvEnum.APPLY_PUT.getCode()); + param.put("deviceCode",deviceCode); + // 调用接口 + JSONObject result = conveyorService.applyPutAndGet(param); + + if (result.getIntValue("action") == XgAgvEnum.SSX_ACTION_PUT.getCode()) { if (ObjectUtil.isNotEmpty(taskDto.getIs_vehicle()) && taskDto.getIs_vehicle().equals("1")) { // 获取当前母载具号 - taskDto.setVehicle_code(driver.getBarcode()); + taskDto.setVehicle_code(result.getString("barcode")); taskService.update(taskDto); } - + String message = "允许AGV放货。"; + this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); + flag = true; } else { - this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", "光电信号为:" + driver.getMove()); + this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", result.getString("massage")); } + } else { flag = true; } @@ -163,26 +177,29 @@ public class AgvWaitUtil { log.info("仙工AGV放货完成后请求离开,设备号 - {}", deviceCode); boolean flag = false; + JSONObject jsonDevice = WQLObject.getWQLObject("acs_storage_cell").query("storage_code = '" + deviceCode + "'").uniqueResult(0); Device device = this.deviceAppService.findDeviceByCode(deviceCode); - if (ObjectUtil.isEmpty(device)) { + if (ObjectUtil.isEmpty(device) && ObjectUtil.isEmpty(jsonDevice)) { throw new BadRequestException("请求失败,未找到设备!"); } - if (device.getDeviceDriver() instanceof StandardCoveyorControlDeviceDriver) { - // 标准版输送线驱动 - StandardCoveyorControlDeviceDriver driver = (StandardCoveyorControlDeviceDriver) device.getDeviceDriver(); - // 通知输送线放货完成-4 - driver.writing("toCommand",XgAgvEnum.APPLY_PUT_SUCCESS.getCode()); - if (driver.getMove() == XgAgvEnum.SSX_MOVE_NO.getCode()) { + if (code.contains(deviceCode)) { + // 通知输送线取货完成-2 + JSONObject param = new JSONObject(); + param.put("toCommand",XgAgvEnum.APPLY_PUT_SUCCESS.getCode()); + param.put("deviceCode",deviceCode); + + // 调用接口 + JSONObject result = conveyorService.applyPutAndGet(param); + + if (result.getIntValue("action") == XgAgvEnum.SSX_ACTION_PUT_MOVE.getCode()) { String message = "允许AGV放货后离开。"; - driver.setMessage(message); this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); flag = true; } else { - String message = "光电信号有货,不允许AGV放货后离开。"; - driver.setMessage(message); - this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", message); + this.deviceExecuteLogService.deviceExecuteLog(deviceCode, "", "", result.getString("massage")); } + } else { flag = true; } diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/ConveyorService.java b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/ConveyorService.java new file mode 100644 index 0000000..2183581 --- /dev/null +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/ConveyorService.java @@ -0,0 +1,21 @@ +package org.nl.acs.agv.server; + +import com.alibaba.fastjson.JSONObject; +import org.nl.acs.ext.UnifiedResponse; +import org.nl.acs.instruction.service.dto.Instruction; + +/** + * @Author: lyd + * @Description: + * @Date: 2022-08-15 + */ +public interface ConveyorService { + /** + * 请求输送线取放货 + * + * @param json + * @return + */ + JSONObject applyPutAndGet(JSONObject json); + +} diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ConveyorServiceImpl.java b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ConveyorServiceImpl.java new file mode 100644 index 0000000..f98fdca --- /dev/null +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ConveyorServiceImpl.java @@ -0,0 +1,48 @@ +package org.nl.acs.agv.server.impl; + +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpRequest; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.nl.acs.agv.server.ConveyorService; +import org.nl.acs.config.AcsConfig; +import org.nl.modules.common.exception.BadRequestException; +import org.nl.modules.system.service.ParamService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Slf4j +@Service +@RequiredArgsConstructor +public class ConveyorServiceImpl implements ConveyorService { + + @Autowired + private ParamService paramService; + + @Override + public JSONObject applyPutAndGet(JSONObject json) { + log.info("applyPutAndGet - 请求参数 {}"+ json.toString()); + + if (!StrUtil.equals(paramService.findByCode(AcsConfig.CONVEYOR).getValue(), "1")) { + throw new BadRequestException("未连接输送线系统!"); + } + String url = paramService.findByCode(AcsConfig.CONVEYOR_URL).getValue(); + try { + /* String body = HttpRequest + .post(url) + .setConnectionTimeout(10000) + .body(JSON.toJSONString(json)) + .execute() + .body(); + log.info("applyPutAndGet - 返回参数 {}", body); + return JSON.parseObject(body);*/ + JSONObject result = new JSONObject(); + result.put("action", "1"); + return JSON.parseObject(result.toString()); + } catch (Exception e) { + throw new BadRequestException(e.getMessage()); + } + } +} diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java index aae6470..c738b9e 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java @@ -29,6 +29,7 @@ import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.dto.TaskDto; import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.system.service.ParamService; +import org.nl.modules.wql.core.bean.WQLObject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -891,11 +892,13 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { if (StrUtil.isBlank(address)) { throw new BadRequestException("请求失败,地址为空!"); } - + WQLObject tab = WQLObject.getWQLObject("acs_storage_cell"); if (address.contains("IN")) { String deviceCodeNow = address.substring(0, address.length() - 5); - if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) { + JSONObject jsonDevice = tab.query("storage_code = '" + deviceCodeNow + "'").uniqueResult(0); + + if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow)) && ObjectUtil.isEmpty(jsonDevice)) { throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!"); } @@ -907,7 +910,9 @@ public class XianGongAgvServiceImpl implements XianGongAgvService { } if (address.contains("OUT")) { String deviceCodeNow = address.substring(0, address.length() - 6); - if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) { + JSONObject jsonDevice = tab.query("storage_code = '" + deviceCodeNow + "'").uniqueResult(0); + + if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow)) && ObjectUtil.isEmpty(jsonDevice)) { throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!"); } diff --git a/acs2/nladmin-system/src/main/java/org/nl/acs/config/AcsConfig.java b/acs2/nladmin-system/src/main/java/org/nl/acs/config/AcsConfig.java index 4134c48..f0d69e1 100644 --- a/acs2/nladmin-system/src/main/java/org/nl/acs/config/AcsConfig.java +++ b/acs2/nladmin-system/src/main/java/org/nl/acs/config/AcsConfig.java @@ -77,4 +77,12 @@ public interface AcsConfig { * 自动清理日志保留时间 */ public final static String AUTO_CLEAN_DAYS = "autoCleanDays"; + /** + * 是否连接输送线 + */ + public final static String CONVEYOR = "is_conveyor"; + /** + * 输送线url + */ + public final static String CONVEYOR_URL = "conveyor_url"; } diff --git a/acs2/nladmin-system/src/main/resources/log/AcsToConveyor.xml b/acs2/nladmin-system/src/main/resources/log/AcsToConveyor.xml new file mode 100644 index 0000000..eda9e4a --- /dev/null +++ b/acs2/nladmin-system/src/main/resources/log/AcsToConveyor.xml @@ -0,0 +1,33 @@ + + + + + + + + + ${LOG_HOME}/ACS请求输送线/%d{yyyy-MM-dd}.%i.log + + 15 + + 200MB + + 2GB + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + ${log.charset} + + + + + + + + 512 + + + + + diff --git a/acs2/nladmin-system/src/main/resources/logback-spring.xml b/acs2/nladmin-system/src/main/resources/logback-spring.xml index 6d1c51d..a9a058d 100644 --- a/acs2/nladmin-system/src/main/resources/logback-spring.xml +++ b/acs2/nladmin-system/src/main/resources/logback-spring.xml @@ -25,6 +25,7 @@ https://juejin.cn/post/6844903775631572999 + diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java index ff16860..7eb59c5 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java @@ -60,7 +60,6 @@ public class AppRun { */ @SneakyThrows @GetMapping("/") - @Limit(period = 2, count = 1) @SaIgnore public String index() { // Thread.sleep(100000); diff --git a/lms/nladmin-ui/.env.production b/lms/nladmin-ui/.env.production index 65580f0..4c3227d 100644 --- a/lms/nladmin-ui/.env.production +++ b/lms/nladmin-ui/.env.production @@ -2,6 +2,6 @@ ENV = 'production' # 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇,Nginx 配置 # 接口地址,注意协议,如果你没有配置 ssl,需要将 https 改为 http -VUE_APP_BASE_API = 'http://10.93.41.201:8010' +VUE_APP_BASE_API = 'http://127.0.0.1:8011' # 如果接口是 http 形式, wss 需要改为 ws -VUE_APP_WS_API = 'ws://10.93.41.201:8010' +VUE_APP_WS_API = 'ws://127.0.0.1:8011'