rev:自动门

This commit is contained in:
2026-01-31 20:50:46 +08:00
parent 26466cee21
commit dd05b1abea
20 changed files with 143 additions and 455 deletions

View File

@@ -3,9 +3,9 @@ package org.nl.acs.agv.hk;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.agv.hk.log.ToOthersInterfaceLog;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Component;
* @Date 2024/4/22
*/
@Component
@Slf4j
public class HkHttpUtil {
private static final RequestAdapter REQUEST_ADAPTER = new HkRequestAdapter();
@@ -24,11 +25,11 @@ public class HkHttpUtil {
@Autowired
private ISysParamService paramService;
@ToOthersInterfaceLog("ACS->HK")
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam, Class<T> type) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
}
log.info("sendPostRequest-----请求参数{}", requestParam.toString());
try {
String body = HttpRequest
.post(REQUEST_ADAPTER.getUrl() + path)
@@ -36,17 +37,18 @@ public class HkHttpUtil {
.body(JSON.toJSONString(requestParam))
.execute()
.body();
log.info("sendPostRequest-----返回参数{}", body);
return RESPONSE_ADAPTER.adapt(body, type);
} catch (Exception e) {
return new UnifiedResponse<>(false, e.getMessage());
}
}
@ToOthersInterfaceLog("ACS->HK")
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
}
log.info("sendPostRequest-----请求参数{}", requestParam.toString());
try {
String body = HttpRequest
.post(REQUEST_ADAPTER.getUrl() + path)
@@ -54,13 +56,13 @@ public class HkHttpUtil {
.body(JSON.toJSONString(requestParam))
.execute()
.body();
log.info("sendPostRequest-----返回参数{}", body);
return RESPONSE_ADAPTER.adapt(body, null);
} catch (Exception e) {
return new UnifiedResponse<>(false, e.getMessage());
}
}
@ToOthersInterfaceLog("ACS->HK")
public <T> UnifiedResponse<T> sendPostRequest(String path, Class<T> type) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
@@ -77,7 +79,6 @@ public class HkHttpUtil {
}
}
@ToOthersInterfaceLog("ACS->HK")
public <T> UnifiedResponse<T> sendPostRequest(String path) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
@@ -94,7 +95,6 @@ public class HkHttpUtil {
}
}
@ToOthersInterfaceLog("ACS->HK")
public <T> UnifiedResponse<T> sendGetRequest(String path, Class<T> type) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
@@ -111,7 +111,6 @@ public class HkHttpUtil {
}
}
@ToOthersInterfaceLog("ACS->HK")
public <T> UnifiedResponse<T> sendGetRequest(String path) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HAS_HK).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");

View File

