diff --git a/ABAP_AS_WITH_POOL.jcoDestination b/ABAP_AS_WITH_POOL.jcoDestination
new file mode 100644
index 0000000..5281aae
--- /dev/null
+++ b/ABAP_AS_WITH_POOL.jcoDestination
@@ -0,0 +1,11 @@
+#for tests only !
+#Tue Apr 30 14:23:52 CST 2024
+jco.destination.pool_capacity=10
+jco.client.lang=ZH
+jco.client.ashost=172.19.0.125
+jco.client.saprouter=
+jco.client.user=RFC
+jco.client.sysnr=00
+jco.destination.peak_limit=10
+jco.client.passwd=dZ7%0^^S.BC9=76d+x^RaptI:lSr7*7(n*?L**;[-c`$qn-b
+jco.client.client=800
diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index aeeddc2..c3442f7 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -16,7 +16,6 @@
-
org.springframework.boot
@@ -98,6 +97,15 @@
fastjson
1.2.83
+
+
+
+ com.sap.conn.jco
+ sapjco3
+ 3.1.2
+ system
+ ${basedir}/src/main/resources/lib/sapjco3.jar
+
@@ -108,6 +116,7 @@
2.5.15
true
+ true
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SapRfcController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SapRfcController.java
new file mode 100644
index 0000000..9d02a3c
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/SapRfcController.java
@@ -0,0 +1,117 @@
+package com.ruoyi.web.controller.common;
+
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.constant.CacheConstants;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.redis.RedisCache;
+import com.ruoyi.common.core.redis.RedisLock;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.file.FileUploadUtils;
+import com.ruoyi.common.utils.file.FileUtils;
+import com.ruoyi.common.utils.file.MinioUtil;
+import com.ruoyi.customer.domain.Customer;
+import com.ruoyi.framework.config.ServerConfig;
+import com.ruoyi.materialType.domain.CMaterialType;
+import com.ruoyi.web.utils.SapFunction.RfcResult;
+import com.ruoyi.web.utils.SapFunction.SapRfcUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * SAP-Rfc Controller
+ *
+ * @author ruoyi
+ */
+@RestController
+@RequestMapping("/rfc/rfc")
+public class SapRfcController
+{
+ private static final Logger log = LoggerFactory.getLogger(SapRfcController.class);
+
+ @Autowired
+ private RedisCache redisCache;
+
+ /**
+ * 获取SAP 国家数据
+ * @param customer
+ * @return
+ */
+ @PreAuthorize("@ss.hasPermi('customer:customer:list')")
+ @GetMapping("/getCountrys")
+ public AjaxResult countrys(Customer customer)
+ {
+ AjaxResult ajax = AjaxResult.success();
+
+ List resCache = redisCache.getCacheObject(getSapCacheKey("country"));
+ if(CollectionUtils.isEmpty(resCache)){
+ resCache = SapRfcUtils.getCountrys(null);
+ redisCache.setCacheObject(getSapCacheKey("country"),resCache);
+ }
+ log.info("获取国家数据条数 - {}", resCache.size());
+ ajax.put("countrysDicts", resCache);
+ return ajax;
+ }
+
+ /**
+ * 获取SAP 行业代码数据
+ * @param customer
+ * @return
+ */
+ @PreAuthorize("@ss.hasPermi('customer:customer:list')")
+ @GetMapping("/getIndustryCode")
+ public AjaxResult industryCode(Customer customer)
+ {
+ AjaxResult ajax = AjaxResult.success();
+
+ List resCache = redisCache.getCacheObject(getSapCacheKey("industryCode"));
+ if(CollectionUtils.isEmpty(resCache)){
+ resCache = SapRfcUtils.getIndustryCode(null);
+ redisCache.setCacheObject(getSapCacheKey("industryCode"),resCache);
+ }
+ log.info("获取行业代码数据条数 - {}", resCache.size());
+ ajax.put("industryCodeDicts", resCache);
+ return ajax;
+ }
+
+ /**
+ * 获取SAP 语言数据
+ * @param customer
+ * @return
+ */
+ @PreAuthorize("@ss.hasPermi('customer:customer:list')")
+ @GetMapping("/getLanguage")
+ public AjaxResult language(Customer customer)
+ {
+ AjaxResult ajax = AjaxResult.success();
+
+ List resCache = redisCache.getCacheObject(getSapCacheKey("language"));
+ if(CollectionUtils.isEmpty(resCache)){
+ resCache = SapRfcUtils.getLanguage(null);
+ redisCache.setCacheObject(getSapCacheKey("language"),resCache);
+ }
+ log.info("获取语言数据条数 - {}", resCache.size());
+ ajax.put("languageDicts", resCache);
+ return ajax;
+ }
+
+ private String getSapCacheKey(String type)
+ {
+ return CacheConstants.SAP_COMMON + type;
+ }
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java
index 19dbb58..8128c65 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/CacheController.java
@@ -44,6 +44,8 @@ public class CacheController
caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
caches.add(new SysCache(CacheConstants.STORAGE_LOCATION, "车间库位"));
caches.add(new SysCache(CacheConstants.SYS_JOB_KEY, "定时任务"));
+
+ caches.add(new SysCache(CacheConstants.SAP_COMMON, "SAP公共数据"));
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/ConnectToSAP.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/ConnectToSAP.java
new file mode 100644
index 0000000..2033f94
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/ConnectToSAP.java
@@ -0,0 +1,83 @@
+package com.ruoyi.web.utils.SapFunction;
+
+import com.sap.conn.jco.JCoDestination;
+import com.sap.conn.jco.JCoDestinationManager;
+import com.sap.conn.jco.JCoException;
+import com.sap.conn.jco.ext.DestinationDataProvider;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.util.Properties;
+
+public class ConnectToSAP {
+
+ private static final String ABAP_AS_POOLED = "ABAP_AS_WITH_POOL";
+ private static JCoDestination destination = null;
+
+ /**
+ * 初始化SAP连接
+ */
+ private static void initProperties() {
+ Properties connectProperties = new Properties();
+ // SAP服务器
+ connectProperties.setProperty(DestinationDataProvider.JCO_ASHOST, "172.19.0.125");
+ // SAP系统编号
+ connectProperties.setProperty(DestinationDataProvider.JCO_SYSNR, "00");
+ // SAP集团
+ connectProperties.setProperty(DestinationDataProvider.JCO_CLIENT, "800");
+ // SAP用户名
+ connectProperties.setProperty(DestinationDataProvider.JCO_USER, "RFC");
+ // SAP密码
+ connectProperties.setProperty(DestinationDataProvider.JCO_PASSWD, "654321");
+ // SAP登录语言
+ connectProperties.setProperty(DestinationDataProvider.JCO_LANG, "ZH");
+ // 最大连接数
+ connectProperties.setProperty(DestinationDataProvider.JCO_POOL_CAPACITY, "10");
+ // 最大连接线程
+ connectProperties.setProperty(DestinationDataProvider.JCO_PEAK_LIMIT, "10");
+ // SAP ROUTER
+ connectProperties.setProperty(DestinationDataProvider.JCO_SAPROUTER, "");
+
+ createDataFile(ABAP_AS_POOLED, "jcoDestination", connectProperties);
+ }
+
+ /**
+ * 创建SAP接口属性文件。
+ *
+ * @param name
+ * ABAP管道名称
+ * @param suffix
+ * 属性文件后缀
+ * @param properties
+ * 属性文件内容
+ */
+ private static void createDataFile(String name, String suffix, Properties properties) {
+ File cfg = new File(name + "." + suffix);
+ if (cfg.exists()) {
+ cfg.deleteOnExit();
+ }
+ try {
+ FileOutputStream fos = new FileOutputStream(cfg, false);
+ properties.store(fos, "for tests only !");
+ fos.close();
+ } catch (Exception e) {
+ System.out.println("Create Data file fault, error msg: " + e.toString());
+ throw new RuntimeException("Unable to create the destination file " + cfg.getName(), e);
+ }
+ }
+
+ /*
+ * * 获取SAP连接
+ *
+ * @return SAP连接对象
+ */
+ public static JCoDestination connect() {
+ try {
+ initProperties();
+ if(null == destination)
+ destination = JCoDestinationManager.getDestination(ABAP_AS_POOLED);
+ } catch (JCoException e) {
+ System.out.println("Connect SAP fault, error msg: " + e.toString());
+ }
+ return destination;
+ }
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/RfcResult.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/RfcResult.java
new file mode 100644
index 0000000..4d3a199
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/RfcResult.java
@@ -0,0 +1,22 @@
+package com.ruoyi.web.utils.SapFunction;
+
+public class RfcResult {
+ private String value;
+ private String label;
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+ public String getLabel() {
+ return label;
+ }
+
+ public void setLabel(String label) {
+ this.label = label;
+ }
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/SapRfcUtils.java b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/SapRfcUtils.java
new file mode 100644
index 0000000..4a40798
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/utils/SapFunction/SapRfcUtils.java
@@ -0,0 +1,108 @@
+package com.ruoyi.web.utils.SapFunction;
+
+import com.ruoyi.common.utils.StringUtils;
+import com.sap.conn.jco.JCoDestination;
+import com.sap.conn.jco.JCoFunction;
+import com.sap.conn.jco.JCoParameterList;
+import com.sap.conn.jco.JCoTable;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class SapRfcUtils {
+ /**
+ * 获取SAP国家数据
+ * @param param 不传查询全部
+ * @return
+ */
+ public static List getCountrys(String param){
+ JCoFunction function = null;
+ RfcResult rfcResult = null;
+ List countrys = new ArrayList<>();
+
+ JCoDestination destination = ConnectToSAP.connect();
+ try {
+ function = destination.getRepository().getFunctionTemplate("ZRFC_BASIC_DATA").getFunction();
+ if (function == null)
+ throw new RuntimeException("RFC_SYSTEM_INFO not found in SAP.");
+ JCoParameterList input = function.getImportParameterList();
+ input.setValue("FALG20", StringUtils.isNotNull(param)?param:"X");//输入参数
+ function.execute(destination);
+ JCoTable table = function.getTableParameterList().getTable("T_T005T");
+ for(int i = 0; i getIndustryCode(String param){
+ JCoFunction function = null;
+ RfcResult rfcResult = null;
+ List countrys = new ArrayList<>();
+
+ JCoDestination destination = ConnectToSAP.connect();
+ try {
+ function = destination.getRepository().getFunctionTemplate("ZRFC_BASIC_DATA").getFunction();
+ if (function == null)
+ throw new RuntimeException("RFC_SYSTEM_INFO not found in SAP.");
+ JCoParameterList input = function.getImportParameterList();
+ input.setValue("FLAG59", StringUtils.isNotNull(param)?param:"X");//输入参数
+ function.execute(destination);
+ JCoTable table = function.getTableParameterList().getTable("T_TBRC");
+ for(int i = 0; i getLanguage(String param){
+ JCoFunction function = null;
+ RfcResult rfcResult = null;
+ List countrys = new ArrayList<>();
+
+ JCoDestination destination = ConnectToSAP.connect();
+ try {
+ function = destination.getRepository().getFunctionTemplate("ZRFC_BASIC_DATA").getFunction();
+ if (function == null)
+ throw new RuntimeException("RFC_SYSTEM_INFO not found in SAP.");
+ JCoParameterList input = function.getImportParameterList();
+ input.setValue("FLAG27", StringUtils.isNotNull(param)?param:"X");//输入参数
+ function.execute(destination);
+ JCoTable table = function.getTableParameterList().getTable("T_T002T");
+ for(int i = 0; i
+ v-for="item in countrysDicts"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value"
+ />
@@ -249,11 +249,11 @@
+ v-for="item in languageDicts"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value"
+ />
@@ -390,9 +390,11 @@