feat: 海康交互接口-base
This commit is contained in:
@@ -63,4 +63,8 @@ public interface AcsConfig {
|
||||
String LOGLEVEL = "log_level";
|
||||
|
||||
String ELECTRIC ="electric";
|
||||
|
||||
String HAS_HK = "has_hk";
|
||||
|
||||
String HK_URL = "hk_url";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
package org.nl.acs.agv.hk;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/4/22
|
||||
*/
|
||||
@Component
|
||||
public class HkHttpUtil {
|
||||
|
||||
private static final RequestAdapter REQUEST_ADAPTER = new HkRequestAdapter();
|
||||
private static final ResponseAdapter RESPONSE_ADAPTER = new HkResponseAdapter();
|
||||
|
||||
@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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.post(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.body(JSON.toJSONString(requestParam))
|
||||
.execute()
|
||||
.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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.post(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.body(JSON.toJSONString(requestParam))
|
||||
.execute()
|
||||
.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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.post(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, type);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.post(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, null);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.get(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, type);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.get(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, null);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.acs.agv.hk;
|
||||
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/4/22
|
||||
*/
|
||||
public class HkRequestAdapter implements RequestAdapter {
|
||||
@Override
|
||||
public String getUrl() {
|
||||
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
||||
return paramService.findByCode(AcsConfig.HK_URL).getValue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package org.nl.acs.agv.hk;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/4/22
|
||||
*/
|
||||
public class HkResponseAdapter implements ResponseAdapter {
|
||||
|
||||
@Override
|
||||
public <T> UnifiedResponse<T> adapt(String responseBody, Class<T> type) {
|
||||
JSONObject resp = JSON.parseObject(responseBody);
|
||||
boolean isSuccess = resp.getInteger("code") == 0;
|
||||
String message = resp.getString("message");
|
||||
String reqCode = resp.getString("reqCode");
|
||||
if (type != null) {
|
||||
Object dataObject = resp.get("data");
|
||||
T data;
|
||||
if (type == String.class) {
|
||||
data = type.cast(dataObject.toString());
|
||||
} else if (type == Object.class) {
|
||||
data = type.cast(dataObject);
|
||||
} else if (type.isArray() || Collection.class.isAssignableFrom(type)) {
|
||||
data = JSON.parseObject(dataObject.toString(), type);
|
||||
} else {
|
||||
data = JSON.parseObject(resp.getString("data"), type);
|
||||
}
|
||||
return new UnifiedResponse<>(isSuccess, message, reqCode, data);
|
||||
}
|
||||
return new UnifiedResponse<>(isSuccess, message, reqCode);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.nl.acs.agv.hk;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/4/22
|
||||
*/
|
||||
public interface RequestAdapter {
|
||||
String getUrl();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.acs.agv.hk;
|
||||
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/4/22
|
||||
*/
|
||||
public interface ResponseAdapter {
|
||||
public <T> UnifiedResponse<T> adapt(String responseBody, Class<T> type);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
package org.nl.acs.agv.hk;
|
||||
|
||||
|
||||
public class UnifiedResponse<T> {
|
||||
private boolean success;
|
||||
private String message;
|
||||
private String reqCode;
|
||||
private T data;
|
||||
|
||||
public UnifiedResponse(boolean success, String message, T data) {
|
||||
this.success = success;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public UnifiedResponse(boolean success, String message, String reqCode, T data) {
|
||||
this.success = success;
|
||||
this.message = message;
|
||||
this.reqCode = reqCode;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
|
||||
public UnifiedResponse(boolean success, String message) {
|
||||
this.success = success;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public UnifiedResponse(boolean success, String message, String reqCode) {
|
||||
this.success = success;
|
||||
this.message = message;
|
||||
this.reqCode = reqCode;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return this.success;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public String getReqCode() {
|
||||
return this.reqCode;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
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 "";
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
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 "";
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package org.nl.acs.agv.hk.rest;
|
||||
|
||||
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.service.AcsToHkService;
|
||||
import org.nl.acs.agv.hk.service.data.BindPodAndBerthReq;
|
||||
import org.nl.acs.agv.hk.service.data.QueryTaskStatusReq;
|
||||
import org.nl.acs.agv.hk.service.data.ResumeRobotReq;
|
||||
import org.nl.acs.agv.hk.service.data.StopRobotReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author ludj
|
||||
* @date 2021-07-21
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/acsToHk")
|
||||
@Slf4j
|
||||
public class AcsToHkController {
|
||||
|
||||
@Autowired
|
||||
private AcsToHkService acsToHkService;
|
||||
|
||||
@SaIgnore
|
||||
@PostMapping("/queryTaskStatus")
|
||||
public ResponseEntity<Object> agvCallback(@RequestBody JSONObject requestParam) {
|
||||
QueryTaskStatusReq queryTaskStatusReq = JSONObject.toJavaObject(requestParam, QueryTaskStatusReq.class);
|
||||
QueryTaskStatusReq req = QueryTaskStatusReq.builder().taskCodes(requestParam.getJSONArray("taskCodes").toJavaList(String.class)).build();
|
||||
return new ResponseEntity<>(acsToHkService.queryTaskStatus(queryTaskStatusReq, List.class), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
@PostMapping("/stopRobot")
|
||||
public ResponseEntity<Object> stopRobot(@RequestBody JSONObject requestParam) {
|
||||
StopRobotReq req = StopRobotReq.builder().robotCount(requestParam.getString("robotCount")).robots(requestParam.getJSONArray("robots").toJavaList(String.class)).build();
|
||||
return new ResponseEntity<>(acsToHkService.stopRobot(req), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
@PostMapping("/resumeRobot")
|
||||
public ResponseEntity<Object> resumeRobot(@RequestBody JSONObject requestParam) {
|
||||
ResumeRobotReq req = ResumeRobotReq.builder().robotCount(requestParam.getString("robotCount")).robots(requestParam.getJSONArray("robots").toJavaList(String.class)).build();
|
||||
return new ResponseEntity<>(acsToHkService.resumeRobot(req), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@SaIgnore
|
||||
@PostMapping("/bindPodAndBerth")
|
||||
public ResponseEntity<Object> bindPodAndBerth(@RequestBody JSONObject requestParam) {
|
||||
BindPodAndBerthReq req = BindPodAndBerthReq.builder().podCode(requestParam.getString("podCode")).positionCode(requestParam.getString("positionCode")).indBind(requestParam.getString("indBind")).build();
|
||||
return new ResponseEntity<>(acsToHkService.bindPodAndBerth(req), HttpStatus.OK);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package org.nl.acs.agv.hk.rest;
|
||||
|
||||
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;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author wangs
|
||||
* @date 2021-07-21
|
||||
**/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/hkToAcs")
|
||||
@Slf4j
|
||||
public class HkToACSController {
|
||||
|
||||
private final HkToAcsService hkToAcsService;
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
package org.nl.acs.agv.hk.service;
|
||||
|
||||
|
||||
import org.nl.acs.agv.hk.UnifiedResponse;
|
||||
import org.nl.acs.agv.hk.service.data.BaseReq;
|
||||
|
||||
/**
|
||||
* @author onepiece
|
||||
*/
|
||||
public interface AcsToHkService {
|
||||
|
||||
/**
|
||||
* 生成任务单
|
||||
*
|
||||
* @param type 响应类型
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> genAgvSchedulingTask(BaseReq<R> requestParam, Class<T> type);
|
||||
|
||||
/**
|
||||
* 继续执行任务
|
||||
*
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> continueTask(BaseReq<R> requestParam);
|
||||
|
||||
/**
|
||||
* 取消任务
|
||||
*
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> cancelTask(BaseReq<R> requestParam);
|
||||
|
||||
/**
|
||||
* 查询任务状态
|
||||
*
|
||||
* @param type 响应类型
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> queryTaskStatus(BaseReq<R> requestParam, Class<T> type);
|
||||
|
||||
|
||||
/**
|
||||
* 查询AGV状态
|
||||
*
|
||||
* @param type 响应类型
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> queryAgvStatus(BaseReq<R> requestParam, Class<T> type);
|
||||
|
||||
|
||||
/**
|
||||
* 停止AGV
|
||||
*
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> stopRobot(BaseReq<R> requestParam);
|
||||
|
||||
/**
|
||||
* 恢复AGV
|
||||
*
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> resumeRobot(BaseReq<R> requestParam);
|
||||
|
||||
|
||||
/**
|
||||
* 区域清空或释放
|
||||
*
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> blockArea(BaseReq<R> requestParam);
|
||||
|
||||
|
||||
/**
|
||||
* 预调度对外接口
|
||||
*
|
||||
* @param type 响应类型
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> genPreScheduleTask(BaseReq<R> requestParam, Class<T> type);
|
||||
|
||||
/**
|
||||
* 料箱取放回调
|
||||
*
|
||||
* @param type 响应类型
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> boxApplyPass(BaseReq<R> requestParam, Class<T> type);
|
||||
|
||||
|
||||
/**
|
||||
* 货架与位置绑定、解绑
|
||||
*
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
public <T,R> UnifiedResponse<T> bindPodAndBerth(BaseReq<R> requestParam);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.nl.acs.agv.hk.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
|
||||
/**
|
||||
* @author onepiece
|
||||
*/
|
||||
public interface HkToAcsService {
|
||||
|
||||
/**
|
||||
* CTU回调接口处理逻辑
|
||||
*
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
JSONObject agvCallback(JSONObject requestParam);
|
||||
|
||||
|
||||
/**
|
||||
* CTU报警接口处理逻辑
|
||||
*
|
||||
* @param requestParam
|
||||
* @return
|
||||
*/
|
||||
JSONObject warnCallback(JSONObject requestParam);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.nl.config.IdUtil;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class BaseReq<T> {
|
||||
@Builder.Default
|
||||
private String reqCode = IdUtil.getStringId();
|
||||
@Builder.Default
|
||||
private String reqTime = DateUtil.now();
|
||||
private String clientCode;
|
||||
private String tokenCode;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class BaseResp {
|
||||
private String reqCode;
|
||||
private String code;
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class BindPodAndBerthReq <T> extends BaseReq<T> {
|
||||
private String podCode;
|
||||
private String positionCode;
|
||||
private String podDir;
|
||||
private String characterValue;
|
||||
private String indBind;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class BindPodAndBerthResp extends BaseResp {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class BlockAreaReq <T> extends BaseReq<T> {
|
||||
/**
|
||||
* 被封锁或解封的区域编号
|
||||
*/
|
||||
private String matterArea;
|
||||
|
||||
/**
|
||||
* "1":封锁,
|
||||
* "0":解封
|
||||
*/
|
||||
private String indBind;
|
||||
|
||||
|
||||
private String pause;
|
||||
private String controlMod;
|
||||
private String targetArea;
|
||||
private String noticeThird;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class BlockAreaResp extends BaseResp {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class BoxApplyPassReq <T> extends BaseReq<T> {
|
||||
/**
|
||||
* 指令号
|
||||
*/
|
||||
private String taskCode;
|
||||
/**
|
||||
* 1-取申请通过
|
||||
* <p>
|
||||
* 2-放申请通过
|
||||
*/
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class BoxApplyPassResp extends BaseResp {
|
||||
private String data;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class CancelTaskReq <T> extends BaseReq<T>{
|
||||
private String forceCancel;
|
||||
private String matterArea;
|
||||
private String agvCode;
|
||||
private String taskCode;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class CanncelTaskResp extends BaseResp {
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class ContinueTaskReq <T> extends BaseReq<T>{
|
||||
private String wbCode;
|
||||
private String podCode;
|
||||
private String agvCode;
|
||||
private String taskCode;
|
||||
private String taskSeq;
|
||||
private Object nextPositionCode;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class ContinueTaskResp extends BaseResp {
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class GenAgvSchedulingTaskReq<T> extends BaseReq<T>{
|
||||
private String taskTyp;
|
||||
private String ctnrTyp;
|
||||
private String ctnrCode;
|
||||
private String ctnrNum;
|
||||
private String taskMode;
|
||||
private String wbCode;
|
||||
private List<Map<String,String>> positionCodePath;
|
||||
private String podCode;
|
||||
private String podDir;
|
||||
private String podTyp;
|
||||
private String materialLot;
|
||||
private String materialType;
|
||||
private String priority;
|
||||
private String taskCode;
|
||||
private String agvCode;
|
||||
private String groupId;
|
||||
private String agvTyp;
|
||||
private String positionSelStrategy;
|
||||
private String data;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class GenAgvSchedulingTaskResp extends BaseResp {
|
||||
private String data;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class GenPreScheduleTaskReq <T> extends BaseReq<T> {
|
||||
/**
|
||||
* 任务点位呼叫号
|
||||
*/
|
||||
private String positionCode;
|
||||
/**
|
||||
* 预调度时间(s)
|
||||
* 表示真实任务预计多久后生成,传-1
|
||||
* 清空点位全部的预调度任务
|
||||
*/
|
||||
private String nextTask;
|
||||
/**
|
||||
* AGV 类型,预调度需要指定车型
|
||||
*/
|
||||
private String agvTyp;
|
||||
/**
|
||||
* 优先级
|
||||
*/
|
||||
private String priority;
|
||||
/**
|
||||
* 需求空仓位数
|
||||
*/
|
||||
private String useableLayers;
|
||||
/**
|
||||
* 缓存料箱数
|
||||
*/
|
||||
private String cacheCount;
|
||||
/**
|
||||
* 是否更新,默认为 0
|
||||
*/
|
||||
private BigDecimal update;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class GenPreScheduleTaskResp extends BaseResp {
|
||||
private String data;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
public class QueryAgvStatusReq <T> extends BaseReq<T> {
|
||||
/**
|
||||
* 地图编号
|
||||
*/
|
||||
private String mapCode;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.acs.agv.hk.service.data.dto.QueryAgvStatusDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class QueryAgvStatusResp extends BaseResp {
|
||||
private List<QueryAgvStatusDto> data;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class QueryTaskStatusReq <T> extends BaseReq<T>{
|
||||
private List<String> taskCodes;
|
||||
private String agvCode;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
import org.nl.acs.agv.hk.service.data.dto.QueryTaskStatusDto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class QueryTaskStatusResp extends BaseResp {
|
||||
private List<QueryTaskStatusDto> data;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class ResumeRobotReq <T> extends BaseReq<T> {
|
||||
private String robotCount;
|
||||
private String mapShortName;
|
||||
private List<String> robots;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class ResumeRobotResp extends BaseResp {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@SuperBuilder
|
||||
public class StopRobotReq <T> extends BaseReq<T> {
|
||||
private String robotCount;
|
||||
private String mapShortName;
|
||||
private List<String> robots;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package org.nl.acs.agv.hk.service.data;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/12/28
|
||||
*/
|
||||
@Data
|
||||
public class StopRobotResp extends BaseResp {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.nl.acs.agv.hk.service.data.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2025/1/3
|
||||
*/
|
||||
@Data
|
||||
public class QueryAgvStatusDto {
|
||||
private String robotCode;
|
||||
private String robotDir;
|
||||
private String robotIp;
|
||||
private String battery;
|
||||
private String posX;
|
||||
private String posY;
|
||||
private String mapCode;
|
||||
private String speed;
|
||||
private String status;
|
||||
private String exclType;
|
||||
private String stop;
|
||||
private String podCode;
|
||||
private String podDir;
|
||||
private List<String> path;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.nl.acs.agv.hk.service.data.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2025/1/3
|
||||
*/
|
||||
@Data
|
||||
public class QueryTaskStatusDto {
|
||||
private String taskCode;
|
||||
private String taskTyp;
|
||||
private String taskStatus;
|
||||
private String agvCode;
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
package org.nl.acs.agv.hk.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.address.service.AddressService;
|
||||
import org.nl.acs.address.service.dto.AddressDto;
|
||||
import org.nl.acs.agv.hk.HkHttpUtil;
|
||||
import org.nl.acs.agv.hk.UnifiedResponse;
|
||||
import org.nl.acs.agv.hk.service.AcsToHkService;
|
||||
import org.nl.acs.agv.hk.service.data.BaseReq;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
/**
|
||||
* @author onepiece
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class AcsToHkServiceImpl implements AcsToHkService {
|
||||
|
||||
@Autowired
|
||||
private AddressService addressService;
|
||||
@Autowired
|
||||
private HkHttpUtil hkHttpUtil;
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> genAgvSchedulingTask(BaseReq<R> requestParam, Class<T> type) {
|
||||
AddressDto addressDto = addressService.findByCode("genAgvSchedulingTask");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> continueTask(BaseReq<R> requestParam) {
|
||||
AddressDto addressDto = addressService.findByCode("continueTask");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> cancelTask(BaseReq<R> requestParam) {
|
||||
AddressDto addressDto = addressService.findByCode("cancelTask");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> queryTaskStatus(BaseReq<R> requestParam, Class<T> type) {
|
||||
AddressDto addressDto = addressService.findByCode("queryTaskStatus");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> queryAgvStatus(BaseReq<R> requestParam, Class<T> type) {
|
||||
AddressDto addressDto = addressService.findByCode("queryAgvStatus");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> stopRobot(BaseReq<R> requestParam) {
|
||||
AddressDto addressDto = addressService.findByCode("stopRobot");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> resumeRobot(BaseReq<R> requestParam) {
|
||||
AddressDto addressDto = addressService.findByCode("resumeRobot");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> blockArea(BaseReq<R> requestParam) {
|
||||
AddressDto addressDto = addressService.findByCode("blockArea");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> genPreScheduleTask(BaseReq<R> requestParam, Class<T> type) {
|
||||
AddressDto addressDto = addressService.findByCode("genPreScheduleTask");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T,R> UnifiedResponse<T> boxApplyPass(BaseReq<R> requestParam, Class<T> type) {
|
||||
AddressDto addressDto = addressService.findByCode("boxApplyPass");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T, R> UnifiedResponse<T> bindPodAndBerth(BaseReq<R> requestParam) {
|
||||
AddressDto addressDto = addressService.findByCode("bindPodAndBerth");
|
||||
return hkHttpUtil.sendPostRequest(addressDto.getMethods_url(), requestParam);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
package org.nl.acs.agv.hk.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.agv.hk.service.AcsToHkService;
|
||||
import org.nl.acs.agv.hk.service.HkToAcsService;
|
||||
import org.nl.acs.agv.hk.service.data.GenPreScheduleTaskReq;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.domain.Instruction;
|
||||
import org.nl.acs.instruction.enums.InstTypeEnum;
|
||||
import org.nl.acs.instruction.enums.InstructionStatusEnum;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.task.enums.TaskTypeEnum;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.acs.task.service.dto.TaskDto;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
|
||||
/**
|
||||
* 海康AGV接口
|
||||
*
|
||||
* @author: gengby
|
||||
* @createDate: 2024/12/28
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class HkToAcsServiceImpl implements HkToAcsService {
|
||||
|
||||
@Autowired
|
||||
private InstructionService instructionService;
|
||||
@Autowired
|
||||
private DeviceAppService deviceAppService;
|
||||
@Autowired
|
||||
private AcsToHkService acsToHkService;
|
||||
@Autowired
|
||||
private ISysParamService sysParamService;
|
||||
@Autowired
|
||||
private AcsToWmsService acsToWmsService;
|
||||
@Autowired
|
||||
private TaskService taskService;
|
||||
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public JSONObject agvCallback(JSONObject requestParam) {
|
||||
JSONObject resp = new JSONObject();
|
||||
String reqCode = requestParam.getString("reqCode");
|
||||
String robotCode = requestParam.getString("robotCode");
|
||||
String taskCode = requestParam.getString("taskCode");
|
||||
String method = requestParam.getString("method");
|
||||
Instruction instruction = instructionService.findByCodeFromCache(taskCode);
|
||||
if (ObjectUtil.isEmpty(instruction)) {
|
||||
resp.put("code", "1");
|
||||
resp.put("message", "请求失败,指令信息不存在,指令号:" + taskCode);
|
||||
resp.put("reqCode", reqCode);
|
||||
return resp;
|
||||
}
|
||||
TaskDto taskDto = taskService.findByCodeFromCache(instruction.getTask_code());
|
||||
if (ObjectUtil.isEmpty(taskDto)) {
|
||||
resp.put("code", "1");
|
||||
resp.put("message", "请求失败,任务信息不存在,指令号:" + taskCode);
|
||||
resp.put("reqCode", reqCode);
|
||||
return resp;
|
||||
}
|
||||
String now = DateUtil.now();
|
||||
//method 回调1、任务开始start
|
||||
if (StrUtil.equals(method, "start")) {
|
||||
//修改指令状态执行中并修改CTU车号
|
||||
instruction.setCarno(robotCode);
|
||||
instruction.setInstruction_status(InstructionStatusEnum.BUSY.getIndex());
|
||||
instruction.setExecute_device_code(instruction.getStart_point_code());
|
||||
instruction.setUpdate_time(now);
|
||||
instructionService.update(instruction);
|
||||
|
||||
JSONObject reqParam = new JSONObject();
|
||||
reqParam.put("task_id", instruction.getTask_id());
|
||||
reqParam.put("task_code", instruction.getTask_code());
|
||||
reqParam.put("car_no", robotCode);
|
||||
acsToWmsService.feedCarNo(reqParam);
|
||||
}
|
||||
//method 回调2、任务完成/结束end
|
||||
else if (StrUtil.equals(method, "end")) {
|
||||
if (instruction.getInstruction_type().equals(InstTypeEnum.AGV_THREE_TASK.getCode())) {
|
||||
instruction.setExecute_device_code(instruction.getStart_point_code());
|
||||
}
|
||||
//修改指令状态完成
|
||||
instruction.setInstruction_status(InstructionStatusEnum.FINISHED.getIndex());
|
||||
instruction.setUpdate_time(now);
|
||||
instructionService.finish(instruction);
|
||||
if (StrUtil.equals(instruction.getIs_wait(), "1") && StrUtil.equals(instruction.getInstruction_type(), InstTypeEnum.CTU_OUT_TASK.getCode())) {
|
||||
String ctuWaitTime = Optional.ofNullable(sysParamService.findByCode("ctuWaitTime").getValue()).map(Object::toString).orElse("3600");
|
||||
GenPreScheduleTaskReq gpsReq = GenPreScheduleTaskReq.builder()
|
||||
.positionCode(instruction.getStart_device_code())
|
||||
.nextTask(ctuWaitTime)
|
||||
.agvTyp("10")
|
||||
.build();
|
||||
acsToHkService.genPreScheduleTask(gpsReq, null);
|
||||
}
|
||||
}
|
||||
//method 回调3、任务取消cancel
|
||||
else if (StrUtil.equals(method, "cancel")) {
|
||||
//修改指令状态取消
|
||||
instruction.setInstruction_status(InstructionStatusEnum.CANCEL.getIndex());
|
||||
instruction.setUpdate_time(now);
|
||||
instructionService.update(instruction);
|
||||
}
|
||||
//method 回调4、取放料箱申请inApply
|
||||
else if (StrUtil.equals(method, "inApply")) {
|
||||
Device device = deviceAppService.findDeviceByCode(instruction.getStart_device_code());
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
resp.put("code", "1");
|
||||
resp.put("message", "请求失败,请求位置编号不存在!");
|
||||
resp.put("reqCode", reqCode);
|
||||
return resp;
|
||||
}
|
||||
// StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver;
|
||||
// //CTU取货申请
|
||||
// //如果请求位置编号与指令起点一致并且是输送线则是取货申请
|
||||
// if (device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
|
||||
// standardWeightSiteDeviceDriver = (StandardWeightSiteDeviceDriver) device.getDeviceDriver();
|
||||
// if (TaskTypeEnum.CTU_TASK.getCode().equals(taskDto.getTask_type())) {
|
||||
// standardWeightSiteDeviceDriver.setReqCtuTakeRequireSuccess(true);
|
||||
// standardWeightSiteDeviceDriver.setReqCtuTakeInstCode(taskCode);
|
||||
// } else {
|
||||
// standardWeightSiteDeviceDriver.setReqAgvTakeRequireSuccess(true);
|
||||
// standardWeightSiteDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
//method 回调5、inApplyOk
|
||||
else if (StrUtil.equals(method, "inApplyOK")) {
|
||||
//如果是WMS下发的任务,就反馈WMS取货完成
|
||||
if (!instruction.getTask_code().startsWith("-")) {
|
||||
JSONObject reqParam = new JSONObject();
|
||||
reqParam.put("task_code", instruction.getTask_code());
|
||||
reqParam.put("point_code", instruction.getStart_point_code());
|
||||
acsToWmsService.takeFinish(reqParam);
|
||||
}
|
||||
}
|
||||
//method 回调6、放料箱申请outApply
|
||||
else if (StrUtil.equals(method, "outApply")) {
|
||||
Device device = deviceAppService.findDeviceByCode(instruction.getNext_device_code());
|
||||
if (instruction.getInstruction_type().equals(InstTypeEnum.AGV_THREE_TASK.getCode())) {
|
||||
device = deviceAppService.findDeviceByCode(instruction.getStart_device_code());
|
||||
}
|
||||
if (ObjectUtil.isEmpty(device)) {
|
||||
resp.put("code", "1");
|
||||
resp.put("message", "请求失败,请求位置编号不存在!");
|
||||
resp.put("reqCode", reqCode);
|
||||
return resp;
|
||||
}
|
||||
// StandardWeightSiteDeviceDriver standardWeightSiteDeviceDriver;
|
||||
// //CTU取货申请
|
||||
// //如果请求位置编号与指令起点一致并且是输送线则是取货申请
|
||||
// if (device.getDeviceDriver() instanceof StandardWeightSiteDeviceDriver) {
|
||||
// standardWeightSiteDeviceDriver = (StandardWeightSiteDeviceDriver) device.getDeviceDriver();
|
||||
// if (TaskTypeEnum.CTU_TASK.getCode().equals(taskDto.getTask_type())) {
|
||||
// standardWeightSiteDeviceDriver.setReqCtuTakeRequireSuccess(true);
|
||||
// standardWeightSiteDeviceDriver.setReqCtuTakeInstCode(taskCode);
|
||||
// } else {
|
||||
// standardWeightSiteDeviceDriver.setReqAgvTakeRequireSuccess(true);
|
||||
// standardWeightSiteDeviceDriver.setReqAgvTakeInstCode(taskCode);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
resp.put("code", "0");
|
||||
resp.put("message", "成功");
|
||||
resp.put("reqCode", reqCode);
|
||||
return resp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject warnCallback(JSONObject requestParam) {
|
||||
String reqCode = requestParam.getString("reqCode");
|
||||
String reqTime = requestParam.getString("reqTime");
|
||||
JSONArray data = requestParam.getJSONArray("data");
|
||||
JSONObject resp = new JSONObject();
|
||||
resp.put("code", "0");
|
||||
resp.put("message", "成功");
|
||||
resp.put("reqCode", reqCode);
|
||||
return resp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.nl.acs.agv.hk.utils;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/6/25
|
||||
*/
|
||||
public class IpUtil {
|
||||
|
||||
public static final String LOCAL_IP = localIP();
|
||||
|
||||
public static String localIP() {
|
||||
try {
|
||||
Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
|
||||
while (networkInterfaces.hasMoreElements()) {
|
||||
NetworkInterface networkInterface = networkInterfaces.nextElement();
|
||||
Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
|
||||
while (inetAddresses.hasMoreElements()) {
|
||||
InetAddress inetAddress = inetAddresses.nextElement();
|
||||
if (!inetAddress.isLoopbackAddress() && inetAddress instanceof java.net.Inet4Address) {
|
||||
return inetAddress.getHostAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.nl.acs.agv.hk.utils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2025/1/3
|
||||
*/
|
||||
public class TypeCastingUtil {
|
||||
|
||||
|
||||
public static <T> List<T> convertToList(List<?> rawList, Class<T> clazz) {
|
||||
return rawList.stream()
|
||||
.filter(item -> item instanceof JSONObject)
|
||||
.map(item -> {
|
||||
JSONObject jsonObject = (JSONObject) item;
|
||||
return clazz.cast(jsonObject.toJavaObject(clazz));
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package org.nl.acs.ext.wms;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/4/22
|
||||
*/
|
||||
@Component
|
||||
public class LmsHttpUtil {
|
||||
|
||||
private static final RequestAdapter REQUEST_ADAPTER = new LmsRequestAdapter();
|
||||
private static final ResponseAdapter RESPONSE_ADAPTER = new LmsResponseAdapter();
|
||||
|
||||
@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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.post(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.body(JSON.toJSONString(requestParam))
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, type);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.post(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.body(JSON.toJSONString(requestParam))
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, null);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.post(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, type);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ToOthersInterfaceLog("ACS->WMS")
|
||||
public <T> UnifiedResponse<T> sendPostRequest(String path) {
|
||||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) {
|
||||
return new UnifiedResponse<>(false, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.post(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, null);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@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, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.get(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, type);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@ToOthersInterfaceLog("ACS->WMS")
|
||||
public <T> UnifiedResponse<T> sendGetRequest(String path) {
|
||||
if (!StrUtil.equals(paramService.findByCode(AcsConfig.HASWMS).getValue(), CommonFinalParam.ONE)) {
|
||||
return new UnifiedResponse<>(false, "未开启连接该系统!");
|
||||
}
|
||||
try {
|
||||
String body = HttpRequest
|
||||
.get(REQUEST_ADAPTER.getUrl() + path)
|
||||
.setConnectionTimeout(5000)
|
||||
.execute()
|
||||
.body();
|
||||
return RESPONSE_ADAPTER.adapt(body, null);
|
||||
} catch (Exception e) {
|
||||
return new UnifiedResponse<>(false, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.nl.acs.ext.wms;
|
||||
|
||||
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.agv.hk.RequestAdapter;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/4/22
|
||||
*/
|
||||
public class LmsRequestAdapter implements RequestAdapter {
|
||||
@Override
|
||||
public String getUrl() {
|
||||
ISysParamService paramService = SpringContextHolder.getBean(ISysParamService.class);
|
||||
return paramService.findByCode(AcsConfig.WMSURL).getValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.nl.acs.ext.wms;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.agv.hk.ResponseAdapter;
|
||||
import org.nl.acs.agv.hk.UnifiedResponse;
|
||||
|
||||
/**
|
||||
* @Description TODO
|
||||
* @Author Gengby
|
||||
* @Date 2024/4/22
|
||||
*/
|
||||
public class LmsResponseAdapter implements ResponseAdapter {
|
||||
|
||||
@Override
|
||||
public <T> UnifiedResponse<T> adapt(String responseBody, Class<T> type) {
|
||||
JSONObject jsonResponse = JSONObject.parseObject(responseBody);
|
||||
boolean isSuccess = jsonResponse.getInteger("status") == 200;
|
||||
String message = jsonResponse.getString("message");
|
||||
if (type != null) {
|
||||
if (type.isArray()) {
|
||||
T data = JSONObject.toJavaObject(jsonResponse.getJSONArray("data"), type);
|
||||
return new UnifiedResponse<>(isSuccess, message, data);
|
||||
} else {
|
||||
T data = JSONObject.toJavaObject(jsonResponse.getJSONObject("data"), type);
|
||||
return new UnifiedResponse<>(isSuccess, message, data);
|
||||
}
|
||||
}
|
||||
return new UnifiedResponse<>(isSuccess, message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.nl.acs.ext.wms.service;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.acs.agv.hk.UnifiedResponse;
|
||||
import org.nl.acs.ext.wms.data.ApplyGreenFoilButtonRequest;
|
||||
import org.nl.acs.ext.wms.data.ApplyGreenFoilButtonResponse;
|
||||
import org.nl.acs.ext.wms.data.BlankingButtonRequest;
|
||||
@@ -129,4 +130,41 @@ public interface AcsToWmsService {
|
||||
*/
|
||||
BlankingButtonResponse applyBlankButtonTask(BlankingButtonRequest param);
|
||||
|
||||
/**
|
||||
* 反馈车号
|
||||
*
|
||||
* @param request
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
<T> UnifiedResponse<T> feedCarNo(JSONObject request);
|
||||
|
||||
/**
|
||||
* 反馈重量
|
||||
*
|
||||
* @param request
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
<T> UnifiedResponse<T> feedWeight(JSONObject request, Class<T> type);
|
||||
|
||||
|
||||
/**
|
||||
* 申请放货
|
||||
*
|
||||
* @param request
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
<T> UnifiedResponse<T> applyPass(JSONObject request, Class<T> type);
|
||||
|
||||
/**
|
||||
* 取货完成
|
||||
*
|
||||
* @param request
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
<T> UnifiedResponse<T> takeFinish(JSONObject request);
|
||||
|
||||
}
|
||||
|
||||
@@ -14,7 +14,9 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.AcsConfig;
|
||||
import org.nl.acs.address.service.AddressService;
|
||||
import org.nl.acs.address.service.dto.AddressDto;
|
||||
import org.nl.acs.agv.hk.UnifiedResponse;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.ext.wms.LmsHttpUtil;
|
||||
import org.nl.acs.ext.wms.data.ApplyGreenFoilButtonRequest;
|
||||
import org.nl.acs.ext.wms.data.ApplyGreenFoilButtonResponse;
|
||||
import org.nl.acs.ext.wms.data.BlankingButtonRequest;
|
||||
@@ -59,6 +61,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
|
||||
public String token;
|
||||
|
||||
@Autowired
|
||||
private LmsHttpUtil lmsHttpUtil;
|
||||
|
||||
TLogHutoolhttpInterceptor tLogHutoolhttpInterceptor = new TLogHutoolhttpInterceptor();
|
||||
|
||||
private String log_file_type = "log_file_type";
|
||||
@@ -147,7 +152,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
.header(Header.USER_AGENT, "Hutool http")
|
||||
.header("Authorization", token).body(String.valueOf(data))
|
||||
.execute();
|
||||
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"feedTaskStatus", String.valueOf(result2.getStatus()),
|
||||
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "feedTaskStatus", String.valueOf(result2.getStatus()),
|
||||
String.valueOf(data), String.valueOf(result2.body()), "ACS向WMS反馈任务状态");
|
||||
luceneLogService.interfaceExecuteLog(luceneLogDto);
|
||||
} catch (Exception e) {
|
||||
@@ -162,7 +167,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
type = "info";
|
||||
JSONObject jo = JSONObject.parseObject(result2.body());
|
||||
log.info("feedbackTaskStatusToWms-----输出参数{}", jo.toString());
|
||||
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"feedTaskStatus", String.valueOf(result2.getStatus()),
|
||||
LuceneLogDto luceneLogDto = new LuceneLogDto(4, "feedTaskStatus", String.valueOf(result2.getStatus()),
|
||||
String.valueOf(data), String.valueOf(result2.body()), "ACS向WMS反馈任务状态");
|
||||
luceneLogService.interfaceExecuteLog(luceneLogDto);
|
||||
return result2;
|
||||
@@ -243,4 +248,28 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
MDC.remove(log_file_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> UnifiedResponse<T> feedCarNo(JSONObject request) {
|
||||
AddressDto addressDto = addressService.findByCode("feedCarNo");
|
||||
return lmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), request);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> UnifiedResponse<T> feedWeight(JSONObject request, Class<T> type) {
|
||||
AddressDto addressDto = addressService.findByCode("feedWeight");
|
||||
return lmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), request, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> UnifiedResponse<T> applyPass(JSONObject request, Class<T> type) {
|
||||
AddressDto addressDto = addressService.findByCode("applyPass");
|
||||
return lmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), request, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> UnifiedResponse<T> takeFinish(JSONObject request) {
|
||||
AddressDto addressDto = addressService.findByCode("takeFinish");
|
||||
return lmsHttpUtil.sendPostRequest(addressDto.getMethods_url(), request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package org.nl.acs.instruction.enums;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author 20220102CG\noblelift
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum InstTypeEnum {
|
||||
|
||||
CTU_IN_TASK("A031", "A031", "CTU入库任务"),
|
||||
CTU_OUT_TASK("A032", "A032", "CTU出库任务"),
|
||||
CTU_MOVE_TASK("A033", "A033", "CTU移库任务"),
|
||||
AGV_TWO_TASK("A012", "A012", "AGV两点任务(称重位到库外站点)"),
|
||||
AGV_TWO2_TASK("A021", "A021", "AGV两点任务(库外站点到库外站点)"),
|
||||
AGV_TWO3_TASK("A013", "A013", "AGV两点任务(库外站点到称重位)"),
|
||||
AGV_THREE_TASK("A011", "A011", "AGV三点任务(称重位到库外站点到称重位)"),
|
||||
OTHER_TASK("8", "8", "其他任务类型");
|
||||
|
||||
|
||||
/**
|
||||
* 索引
|
||||
*/
|
||||
private String index;
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 名字
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param index
|
||||
* @param code
|
||||
* @param name
|
||||
*/
|
||||
InstTypeEnum(String index, String code, String name) {
|
||||
this.index = index;
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
|
||||
}
|
||||
|
||||
public static JSONArray getList() {
|
||||
JSONArray arr = new JSONArray();
|
||||
JSONObject json = new JSONObject();
|
||||
for (InstTypeEnum em : InstTypeEnum.values()) {
|
||||
json.put("code", em.getCode());
|
||||
json.put("name", em.getName());
|
||||
arr.add(json);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public static String getName(String code) {
|
||||
for (InstTypeEnum c : InstTypeEnum.values()) {
|
||||
if (c.code == code) {
|
||||
return c.name;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -364,4 +364,9 @@ public class InstructionDto implements Serializable {
|
||||
*/
|
||||
private String to_device_code;
|
||||
|
||||
/**
|
||||
* 任务完成是否等待
|
||||
*/
|
||||
private String is_wait;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,33 @@ public class LuceneLogDto {
|
||||
/* 指令编码 */
|
||||
private String instruct_code;
|
||||
|
||||
/**
|
||||
* 请求路径
|
||||
*/
|
||||
private String request_url;
|
||||
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private String request_param;
|
||||
|
||||
/**
|
||||
* 响应参数
|
||||
*/
|
||||
private String response_param;
|
||||
|
||||
|
||||
/**
|
||||
* 请求方向
|
||||
*/
|
||||
private String request_direction;
|
||||
|
||||
/**
|
||||
* 执行时间
|
||||
*/
|
||||
private long executeTime;
|
||||
|
||||
/* 任务标识 */
|
||||
private String task_id;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user