@@ -1,109 +0,0 @@
package org.nl.acs.agv.hk.log;
import com.alibaba.fastjson.JSON;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.nl.acs.agv.hk.utils.IpUtil;
import org.nl.common.exception.BadRequestException;
import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.lucene.dto.LuceneLogDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.*;
import java.lang.reflect.Method;
/**
* @Description TODO
* @Author Gengby
* @Date 2024/7/8
*/
@Aspect
@Component
public class OtherToInterfaceLogAspect {
@Autowired
private LuceneExecuteLogService logService;
@Around("@annotation(org.nl.acs.ext.hk.log.OthersToInterfaceLog)")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
Class<?> targetClass = joinPoint.getTarget().getClass();
RequestMapping classRequestMapping = targetClass.getAnnotation(RequestMapping.class);
String classUrlValue = classRequestMapping != null ? String.join(",", classRequestMapping.value()) : "No Class Annotation";
String methodUrlValue = "";
if (method.isAnnotationPresent(GetMapping.class)) {
GetMapping getMapping = method.getAnnotation(GetMapping.class);
methodUrlValue = String.join(",", getMapping.value());
} else if (method.isAnnotationPresent(PostMapping.class)) {
PostMapping postMapping = method.getAnnotation(PostMapping.class);
methodUrlValue = String.join(",", postMapping.value());
} else if (method.isAnnotationPresent(PutMapping.class)) {
PutMapping putMapping = method.getAnnotation(PutMapping.class);
methodUrlValue = String.join(",", putMapping.value());
} else if (method.isAnnotationPresent(DeleteMapping.class)) {
DeleteMapping deleteMapping = method.getAnnotation(DeleteMapping.class);
methodUrlValue = String.join(",", deleteMapping.value());
} else if (method.isAnnotationPresent(RequestMapping.class)) {
RequestMapping methodRequestMapping = method.getAnnotation(RequestMapping.class);
methodUrlValue = String.join(",", methodRequestMapping.value());
}
String request_direction = "";
if (method.isAnnotationPresent(OthersToInterfaceLog.class)) {
OthersToInterfaceLog interfaceLog = method.getAnnotation(OthersToInterfaceLog.class);
request_direction = interfaceLog.value();
}
String methodName = joinPoint.getSignature().getName();
Object[] args = joinPoint.getArgs();
LuceneLogDto logDto =
LuceneLogDto.builder()
.logType("接口日志")
.request_url(IpUtil.localIP() + classUrlValue + methodUrlValue)
.request_direction(request_direction)
.request_param(JSON.toJSONString(args))
.method(methodName)
.content("开始请求")
.build();
logService.interfaceExecuteLog(logDto);
Object result = null;
try {
result = joinPoint.proceed();
} catch (Exception e) {
logDto =
LuceneLogDto.builder()
.logType("接口日志")
.request_url(IpUtil.localIP() + classUrlValue + methodUrlValue)
.request_direction(request_direction)
.request_param(JSON.toJSONString(args))
.method(methodName)
.response_param(e.getMessage())
.executeTime(System.currentTimeMillis() - startTime)
.content("响应请求")
.build();
logService.interfaceExecuteLog(logDto);
throw new BadRequestException(e.getMessage());
}
logDto =
LuceneLogDto.builder()
.logType("接口日志")
.request_url(IpUtil.localIP() + classUrlValue + methodUrlValue)
.request_direction(request_direction)
.request_param(JSON.toJSONString(args))
.method(methodName)
.response_param(JSON.toJSONString(result))
.executeTime(System.currentTimeMillis() - startTime)
.content("响应请求")
.build();
logService.interfaceExecuteLog(logDto);
return result;
}
}

View File

@@ -1,12 +0,0 @@
package org.nl.acs.agv.hk.log;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface OthersToInterfaceLog {
String value() default "";
}

View File

@@ -1,139 +0,0 @@
package org.nl.acs.agv.hk.log;
import com.alibaba.fastjson.JSON;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.nl.common.exception.BadRequestException;
import org.nl.system.service.lucene.LuceneExecuteLogService;
import org.nl.system.service.lucene.dto.LuceneLogDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.ReflectionUtils;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* @Description TODO
* @Author Gengby
* @Date 2024/7/8
*/
@Aspect
@Component
public class ToOtherInterfaceLogAspect {
private static final ConcurrentMap<Class<?>, Field> fieldCache = new ConcurrentHashMap<>();
private static final ConcurrentMap<Class<?>, Method> methodCache = new ConcurrentHashMap<>();
@Autowired
private LuceneExecuteLogService logService;
@Around("@annotation(org.nl.acs.ext.hk.log.ToOthersInterfaceLog)")
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
long startTime = System.currentTimeMillis();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method method = signature.getMethod();
String request_direction = "";
if (method.isAnnotationPresent(ToOthersInterfaceLog.class)) {
ToOthersInterfaceLog interfaceLog = method.getAnnotation(ToOthersInterfaceLog.class);
request_direction = interfaceLog.value();
}
String methodName = joinPoint.getSignature().getName();
Object[] args = joinPoint.getArgs();
Object url = "";
Object requesr_param = "";
if (args.length > 1) {
url = args[0];
requesr_param = args[1];
}
Class<?> targetClass = joinPoint.getTarget().getClass();
Object ipPort = "";
try {
Field requestAdapterField = fieldCache.computeIfAbsent(targetClass, clazz -> {
try {
Field field = clazz.getDeclaredField("REQUEST_ADAPTER");
ReflectionUtils.makeAccessible(field);
return field;
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
}
});
Object requestAdapterObject = requestAdapterField.get(null);
Method getUrlMethod = methodCache.computeIfAbsent(requestAdapterObject.getClass(), clazz -> {
try {
Method m = clazz.getDeclaredMethod("getUrl");
ReflectionUtils.makeAccessible(m);
return m;
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
}
});
ipPort = getUrlMethod.invoke(requestAdapterObject);
} catch (Exception e) {
LuceneLogDto logDto =
LuceneLogDto.builder()
.logType("接口日志")
.request_url(ipPort + String.valueOf(url))
.request_direction(request_direction)
.request_param(JSON.toJSONString(requesr_param))
.method(methodName)
.content("开始请求,获取url失败," + e.getMessage())
.build();
logService.interfaceExecuteLog(logDto);
}
LuceneLogDto logDto =
LuceneLogDto.builder()
.logType("接口日志")
.request_url(ipPort + String.valueOf(url))
.request_direction(request_direction)
.request_param(JSON.toJSONString(requesr_param))
.method(methodName)
.content("开始请求")
.build();
logService.interfaceExecuteLog(logDto);
Object result = null;
try {
result = joinPoint.proceed();
} catch (Exception e) {
logDto =
LuceneLogDto.builder()
.logType("接口日志")
.request_url(ipPort + String.valueOf(url))
.request_direction(request_direction)
.request_param(JSON.toJSONString(requesr_param))
.method(methodName)
.response_param(e.getMessage())
.executeTime(System.currentTimeMillis() - startTime)
.content("响应请求")
.build();
logService.interfaceExecuteLog(logDto);
throw new BadRequestException(e.getMessage());
}
logDto =
LuceneLogDto.builder()
.logType("接口日志")
.request_url(ipPort + String.valueOf(url))
.request_direction(request_direction)
.request_param(JSON.toJSONString(requesr_param))
.method(methodName)
.response_param(JSON.toJSONString(result))
.executeTime(System.currentTimeMillis() - startTime)
.content("响应请求")
.build();
logService.interfaceExecuteLog(logDto);
return result;
}
}

