andy 11 сар өмнө
parent
commit
dfbc7f8ed0

+ 32 - 1
src/main/java/com/scbfkj/uni/api/FileApi.java

@@ -1,4 +1,35 @@
 package com.scbfkj.uni.api;
 
+import com.scbfkj.uni.library.FileUtil;
+import com.scbfkj.uni.library.UniReturnUtil;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+@RestController
+@RequestMapping("file")
 public class FileApi {
-}
+
+    private static final Set<String> CONTENT_TYPES = Set.of("application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+
+    @PostMapping("/upload")
+    public ResponseEntity<Map<String, Object>> uploadFiles(@RequestParam("file") MultipartFile file) throws IOException {
+        // 处理多个文件上传逻辑
+        if (CONTENT_TYPES.contains(file.getContentType())) {
+            Map<String, List<List<String>>> excelToMap = FileUtil.readExcelToMap(file.getInputStream());
+
+            return ResponseEntity.ok(UniReturnUtil.success("Files uploaded successfully"));
+        }else{
+        return ResponseEntity.ok(UniReturnUtil.fail("Please upload an Excel file"));
+
+        }
+    }
+}

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

@@ -15,12 +15,12 @@ import java.util.List;
 import java.util.Map;
 
 @RestController
-@RequestMapping("openApi")
+@RequestMapping
 public class GenericApi {
 
     private static final DataBase DATA_BASE = new DataBase();
 
-    @PostMapping({"newdata", "modifydata", "movedata", "query"})
+    @PostMapping({"/openApi/newdata", "/openApi/modifydata", "/openApi/movedata", "/openApi/query"})
     public ResponseEntity<Map<String, Object>> base(@RequestBody Map<String, Object> body) {
         String uri = RequestUtil.getUri();
         String event = "0";
@@ -49,7 +49,7 @@ public class GenericApi {
      * @throws Exception
      */
 
-    @PostMapping("*")
+    @PostMapping("/**")
     public ResponseEntity<Map<String, Object>> matchService(@RequestBody Map<String, Object> body) throws Exception {
         String uri = RequestUtil.getUri();
         List<Map<String, Object>> serviceinfoList = DATA_BASE.query(Config.getCenterConnectionStr(), """

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

@@ -30,7 +30,7 @@ public class LogAop {
     private Util util;
 
     @Around(value = "within(com.scbfkj.uni.api.*Api)")
-    public ResponseEntity<Map<String, Object>> invokeAround(ProceedingJoinPoint joinPoint) {
+    public ResponseEntity<Object> invokeAround(ProceedingJoinPoint joinPoint) {
         LocalDateTime requestTime = LocalDateTime.now();
 //        请求
         String uri = RequestUtil.getUri();
@@ -63,7 +63,13 @@ public class LogAop {
 //                    查找serviceid
                     body = map;
                     serviceid = DataAliasGetUtil.getValue("serviceid", map);
-                    if (serviceid.isPresent() && uri.startsWith("/openApi")) {
+                    if (serviceid.isEmpty()) {
+                        List<Map<String, Object>> query = DATA_BASE.query(Config.getCenterConnectionStr(), "select * from serviceinfo where urilist=?", uri);
+                        if (!query.isEmpty()) {
+                            serviceid = DataAliasGetUtil.getValue("serviceid", query.get(0));
+                        }
+                    }
+                    if (serviceid.isPresent()) {
 //                        查找状态
                         List<Map<String, Object>> mapList = DATA_BASE.query(Config.getCenterConnectionStr(), """
                                 select runstate from servicestate where stoptime is null and  serviceid=? and containercode = ?""", serviceid.get(), Config.getContainerCode());
@@ -87,16 +93,31 @@ public class LogAop {
                 return ResponseEntity.ok(UniReturnUtil.fail(message));
             }
 
-            Util.addFilter(body, serviceid,uri,true);
+            Util.addFilter(body, serviceid, uri, true);
 
             ResponseEntity<Map<String, Object>> responseEntity = (ResponseEntity<Map<String, Object>>) joinPoint.proceed(args);
-            if (!responseEntity.getStatusCode().is2xxSuccessful()) {
+            Map<String, Object> responseEntityBody = responseEntity.getBody();
+            if (responseEntity.getStatusCode().is2xxSuccessful()) {
                 if (Config.isDebug()) {
                     System.out.println("返回值:" + DataFormatUtil.toString(returnData));
                 }
-                return responseEntity;
+                if ("0".equals(responseEntityBody.get("code")) && serviceid.isPresent()) {
+                    List<Map<String, Object>> serviceInfoes = DATA_BASE.query(Config.getCenterConnectionStr(), "select * from serviceinfo where serviceid=?", serviceid.get());
+                    if (!serviceInfoes.isEmpty()) {
+                        Map<String, Object> serviceInfo = serviceInfoes.get(0);
+                        Object raw = serviceInfo.get("raw");
+                        if (raw != null && raw.toString().equalsIgnoreCase("1")) {
+                            Object data = responseEntityBody.getOrDefault("returnData", responseEntityBody);
+                            if (data instanceof List<?> d && d.size() == 1) {
+                                data = d.get(0);
+                            }
+                            return ResponseEntity.ok(data);
+                        }
+                    }
+                }
+                return ResponseEntity.ok(responseEntityBody);
             } else {
-                returnData = responseEntity.getBody();
+                returnData = responseEntityBody;
             }
 
         } catch (Throwable e) {

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

@@ -5,7 +5,9 @@ import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.LongNode;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.fasterxml.jackson.databind.node.TextNode;
 import com.fasterxml.jackson.dataformat.xml.XmlMapper;
 import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
 import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
@@ -57,6 +59,12 @@ public final class DataFormatUtil {
         if (source instanceof String || source instanceof Number) {
             return source.toString();
         }
+        if (source instanceof TextNode jsonNode) {
+            return jsonNode.asText();
+        }
+        if (source instanceof JsonNode jsonNode) {
+            return jsonNode.toString();
+        }
         if (source instanceof LocalDate result) {
             return result.format(dateTimeFormatter);
         }
@@ -78,8 +86,8 @@ public final class DataFormatUtil {
         } else if (dateObj instanceof Date date) {
             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:dd:ss");
             String formatDate = simpleDateFormat.format(date);
-            return LocalDate.parse(formatDate.replace(" ","T"));
-        }  else {
+            return LocalDate.parse(formatDate.replace(" ", "T"));
+        } else {
             return null;
         }
     }
@@ -92,7 +100,7 @@ public final class DataFormatUtil {
         } else if (dateTimeObj instanceof Date date) {
             SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:dd:ss");
             String formatDate = simpleDateFormat.format(date);
-            return LocalDateTime.parse(formatDate.replace(" ","T"));
+            return LocalDateTime.parse(formatDate.replace(" ", "T"));
         } else {
             return null;
         }
@@ -110,23 +118,16 @@ public final class DataFormatUtil {
         if (Objects.isNull(value)) {
             return null;
         }
-        ArrayList<Object> result = new ArrayList<>();
         if (value instanceof Iterable<?> iterable) {
+            ArrayList<Object> result = new ArrayList<>();
             iterable.forEach(result::add);
-            return result.stream().map(it->{
-                if (it instanceof JsonNode){
-                    return it.toString();
-                }else{
-                    return it;
-                }
-            }).toList();
+            return result;
         }
         if (value.getClass().isArray()) {
-            result.addAll(Arrays.asList(((Object[]) value)));
-            return result.stream().map(it->{
-                if (it instanceof JsonNode){
+            return Arrays.stream(((Object[]) value)).map(it -> {
+                if (it instanceof JsonNode) {
                     return it.toString();
-                }else{
+                } else {
                     return it;
                 }
             }).toList();
@@ -145,6 +146,9 @@ public final class DataFormatUtil {
         if (Objects.isNull(value)) {
             return null;
         }
+        if (value.getClass().isArray()) {
+            return (Object[]) value;
+        }
         return Objects.requireNonNull(toList(value)).toArray();
     }
 
@@ -155,20 +159,19 @@ public final class DataFormatUtil {
         if (value instanceof Map<?, ?> map) {
             return map;
         }
-        if (value instanceof String str) {
+        String str = DataFormatUtil.toString(value);
+        try {
+            return DataFormatUtil.stringToMap(str);
+        } catch (JsonProcessingException ignored) {
             try {
-                return DataFormatUtil.stringToMap(str);
-            } catch (JsonProcessingException ignored) {
+                return stringToMap(str);
+            } catch (JsonProcessingException e) {
                 try {
-                    return stringToMap(str);
-                } catch (JsonProcessingException e) {
-                    try {
-                        HashMap<Object, Object> data = new HashMap<>();
-                        data.put("root", toJsonNode(str));
-                        return data;
-                    } catch (JsonProcessingException ex) {
+                    HashMap<Object, Object> data = new HashMap<>();
+                    data.put("root", toJsonNode(str));
+                    return data;
+                } catch (JsonProcessingException ex) {
 
-                    }
                 }
             }
         }
@@ -277,11 +280,64 @@ public final class DataFormatUtil {
     }
 
     public static boolean isJson(String data) {
-        try{
+        try {
             JsonNode jsonNode = getObjectMapper().readTree(data);
             return true;
-        }catch (Exception e){
+        } catch (Exception e) {
             return false;
         }
     }
+
+    public static <T> T castType(Object node, Class<T> parameterType) {
+
+        if (node == null) {
+            return null;
+        }
+        String type = parameterType.getSimpleName();
+        Object result = null;
+        if ("String".equalsIgnoreCase(type)) {
+            if (node instanceof JsonNode jsonNode) {
+                result = jsonNode.asText();
+            } else {
+                result = node.toString();
+            }
+        } else if ("List".equalsIgnoreCase(type)) {
+            result = DataFormatUtil.toList(node);
+        } else if ("Array".equalsIgnoreCase(type)) {
+            result = DataFormatUtil.toArray(node);
+        } else if ("Map".equalsIgnoreCase(type)) {
+            result = DataFormatUtil.toMap(node);
+        } else if ("Long".equalsIgnoreCase(type)) {
+            if (node instanceof JsonNode jsonNode) {
+                result = jsonNode.asLong();
+            } else {
+                result = Long.valueOf(node.toString());
+            }
+        } else if ("Integer".equalsIgnoreCase(type)) {
+            if (node instanceof JsonNode jsonNode) {
+                result = jsonNode.asInt();
+            } else {
+                result = Integer.valueOf(node.toString());
+            }
+        } else if ("Double".equalsIgnoreCase(type)) {
+            if (node instanceof JsonNode jsonNode) {
+                result = jsonNode.doubleValue();
+            } else {
+                result = Double.valueOf(node.toString());
+            }
+        } else if ("Float".equalsIgnoreCase(type)) {
+            if (node instanceof JsonNode jsonNode) {
+                result = jsonNode.floatValue();
+            } else {
+                result = Float.valueOf(node.toString());
+            }
+        } else if ("Boolean".equalsIgnoreCase(type)) {
+            if (node instanceof JsonNode jsonNode) {
+                result = jsonNode.asBoolean();
+            } else {
+                result = Boolean.valueOf(node.toString());
+            }
+        }
+        return (T) result;
+    }
 }

+ 11 - 2
src/main/java/com/scbfkj/uni/library/FileUtil.java

@@ -5,6 +5,7 @@ import org.apache.poi.ss.usermodel.*;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -12,11 +13,19 @@ import java.util.Map;
 
 public class FileUtil {
 
+
     public static Map<String, List<List<String>>> readExcelToMap(File file) throws IOException {
+
+        try (FileInputStream fis = new FileInputStream(file)) {
+            return readExcelToMap(fis);
+        }
+    }
+
+    public static Map<String, List<List<String>>> readExcelToMap(InputStream fis) throws IOException {
         Map<String, List<List<String>>> dataMap = new HashMap<>();
 
-        try (FileInputStream fis = new FileInputStream(file);
-             Workbook workbook = WorkbookFactory.create(fis)) {
+        try (
+                Workbook workbook = WorkbookFactory.create(fis)) {
             for (int i = 0; i < workbook.getNumberOfSheets(); i++) {
                 Sheet sheet = workbook.getSheetAt(i);
 

+ 7 - 0
src/main/java/com/scbfkj/uni/library/script/JavaScriptEngineUtil.java

@@ -138,6 +138,13 @@ public class JavaScriptEngineUtil {
         }
 
         public Object invokeApply(Object... args) throws InvocationTargetException, IllegalAccessException {
+            Class<?>[] parameterTypes = apply.getParameterTypes();
+            for (int i = 0; i < parameterTypes.length; i++) {
+                Object arg = args[i];
+                if(!parameterTypes[i].isInstance(arg)) {
+                    args[i] = DataFormatUtil.castType(arg,parameterTypes[i]);
+                }
+            }
             return apply.invoke(instance, args);
         }
     }

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

@@ -14,10 +14,7 @@ import org.springframework.jms.connection.UserCredentialsConnectionFactoryAdapte
 import org.springframework.jms.core.JmsTemplate;
 
 import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 
 
 public class IBMMQ {
@@ -27,27 +24,27 @@ public class IBMMQ {
 
     private final ObjectMapper mapper = new ObjectMapper();
 
-    public List<String> receptionMessageByDataSourceId( String dataSourceId, String channel, String queueManager, String queueName, Long ccsid, Long receiveTimeout, Long pollSize, Long retry) throws Exception {
-        Map<String,Object> config = queryConnectionStr(dataSourceId);
+    public List<String> receptionMessageByDataSourceId(String dataSourceId, String channel, String queueManager, String queueName, Long ccsid, Long receiveTimeout, Long pollSize, Long retry) throws Exception {
+        Map<String, Object> config = queryConnectionStr(dataSourceId);
 
         long port = 1414L;
         String host = Objects.toString(config.get("host"));
-        if(host.contains(":")){
+        if (host.contains(":")) {
             String[] split = host.split(":");
             port = Long.parseLong(split[1]);
             host = split[0];
         }
-        String username =null;
-        String password =null;
+        String username = null;
+        String password = null;
         Object username1 = config.get("username");
-        if(Objects.nonNull(username1)){
+        if (Objects.nonNull(username1)) {
             username = username1.toString();
         }
         Object password1 = config.get("password");
-        if(Objects.nonNull(password1)){
+        if (Objects.nonNull(password1)) {
             password = password1.toString();
         }
-        return receptionMessage(host,port,channel,queueManager,queueName,ccsid,username,password,receiveTimeout,pollSize,retry);
+        return receptionMessage(host, port, channel, queueManager, queueName, ccsid, username, password, receiveTimeout, pollSize, retry);
 
     }
 
@@ -96,52 +93,57 @@ public class IBMMQ {
     }
 
 
-    public void sendMessageByDataSourceId(
+    public void sendSingletonMessageByDataSourceId(
             String dataSourceId, String channel, String queueManager, String queueName, Long ccsid,
             Object data
     ) throws Exception {
-        Map<String,Object> config = queryConnectionStr(dataSourceId);
+        sendMessageByDataSourceId(dataSourceId, channel, queueManager, queueName, ccsid, Collections.singletonList(data));
+    }
+
+    public void sendMessageByDataSourceId(
+            String dataSourceId, String channel, String queueManager, String queueName, Long ccsid,
+            List<Object> data
+    ) throws Exception {
+        Map<String, Object> config = queryConnectionStr(dataSourceId);
 
         long port = 1414L;
         String host = Objects.toString(config.get("host"));
-        if(host.contains(":")){
+        if (host.contains(":")) {
             String[] split = host.split(":");
             port = Long.parseLong(split[1]);
             host = split[0];
         }
-        String username =null;
-        String password =null;
+        String username = null;
+        String password = null;
         Object username1 = config.get("username");
-        if(Objects.nonNull(username1)){
+        if (Objects.nonNull(username1)) {
             username = username1.toString();
         }
         Object password1 = config.get("password");
-        if(Objects.nonNull(password1)){
+        if (Objects.nonNull(password1)) {
             password = password1.toString();
         }
-        sendMessage(host,port,channel,queueManager,queueName,ccsid,username,password,data);
+        sendMessage(host, port, channel, queueManager, queueName, ccsid, username, password, data);
     }
-    public void sendMessage(
+
+    public void sendSingletonMessage(
             String host, Long port, String channel, String queueManager, String queueName, Long ccsid, String username, String password,
             Object data
     ) throws JMSException {
+        sendMessage(host, port, channel, queueManager, queueName, ccsid, username, password, Collections.singletonList(data));
+    }
+
+    public void sendMessage(
+            String host, Long port, String channel, String queueManager, String queueName, Long ccsid, String username, String password,
+            Collection<Object> data
+    ) throws JMSException {
 
         JmsTemplate template = getJmsTemplate(host, port.intValue(), ccsid.intValue(), queueManager, channel, username, password);
 
         try {
-            if (data instanceof Object[] datas) {
-                for (Object it : datas) {
+            for (Object it : data) {
 
-                    execSend(template, it, queueName);
-                }
-            } else if (data instanceof Iterable<?> datas) {
-
-                for (Object it : datas) {
-
-                    execSend(template, it, queueName);
-                }
-            } else {
-                execSend(template, data, queueName);
+                execSend(template, it, queueName);
             }
 
         } catch (Exception e) {
@@ -212,8 +214,7 @@ public class IBMMQ {
     }
 
 
-
-    private static Map<String,Object> queryConnectionStr(String datasourceId) throws Exception {
+    private static Map<String, Object> queryConnectionStr(String datasourceId) throws Exception {
         List<Map<String, Object>> result = DATA_BASE.query(Config.getCenterConnectionStr(), """
                 select host,
                 password,

+ 12 - 17
src/main/java/com/scbfkj/uni/process/JMS.java

@@ -16,10 +16,7 @@ import java.lang.reflect.InvocationTargetException;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 
 public class JMS {
 
@@ -74,29 +71,27 @@ public class JMS {
     }
 
 
+    public void sendSingletonMessage(String path, String className,
+                                     String queueName,
+                                     Object data, String... args
+    ) throws JMSException, MalformedURLException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
+        sendMessage(path, className, queueName, Collections.singletonList(data), args);
+    }
+
     public void sendMessage(String path, String className,
                             String queueName,
-                            Object data, String... args
+                            List<Object> data, String... args
     ) throws JMSException, MalformedURLException, ClassNotFoundException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException {
 
         JmsTemplate template = getJmsTemplate(path, className, (Object[]) args);
 
         try {
-            if (data instanceof Object[] datas) {
-                for (Object it : datas) {
-
-                    execSend(template, it, queueName);
-                }
-            } else if (data instanceof Iterable<?> datas) {
-
-                for (Object it : datas) {
+            for (Object it : data) {
 
-                    execSend(template, it, queueName);
-                }
-            } else {
-                execSend(template, data, queueName);
+                execSend(template, it, queueName);
             }
 
+
         } catch (Exception e) {
             if (Config.isDebug()) {
                 e.printStackTrace();

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

@@ -41,6 +41,10 @@ public class Kafka {
         }
     });
 
+    public static Map<String, Object> sendSingletonMessage(String connection, String topic, Object datas) throws Exception {
+        return sendMessage(connection, topic, Collections.singletonList(datas));
+    }
+
     public static Map<String, Object> sendMessage(String connection, String topic, List<Object> datas) throws Exception {
 
         if (Objects.isNull(datas) || datas.isEmpty()) {

+ 12 - 13
src/main/java/com/scbfkj/uni/process/RabbitMQ.java

@@ -11,6 +11,7 @@ import org.springframework.jms.core.JmsTemplate;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 public class RabbitMQ {
@@ -66,29 +67,27 @@ public class RabbitMQ {
     }
 
 
-    public void sendMessage(
+    public void sendSingletonMessage(
             String host, Long port, String username, String password, String virtualHost, String queueName,
             Object data
     ) throws JMSException {
+        sendMessage(host, port, username, password, virtualHost, queueName, Collections.singletonList(data));
+    }
+
+    public void sendMessage(
+            String host, Long port, String username, String password, String virtualHost, String queueName,
+            List<Object> data
+    ) throws JMSException {
 
         JmsTemplate template = getJmsTemplate(host, port.intValue(), username, password, virtualHost);
 
         try {
-            if (data instanceof Object[] datas) {
-                for (Object it : datas) {
 
-                    execSend(template, it, queueName);
-                }
-            } else if (data instanceof Iterable<?> datas) {
-
-                for (Object it : datas) {
-
-                    execSend(template, it, queueName);
-                }
-            } else {
-                execSend(template, data, queueName);
+            for (Object datum : data) {
+                execSend(template, datum, queueName);
             }
 
+
         } catch (Exception e) {
             if (Config.isDebug()) {
                 e.printStackTrace();

+ 120 - 53
src/main/java/com/scbfkj/uni/system/ProcessUtil.java

@@ -2,11 +2,12 @@ package com.scbfkj.uni.system;
 
 import com.fasterxml.jackson.core.JsonProcessingException;
 import com.fasterxml.jackson.databind.JsonNode;
-import com.scbfkj.uni.dtos.Expression;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.JsonNodeFactory;
+import com.fasterxml.jackson.databind.node.NullNode;
 import com.scbfkj.uni.library.DataAliasGetUtil;
 import com.scbfkj.uni.library.DataFormatUtil;
 import com.scbfkj.uni.library.UniReturnUtil;
-import com.scbfkj.uni.library.script.DatabaseScriptUtil;
 import com.scbfkj.uni.library.script.JavaScriptEngineUtil;
 import com.scbfkj.uni.library.script.JsScriptEngineUtil;
 import com.scbfkj.uni.process.DataBase;
@@ -32,9 +33,10 @@ public class ProcessUtil {
     public Map<String, Object> process(Map<String, Object> inData) {
         String lifecycleid = null;
         List<Map<String, Object>> resource = new ArrayList<>();
-        List<Map<String, Object>> tempResult = new ArrayList<>();
+//        List<Map<String, Object>> tempResult = new ArrayList<>();
         List<Map<String, Object>> preResource = new ArrayList<>();
-        tempResult.add(inData);
+//        tempResult.add(inData);
+        inData.put("index", 0);
         resource.add(inData);
         String serviceId = null;
         LocalDateTime startDateTime = LocalDateTime.now();
@@ -65,8 +67,6 @@ public class ProcessUtil {
             if (!serviceInfoList.isEmpty()) {
                 serviceInfo = serviceInfoList.get(0);
             }
-
-
             Optional<String> lifecycleidOpt = DataAliasGetUtil.getValue("lifecycleid", inData);
 
             if (lifecycleidOpt.isEmpty()) {
@@ -75,7 +75,7 @@ public class ProcessUtil {
             } else {
                 lifecycleid = lifecycleidOpt.get();
             }
-            HashMap<String, Object> source = new HashMap<>();
+//            HashMap<String, Object> source = new HashMap<>();
 
             Map<String, Integer> algorithmLibrariesOrders = new HashMap<>();
 
@@ -123,19 +123,22 @@ public class ProcessUtil {
                         HashMap<String, Object> data = new HashMap<>();
                         Object preConditions = algorithmLibrary.get("preconditions");
 
-                        source.put("args", resource);
-                        source.put("algorithm", algorithmLibrary);
+//                        source.put("args", resource);
+//                        source.put("algorithm", algorithmLibrary);
                         if (Objects.nonNull(preConditions)) {
-                            Map<String, Object> eval = JsScriptEngineUtil.eval(preConditions.toString(), tempResult);
+                            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);
-                            preCode = eval.get("code").toString();
+                            preCode = eval.get("returnData").toString();
                         }
 
-                        if ("1".equalsIgnoreCase(preCode) || "2".equalsIgnoreCase(preCode) || "3".equalsIgnoreCase(preCode)) {
+                        if ("1".equalsIgnoreCase(preCode)) {
+                            continue;
+                        }
+                        if ("2".equalsIgnoreCase(preCode) || "3".equalsIgnoreCase(preCode)) {
                             break;
                         }
 
@@ -155,7 +158,7 @@ public class ProcessUtil {
                         List<Object> parameters = new ArrayList<>();
                         if ("com.scbfkj.uni.library.script.JsScriptEngineUtil".equals(className) && "eval".equals(methodName)) {
                             String expressionStr = algorithmLibrary.get("computingexpression").toString();
-                            result = JsScriptEngineUtil.eval(expressionStr, tempResult);
+                            result = JsScriptEngineUtil.eval(expressionStr, resource);
                         } else {
                             List<Map<String, Object>> params = DATA_BASE.query(Config.getCenterConnectionStr(), """
                                     select
@@ -175,7 +178,7 @@ public class ProcessUtil {
                                 } else if ("2".equals(o)) {
                                     parseData(parameterType, parameters, subscriptionExpressions);
                                 } else if ("3".equals(o)) {
-                                    parameters.add(getParams(parameterType.toString(), "/args", subscriptionExpressions.toString(), source));
+                                    parameters.add(getParamsByIndex(subscriptionExpressions.toString(), resource, false));
                                 }
                             }
                             result = JavaScriptEngineUtil.invoke(configMap, methodName.toString(), parameters.toArray());
@@ -192,6 +195,7 @@ public class ProcessUtil {
                         data.put("lifecycleid", lifecycleid);
                         data.put("algorithmlibraryid", algorithmlibraryid);
                         data.put("result", result);
+                        data.put("index", algorithmLibrariesOrders.get(algorithmlibraryid));
                         data.put("parameters", parameters);
 //                    执行时长
                         data.put("execTime", System.currentTimeMillis() - startTime);
@@ -201,12 +205,13 @@ public class ProcessUtil {
                         message = Optional.ofNullable(result.get("message")).map(DataFormatUtil::toString).orElse(null);
                         data.put("resultCode", code);
 
-                        tempResult.add(algorithmLibrariesOrders.get(algorithmlibraryid.toString()), data);
+//                        tempResult.set(algorithmLibrariesOrders.get(algorithmlibraryid.toString()), data);
                         resource.add(data);
                     }
-
-
-                    if ("2".equalsIgnoreCase(preCode) || "3".equalsIgnoreCase(preCode)) {
+                    if ("2".equalsIgnoreCase(preCode)) {
+                        continue;
+                    }
+                    if ("3".equalsIgnoreCase(preCode)) {
                         break;
                     }
                 }
@@ -313,7 +318,66 @@ public class ProcessUtil {
     }
 
 
-    public Object getParams(String type, String root, String parameterSet, Object source) throws JsonProcessingException {
+    public Object getParamsByIndex(String parameterSet, Object source, boolean all) throws JsonProcessingException {
+        if (Objects.isNull(source)) {
+            return null;
+        }
+        if (parameterSet == null) return NullNode.instance;
+        ArrayNode jsonNode = DataFormatUtil.toJsonNode(source).withArray("");
+        if (parameterSet.trim().isEmpty()) return jsonNode;
+        String jsonPtrExpr = parameterSet.replaceAll("[\\[\\]$.]", "/").replaceAll("/+", "/");
+
+        String[] split = jsonPtrExpr.split("/", 2);
+
+        if (split.length > 1) {
+            if (split[0].isEmpty()) {
+                if (split.length == 2) {
+                    jsonPtrExpr = split[1];
+                }
+            }
+        }
+        if (!jsonPtrExpr.equalsIgnoreCase("/") && jsonPtrExpr.endsWith("/")) {
+            jsonPtrExpr = jsonPtrExpr.substring(0, jsonPtrExpr.length() - 1);
+        }
+        String[] split1 = jsonPtrExpr.split("/", 2);
+        JsonNode result = NullNode.getInstance();
+
+        for (int i = 0; i < split1.length; i++) {
+            String key = split1[i];
+            if (i == 0) {
+                ArrayNode arrayNode = new ArrayNode(JsonNodeFactory.instance);
+                var index = 0;
+                for (JsonNode node : jsonNode) {
+
+                    if (node.get("index").asText().equals(key)) {
+                        if (!all) {
+                            if (index == jsonNode.size() - 1) {
+                                arrayNode.add(node);
+                                result = node;
+                            }
+                        } else {
+                            arrayNode.add(node);
+                            result = node;
+                        }
+                    }
+                    index++;
+                }
+                jsonNode = arrayNode;
+            } else {
+                ArrayNode arrayNode = new ArrayNode(JsonNodeFactory.instance);
+                for (JsonNode node : jsonNode) {
+                    JsonNode node1 = node.at("/" + key);
+                    arrayNode.add(node1);
+                    result = node1;
+                }
+                jsonNode = arrayNode;
+            }
+        }
+        return all ? jsonNode : result;
+    }
+
+
+    public Object getParams(String root, String parameterSet, Object source) throws JsonProcessingException {
 
 
         if (Objects.isNull(source)) {
@@ -329,41 +393,44 @@ public class ProcessUtil {
         if (!jsonPtrExpr.startsWith("/")) {
             jsonPtrExpr = "/" + jsonPtrExpr;
         }
-        JsonNode node = "/".equalsIgnoreCase(jsonPtrExpr) ? jsonNode : jsonNode.at(jsonPtrExpr);
-        if (!List.of("string", "list", "map", "array", "long", "integer", "boolean", "double", "float", "datetime").contains(type.toLowerCase())) {
-            if ("null".equalsIgnoreCase(type)) {
-                return null;
-            } else {
-                throw new RuntimeException("数据类型错误: " + type);
-            }
-        }
-        if ("String".equalsIgnoreCase(type)) {
-            return node.toString();
-        } else if ("List".equalsIgnoreCase(type)) {
-            return DataFormatUtil.toList(node);
-        } else if ("Array".equalsIgnoreCase(type)) {
-            return DataFormatUtil.toArray(node);
-        } else if ("Map".equalsIgnoreCase(type)) {
-            return DataFormatUtil.toMap(node);
-        } else if ("Long".equalsIgnoreCase(type)) {
-            return node.asLong();
-        } else if ("Integer".equalsIgnoreCase(type)) {
-            return node.asInt();
-        } else if ("Double".equalsIgnoreCase(type)) {
-            return node.asDouble();
-        } else if ("Float".equalsIgnoreCase(type)) {
-            return node.floatValue();
-        } else if ("Boolean".equalsIgnoreCase(type)) {
-            return node.asBoolean();
-        } else if ("Datetime".equalsIgnoreCase(type)) {
-            String string = node.asText();
-            String patten = "yyyy-MM-dd HH:mm:ss";
-            if (string.contains("(")) {
-                patten = string.substring(string.indexOf("(") + 1, string.length() - 1);
-                string = string.substring(0, string.indexOf("("));
-            }
-            return LocalDateTime.parse(string, DateTimeFormatter.ofPattern(patten));
+        if (jsonPtrExpr.endsWith("/") && jsonPtrExpr.length() > 1) {
+            jsonPtrExpr = jsonPtrExpr.substring(0, jsonPtrExpr.length() - 1);
         }
+        JsonNode node = "/".equalsIgnoreCase(jsonPtrExpr) ? jsonNode : jsonNode.at(jsonPtrExpr);
+//        if (!List.of("string", "list", "map", "array", "long", "integer", "boolean", "double", "float", "datetime").contains(type.toLowerCase())) {
+//            if ("null".equalsIgnoreCase(type)) {
+//                return null;
+//            } else {
+//                throw new RuntimeException("数据类型错误: " + type);
+//            }
+//        }
+//        if ("String".equalsIgnoreCase(type)) {
+//            return node.toString();
+//        } else if ("List".equalsIgnoreCase(type)) {
+//            return DataFormatUtil.toList(node);
+//        } else if ("Array".equalsIgnoreCase(type)) {
+//            return DataFormatUtil.toArray(node);
+//        } else if ("Map".equalsIgnoreCase(type)) {
+//            return DataFormatUtil.toMap(node);
+//        } else if ("Long".equalsIgnoreCase(type)) {
+//            return node.asLong();
+//        } else if ("Integer".equalsIgnoreCase(type)) {
+//            return node.asInt();
+//        } else if ("Double".equalsIgnoreCase(type)) {
+//            return node.asDouble();
+//        } else if ("Float".equalsIgnoreCase(type)) {
+//            return node.floatValue();
+//        } else if ("Boolean".equalsIgnoreCase(type)) {
+//            return node.asBoolean();
+//        } else if ("Datetime".equalsIgnoreCase(type)) {
+//            String string = node.asText();
+//            String patten = "yyyy-MM-dd HH:mm:ss";
+//            if (string.contains("(")) {
+//                patten = string.substring(string.indexOf("(") + 1, string.length() - 1);
+//                string = string.substring(0, string.indexOf("("));
+//            }
+//            return LocalDateTime.parse(string, DateTimeFormatter.ofPattern(patten));
+//        }
         return node;
     }
 

+ 5 - 1
src/main/java/com/scbfkj/uni/utils/Util.java

@@ -38,7 +38,11 @@ public class Util {
         if (check) {
             checkToken(uri);
         }
-        if (Objects.nonNull(body) && uri.startsWith("/openApi")) {
+        if(!Config.isSecurityEnable()){
+            body.put("filterColumns", Collections.singletonList("*"));
+            return;
+        }
+        if (Objects.nonNull(body) && (!uri.startsWith("/controlApi") && !uri.startsWith("/user") && !uri.startsWith("/foxlibc"))) {
 
             Map<String, Object> userInfo = RequestUtil.getUserInfo();