andy 11 months ago
parent
commit
6d4dd2e44f

+ 1 - 0
license

@@ -0,0 +1 @@
+DAeCLMulHH/CISfb8yIT5Y/WPvQjcE12NqTnWXngN2k6BIlHWgMoVjwX1KzZ/cqV/aQ9yykOfNJvpiwlRXuOvhIlCTiUFalkXcdAUOgCi5HIiG56mGxi2gtsklYEZiiQSRKOEZbju01KBgwdiOWmI979teHmnJZOxKM6YKSyIH42XEzlMp9ecEuxS0gYVgcLq0XHKQpemreWasUBRGJgfxNum51HeQdufPYF1REwCS2fq0UE4Xhf+cMFYK1LOugP8hfB+mgguUG9tnOC1GIMqNB0SoZZTzOsOLeLss4wKWMRJgxX2LqTTpe2KduR9mG/tKwLR34Yfiiictye6kjnPQ==

+ 1 - 4
src/main/java/com/scbfkj/uni/api/GenericApi.java

@@ -6,10 +6,7 @@ import com.scbfkj.uni.system.Config;
 import com.scbfkj.uni.system.ProcessUtil;
 import com.scbfkj.uni.system.ProcessUtil;
 import org.springframework.http.HttpStatusCode;
 import org.springframework.http.HttpStatusCode;
 import org.springframework.http.ResponseEntity;
 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 org.springframework.web.bind.annotation.*;
 
 
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;

+ 3 - 3
src/main/java/com/scbfkj/uni/api/LogAop.java

