Browse Source

rev:输送接口

master
刘先源 2 weeks ago
parent
commit
61573ae778
  1. 2
      acs2/nladmin-system/src/main/java/org/nl/acs/agv/XgAgvEnum.java
  2. 105
      acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvWaitUtil.java
  3. 21
      acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/ConveyorService.java
  4. 48
      acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/ConveyorServiceImpl.java
  5. 11
      acs2/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java
  6. 8
      acs2/nladmin-system/src/main/java/org/nl/acs/config/AcsConfig.java
  7. 33
      acs2/nladmin-system/src/main/resources/log/AcsToConveyor.xml
  8. 1
      acs2/nladmin-system/src/main/resources/logback-spring.xml
  9. 1
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/AppRun.java
  10. 4
      lms/nladmin-ui/.env.production

2
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,"不允许"),

105
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;
}

21
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);
}

48
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());
}
}
}

11
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 + " 不存在!");
}

8
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";
}

33
acs2/nladmin-system/src/main/resources/log/AcsToConveyor.xml

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<included>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<property name="LOG_HOME" value="${logPath}"/>
<!-- 按照每天生成日志文件 -->
<appender name="ConveyorServiceImpl" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/ACS请求输送线/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>200MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>${log.charset}</charset>
</encoder>
</appender>
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="ConveyorServiceImpl"/>
<!-- 设置队列大小,根据您的需求调整 -->
<queueSize>512</queueSize>
</appender>
<logger name="org.nl.acs.agv.server.impl.ConveyorServiceImpl" level="info" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
</included>

1
acs2/nladmin-system/src/main/resources/logback-spring.xml

@ -25,6 +25,7 @@ https://juejin.cn/post/6844903775631572999
<include resource="log/WmsToAcs.xml"/>
<include resource="log/XgToAcs.xml"/>
<include resource="log/AcsToXg.xml"/>
<include resource="log/AcsToConveyor.xml"/>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<!--withJansi 参数改为true-->

1
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);

4
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'

Loading…
Cancel
Save