View File

@@ -1,12 +0,0 @@
package org.nl.acs.agv.hk.log;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface ToOthersInterfaceLog {
String value() default "";
}

View File

@@ -4,7 +4,6 @@ import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.hk.log.OthersToInterfaceLog;
import org.nl.acs.agv.hk.service.HkToAcsService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@@ -27,14 +26,12 @@ public class HkToACSController {
@SaIgnore
@PostMapping("/agv/agvCallbackService/agvCallback")
@OthersToInterfaceLog("HK->ACS")
public ResponseEntity<Object> agvCallback(@RequestBody JSONObject requestParam) {
return new ResponseEntity<>(hkToAcsService.agvCallback(requestParam), HttpStatus.OK);
}
@SaIgnore
@PostMapping("/agvCallbackService/warnCallback")
@OthersToInterfaceLog("HK->ACS")
public ResponseEntity<Object> warnCallback(@RequestBody JSONObject requestParam) {
return new ResponseEntity<>(hkToAcsService.warnCallback(requestParam), HttpStatus.OK);
}

View File

@@ -168,8 +168,8 @@ public class HkToAcsServiceImpl implements HkToAcsService {
Map<String, Object> map = new HashMap<>();
map.put("to_out", "0");
robotArmDeviceDriver.writing(map);
robotArmDeviceDriver.setReqAgvTakeRequireSuccess(true);
robotArmDeviceDriver.setReqAgvTakeInstCode(taskCode);
// robotArmDeviceDriver.setReqAgvTakeRequireSuccess(true);
// robotArmDeviceDriver.setReqAgvTakeInstCode(taskCode);
}
}
//method 回调6、放料箱申请outApply
@@ -216,8 +216,8 @@ public class HkToAcsServiceImpl implements HkToAcsService {
Map<String, Object> map = new HashMap<>();
map.put("to_in", "0");
robotArmDeviceDriver.writing(map);
robotArmDeviceDriver.setReqAgvTakeRequireSuccess(true);
robotArmDeviceDriver.setReqAgvTakeInstCode(taskCode);
// robotArmDeviceDriver.setReqAgvTakeRequireSuccess(true);
// robotArmDeviceDriver.setReqAgvTakeInstCode(taskCode);
}
}
resp.put("code", "0");

View File