@@ -56,12 +56,13 @@ public class LogAop {
         try {
         try {
             Map body = null;
             Map body = null;
 
 
-//            判断服务状态是否为健康状态 runstate!=0
-            if (args.length > 0) {
+//            判断服务状态是否为健康状态 runstate!=0 只判断openApi接口
+            if (args.length > 0 && uri.startsWith("/openApi")) {
                 Object arg = args[0];
                 Object arg = args[0];
                 if (arg instanceof Map map) {
                 if (arg instanceof Map map) {
 //                    查找serviceid
 //                    查找serviceid
                     body = map;
                     body = map;
+                    Util.addFilter(body, serviceid, uri, true);
                     serviceid = DataAliasGetUtil.getValue("serviceid", map);
                     serviceid = DataAliasGetUtil.getValue("serviceid", map);
                     if (serviceid.isEmpty()) {
                     if (serviceid.isEmpty()) {
                         List<Map<String, Object>> query = DATA_BASE.query(Config.getCenterConnectionStr(), "select * from serviceinfo where urilist=?", uri);
                         List<Map<String, Object>> query = DATA_BASE.query(Config.getCenterConnectionStr(), "select * from serviceinfo where urilist=?", uri);
@@ -93,7 +94,6 @@ public class LogAop {
                 return ResponseEntity.ok(UniReturnUtil.fail(message));
                 return ResponseEntity.ok(UniReturnUtil.fail(message));
             }
             }
 
 
-            Util.addFilter(body, serviceid, uri, true);
 
 
             ResponseEntity<Map<String, Object>> responseEntity = (ResponseEntity<Map<String, Object>>) joinPoint.proceed(args);
             ResponseEntity<Map<String, Object>> responseEntity = (ResponseEntity<Map<String, Object>>) joinPoint.proceed(args);
             Map<String, Object> responseEntityBody = responseEntity.getBody();
             Map<String, Object> responseEntityBody = responseEntity.getBody();

+ 1 - 1
src/main/java/com/scbfkj/uni/config/CorsConfig.java

@@ -11,7 +11,7 @@ public class CorsConfig implements WebMvcConfigurer {
         registry.addMapping("/**") // 所有接口
         registry.addMapping("/**") // 所有接口
                 .allowCredentials(true) // 是否发送 Cookie
                 .allowCredentials(true) // 是否发送 Cookie
                 .allowedOriginPatterns("*") // 支持域
                 .allowedOriginPatterns("*") // 支持域
-                .allowedMethods("GET", "POST", "PUT", "DELETE") // 支持方法
+                .allowedMethods("GET", "POST") // 支持方法
                 .allowedHeaders("*")
                 .allowedHeaders("*")
                 .exposedHeaders("*");
                 .exposedHeaders("*");
     }
     }

+ 1 - 1
src/main/java/com/scbfkj/uni/library/DataFormatUtil.java

@@ -301,7 +301,7 @@ public final class DataFormatUtil {
             } else {
             } else {
                 result = node.toString();
                 result = node.toString();
             }
             }
-        } else if ("List".equalsIgnoreCase(type)) {
+        } else if ("List".equalsIgnoreCase(type) || "Collection".equalsIgnoreCase(type)) {
             result = DataFormatUtil.toList(node);
             result = DataFormatUtil.toList(node);
         } else if ("Array".equalsIgnoreCase(type)) {
         } else if ("Array".equalsIgnoreCase(type)) {
             result = DataFormatUtil.toArray(node);
             result = DataFormatUtil.toArray(node);

+ 5 - 2
src/main/java/com/scbfkj/uni/library/script/JavaScriptEngineUtil.java

@@ -141,11 +141,14 @@ public class JavaScriptEngineUtil {
             Class<?>[] parameterTypes = apply.getParameterTypes();
             Class<?>[] parameterTypes = apply.getParameterTypes();
             for (int i = 0; i < parameterTypes.length; i++) {
             for (int i = 0; i < parameterTypes.length; i++) {
                 Object arg = args[i];
                 Object arg = args[i];
-                if(!parameterTypes[i].isInstance(arg)) {
-                    args[i] = DataFormatUtil.castType(arg,parameterTypes[i]);
+                if (!parameterTypes[i].isInstance(arg)) {
+                    if (arg != null) {
+                        args[i] = DataFormatUtil.castType(arg, parameterTypes[i]);
+                    }
                 }
                 }
             }
             }
             return apply.invoke(instance, args);
             return apply.invoke(instance, args);
+
         }
         }
     }
     }
 }
 }

+ 66 - 31
src/main/java/com/scbfkj/uni/library/script/JsScriptEngineUtil.java

@@ -3,19 +3,11 @@ package com.scbfkj.uni.library.script;
 import com.scbfkj.uni.library.DataFormatUtil;
 import com.scbfkj.uni.library.DataFormatUtil;
 import com.scbfkj.uni.library.UniReturnUtil;
 import com.scbfkj.uni.library.UniReturnUtil;
 import com.scbfkj.uni.system.Config;
 import com.scbfkj.uni.system.Config;
-import org.apache.commons.pool2.BaseKeyedPooledObjectFactory;
-import org.apache.commons.pool2.KeyedObjectPool;
-import org.apache.commons.pool2.PooledObject;
-import org.apache.commons.pool2.impl.DefaultPooledObject;
-import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
-import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
 import org.graalvm.polyglot.Context;
 import org.graalvm.polyglot.Context;
 import org.graalvm.polyglot.Source;
 import org.graalvm.polyglot.Source;
 import org.graalvm.polyglot.Value;
 import org.graalvm.polyglot.Value;
 
 
-import java.util.List;
 import java.util.Map;
 import java.util.Map;
-import java.util.Objects;
 
 
 public final class JsScriptEngineUtil {
 public final class JsScriptEngineUtil {
 
 
@@ -31,45 +23,51 @@ public final class JsScriptEngineUtil {
             args =JSON.parse(paramsArgsObject)
             args =JSON.parse(paramsArgsObject)
             }
             }
             """;
             """;
-    private static final KeyedObjectPool<String, Source> sourcePool = new GenericKeyedObjectPool<>(new BaseKeyedPooledObjectFactory<>() {
-        @Override
-        public Source create(String script) {
-            return Source.create("js", script);
-        }
-
-        @Override
-        public PooledObject<Source> wrap(Source value) {
-            return new DefaultPooledObject<>(value);
-        }
-
-        @Override
-        public void destroyObject(String key, PooledObject<Source> p) throws Exception {
-            super.destroyObject(key, p);
-        }
-    }, new GenericKeyedObjectPoolConfig<>());
-
 
 
+    /**
+     * 执行脚本并返回执行结果。
+     *
+     * @param script 要执行的脚本代码。
+     * @param args   脚本执行时传递的参数。
+     * @return 执行结果,是一个包含执行结果的Map对象。
+     * @throws Exception 如果执行过程中发生异常,则抛出Exception。
+     */
     public static Map<String, Object> eval(String script, Object args) throws Exception {
     public static Map<String, Object> eval(String script, Object args) throws Exception {
 
 
         try {
         try {
+            // 尝试执行脚本并返回结果
             return UniReturnUtil.success(exec(script, args));
             return UniReturnUtil.success(exec(script, args));
         } catch (Exception e) {
         } catch (Exception e) {
+            // 当处于调试模式时,输出脚本和参数信息以及异常栈跟踪
             if (Config.isDebug()) {
             if (Config.isDebug()) {
+                System.out.println(script + "\n" + DataFormatUtil.toString(args));
                 e.printStackTrace();
                 e.printStackTrace();
             }
             }
+            // 重新抛出捕获到的异常
             throw e;
             throw e;
         }
         }
     }
     }
 
 
+    /**
+     * 执行指定的JavaScript脚本并返回执行结果。
+     *
+     * @param script 要执行的JavaScript脚本代码。
+     * @param args   传递给脚本的参数,可以是任意类型。
+     * @return 执行脚本后的结果,类型为Object,具体返回值取决于脚本的执行结果。
+     * @throws Exception 如果执行过程中发生错误,则抛出Exception。
+     */
     public static Object exec(String script, Object args) throws Exception {
     public static Object exec(String script, Object args) throws Exception {
 
 
-        String sc = ARGS + script;
-
-        Source source = Source.create("js", sc);
+        Source source = Source.create("js", script);
         try (Context context = Context.create("js")) {
         try (Context context = Context.create("js")) {
             Value bindings = context.getBindings("js");
             Value bindings = context.getBindings("js");
             bindings.putMember("paramsArgsObject", DataFormatUtil.toString(args));
             bindings.putMember("paramsArgsObject", DataFormatUtil.toString(args));
+
+            context.eval("js", ARGS);
+            // 执行源代码并获取结果
             Value function = context.eval(source);
             Value function = context.eval(source);
+
+            // 判断结果是否可执行,若可执行则执行并返回结果,否则直接返回结果对象
             if (function.canExecute()) {
             if (function.canExecute()) {
                 Value result = function.execute();
                 Value result = function.execute();
                 return toHostObject(result);
                 return toHostObject(result);
@@ -79,20 +77,57 @@ public final class JsScriptEngineUtil {
         }
         }
     }
     }
 
 
-    public static Object toHostObject(Value result) throws Exception {
 
 
+    /**
+     * 将 Value 对象转换为宿主对象。
+     *
+     * @param result Value对象,表示待转换的数据。
+     * @return 返回转换后的宿主对象。如果result是字符串,则返回对应的字符串对象;否则,将result转换为JSON节点对象。
+     * @throws Exception 如果转换过程中发生错误,则抛出异常。
+     */
+    private static Object toHostObject(Value result) throws Exception {
+        if (result.isNull()) {
+            return null;
+        }
+        if (result.isBoolean()) {
+            return (Boolean) result.asBoolean();
+        }
+        if (result.fitsInLong()) {
+            return (Long) result.asLong();
+        }
+        if (result.fitsInDouble()) {
+            return (Double) result.asDouble();
+        }
+        if (result.isDate()) {
+            return result.asDate();
+        }
+        if (result.isHostObject()) {
+            return result.asHostObject();
+        }
         if (result.isString()) {
         if (result.isString()) {
             return result.asString();
             return result.asString();
         }
         }
-        String string = toString(result);
+
+        // 将result转换为字符串,并进一步转换为JSON节点对象
+        String string = jsToString(result);
         return DataFormatUtil.toJsonNode(string);
         return DataFormatUtil.toJsonNode(string);
     }
     }
 
 
-    private static String toString(Value value) throws Exception {
+    /**
+     * 将JavaScript类型的值转换为字符串。
+     *
+     * @param value 需要转换的JavaScript值。
+     * @return 转换后的字符串。
+     * @throws Exception 如果执行JavaScript脚本或转换过程中发生错误,则抛出异常。
+     */
+    private static String jsToString(Value value) throws Exception {
+        // 创建一个包含转换逻辑的JavaScript源码
         Source source = Source.create("js", TO_STRING_SCRIPT);
         Source source = Source.create("js", TO_STRING_SCRIPT);
         try (Context context = Context.create("js")) {
         try (Context context = Context.create("js")) {
+            // 在JavaScript环境中评估该源码,得到一个函数
             Value function = context.eval(source);
             Value function = context.eval(source);
 
 
+            // 使用该函数执行给定的JavaScript值,并将结果转换为字符串
             return function.execute(value).asString();
             return function.execute(value).asString();
         }
         }
     }
     }

+ 79 - 77
src/main/java/com/scbfkj/uni/process/DataBase.java

@@ -22,59 +22,60 @@ public class DataBase {
 
 
 //        缓存数据 connectionStr + sql
 //        缓存数据 connectionStr + sql
 
 
-        String key = "%s;%s;%s".formatted(connectionStr, sql, DataFormatUtil.toString(argsList));
-        String effectivedurationColumnName = "effectiveduration";
-        if (cacheDatas.containsKey(key)) {
-            Map<String, Object> cacheData = cacheDatas.get(key);
-
-            Object effectiveduration = cacheData.get(effectivedurationColumnName);
-            if (Objects.isNull(effectiveduration) || ((LocalDateTime) effectiveduration).isBefore(LocalDateTime.now())) {
-                cacheDatas.remove(key);
-            } else {
-                return ((List<Map<String, Object>>) cacheData.get("data"));
-            }
-        }
-
-        HikariPool dataSourcePool = getDataSourcePool(connectionStr);
-        List<Map<String, Object>> result = argsList.parallelStream().flatMap(args -> {
-            Connection connection = null;
-            try {
-                synchronized (dataSourcePool) {
-                    connection = dataSourcePool.getConnection();
+            String key = "%s;%s;%s".formatted(connectionStr, sql, DataFormatUtil.toString(argsList));
+            String effectivedurationColumnName = "effectiveduration";
+            if (cacheDatas.containsKey(key)) {
+                Map<String, Object> cacheData = cacheDatas.get(key);
+
+                Object effectiveduration = cacheData.get(effectivedurationColumnName);
+                if (Objects.isNull(effectiveduration) || ((LocalDateTime) effectiveduration).isBefore(LocalDateTime.now())) {
+                    cacheDatas.remove(key);
+                } else {
+                    return ((List<Map<String, Object>>) cacheData.get("data"));
                 }
                 }
-            } catch (SQLException e) {
-                throw new RuntimeException("数据库连接异常: %s\n sql: %s ;\n args: %s ".formatted(e.getMessage(), sql, DataFormatUtil.toString(args)));
             }
             }
-            try (
-                    PreparedStatement preparedStatement = connection.prepareStatement(sql)
-            ) {
-                for (int i = 0; i < args.length; i++) {
-                    preparedStatement.setObject(i + 1, args[i]);
-                }
-                ResultSet resultSet = preparedStatement.executeQuery();
-                return getResult(connectionStr, sql, resultSet).stream();
-            } catch (Exception exception) {
-                throw new RuntimeException("数据异常: %s\n sql: %s ;\n args: %s ".formatted(exception.getMessage(), sql, DataFormatUtil.toString(args)));
-            } finally {
+
+            HikariPool dataSourcePool = getDataSourcePool(connectionStr);
+            List<Map<String, Object>> result = argsList.parallelStream().flatMap(args -> {
+                Connection connection = null;
                 try {
                 try {
-                    connection.close();
+                    synchronized (dataSourcePool) {
+                        connection = dataSourcePool.getConnection();
+                    }
                 } catch (SQLException e) {
                 } catch (SQLException e) {
-                    if (Config.isDebug()) {
-                        e.printStackTrace();
+                    throw new RuntimeException("数据库连接异常: %s\n sql: %s ;\n args: %s ".formatted(e.getMessage(), sql, DataFormatUtil.toString(args)));
+                }
+                try (
+                        PreparedStatement preparedStatement = connection.prepareStatement(sql)
+                ) {
+                    for (int i = 0; i < args.length; i++) {
+                        preparedStatement.setObject(i + 1, args[i]);
+                    }
+                    ResultSet resultSet = preparedStatement.executeQuery();
+                    return getResult(connectionStr, sql, resultSet).stream();
+                } catch (Exception exception) {
+                    throw new RuntimeException("数据异常: %s\n sql: %s ;\n args: %s ".formatted(exception.getMessage(), sql, DataFormatUtil.toString(args)));
+                } finally {
+                    try {
+                        connection.close();
+                    } catch (SQLException e) {
+                        if (Config.isDebug()) {
+                            e.printStackTrace();
+                        }
                     }
                     }
                 }
                 }
+            }).toList();
+            String querySql = """
+                    select
+                        datacacheid, connectset, querysql, querytable, effectiveduration, datacachedescribe
+                    from datacache""";
+            if (!Objects.equals(querySql, sql)) {
+                cacheConfigList = query(Config.getCenterConnectionStr(), querySql);
             }
             }
-        }).toList();
-        String querySql = """
-                select
-                    datacacheid, connectset, querysql, querytable, effectiveduration, datacachedescribe
-                from datacache""";
-        if (!Objects.equals(querySql, sql)) {
-            cacheConfigList = query(Config.getCenterConnectionStr(), querySql);
-        }
-        List<Map<String, Object>> finalResult = result;
-        saveCacheData(connectionStr, sql, key, effectivedurationColumnName, finalResult);
-        return result;
+            List<Map<String, Object>> finalResult = result;
+            saveCacheData(connectionStr, sql, key, effectivedurationColumnName, finalResult);
+            return result;
+
     }
     }
 
 
     private void saveCacheData(String connectionStr, String sql, String key, String effectivedurationColumnName, List<Map<String, Object>> finalResult) {
     private void saveCacheData(String connectionStr, String sql, String key, String effectivedurationColumnName, List<Map<String, Object>> finalResult) {
@@ -92,43 +93,44 @@ public class DataBase {
 
 
 //        缓存数据 connectionStr + sql
 //        缓存数据 connectionStr + sql
 
 
-        String key = "%s;%s;%s".formatted(connectionStr, sql, DataFormatUtil.toString(args));
-        String effectivedurationColumnName = "effectiveduration";
-        if (cacheDatas.containsKey(key)) {
-            Map<String, Object> cacheData = cacheDatas.get(key);
+            String key = "%s;%s;%s".formatted(connectionStr, sql, DataFormatUtil.toString(args));
+            String effectivedurationColumnName = "effectiveduration";
+            if (cacheDatas.containsKey(key)) {
+                Map<String, Object> cacheData = cacheDatas.get(key);
+
+                Object effectiveduration = cacheData.get(effectivedurationColumnName);
+                if (Objects.isNull(effectiveduration) || ((LocalDateTime) effectiveduration).isBefore(LocalDateTime.now())) {
+                    cacheDatas.remove(key);
+                } else {
+                    return ((List<Map<String, Object>>) cacheData.get("data"));
+                }
 
 
-            Object effectiveduration = cacheData.get(effectivedurationColumnName);
-            if (Objects.isNull(effectiveduration) || ((LocalDateTime) effectiveduration).isBefore(LocalDateTime.now())) {
-                cacheDatas.remove(key);
-            } else {
-                return ((List<Map<String, Object>>) cacheData.get("data"));
             }
             }
 
 
-        }
+            HikariPool dataSourcePool = getDataSourcePool(connectionStr);
+            List<Map<String, Object>> result;
+            try (Connection connection = dataSourcePool.getConnection();
+                 PreparedStatement preparedStatement = connection.prepareStatement(sql)
+            ) {
+                for (int i = 0; i < args.length; i++) {
+                    preparedStatement.setObject(i + 1, args[i]);
+                }
+                ResultSet resultSet = preparedStatement.executeQuery();
+                result = getResult(connectionStr, sql, resultSet);
+            } catch (Exception exception) {
+                throw new RuntimeException("数据异常: %s\n sql: %s ;\n args: %s ".formatted(exception.getMessage(), sql, DataFormatUtil.toDate(args)));
+            }
 
 
-        HikariPool dataSourcePool = getDataSourcePool(connectionStr);
-        List<Map<String, Object>> result;
-        try (Connection connection = dataSourcePool.getConnection();
-             PreparedStatement preparedStatement = connection.prepareStatement(sql)
-        ) {
-            for (int i = 0; i < args.length; i++) {
-                preparedStatement.setObject(i + 1, args[i]);
+            String querySql = """
+                    select
+                        datacacheid, connectset, querysql, querytable, effectiveduration, datacachedescribe
+                    from datacache""";
+            if (!Objects.equals(querySql, sql)) {
+                cacheConfigList = query(Config.getCenterConnectionStr(), querySql);
             }
             }
-            ResultSet resultSet = preparedStatement.executeQuery();
-            result = getResult(connectionStr, sql, resultSet);
-        } catch (Exception exception) {
-            throw new RuntimeException("数据异常: %s\n sql: %s ;\n args: %s ".formatted(exception.getMessage(), sql, DataFormatUtil.toDate(args)));
-        }
+            saveCacheData(connectionStr, sql, key, effectivedurationColumnName, result);
+            return result;
 
 
-        String querySql = """
-                select
-                    datacacheid, connectset, querysql, querytable, effectiveduration, datacachedescribe
-                from datacache""";
-        if (!Objects.equals(querySql, sql)) {
-            cacheConfigList = query(Config.getCenterConnectionStr(), querySql);
-        }
-        saveCacheData(connectionStr, sql, key, effectivedurationColumnName, result);
-        return result;
     }
     }
 
 
     public int[] updateBatch(String connectionStr, String sql, List<Object[]> argsList) throws Exception {
     public int[] updateBatch(String connectionStr, String sql, List<Object[]> argsList) throws Exception {

+ 8 - 5
src/main/java/com/scbfkj/uni/process/Http.java

@@ -11,7 +11,6 @@ import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
 import org.apache.http.util.EntityUtils;
 import org.apache.http.util.EntityUtils;
 
 
-import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
@@ -53,7 +52,7 @@ public class Http {
         return execWebApi(headers, method, defaultBody, host);
         return execWebApi(headers, method, defaultBody, host);
     }
     }
 
 
-    public Map<String, Object> execWebApi(Object headers, String method, Object defaultBody, String url) throws IOException {
+    public Map<String, Object> execWebApi(Object headers, String method, Object defaultBody, String url) {
 
 
         if (Config.isDebug()) {
         if (Config.isDebug()) {
             System.out.println("url: " + DataFormatUtil.toString(url));
             System.out.println("url: " + DataFormatUtil.toString(url));
@@ -90,14 +89,18 @@ public class Http {
 
 
         try {
         try {
             HttpResponse response = httpClient.execute(request);
             HttpResponse response = httpClient.execute(request);
+            String contentType = response.getEntity().getContentType().getValue();
             int statusCode = response.getStatusLine().getStatusCode();
             int statusCode = response.getStatusLine().getStatusCode();
-            String responseBody = EntityUtils.toString(response.getEntity());
+            if (contentType.equalsIgnoreCase("application/octet-stream")) {
+                return UniReturnUtil.success(EntityUtils.toByteArray(response.getEntity()));
+            }
+            Object responseBody = EntityUtils.toString(response.getEntity());
             if (statusCode >= 200 && statusCode < 300) {
             if (statusCode >= 200 && statusCode < 300) {
                 return UniReturnUtil.success(responseBody);
                 return UniReturnUtil.success(responseBody);
             } else {
             } else {
-                return UniReturnUtil.fail(responseBody);
+                return UniReturnUtil.fail(responseBody.toString());
             }
             }
-        }catch (Exception e){
+        } catch (Exception e) {
             return UniReturnUtil.fail(e);
             return UniReturnUtil.fail(e);
         }
         }
 
 

+ 4 - 4
src/main/java/com/scbfkj/uni/process/IBMMQ.java

@@ -4,6 +4,7 @@ package com.scbfkj.uni.process;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.ibm.mq.MQException;
 import com.ibm.mq.MQException;
 import com.ibm.mq.jakarta.jms.MQQueueConnectionFactory;
 import com.ibm.mq.jakarta.jms.MQQueueConnectionFactory;
+import com.scbfkj.uni.library.DataFormatUtil;
 import com.scbfkj.uni.system.Config;
 import com.scbfkj.uni.system.Config;
 import jakarta.jms.ConnectionFactory;
 import jakarta.jms.ConnectionFactory;
 import jakarta.jms.JMSException;
 import jakarta.jms.JMSException;
@@ -135,7 +136,7 @@ public class IBMMQ {
 
 
     public void sendMessage(
     public void sendMessage(
             String host, Long port, String channel, String queueManager, String queueName, Long ccsid, String username, String password,
             String host, Long port, String channel, String queueManager, String queueName, Long ccsid, String username, String password,
-            Collection<Object> data
+            List<Object> data
     ) throws JMSException {
     ) throws JMSException {
 
 
         JmsTemplate template = getJmsTemplate(host, port.intValue(), ccsid.intValue(), queueManager, channel, username, password);
         JmsTemplate template = getJmsTemplate(host, port.intValue(), ccsid.intValue(), queueManager, channel, username, password);
@@ -162,9 +163,8 @@ public class IBMMQ {
             JmsTemplate template,
             JmsTemplate template,
             Object data,
             Object data,
             String queueName
             String queueName
-    ) throws IOException, MQException {
-        String message = mapper.writeValueAsString(data);
-
+    ) {
+        String message = DataFormatUtil.toString(data);
         template.send(queueName, session -> session.createTextMessage(message));
         template.send(queueName, session -> session.createTextMessage(message));
     }
     }
 
 

+ 13 - 10
src/main/java/com/scbfkj/uni/service/LoggerService.java

@@ -60,22 +60,25 @@ public class LoggerService {
                 fileNames.add(filename);
                 fileNames.add(filename);
                 fileNames.removeIf(it -> it + 1000 < filename);
                 fileNames.removeIf(it -> it + 1000 < filename);
             }
             }
-            try {
-                List<Object[]> datas = new ArrayList<>();
-                List<Map<String, Object>> targets = DATA_BASE.query(Config.getCenterConnectionStr(), "select * from systeminfo where keyname=?", type.getName());
-                for (Map<String, Object> targetconnection : targets) {
-                    datas.add(new Object[]{type.getName(), filePath, targetconnection.get("datasourceid"), targetconnection.get("expression"), DataFormatUtil.toString(data)});
-                }
-                DATA_BASE.updateBatch(connectionStr, "insert into logs (target,currentfile,datasourceid,expression,datacontent) values(?,?,?,?,?)", datas);
-            } catch (Exception e) {
-                if (Config.isDebug()) {
-                    e.printStackTrace();
+            if (data != null && !data.isEmpty()) {
+                try {
+                    List<Object[]> datas = new ArrayList<>();
+                    List<Map<String, Object>> targets = DATA_BASE.query(Config.getCenterConnectionStr(), "select * from systeminfo where keyname=?", type.getName());
+                    for (Map<String, Object> targetconnection : targets) {
+                        datas.add(new Object[]{type.getName(), filePath, targetconnection.get("datasourceid"), targetconnection.get("expression"), DataFormatUtil.toString(data)});
+                    }
+                    DATA_BASE.updateBatch(connectionStr, "insert into logs (target,currentfile,datasourceid,expression,datacontent) values(?,?,?,?,?)", datas);
+                } catch (Exception e) {
+                    if (Config.isDebug()) {
+                        e.printStackTrace();
+                    }
                 }
                 }
             }
             }
         }
         }
     }
     }
 
 
     public static void sendMessage() {
     public static void sendMessage() {
+        log(LogType.SYSTEM, null);
 
 
 //        判断目录
 //        判断目录
 
 

+ 0 - 1
src/main/java/com/scbfkj/uni/system/Config.java

@@ -7,7 +7,6 @@ import java.util.Map;
 
 
 
 
 public class Config {
 public class Config {
-    public static final List<String> sessions = new ArrayList<>();
     public static final Map<String, Map<String, Object>> cache = new Hashtable<>();
     public static final Map<String, Map<String, Object>> cache = new Hashtable<>();
     public static List<Map<String, Object>> targets = new ArrayList<>();
     public static List<Map<String, Object>> targets = new ArrayList<>();
     private static String centerConnectionStr;
     private static String centerConnectionStr;

+ 14 - 16
src/main/java/com/scbfkj/uni/system/ProcessUtil.java

@@ -115,30 +115,31 @@ public class ProcessUtil {
 
 
                 for (int g = 0; g < group.count; g++) {
                 for (int g = 0; g < group.count; g++) {
                     for (Map<String, Object> algorithmLibrary : list) {
                     for (Map<String, Object> algorithmLibrary : list) {
-
-
                         startDateTime = LocalDateTime.now();
                         startDateTime = LocalDateTime.now();
                         long startTime = System.currentTimeMillis();
                         long startTime = System.currentTimeMillis();
                         algorithmlibraryid = algorithmLibrary.get("algorithmlibraryid");
                         algorithmlibraryid = algorithmLibrary.get("algorithmlibraryid");
                         HashMap<String, Object> data = new HashMap<>();
                         HashMap<String, Object> data = new HashMap<>();
+                        data.put("count", g);
                         Object preConditions = algorithmLibrary.get("preconditions");
                         Object preConditions = algorithmLibrary.get("preconditions");
 
 
 //                        source.put("args", resource);
 //                        source.put("args", resource);
 //                        source.put("algorithm", algorithmLibrary);
 //                        source.put("algorithm", algorithmLibrary);
+                        HashMap<String, Object> preData = new HashMap<>();
+                        preData.put("preConditions", preConditions);
+                        preData.put("algorithmlibraryid", algorithmlibraryid);
+                        preData.put("args", resource);
+                        preData.put("count", g);
+                        preResource.add(preData);
                         if (Objects.nonNull(preConditions)) {
                         if (Objects.nonNull(preConditions)) {
                             Map<String, Object> eval = JsScriptEngineUtil.eval(preConditions.toString(), resource);
                             Map<String, Object> eval = JsScriptEngineUtil.eval(preConditions.toString(), resource);
-                            HashMap<String, Object> preData = new HashMap<>();
-                            preResource.add(preData);
-
-                            preData.put("algorithmlibraryid", algorithmlibraryid);
                             preData.put("preResult", eval);
                             preData.put("preResult", eval);
                             preCode = eval.get("returnData").toString();
                             preCode = eval.get("returnData").toString();
                         }
                         }
 
 
-                        if ("1".equalsIgnoreCase(preCode)) {
-                            continue;
-                        }
-                        if ("2".equalsIgnoreCase(preCode) || "3".equalsIgnoreCase(preCode)) {
+//                        if ("1".equalsIgnoreCase(preCode)) {
+//                            continue;
+//                        }
+                        if ("1".equalsIgnoreCase(preCode) || "2".equalsIgnoreCase(preCode) || "3".equalsIgnoreCase(preCode)) {
                             break;
                             break;
                         }
                         }
 
 
@@ -158,6 +159,7 @@ public class ProcessUtil {
                         List<Object> parameters = new ArrayList<>();
                         List<Object> parameters = new ArrayList<>();
                         if ("com.scbfkj.uni.library.script.JsScriptEngineUtil".equals(className) && "eval".equals(methodName)) {
                         if ("com.scbfkj.uni.library.script.JsScriptEngineUtil".equals(className) && "eval".equals(methodName)) {
                             String expressionStr = algorithmLibrary.get("computingexpression").toString();
                             String expressionStr = algorithmLibrary.get("computingexpression").toString();
+                            data.put("expression", expressionStr);
                             result = JsScriptEngineUtil.eval(expressionStr, resource);
                             result = JsScriptEngineUtil.eval(expressionStr, resource);
                         } else {
                         } else {
                             List<Map<String, Object>> params = DATA_BASE.query(Config.getCenterConnectionStr(), """
                             List<Map<String, Object>> params = DATA_BASE.query(Config.getCenterConnectionStr(), """
@@ -195,7 +197,7 @@ public class ProcessUtil {
                         data.put("lifecycleid", lifecycleid);
                         data.put("lifecycleid", lifecycleid);
                         data.put("algorithmlibraryid", algorithmlibraryid);
                         data.put("algorithmlibraryid", algorithmlibraryid);
                         data.put("result", result);
                         data.put("result", result);
-                        data.put("index", algorithmLibrariesOrders.get(algorithmlibraryid));
+                        data.put("index", algorithmLibrariesOrders.get(algorithmlibraryid.toString()));
                         data.put("parameters", parameters);
                         data.put("parameters", parameters);
 //                    执行时长
 //                    执行时长
                         data.put("execTime", System.currentTimeMillis() - startTime);
                         data.put("execTime", System.currentTimeMillis() - startTime);
@@ -205,13 +207,9 @@ public class ProcessUtil {
                         message = Optional.ofNullable(result.get("message")).map(DataFormatUtil::toString).orElse(null);
                         message = Optional.ofNullable(result.get("message")).map(DataFormatUtil::toString).orElse(null);
                         data.put("resultCode", code);
                         data.put("resultCode", code);
 
 
-//                        tempResult.set(algorithmLibrariesOrders.get(algorithmlibraryid.toString()), data);
                         resource.add(data);
                         resource.add(data);
                     }
                     }
-                    if ("2".equalsIgnoreCase(preCode)) {
-                        continue;
-                    }
-                    if ("3".equalsIgnoreCase(preCode)) {
+                    if ("2".equalsIgnoreCase(preCode) || "3".equalsIgnoreCase(preCode)) {
                         break;
                         break;
                     }
                     }
                 }
                 }

+ 3 - 1
src/main/resources/application.yml

@@ -1,5 +1,7 @@
 app:
 app:
   enable-reset-config: false
   enable-reset-config: false
+  license:
+    file: ./license
   security:
   security:
     enable: true
     enable: true
     encrypt: true
     encrypt: true
@@ -7,4 +9,4 @@ server:
   port: 9500
   port: 9500
 spring:
 spring:
   profiles:
   profiles:
-    default: test
+    default: test