Browse Source

2.0 异常修改

pms 2 years ago
parent
commit
f48cfaca04

+ 0 - 8
mainFactory/pom.xml

@@ -123,14 +123,6 @@
             <artifactId>com.ibm.mq.allclient</artifactId>
             <version>9.3.2.0</version>
         </dependency>
-
-<!--        <dependency>-->
-<!--            <groupId>com.bfkj</groupId>-->
-<!--            <artifactId>ibmq6</artifactId>-->
-<!--            <version>0.0.1</version>-->
-<!--            <scope>system</scope>-->
-<!--            <systemPath>${project.basedir}/src/main/resources/lib/com.ibmq.mq-6.jar</systemPath>-->
-<!--        </dependency>-->
         <dependency>
             <groupId>org.elasticsearch.client</groupId>
             <artifactId>elasticsearch-rest-high-level-client</artifactId>

+ 1 - 1
mainFactory/src/main/java/org/bfkj/MainFactoryApplication.java

@@ -320,7 +320,7 @@ public class MainFactoryApplication {
         }
 
         /*批量写日志*/
-        if (logSuccessMap.size() ==0 &&logErrorMap.size() ==0&& logSourceMap.size()==0 ) return;
+        if (logErrorList.size() ==0 &&logSourceList.size() ==0&& logSuccessList.size()==0 ) return;
         MyDbHelper myDbHelper = ObjectMap.getordropMyDbHelper(AppConfig.getSystemParams(AppConfig.REMOTE_DB_CONNECT));
         if (Objects.nonNull(myDbHelper.getErrorMessage())) {
             System.out.println("获取远程数据库失败:写入日志失败");

+ 10 - 1
mainFactory/src/main/java/org/bfkj/application/DataProcess.java

@@ -216,6 +216,8 @@ public class DataProcess {//数据处理对象
         List<Map<String, Object>> calcData = Objects.isNull(inData) || inData.isEmpty() ? new ArrayList<>() : inData;//默认算法全量计算结果等于入口参数
         try {
             Map<String, Object> preCalMap = new HashMap<>();//用于组建前置检测算法配置
+            // 获取当前时间搓
+            long beginTime = System.currentTimeMillis();
             for (Map<String, Object> calculationLibrary : calcList) {//循环算法库
                 lastLibraryId = calculationLibrary.get("library_id").toString();//当前进行的算法编号
                 if (MapTools.isNotBlank(beginLibraryId) && !beginLibraryId.equals(lastLibraryId)) {
@@ -229,6 +231,9 @@ public class DataProcess {//数据处理对象
                     preCalMap.put("library_type", 2);/*如果脚本包含function则js否则java*/
                     preCalMap.put("computing_expression", is_exec); //组建前置算法配置信息
                     Map<String, Object> preEnginResult = execEngine(lastLibraryId, preCalMap, calcData);//调用算法引擎进行执行
+                    preEnginResult.put("preExecTime",System.currentTimeMillis()-beginTime);
+                    beginTime = System.currentTimeMillis();
+                    // 获取当前时间搓
                     preData.add(preEnginResult);//添加执行结果到前置检测结果列表
                     setServiceErrorCount(lastLibraryId, preEnginResult.get("code").toString());//依据返回的code进行连续错误计数和重置
                     if ("-1".equals(preEnginResult.get("code")) || Objects.equals("2", preEnginResult.get("returnData"))) {
@@ -242,6 +247,9 @@ public class DataProcess {//数据处理对象
                 }
                 //依据算法类型调用数据库对象或脚本引擎对象进行算法执行
                 Map<String, Object> currentResult = calculationLibrary.get("library_type").toString().equals("3") ? execDB(lastLibraryId, calculationLibrary, inData, dataObjectId) : execEngine(lastLibraryId, calculationLibrary, inData);
+                currentResult.put("execTime",System.currentTimeMillis()-beginTime);
+                beginTime = System.currentTimeMillis();
+
                 setServiceErrorCount(lastLibraryId, Objects.nonNull(currentResult) && currentResult.containsKey("code") ? currentResult.get("code").toString() : "0");//依据返回的code进行连续错误计数和重置
                 calcData.add(currentResult);//添加到全量算法结果中
                 if (Objects.nonNull(currentResult) && !currentResult.get("code").equals("0")) {//算法执行异常则退出
@@ -282,7 +290,8 @@ public class DataProcess {//数据处理对象
                 Object currentData = dataSubscription(calcAllData, key, currentCalMap);//获取数据
                 paramValue.put(currentCalMap.get("library_type").toString().equals("2")?parmaNames.get(key):key, currentData);
             }
-            return currentEngin.execScript(paramValue);
+            Map<String, Object> stringObjectMap = currentEngin.execScript(paramValue);
+            return stringObjectMap;
         }catch (Exception e){
             return processFail("创建引擎失败".concat(LogUtils.getException(e)), library_id);
         }

+ 116 - 0
mainFactory/src/main/java/org/bfkj/protocol/ElasticHandler.java

@@ -0,0 +1,116 @@
+package org.bfkj.protocol;
+
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.bfkj.config.AppConfig;
+import org.bfkj.utils.LogUtils;
+import org.bfkj.utils.MapTools;
+import org.elasticsearch.action.ShardOperationFailedException;
+import org.elasticsearch.action.index.IndexRequest;
+import org.elasticsearch.action.index.IndexResponse;
+import org.elasticsearch.action.support.replication.ReplicationResponse;
+import org.elasticsearch.client.RequestOptions;
+import org.elasticsearch.client.RestClient;
+import org.elasticsearch.client.RestClientBuilder;
+import org.elasticsearch.client.RestHighLevelClient;
+import org.elasticsearch.xcontent.XContentType;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+/*es协议*/
+public class ElasticHandler {
+
+    private RestHighLevelClient restHighLevelClient;
+
+    public synchronized Map<String, Object> sendData(String indexName, List<Object> dataContent, String connectConfig, String serviceId) {
+        if (Objects.isNull(indexName)) {
+            return MapTools.processFail("队列为空: " + dataContent);
+        }
+        if (Objects.isNull(dataContent)) {
+            return MapTools.processSuccess(null);
+        }
+        try {
+            Map<String, Object> connectConfigMaps = (Map<String, Object>) MapTools.strToObj(connectConfig);
+            if (Objects.isNull(restHighLevelClient)) {
+                String scheme = connectConfigMaps.get("scheme").toString();
+                String hostname = connectConfigMaps.get("hostname").toString();
+                int port = Integer.parseInt(connectConfigMaps.get("port").toString());
+                Object account = connectConfigMaps.get("auth");
+                if (null != account && "true".equals(account.toString())) {
+                    //有权限验证
+                    String username = connectConfigMaps.get("username").toString();
+                    String password = connectConfigMaps.get("password").toString();
+                    final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
+                    credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
+                    RestClientBuilder restClientBuilder = RestClient.builder(new HttpHost(hostname, port, scheme)).setHttpClientConfigCallback((httpAsyncClientBuilder) -> httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
+                    restHighLevelClient = new RestHighLevelClient(restClientBuilder);
+                } else {
+                    //无权限验证
+                    restHighLevelClient = new RestHighLevelClient(RestClient.builder(new HttpHost(hostname, port, scheme)));
+                }
+            }
+        } catch (Exception e) {
+            return MapTools.processFail("es发送参数异常:" + LogUtils.getException(e));
+        }
+        String dataJSON = "";
+        try {
+            IndexRequest request = new IndexRequest(indexName);
+            dataJSON = MapTools.objToJSONStr(dataContent);
+            request.id(createLifeCycleCol(Long.valueOf(AppConfig.WORK_ID), Integer.valueOf(MapTools.isBlank(serviceId) ? "0" : serviceId)));
+            request.timeout("1s");
+            request.source(dataJSON, XContentType.JSON);
+            IndexResponse indexResponse = restHighLevelClient.index(request, RequestOptions.DEFAULT);
+            ReplicationResponse.ShardInfo shardInfo = indexResponse.getShardInfo();
+            if (shardInfo.getFailed() > 0) {
+                String collect = Arrays.stream(shardInfo.getFailures()).map(ShardOperationFailedException::reason).collect(Collectors.joining(";\n"));
+                return MapTools.processSuccess(collect);
+            }
+        } catch (IOException e) {
+            try {
+                Thread.sleep(1000 * 6);
+            } catch (InterruptedException ex) {
+                System.out.println("es数据发送异常: ".concat(LogUtils.getException(e)));
+            }
+            return MapTools.processFail(LogUtils.getException(e));
+        } finally {
+            try {
+                if (null != restHighLevelClient) {
+                    restHighLevelClient.close();
+                }
+            } catch (IOException ex) {
+                System.out.println("es数据发送异常: ".concat(LogUtils.getException(ex)));
+            }
+        }
+        return MapTools.processSuccess("数据发送成功:".concat(dataJSON));
+    }
+
+    private long sequence = 0L;
+    private long lastTimestamp = -1L;
+
+    public String createLifeCycleCol(Long workerId, Integer serviceId) {
+        long timestamp = System.currentTimeMillis();
+        //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
+        if (lastTimestamp == timestamp) { //如果是同一时间生成的,则进行毫秒内序列
+            sequence++;
+            if (sequence > 999L) {//毫秒内序列溢出
+                sequence = 0;
+                while (lastTimestamp == System.currentTimeMillis()) {//阻塞到下一个毫秒,获得新的时间戳
+                }
+                timestamp = System.currentTimeMillis();
+            }
+        } else {
+            sequence = 0L;
+        }
+        lastTimestamp = timestamp;//上次生成ID的时间截
+        //移位并通过或运算拼到一起组成64位的ID
+        return String.valueOf(timestamp).concat(String.format("%03d", sequence)).concat(String.format("%04d", workerId)).concat(String.format("%04d", serviceId));
+    }
+}

+ 0 - 165
mainFactory/src/main/java/org/bfkj/protocol/EsAlgorithm.java

@@ -1,165 +0,0 @@
-package org.bfkj.protocol;
-
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.bfkj.utils.MapTools;
-import org.elasticsearch.action.ShardOperationFailedException;
-import org.elasticsearch.action.index.IndexRequest;
-import org.elasticsearch.action.index.IndexResponse;
-import org.elasticsearch.action.support.replication.ReplicationResponse;
-import org.elasticsearch.client.RequestOptions;
-import org.elasticsearch.client.RestClient;
-import org.elasticsearch.client.RestClientBuilder;
-import org.elasticsearch.client.RestHighLevelClient;
-import org.elasticsearch.xcontent.XContentType;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-/**
- * Es 算法
- */
-public class EsAlgorithm {
-    private final HashMap<String, RestHighLevelClient> restHighLevelClientHashMap = new HashMap<>();
-
-    /***
-     * 创建ES客户端
-     * @param connectConfig 连接配置信息
-     * @return ES客户端
-     */
-    private Map<String, Object> getRestHighLevelClient(String connectConfig) {
-        RestHighLevelClient restHighLevelClient = restHighLevelClientHashMap.get(connectConfig);
-        if (null == restHighLevelClient) {
-            Map<String, Object>  connectConfigMaps = (Map<String, Object>) MapTools.strToObj(connectConfig);
-            if (Objects.isNull(connectConfigMaps.get("scheme"))) {
-                return MapTools.processFail("请求类型为空,此值应该为http或则https");
-            }
-            if (Objects.isNull(connectConfigMaps.get("hostname"))) {
-                return MapTools.processFail("请求IP为空");
-            }
-            if (Objects.isNull(connectConfigMaps.get("port"))) {
-                return MapTools.processFail("请求端口为空");
-            }
-            String scheme = connectConfigMaps.get("scheme").toString();;
-            String hostname = connectConfigMaps.get("hostname").toString();
-            int port = Integer.parseInt(connectConfigMaps.get("hostname").toString());
-            Object account = connectConfigMaps.get("auth");
-            if (null != account && Objects.equals("true", account)) {
-                if (Objects.isNull(connectConfigMaps.get("username"))) {
-                    return MapTools.processFail("有权限验证用户名为空");
-                }
-                if (Objects.nonNull(connectConfigMaps.get("password"))) {
-                    return MapTools.processFail("有权限验证用户密码为空");
-                }
-                String username = connectConfigMaps.get("username").toString();
-                String password = connectConfigMaps.get("password").toString();
-                //有权限验证
-                final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
-                credentialsProvider.setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(username, password));
-                RestClientBuilder restClientBuilder = RestClient.builder(new HttpHost(hostname, port, scheme)).setHttpClientConfigCallback((httpAsyncClientBuilder) -> httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider));
-                restHighLevelClient = new RestHighLevelClient(restClientBuilder);
-            } else {
-                //无权限验证
-                restHighLevelClient = new RestHighLevelClient(RestClient.builder(new HttpHost(hostname, port, scheme)));
-            }
-            restHighLevelClientHashMap.put(connectConfig, restHighLevelClient);
-        }
-        return MapTools.processSuccess(null);
-    }
-
-    public Map<String, Object> sendMethod(String indexName, String connectConfig, Integer serviceId, String data) {
-        RestHighLevelClient restHighLevelClient = null;
-        try {
-            Map<String, Object> restHighLevelClientMap = getRestHighLevelClient(connectConfig);
-            if (restHighLevelClientMap.get("code").equals("-1")) return restHighLevelClientMap;
-            restHighLevelClient = restHighLevelClientHashMap.get(connectConfig);
-            IndexRequest request = new IndexRequest(indexName);
-            request.id(createLifeCycleCol(1L, serviceId));
-            request.timeout("1s");
-            request.source(data, XContentType.JSON);
-            IndexResponse indexResponse = restHighLevelClient.index(request, RequestOptions.DEFAULT);
-            ReplicationResponse.ShardInfo shardInfo = indexResponse.getShardInfo();
-            if (shardInfo.getFailed() > 0) {
-                return MapTools.processSuccess(Arrays.stream(shardInfo.getFailures()).map(ShardOperationFailedException::reason).collect(Collectors.joining(";\n")));
-            } else {
-                return MapTools.processFail("数据发送到ES异常");
-            }
-        } catch (IOException e) {
-            try {
-                Thread.sleep(1000 * 6);
-            } catch (InterruptedException ex) {
-                System.out.println("发送到ES出现异常,暂停6分钟时异常");
-            }
-            return MapTools.processFail(e.getMessage());
-        } finally {
-            try {
-                restHighLevelClientHashMap.remove(connectConfig);
-                if (null != restHighLevelClient) {
-                    restHighLevelClient.close();
-                }
-            } catch (IOException ex) {
-                System.out.println("发送到ES出现异常,暂停6分钟时异常");
-            }
-        }
-    }
-
-
-    /**
-     * 支持的最大机器id,结果是31 (这个移位算法可以很快计算出几位二进制数所能表示的最大十进制数)
-     */
-    private final static String maxWorkerId = "4";
-    /**
-     * 支持的最大数据标识id,结果是31
-     */
-    private final static String maxServiceId = "4";
-    /**
-     * 毫秒内序列(0~4095)
-     */
-    private static final Long maxSequence = 999L;
-
-    private static long sequence = 0L;
-
-    /**
-     * 上次生成ID的时间截
-     */
-    private static long lastTimestamp = -1L;
-
-    /**
-     * 生命周期ID生成
-     *
-     * @param workerId
-     * @param serviceId
-     * @return
-     */
-    public static synchronized String createLifeCycleCol(Long workerId, Integer serviceId) {
-        long timestamp = System.currentTimeMillis();
-        //如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
-        //如果是同一时间生成的,则进行毫秒内序列
-        if (lastTimestamp == timestamp) {
-            sequence++;
-            //毫秒内序列溢出
-            if (sequence > maxSequence) {
-                //阻塞到下一个毫秒,获得新的时间戳
-                sequence = 0;
-                while (lastTimestamp == System.currentTimeMillis()) {
-                }
-                timestamp = System.currentTimeMillis();
-            }
-        }
-        //时间戳改变,毫秒内序列重置
-        else {
-            sequence = 0L;
-        }
-        //上次生成ID的时间截
-        lastTimestamp = timestamp;
-        //移位并通过或运算拼到一起组成64位的ID
-        return timestamp + "" + (String.format("%0" + (maxSequence.toString().length()) + "d", sequence)) + (String.format("%0" + maxWorkerId + "d", workerId)) + (String.format("%0" + maxServiceId + "d", serviceId));
-    }
-}

+ 2 - 35
mainFactory/src/main/java/org/bfkj/utils/DataFormat.java

@@ -543,11 +543,11 @@ public class DataFormat {
             return MapTools.processSuccess(null);
         }
         if (xmlList.size() == 1) {
-            return customMadeOnexmlToMap(xmlList.get(0), isTwoDimensionalization, noDiKaList, translateName);
+            return customMadexmlToMap(xmlList.get(0), isTwoDimensionalization, noDiKaList, translateName);
         }
         List<Map<String, Object>> batchList = new ArrayList<>();
         xmlList.forEach(xml -> {
-            Map<String, Object> stringObjectMap = customMadeOnexmlToMap(xmlList.get(0), isTwoDimensionalization, noDiKaList, translateName);
+            Map<String, Object> stringObjectMap = customMadexmlToMap(xmlList.get(0), isTwoDimensionalization, noDiKaList, translateName);
             if ("-1".equals(stringObjectMap.get("code").toString())) {
                 stringObjectMap.put("returnData", new ArrayList<>());
             }
@@ -557,39 +557,6 @@ public class DataFormat {
     }
 
 
-    public static Map<String, Object> customMadeOnexmlToMap(String xml, boolean isTwoDimensionalization, List<String> noDiKaList, Map<String, String> translateName) {
-        Map<String, Object> returnMap = xmlToMapFormat(xml); //  code ,message ,returenData
-        if (returnMap.get("code").equals("-1")) return returnMap;
-        if (isTwoDimensionalization) {
-            Map<String, Object> xmlMap = (Map<String, Object>) returnMap.get("returnData");
-            returnMap = twoDimensionalizationFormat(xmlMap, noDiKaList); //  code ,message ,returenData
-            if (returnMap.get("code").equals("-1")) return returnMap;
-        }
-        if (null != translateName && !translateName.isEmpty()) {
-            Object returnData = returnMap.get("returnData"); //  code ,message ,returenData
-            if (returnData instanceof Map) {
-                List<Map<String, Object>> inData = new ArrayList<>();
-                inData.add((Map) returnData);
-                returnMap = translateMapName(inData, translateName); // code message retrunData
-            } else if (returnData instanceof List) {
-                returnMap = translateMapName((List) returnData, translateName); // code message retrunData
-            }
-        }
-        Object tempReturnData = returnMap.get("returnData");
-        List<Map<String,Object>> tempList = new ArrayList<>();
-        if (tempReturnData instanceof Map<?,?>){
-            tempList.add((Map<String, Object>) tempReturnData);
-        }else {
-            tempList = (List<Map<String, Object>>) tempReturnData;
-        }
-        for (Map<String, Object> tempMap : tempList) {
-            tempMap.values().removeAll(Collections.singleton(null));
-            tempMap.values().removeAll(Collections.singleton(""));
-        }
-        returnMap.put("returnData",tempList);
-        return returnMap;
-    }
-
 
     /**
      * map key值转换

+ 4 - 5
mainFactory/src/main/java/org/bfkj/utils/LogUtils.java

@@ -6,13 +6,12 @@ import org.bfkj.config.ObjectMap;
 
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
 import java.util.stream.Collectors;
 
 public class LogUtils { // 依据服务编号ID获取服务类型,如果是异步 异常日志无条件写入到本地数据库(每个服务都有这样的一个数据库) ,在程序启动时会扫描此表,重新进行,如果成功则从此表中移除
-    public static Map<String, List<Object>> logErrorMapList = new ConcurrentHashMap<>();
-    public static Map<String, List<Object>> logSuccessMapList = new ConcurrentHashMap<>();
-    public static Map<String, List<Object>> sourceMapList = new ConcurrentHashMap<>();
+    public static Map<String, List<Object>> logErrorMapList = new HashMap<>();
+    public static Map<String, List<Object>> logSuccessMapList = new HashMap<>();
+    public static Map<String, List<Object>> sourceMapList = new HashMap<>();
 
     public static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     private static Long deleteTime = 0L;
@@ -26,7 +25,7 @@ public class LogUtils { // 依据服务编号ID获取服务类型,如果是异
                 return;
             }
         } catch (Exception e) {
-            System.out.println("过滤:读取空消息: 出现错误".concat(LogUtils.getException(e)).concat(" iNDataContent: ").concat(inData == null ?"":inData));
+            System.out.println("过滤:读取空消息: 出现错误".concat(LogUtils.getException(e)).concat(" iNDataContent: ").concat(inData == null ? "" : inData));
             return;
         }
         String shortData = MapTools.isNotBlank(inData) ? (inData.length() > 20480 ? inData.substring(0, 20480) : inData) : null;

+ 20 - 13
mainFactory/src/main/java/org/bfkj/utils/MyDbHelper.java

@@ -146,12 +146,12 @@ public class MyDbHelper {//目前只差主键的条件优化
                 String whereStr = (String) dbFilter.get("whereStr");//where字符串--依据参数变化不可缓存
 
                 List<Object> dbValueList = new ArrayList<>();
-                event = "6".equals(event) && MapTools.isNotBlank(tableName) ? isExist(tableName, whereStr, filterList) : event;//如果是事件6则需要先进行判断后再决定事件
-                Map<String, Object> dbValueInfo = MapTools.isNotBlank(sqlStr) ? getdbValueForSql(execSQLStr, varList, signParam) : getdbValueForTable(tableName, event, authColumn, signParam, Objects.equals("true", calcInfo.get("isActive")));//获取执行的参数值集合,SQL语句方式针对的是书名号变量,注意使用未替换书名号的SQL语句
+                String  newEvent = "6".equals(event) && MapTools.isNotBlank(tableName) ? isExist(tableName, whereStr, filterList) : event;//如果是事件6则需要先进行判断后再决定事件
+                Map<String, Object> dbValueInfo = MapTools.isNotBlank(sqlStr) ? getdbValueForSql(execSQLStr, varList, signParam) : getdbValueForTable(tableName, newEvent, authColumn, signParam, Objects.equals("true", calcInfo.get("isActive")));//获取执行的参数值集合,SQL语句方式针对的是书名号变量,注意使用未替换书名号的SQL语句
                 dbValueList = (List<Object>) dbValueInfo.get("dbValue");//执行参数
                 execSQLStr = dbValueInfo.get("newSqlStr").toString();//修订后的SQL语句,针对in方式进行修订
-                rowCountSql = "0".equals(event) && MapTools.isNotBlank(allSQLColumn) ? execSQLStr.replace(allSQLColumn, " count(1) ") : "";//查询则创建rowCountSql
-                if (MapTools.isNotBlank(whereStr) && !"1".equals(event)) {//如果where字符串不为空
+                rowCountSql = "0".equals(newEvent) && MapTools.isNotBlank(allSQLColumn) ? execSQLStr.replace(allSQLColumn, " count(1) ") : "";//查询则创建rowCountSql
+                if (MapTools.isNotBlank(whereStr) && !"1".equals(newEvent)) {//如果where字符串不为空
                     execSQLStr = execSQLStr.concat(execSQLStr.lastIndexOf(")") >= execSQLStr.toLowerCase().lastIndexOf(" where ") ? " where " : " and ").concat("(").concat(whereStr).concat(")");
                     rowCountSql = MapTools.isBlank(rowCountSql) ? "" : rowCountSql.concat(rowCountSql.lastIndexOf(")") >= rowCountSql.lastIndexOf(" where ") ? " where " : " and ").concat("(").concat(whereStr).concat(")");
                     dbValueList.addAll(filterList);//组合执行参数
@@ -159,14 +159,14 @@ public class MyDbHelper {//目前只差主键的条件优化
 
                 Map<String, Object> sqlParmMap = new HashMap<>();
                 sqlParmMap.put("rowCountSql", rowCountSql);//行总数查询
-                sqlParmMap.put("event", event);//事件
-                Map<String, Map<String, Object>> tempSQLMap = "1".equals(event) ? inertSQLMap : execSQLMap;
+                sqlParmMap.put("event", newEvent);//事件
+                Map<String, Map<String, Object>> tempSQLMap = "1".equals(newEvent) ? inertSQLMap : execSQLMap;
 
                 List signParamList = Objects.nonNull(tempSQLMap.get(execSQLStr)) && Objects.nonNull(tempSQLMap.get(execSQLStr).get("signParam")) ? (List) tempSQLMap.get(execSQLStr).get("signParam") : new ArrayList<>();//获取对应SQL语句的执行参数,没有则默认为空数组
                 List dbParam = Objects.nonNull(tempSQLMap.get(execSQLStr)) && Objects.nonNull(tempSQLMap.get(execSQLStr).get("dbParam")) ? (List) tempSQLMap.get(execSQLStr).get("dbParam") : new ArrayList<>();//获取对应SQL语句的执行参数,没有则默认为空数组
                 signParamList.add(signParam);
                 sqlParmMap.put("signParam", signParamList);//上传的参数
-                if ("1".equals(event)) {
+                if ("1".equals(newEvent)) {
                     //参数一致时,去重执行
                     dbParam.add(dbValueList);//添加当前行的执行参数
                     sqlParmMap.put("dbParam", dbParam);//执行参数
@@ -174,7 +174,7 @@ public class MyDbHelper {//目前只差主键的条件优化
                 } else {
                     if (!dbParam.contains(dbValueList)) {//参数一致时,去重执行
                         String batchSQL = Objects.nonNull(execSQLMap.get(execSQLStr)) && Objects.nonNull(execSQLMap.get(execSQLStr).get("batchSQL")) ? execSQLMap.get(execSQLStr).get("batchSQL").toString() : "";
-                        if ("0".equals(event)  && dbParam.size() > 0) {
+                        if ("0".equals(newEvent)  && dbParam.size() > 0) {
                             batchSQL = (MapTools.isBlank(batchSQL) ? execSQLStr : batchSQL).concat(" or (").concat(whereStr).concat(")");
                             List tempList = dbParam.isEmpty() ? new ArrayList() : (List) dbParam.get(0);
                             tempList.addAll(dbValueList);
@@ -189,7 +189,7 @@ public class MyDbHelper {//目前只差主键的条件优化
                         }
                     }
                     sqlParmMap.put("dbParam", dbParam);//执行参数
-                    if (MapTools.isBlank(whereStr) && "2,3".contains(event)) {
+                    if (MapTools.isBlank(whereStr) && "2,3".contains(newEvent)) {
                         sqlParmMap.put("noExec", " 禁止全表更新、删除");//执行参数
                     }
                     execSQLMap.put(execSQLStr, sqlParmMap);//添加到最终执行列表中
@@ -431,7 +431,7 @@ public class MyDbHelper {//目前只差主键的条件优化
             Matcher matcher = regExpression.matcher(sqlStr);//正则提取
             while (matcher.find()) {//循环提取到的所有书名号变量
                 String varName = matcher.group();
-                sqlvarList.add(varName);//添加到变量列表---如果是in则书名号应该设置为《:col》,此处替换不使用?,在变量获取时依据变量进行多个?号替换select* from 行李日志表 where 行李牌号 in (《:行李牌号》)
+                sqlvarList.add(varName.trim());//添加到变量列表---如果是in则书名号应该设置为《:col》,此处替换不使用?,在变量获取时依据变量进行多个?号替换select* from 行李日志表 where 行李牌号 in (《:行李牌号》)
                 newSqlStr = newSqlStr.replaceFirst("《".concat(varName).concat("》"), varName.startsWith(":") ? varName.concat("?") : "?"); //修订SQL
             }
             sqlStrVarList.put(sqlStr, sqlvarList);//添加到缓存
@@ -547,12 +547,13 @@ public class MyDbHelper {//目前只差主键的条件优化
         }
         HashSet<Object> tableUniqe = event6Map.get(tableName);//获取已经缓存的数据
         String oldKey = whereStr.concat(MapTools.objToJSONStr(dbFilter));//条件字符串加条件执行参数
-        if (!tableUniqe.contains(oldKey)) {//如果不存在则查数据库
+        if (!tableUniqe.contains(oldKey)) {//如果不存在则查数据库 // 23298306
             try {
                 List<Map<String, Object>> isExistResult = theJdbcTemplate.queryForList("select 1 from ".concat(tableName).concat(" where ").concat(whereStr).concat(" limit 1"), dbFilter.toArray());
                 event = (isExistResult.size() == 0) ? "1" : event;//数据库不存在则新增
                 //如果是新增则修订为新增SQL
                 tableUniqe.add(oldKey);//无论是新增还是更新都添加到缓存
+//                event6Map.put(tableName,tableUniqe);
             } catch (Exception e) {//查询失败并不更新缓存
                 //打印错误即可
             }
@@ -682,12 +683,18 @@ public class MyDbHelper {//目前只差主键的条件优化
             connection = theDataSource.getConnection();//获取连接
             sqlPS = connection.prepareStatement(sqlStr);//预编译SQL
             connection.setAutoCommit(false);    //手动事务
-            for (Object tempSigndbValue : dbValue) {//循环添加参数
-                Object[] signdbValue = ((List<Object>) tempSigndbValue).toArray();
+            for (int i = 0; i < dbValue.size(); i++) {
+
+                Object[] signdbValue = ((List<Object>)dbValue.get(i)).toArray();
                 for (int index = 0; index < signdbValue.length; index++) {
                     sqlPS.setObject(index + 1, signdbValue[index]);
                 }
                 sqlPS.addBatch();
+                if ((i+1) % 500 == 0){
+                    sqlPS.executeBatch();
+                    connection.commit(); // 统一提交
+                    sqlPS.clearBatch();
+                }
             }
             sqlPS.executeBatch();
             connection.commit(); // 统一提交

+ 2 - 1
mainFactory/src/main/java/org/bfkj/utils/ScriptEnginePro.java

@@ -192,7 +192,8 @@ public class ScriptEnginePro {
                 for (String varName : execData.keySet()) {
                     javaParams.set(Integer.parseInt(parmaNames.get(varName)) -1, execData.get(varName));
                 }
-                return processSuccess(javaMethod.invoke(classInstance, javaParams.toArray()));//数组方式传参,无需参数名,按顺序对应
+                Object invoke = javaMethod.invoke(classInstance, javaParams.toArray());
+                return  processSuccess(invoke);//数组方式传参,无需参数名,按顺序对应
             } catch (Exception e) {
                 return processFail("JAVA执行失败,执行参数:".concat(javaParams.toString()).concat(";异常信息:").concat(LogUtils.getException(e)));
             }