From 7d1d8c22e6c9157d353aadf5d8b173b3e0d5eea1 Mon Sep 17 00:00:00 2001
From: gongbaoxiong <751575283@qq.com>
Date: Thu, 10 Jul 2025 13:31:47 +0800
Subject: [PATCH] =?UTF-8?q?add:=E5=A2=9E=E5=8A=A0RCS=E4=B8=8B=E5=8F=91?=
=?UTF-8?q?=E9=80=BB=E8=BE=91=EF=BC=9B=20add:=E5=A2=9E=E5=8A=A0PC=E5=87=BA?=
=?UTF-8?q?=E5=BA=93=E5=88=86=E9=85=8D=E9=80=BB=E8=BE=91=EF=BC=9B=20opt:?=
=?UTF-8?q?=E4=BC=98=E5=8C=96=E9=80=9A=E7=94=A8API=E9=80=9A=E8=AE=AF?=
=?UTF-8?q?=E5=B7=A5=E5=85=B7=EF=BC=9B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../java/org/nl/wms/ext/util/AcsUtil.java | 73 -----------------
.../java/org/nl/wms/ext/util/NotifyUtil.java | 50 +++++++++++
.../wms/gateway/service/GateWayService.java | 82 -------------------
.../wms/gateway/service/IGateWayService.java | 38 +++++++++
4 files changed, 88 insertions(+), 155 deletions(-)
delete mode 100644 nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/util/AcsUtil.java
create mode 100644 nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/util/NotifyUtil.java
delete mode 100644 nladmin-system/nlsso-server/src/main/java/org/nl/wms/gateway/service/GateWayService.java
create mode 100644 nladmin-system/nlsso-server/src/main/java/org/nl/wms/gateway/service/IGateWayService.java
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/util/AcsUtil.java b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/util/AcsUtil.java
deleted file mode 100644
index 300ad13..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/util/AcsUtil.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.nl.wms.ext.util;
-
-import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.http.HttpRequest;
-import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
-import org.nl.config.SpringContextHolder;
-import org.nl.system.enums.SysParamConstant;
-import org.nl.system.service.param.dao.Param;
-import org.nl.system.service.param.impl.SysParamServiceImpl;
-import org.nl.wms.ext.service.util.AcsResponse;
-import org.nl.wms.warehouse_management.enums.IOSConstant;
-import org.springframework.stereotype.Component;
-
-/**
- *
- * ACS工具类
- *
- *
- * @author Liuxy
- * @since 2025-06-09
- */
-@Slf4j
-@Component
-public class AcsUtil {
-
- /**
- * 下发任务
- * @param api acs地址
- * @param param 下发参数
- * @return AcsResponse
- */
- public static AcsResponse notifyAcs(String api, T param) {
- log.info("下发ACS任务的输入参数为:-------------------" + param.toString());
- // 返回参数
- AcsResponse resultAcs;
- // 系统参数类
- SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
- //判断是否连接ACS系统
- Param isConnectAcs = sysParamService.findByCode(SysParamConstant.IS_CONNECT_ACS);
- if (ObjectUtil.isEmpty(isConnectAcs)) {
- return AcsResponse.requestError("系统参数表中:" + SysParamConstant.IS_CONNECT_ACS + "不存在");
- }
- if (isConnectAcs.getValue().equals(IOSConstant.IS_DELETE_NO)) {
- return AcsResponse.requestOkMessage("下发成功,未连接ACS系统!");
- }
-
- //ACS地址
- Param acsUrlParam = sysParamService.findByCode(SysParamConstant.ACS_URL);
- if (ObjectUtil.isEmpty(acsUrlParam)) {
- return AcsResponse.requestError("系统参数表中:" + SysParamConstant.ACS_URL + "不存在");
- }
-
- String url = acsUrlParam.getValue() + api;
- try {
- String resultMsg = HttpRequest.post(url)
- .body(String.valueOf(param))
- .execute().body();
- // 格式转换
- JSONObject result = JSONObject.parseObject(resultMsg);
- resultAcs = JSONObject.toJavaObject(result, AcsResponse.class);
-
- log.info("下发ACS任务的输出参数为:-------------------" + resultMsg);
- } catch (Exception e) {
- //网络不通
- String msg = e.getMessage();
- log.error("连接失败:{}", msg);
- return AcsResponse.requestError("网络不通,操作失败!");
- }
- return resultAcs;
- }
-
-}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/util/NotifyUtil.java b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/util/NotifyUtil.java
new file mode 100644
index 0000000..e57cfb8
--- /dev/null
+++ b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/util/NotifyUtil.java
@@ -0,0 +1,50 @@
+package org.nl.wms.ext.util;
+
+import cn.hutool.core.util.StrUtil;
+import cn.hutool.http.HttpRequest;
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.nl.common.exception.BadRequestException;
+import org.nl.config.SpringContextHolder;
+import org.nl.system.service.param.dao.Param;
+import org.nl.system.service.param.impl.SysParamServiceImpl;
+import org.nl.wms.warehouse_management.enums.IOSConstant;
+import org.springframework.stereotype.Component;
+
+/**
+ *
+ * api连接工具类
+ *
+ *
+ * @author gbx
+ * @since 2025-07-08
+ */
+@Slf4j
+@Component
+public class NotifyUtil {
+ public static R apiNotify(String api, String isNeedConnect, String systemType, T param, Class responseClass) {
+ SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
+ String connectValue = getParam(sysParamService, isNeedConnect);
+ if (IOSConstant.IS_DELETE_NO.equals(connectValue)) {
+ log.info("未连接系统,跳过下发!");
+ }
+ String url = getParam(sysParamService, systemType) + api;
+ try {
+ String response = HttpRequest.post(url).body(String.valueOf(param)).execute().body();
+ log.info("【下发任务请求】API: {}, param: {}", api, param);
+ log.info("下发ACS任务完成,api:{}下发参数为:-------------------{},响应信息:{}", api, param, response);
+ return JSONObject.parseObject(response, responseClass);
+ } catch (Exception e) {
+ log.error("下发任务失败,api: {}, 错误信息: {}", api, e.getMessage(), e);
+ throw new BadRequestException("下发任务失败:网络异常或调用失败!");
+ }
+ }
+
+ private static String getParam(SysParamServiceImpl service, String code) {
+ Param param = service.findByCode(code);
+ if (param == null || StrUtil.isBlank(param.getValue())) {
+ throw new BadRequestException("系统参数不存在: " + code);
+ }
+ return param.getValue();
+ }
+}
diff --git a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/gateway/service/GateWayService.java b/nladmin-system/nlsso-server/src/main/java/org/nl/wms/gateway/service/GateWayService.java
deleted file mode 100644
index be39afb..0000000
--- a/nladmin-system/nlsso-server/src/main/java/org/nl/wms/gateway/service/GateWayService.java
+++ /dev/null
@@ -1,82 +0,0 @@
-package org.nl.wms.gateway.service;
-
-import cn.hutool.core.lang.Assert;
-import com.alibaba.fastjson.JSONObject;
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import org.nl.common.exception.BadRequestException;
-import org.nl.common.utils.RedissonUtils;
-import org.nl.wms.ext.service.AcsToWmsService;
-import org.nl.wms.gateway.dto.InteracteDto;
-import org.nl.wms.gateway.service.impl.GateWayServiceImpl;
-import org.nl.wms.sch_manage.service.ISchBasePointService;
-import org.nl.wms.sch_manage.service.ISchBaseTaskService;
-import org.nl.wms.sch_manage.service.dao.SchBasePoint;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Service;
-
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicReference;
-
-/**
- * 网关执行接口层
- *
- * @author gbx
- * @since 2025-06-27
- */
-@Service
-public class GateWayService {
-
- @Autowired
- private GateWayServiceImpl gateWayServiceImpl;
- @Autowired
- private ISchBasePointService iSchBasePointService;
- @Autowired
- private ISchBaseTaskService iSchBaseTaskService;
-
-
- public JSONObject apply(InteracteDto