@@ -223,8 +223,11 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
StandardAutodoorDeviceDriver driver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
log.info("agv车号为"+carno+",进入自动门:"+device_code+"区域,请求开门中");
// 状态不为0且门开到位
if (driver.getMode() != 0) {
// 下发开门
driver.writing(ItemProtocol.to_open,"1");
log.info("agv车号为"+carno+",进入自动门区域"+"自动门:"+device_code+"已联机,允许开门。");
logServer.deviceExecuteLog(device_code, "", "", "允许开门。");
if (driver.getOpen() == 1) {
flag = true;
} else {
String message = "自动门未联机或未开到位,无法开门。";
@@ -233,13 +236,6 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
log.error("agv车号为"+carno+",进入自动门区域:"+"自动门:"+device_code+"未联机,无法开门。");
}
if (flag) {
driver.writing(ItemProtocol.item_to_command,"1");
driver.setMessage("");
log.info("agv车号为"+carno+",进入自动门区域"+"自动门:"+device_code+"已联机,允许开门。");
logServer.deviceExecuteLog(device_code, "", "", "允许开门。");
}
log.info("自动门:"+device_code+"开门的action的值此时为"+driver.getAction()+"该值应为1");
if (driver.getAction() == 1) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("自动门:"+device_code+"返回开门到位,"+"agv车号为"+carno+",进入自动门。");
}
@@ -266,27 +262,10 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
StandardAutodoorDeviceDriver driver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
// 关门
driver.writing(ItemProtocol.to_open,"0");
log.info("agv车号为"+carno+",准备离开自动门:"+device_code+"区域,请求关门中");
if (driver.getMode() != 0) {
flag = true;
} else {
String message = "自动门未联机,无法关门。";
log.error("agv车号为"+carno+",准备离开自动门区域:"+"自动门:"+device_code+"未联机,无法关门。");
driver.setMessage(message);
logServer.deviceExecuteLog(device_code, "", "", message);
}
log.info("自动门:"+device_code+"关门的action的值此时为"+driver.getAction()+"该值应为0");
if (flag) {
driver.writing(ItemProtocol.item_to_command,"2");
driver.setMessage("");
log.info("自动门:"+device_code+"工作模式正常,"+"agv车号为"+carno+",写入关门信号2准备离开自动门。");
logServer.deviceExecuteLog(device_code, "", "", "允许关门。");
}
//百济没有2已关0就当作已关门
if (driver.getAction() == 0) {
log.info("自动门:"+device_code+"接收到agv写入2信号返回action信号为0,交互成功,"+"agv车号为"+carno+",离开自动门。");
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0);
}
} else {
//上报异常信息

View File

@@ -8,13 +8,10 @@ import java.util.List;
@Slf4j
public class ItemProtocol {
public static String item_heartbeat = "heartbeat";
public static String item_mode = "mode";
public static String item_state = "state";
public static String item_action = "action";
public static String item_error = "error";
public static String item_to_command = "to_command";
public static String item_to_state = "to_state";
public static String close = "close";
public static String open = "open";
public static String to_close = "to_close";
public static String to_open = "to_open";
private StandardAutodoorDeviceDriver driver;
@@ -23,31 +20,22 @@ public class ItemProtocol {
this.driver = driver;
}
public int getHeartbeat() {
return this.getOpcIntegerValue(item_heartbeat);
public int getClose() {
return this.getOpcIntegerValue(close);
}
public int getMode() {
return this.getOpcIntegerValue(item_mode);
public int getOpen() {
return this.getOpcIntegerValue(open);
}
public int getAction() {
return this.getOpcIntegerValue(item_action);
public int getToClose() {
return this.getOpcIntegerValue(to_close);
}
public int getError() {
return this.getOpcIntegerValue(item_error);
public int getToOpen() {
return this.getOpcIntegerValue(to_open);
}
public int getToCommand() {
return this.getOpcIntegerValue(item_to_command);
}
public int getToState() {
return this.getOpcIntegerValue(item_to_state);
}
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
@@ -61,15 +49,15 @@ public class ItemProtocol {
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_heartbeat, "心跳", "VB100"));
list.add(new ItemDto(item_mode, "工作模式", "VB101", Boolean.valueOf(true)));
list.add(new ItemDto(item_action, "动作信号", "VB102"));
list.add(new ItemDto(open, "开门到位", "10001"));
list.add(new ItemDto(close, "关门到位", "10002"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_command, "作业命令", "VW200", Boolean.valueOf(true)));
list.add(new ItemDto(to_open, "开门", "00001", Boolean.valueOf(true)));
list.add(new ItemDto(to_close, "关门", "00002", Boolean.valueOf(true)));
return list;
}

View File

@@ -56,10 +56,8 @@ public class StandardAutodoorDefination implements OpcDeviceDriverDefination {
public static List<ItemDto> getReadableItemDtos2() {
List<ItemDto> list = new ArrayList();
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB600.B0"));
list.add(new ItemDto(ItemProtocol.item_mode, "工作状态", "DB600.B1", true));
list.add(new ItemDto(ItemProtocol.item_action, "动作信号", "DB600.B2"));
list.add(new ItemDto(ItemProtocol.item_error, "报警信号", "DB600.B4"));
list.add(new ItemDto(ItemProtocol.close, "关门到位", "10002"));
list.add(new ItemDto(ItemProtocol.open, "开门到位", "10001"));
return list;
}

View File

@@ -57,18 +57,19 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
//有货标记
protected boolean has_goods_tag = false;
String devicecode;
int mode = 0;
int action = 0;
int close = 0;
int open = 0;
int to_close = 0;
int to_open = 0;
int error = 0;
Boolean iserror = false;
int move = 0;
int task = 0;
int last_action = 0;
int last_mode = 0;
int last_error = 0;
int last_move = 0;
int last_task = 0;
int last_close= 0;
int last_open= 0;
int last_to_close= 0;
int last_to_open= 0;
boolean hasVehicle = false;
boolean isReady = false;
@@ -108,31 +109,19 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
@Override
public void execute() {
devicecode = this.getDevice().getDevice_code();
mode = this.itemProtocol.getMode();
action = this.itemProtocol.getAction();
error = this.itemProtocol.getError();
open = this.itemProtocol.getOpen();
close = this.itemProtocol.getClose();
to_close = this.itemProtocol.getToClose();
to_open = this.itemProtocol.getToOpen();
last_action = action;
last_mode = mode;
last_error = error;
last_close = close;
last_open = open;
last_to_close = to_close;
last_to_open = to_open;
}
public synchronized String getStatus() {
JSONObject jo = new JSONObject();
if (action == 1) {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "OPEN");
} else if (action == 2) {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "CLOSE");
} else {
jo.put("name", this.getDevice().getDevice_code());
jo.put("status", "ERROR");
}
return jo.toString();
return null;
}
@@ -195,13 +184,6 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem
public synchronized void OpenOrClose(String type) {
//开门
if (CommonFinalParam.ONE.equals(type)) {
writing(ItemProtocol.item_to_command, "1");
} else {
writing(ItemProtocol.item_to_command, "2");
}
}
}

View File

@@ -228,25 +228,30 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
// 到达机械手
if (device.getDeviceDriver() instanceof RobotArmDeviceDriver) {
RobotArmDeviceDriver deviceDriver = (RobotArmDeviceDriver) device.getDeviceDriver();
// 下发正在取货
deviceDriver.writing(org.nl.acs.device_driver.basedriver.robot_arm.ItemProtocol.to_out, "1");
log.info("到达{}取货点开始取货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
if (deviceDriver.getHeartbeat() == 1) {
// 下发正在取货
deviceDriver.writing(org.nl.acs.device_driver.basedriver.robot_arm.ItemProtocol.to_out, "1");
log.info("到达{}取货点开始取货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
}
}
// 到达拆盘机
if (device.getDeviceDriver() instanceof PalletDispenseDeviceDriver) {
PalletDispenseDeviceDriver deviceDriver = (PalletDispenseDeviceDriver) device.getDeviceDriver();
// 下发正在取货
deviceDriver.writing(org.nl.acs.device_driver.basedriver.pallet_dispenser.ItemProtocol.to_out, "1");
log.info("到达{}取货点开始取货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
// 判断是否允许取
if (deviceDriver.getEmp_ready() == 1) {
// 下发正在取货
deviceDriver.writing(org.nl.acs.device_driver.basedriver.pallet_dispenser.ItemProtocol.to_out, "1");
log.info("到达{}取货点开始取货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
}
}
} else if (phase == 0x04) {
@@ -315,6 +320,9 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
// 到达机械手取货完成
if (device.getDeviceDriver() instanceof RobotArmDeviceDriver) {
RobotArmDeviceDriver deviceDriver = (RobotArmDeviceDriver) device.getDeviceDriver();
// 取货复位
deviceDriver.writing("to_out","0");
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("agv进入" + device_code + "取货完成");
flag = true;
@@ -322,6 +330,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
// 到达拆盘机手取货完成
if (device.getDeviceDriver() instanceof PalletDispenseDeviceDriver) {
PalletDispenseDeviceDriver deviceDriver = (PalletDispenseDeviceDriver) device.getDeviceDriver();
deviceDriver.writing("to_out","0");
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("agv进入" + device_code + "取货完成");
flag = true;
@@ -402,25 +412,15 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
// 机械手
if (device.getDeviceDriver() instanceof RobotArmDeviceDriver) {
RobotArmDeviceDriver deviceDriver = (RobotArmDeviceDriver) device.getDeviceDriver();
// 下发请求放货
deviceDriver.writing(org.nl.acs.device_driver.basedriver.robot_arm.ItemProtocol.to_in, "1");
log.info("到达{}放货点开始放货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
}
// 拆盘机
if (device.getDeviceDriver() instanceof PalletDispenseDeviceDriver) {
PalletDispenseDeviceDriver deviceDriver = (PalletDispenseDeviceDriver) device.getDeviceDriver();
// 下发请求放货
deviceDriver.writing(org.nl.acs.device_driver.basedriver.pallet_dispenser.ItemProtocol.to_in, "1");
log.info("到达{}放货点开始放货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
if (deviceDriver.getHeartbeat() == 1) {
// 下发请求放货
deviceDriver.writing(org.nl.acs.device_driver.basedriver.robot_arm.ItemProtocol.to_in, "1");
log.info("到达{}放货点开始放货", device_code);
inst.setExecute_status("1");
instructionService.update(inst);
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
flag = true;
}
}
//放货完毕
//(需要WCS反馈)
@@ -491,13 +491,8 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
// 到达机械手放货完成
if (device.getDeviceDriver() instanceof RobotArmDeviceDriver) {
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("{}放货完成", device_code);
flag = true;
}
// 到达拆盘机放货完成
if (device.getDeviceDriver() instanceof PalletDispenseDeviceDriver) {
RobotArmDeviceDriver deviceDriver = (RobotArmDeviceDriver) device.getDeviceDriver();
deviceDriver.writing("to_in","0");
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
log.info("{}放货完成", device_code);
flag = true;

View File

@@ -115,7 +115,7 @@ public class PalletDispenseDeviceDriver extends AbstractOpcDeviceDriver implemen
last_emp_ready = emp_ready;
last_emp_apply = emp_apply;
if (last_heartbeat == 1) {
/* if (last_heartbeat == 1) {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
@@ -123,7 +123,7 @@ public class PalletDispenseDeviceDriver extends AbstractOpcDeviceDriver implemen
this.instruction_require_time = date;
this.executeTask();
}
}
}*/
}
/**

View File

@@ -164,7 +164,7 @@ public class RobotArmDeviceDriver extends AbstractOpcDeviceDriver implements Dev
}
}
// 申请下料任务
if (pallet_apply == 1) {
if (last_pallet_apply == 1) {
List<Task> list = taskserver.list(
new QueryWrapper<Task>().lambda()
.eq(Task::getStart_device_code, devicecode)

View File

@@ -7,7 +7,6 @@ import org.nl.acs.AcsConfig;
import org.nl.acs.agv.hk.RequestAdapter;
import org.nl.acs.agv.hk.ResponseAdapter;
import org.nl.acs.agv.hk.UnifiedResponse;
import org.nl.acs.agv.hk.log.ToOthersInterfaceLog;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.system.service.param.ISysParamService;
import org.springframework.beans.factory.annotation.Autowired;
@@ -27,7 +26,6 @@ public class LmsHttpUtil {
@Autowired
private ISysParamService paramService;
@ToOthersInterfaceLog("ACS->WMS")
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam, Class<T> type) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
@@ -45,7 +43,6 @@ public class LmsHttpUtil {
}
}
@ToOthersInterfaceLog("ACS->WMS")
public <T, W> UnifiedResponse<T> sendPostRequest(String path, W requestParam) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
@@ -63,7 +60,6 @@ public class LmsHttpUtil {
}
}
@ToOthersInterfaceLog("ACS->WMS")
public <T> UnifiedResponse<T> sendPostRequest(String path, Class<T> type) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
@@ -80,7 +76,6 @@ public class LmsHttpUtil {
}
}
@ToOthersInterfaceLog("ACS->WMS")
public <T> UnifiedResponse<T> sendPostRequest(String path) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
@@ -97,7 +92,6 @@ public class LmsHttpUtil {
}
}
@ToOthersInterfaceLog("ACS->WMS")
public <T> UnifiedResponse<T> sendGetRequest(String path, Class<T> type) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");
@@ -114,7 +108,6 @@ public class LmsHttpUtil {
}
}
@ToOthersInterfaceLog("ACS->WMS")
public <T> UnifiedResponse<T> sendGetRequest(String path) {
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) {
return new UnifiedResponse<>(false, "未开启连接该系统!");

View File

@@ -434,7 +434,12 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
if (ObjectUtil.isEmpty(route)) {
throw new BadRequestException(LangProcess.msg("error_isNull", "route"));
}
if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
/*if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
}*/
// 下发ndc系统
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.NDC_System_Type.getIndex())) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
ndcAgvService.sendAgvInstToNDC(task.getAgv_system_type(), dto);
}

View File

@@ -11,17 +11,9 @@ import lombok.Getter;
@AllArgsConstructor
public enum AgvSystemTypeEnum {
/**
* 一期1楼叉车NDC系统
* NDC系统
*/
One_NDC_System_Type("1", "1", "一期1楼叉车NDC系统"),
/**
* 一期2楼NDC系统
*/
Two_NDC_System_Type("2", "2", "一期2楼NDC系统"),
/**
* 仙工AGV系统
*/
// XG_System_Type("3", "3", "仙工AGV系统");
NDC_System_Type("2", "2", "NDC系统"),
/**
* 海康调度系统
*/

View File

@@ -2,16 +2,15 @@
<included>
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
<property name="LOG_HOME" value="${logPath}"/>
<!--<define name="DEVICECODE" class="org.nl.common.logging.DeviceCodeDir"/>-->
<!-- 按照每天生成日志文件 -->
<appender name="FILE_XGAGV" class="ch.qos.logback.core.rolling.RollingFileAppender">
<appender name="AcsToHK" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/XgAgvDeviceDriver/${DEVICECODE}/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<FileNamePattern>${LOG_HOME}/下发HK任务/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>200MB</maxFileSize>
<maxFileSize>100MB</maxFileSize>
<!--所有日志最多占多大容量-->
<totalSizeCap>2GB</totalSizeCap>
</rollingPolicy>
@@ -20,15 +19,14 @@
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
<charset>${log.charset}</charset>
</encoder>
</appender>
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
<appender-ref ref="FILE3"/>
</logger>-->
<!-- 打印sql -->
<logger name="org.nl.system.service.lucene.impl.LuceneExecuteLogServiceImpl" level="info" additivity="false">
<appender-ref ref="FILE_XGAGV"/>
<appender name="asyncFileAppender" class="ch.qos.logback.classic.AsyncAppender">
<appender-ref ref="AcsToHK" />
<!-- 设置队列大小,根据您的需求调整 -->
<queueSize>512</queueSize>
</appender>
<logger name="org.nl.acs.agv.hk.HkHttpUtil" level="info" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
</included>

View File

@@ -0,0 +1,32 @@
<?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="HKToAcs" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<!--日志文件输出的文件名-->
<FileNamePattern>${LOG_HOME}/HK请求ACS/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
<!--日志文件保留天数-->
<maxHistory>15</maxHistory>
<!--单个日志最大容量 至少10MB才能看得出来-->
<maxFileSize>100MB</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="HKToAcs" />
<!-- 设置队列大小,根据您的需求调整 -->
<queueSize>512</queueSize>
</appender>
<logger name="org.nl.acs.agv.hk.service.impl.HkToAcsServiceImpl" level="info" additivity="true">
<appender-ref ref="asyncFileAppender"/>
</logger>
</included>

View File

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