Procházet zdrojové kódy

日志修改,文件上传

pms před 2 roky
rodič
revize
825086cf6e

+ 3 - 0
.idea/compiler.xml

@@ -9,6 +9,9 @@
         <module name="mainFactory" />
       </profile>
     </annotationProcessing>
+    <bytecodeTargetLevel>
+      <module name="mainFactory" target="17" />
+    </bytecodeTargetLevel>
   </component>
   <component name="JavacSettings">
     <option name="ADDITIONAL_OPTIONS_OVERRIDE">

+ 24 - 20
mainFactory/pom.xml

@@ -15,6 +15,7 @@
         <maven.compiler.target>17</maven.compiler.target>
         <java.version>17</java.version>
         <graalvm.version>22.3.1</graalvm.version>
+        <spring.webmvc>6.0.7</spring.webmvc>
     </properties>
 
     <dependencies>
@@ -28,6 +29,7 @@
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
+            <version>2.7.3</version>
             <exclusions>
                 <exclusion>
                     <groupId>org.springframework.boot</groupId>
@@ -37,28 +39,30 @@
                     <groupId>com.vaadin.external.google</groupId>
                     <artifactId>android-json</artifactId>
                 </exclusion>
+                <exclusion>
+                    <groupId>org.springframework.security</groupId>
+                    <artifactId>spring-security-core</artifactId>
+                </exclusion>
             </exclusions>
         </dependency>
 
         <dependency>
-            <groupId>org.apache.poi</groupId>
-            <artifactId>poi</artifactId>
-            <version>3.9</version>
+            <groupId>org.yaml</groupId>
+            <artifactId>snakeyaml</artifactId>
+            <version>2.0</version>
         </dependency>
 
         <dependency>
             <groupId>org.apache.poi</groupId>
-            <artifactId>poi-ooxml</artifactId>
-            <version>3.9</version>
+            <artifactId>poi</artifactId>
+            <version>4.1.1</version>
         </dependency>
 
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-test</artifactId>
-            <version>5.3.22</version>
-            <scope>test</scope>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>4.1.1</version>
         </dependency>
-
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
@@ -69,12 +73,6 @@
             <artifactId>junit</artifactId>
             <scope>test</scope>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-test</artifactId>
-            <version>2.7.2</version>
-            <scope>test</scope>
-        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-jdbc</artifactId>
@@ -83,6 +81,12 @@
         <dependency>
             <groupId>org.springframework.data</groupId>
             <artifactId>spring-data-commons</artifactId>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.apache.commons</groupId>
+                    <artifactId>commons-compress</artifactId>
+                </exclusion>
+            </exclusions>
             <scope>test</scope>
         </dependency>
 
@@ -105,7 +109,7 @@
         <dependency>
             <groupId>org.dom4j</groupId>
             <artifactId>dom4j</artifactId>
-            <version>2.1.3</version>
+            <version>2.0.3</version>
         </dependency>
 
         <!--rabbitmq 9-->
@@ -130,17 +134,17 @@
         <dependency>
             <groupId>org.elasticsearch.client</groupId>
             <artifactId>elasticsearch-rest-high-level-client</artifactId>
-            <version>7.15.2</version>
+            <version>7.17.6</version>
         </dependency>
         <dependency>
             <groupId>org.elasticsearch.client</groupId>
             <artifactId>elasticsearch-rest-client</artifactId>
-            <version>7.15.2</version>
+            <version>8.2.1</version>
         </dependency>
         <dependency>
             <groupId>org.elasticsearch</groupId>
             <artifactId>elasticsearch</artifactId>
-            <version>7.15.2</version>
+            <version>8.2.1</version>
         </dependency>
 
 

+ 42 - 15
mainFactory/src/main/java/org/bfkj/MainFactoryApplication.java

@@ -37,20 +37,19 @@ public class MainFactoryApplication {
         Map<String, String> systemDefaultParams = getSystemDefaultParams(path);
         ConfigurableApplicationContext context = SpringApplication.run(MainFactoryApplication.class, args);
         Environment env = context.getBean(Environment.class);
-        // {"systemParams":{}}
-        if (null != env.getProperty("systemParams") && !"".equals(env.getProperty("systemParams"))) {
-            //替换参数systemDefaultParams
-            Map<String, Object> inSystemParams = MapTools.stringToMap(env.getProperty("systemParams"));
+
+        Map<String, String> configByEnvironment = getConfigByEnvironment(env);
+        if (!configByEnvironment.isEmpty()){
+            systemDefaultParams.putAll(configByEnvironment);
+        }
+        String systemParams = env.getProperty("systemParams");
+        if (Objects.nonNull(systemParams) && !"".equals(systemParams)) {
+            Map<String, Object> inSystemParams = MapTools.stringToMap(systemParams);
             for (String key : inSystemParams.keySet()) {
                 String keyValue = inSystemParams.get(key).toString().replace("path", path);
-                if (key.equals("workId") && !MapTools.isNumber(keyValue)) { //需要判断workID 只能是数字 ip:端口
-                    System.out.println("WorkId 类型异常");
-                    return;
-                }
                 ObjectMapper mapper = new ObjectMapper();
                 try {
                     mapper.registerModule(new JavaTimeModule());
-
                     if (MapTools.stringToMap(keyValue).isEmpty()) {
                         systemDefaultParams.put(key, keyValue);
                     } else {
@@ -81,8 +80,7 @@ public class MainFactoryApplication {
         Runtime.getRuntime().addShutdownHook(new Thread(MainFactoryApplication::currentWorkExit));
         String serviceURL = AppConfig.getSystemParams("serviceURL");
         try {
-            String sql = "select Max(deployNodeID) from deploynode where serviceURL = ? ";
-            Map<String, String> hasDeployNodeIDMap = myDbHelper.queryForObject(sql, serviceURL);
+            Map<String, String> hasDeployNodeIDMap = myDbHelper.queryForObject("select Max(deployNodeID) from deploynode where serviceURL = ? ", serviceURL);
             if (hasDeployNodeIDMap.get("code").equals("-1")) {
                 System.out.println("初始化获取机器表信息: 执行SQL失败 " + hasDeployNodeIDMap.get("message"));
                 return;
@@ -91,10 +89,9 @@ public class MainFactoryApplication {
             if (!"".equals(workID) && !"0".equals(workID)) {
                 AppConfig.WORK_ID = workID;
             } else {
-                sql = "insert into deploynode(serviceURL)  values(?)";
-                Map<String, Object> returnKeyValues = myDbHelper.insertReturnKeyValues(sql, serviceURL);
+                Map<String, Object> returnKeyValues = myDbHelper.insertReturnKeyValues("insert into deploynode(serviceURL)  values(?)", serviceURL);
                 if (returnKeyValues.get("code").equals("-1")) {
-                    System.out.println("根据serviceURL新增入库失败: " + sql + " 参数: " + serviceURL);
+                    System.out.println("根据serviceURL新增入库失败: " + ("insert into deploynode(serviceURL)  values(?)") + " 参数: " + serviceURL);
                     return;
                 }
                 AppConfig.WORK_ID = returnKeyValues.get("returnData").toString();
@@ -128,6 +125,35 @@ public class MainFactoryApplication {
         System.out.println("本机共部署服务个数:" + serviceList.size() + ",启动主动采集个数:" + autoCount);
     }
 
+    private static Map<String, String> getConfigByEnvironment(Environment env) {
+        String url = env.getProperty("mydb.url");
+        String uname = env.getProperty("mydb.title");
+        String cipher = env.getProperty("mydb.cipher");
+        String type = env.getProperty("mydb.type");
+        String serviceURL = env.getProperty("mydb.serviceURL");
+        Map<Object, Object> remoteDBConnect = new HashMap<>();
+        if (null != url) {
+            remoteDBConnect.put("url", url);
+        }
+        if (null != uname) {
+            remoteDBConnect.put("username", uname);
+        }
+        if (null != cipher) {
+            remoteDBConnect.put("password", cipher);
+        }
+        if (null != type) {
+            remoteDBConnect.put("driver-class-name", type);
+        }
+        Map<String, String> returnMap = new HashMap<>();
+        if (null != serviceURL) {
+            returnMap.put("serviceURL", serviceURL);
+        }
+        if (null != url && null != uname && null != type && null != cipher) {
+            returnMap.put("remote_db_connect", MapTools.jacksonObjToStr(remoteDBConnect));
+        }
+        return returnMap;
+    }
+
 
     /**
      * 获取系统默认参数
@@ -157,10 +183,11 @@ public class MainFactoryApplication {
     /*创建文件夹*/
     private static boolean checkFileDir(String path) {
         //初始化默认文件创建
-        List<String> pathList = new ArrayList<String>() {{
+        List<String> pathList = new ArrayList<>() {{
             add("cache");
             add("plugins");
             add("ftp");
+            add("upload");
             add("log");
         }};
         for (String paths : pathList) {

+ 21 - 28
mainFactory/src/main/java/org/bfkj/application/DataProcess.java

@@ -9,7 +9,6 @@ import org.bfkj.utils.MyDbHelper;
 import org.bfkj.utils.ScriptEnginePro;
 
 import java.util.*;
-import java.util.stream.Collectors;
 
 
 /**
@@ -26,9 +25,9 @@ public class DataProcess {
 
     private final Map<String, ScriptEnginePro> ScriptEngineProMaps = new HashMap<>();//用于缓存当前服务的算法引擎对象,数据库的无需缓存
 
-    private Map<String, List<String>> columnMaps = new HashMap<>(); //用于缓存对应数据库算法的SQL结构,表名、字段列表、主键
+    private final Map<String, List<String>> columnMaps = new HashMap<>(); //用于缓存对应数据库算法的SQL结构,表名、字段列表、主键
 
-    private static List<String> baseInfo = new ArrayList<>() {{
+    private static final List<String> baseInfo = new ArrayList<>() {{
         add("serviceId");
         add("event");
         add("page");
@@ -45,8 +44,6 @@ public class DataProcess {
             errorMessage = "获取myDbHelper对象异常: " + myDbHelper.getErrorMessage();
             return;
         }
-        //服务信息
-        // todo 修改: result ,检查外层是否是判断过服务是否存在,如果不在存则修改sql否则移除
         Map<String, Object> serviceInfoResult = myDbHelper.queryByParamsReturnList("select * from serviceinfo where serviceID = ?", service_Id);//直接数据库查询
         List<Map<String, Object>> mapList = MapTools.getMapList(serviceInfoResult);
         if (!serviceInfoResult.get("code").equals("0") || Objects.isNull(mapList) || mapList.isEmpty()) {//查询数据库失败
@@ -60,13 +57,13 @@ public class DataProcess {
         if (!calculationResult.get("code").equals("0")) {//查询数据库失败
             errorMessage = "查询" + service_Id + "的算法失败:" + calculationResult.get("message");
         }
+        if (calculationLibraryList == null || calculationLibraryList.isEmpty()) {//查询数据库失败
+            errorMessage = "服务ID " + service_Id +"没有找到对应的算法";
+        }
     }
 
     /**
      * 关闭的连接信息
-     *
-     * @param
-     * @return
      */
     public void close() {//销毁当前服务对象时,需要将缓存的算法引擎实例同步销毁
         for (ScriptEnginePro scriptEnginePro : ScriptEngineProMaps.values()) {
@@ -166,7 +163,6 @@ public class DataProcess {
         calculationResult.add(inputData);//默认接收数据为第0个算法的结果
         Map<String, List<Map<String, Object>>> execResult = execCalultion(calculationResult, null, event, dataObjectId, inputData.get("page"), inputData.get("pageSize"));
         calculationResult = execResult.get("calcData");//执行当前服务对应的算法库
-
         Map<String, Object> lastResult = calculationResult.get(calculationResult.size() - 1);//获取最后一个计算结果
         if (Objects.equals(lastResult.get("code"), "-1")) {//最后一个计算结果为-1则记录异常,否则全部记录正常
             String libraryId = lastResult.get("library_id").toString();
@@ -181,7 +177,7 @@ public class DataProcess {
         // 循环lastResult
         // 遍历map
         // 如果key不在列权限则删除
-        List<Map<String, Object>> collect = calculationResult.stream().filter(map -> Objects.isNull(map.get("library_id")) || !map.get("library_id").toString().contains("_N")).collect(Collectors.toList());
+        List<Map<String, Object>> collect = calculationResult.stream().filter(map -> Objects.isNull(map.get("library_id")) || !map.get("library_id").toString().contains("_N")).toList();
         return processSuccess(collect.get(collect.size() - 1));
     }
 
@@ -210,6 +206,7 @@ public class DataProcess {
         return inputData;//
     }
 
+    @SuppressWarnings("unchecked")
     private static Map<String, Object> createStandardParameters(Map<String, Object> inDataContent, String event, List<Object> authList) {
         Map<String, Object> returnData = new HashMap<>();//创建返回值returnData{}
         if ("1,2".contains(event)) {//如果事件是新增或更新则(查询和删除无需处理value)
@@ -225,13 +222,13 @@ public class DataProcess {
             Object tempFilterObject = inDataContent.get("filter");//获取filter
             tempFilterObject = Objects.isNull(tempFilterObject) ? inDataContent : tempFilterObject;//如果不存在filter则等于原始MAP
             if (tempFilterObject instanceof Map) {////如果filter是单个Map则
-                authList.addAll(changeSignFilter((Map) tempFilterObject, null, null));
+                authList.addAll(changeSignFilter((Map<String, Object>) tempFilterObject, null, null));
                 returnData.put("filter", authList);//转换为标准条件集
             } else {
                 if (tempFilterObject instanceof List tempFilterObjectList && tempFilterObjectList.get(0) instanceof Map) {//如果filter是List则"123"
                     List<Object> tempFilterList = new ArrayList<>(authList);
                     for (Object o : tempFilterObjectList) {//循环List -{c1:c2,c3:c4}
-                        tempFilterList.addAll(changeSignFilter((Map) o, null, null)); //循环添加
+                        tempFilterList.addAll(changeSignFilter((Map<String, Object>) o, null, null)); //循环添加
                     }
                     returnData.put("filter", tempFilterList);//转换为标准条件集
                 } else {//此时tempFilterObject既不是List也不是Map:1、dataContent包含filter且filter是一个字符串
@@ -248,7 +245,7 @@ public class DataProcess {
             objects.add(filterMap);
             return objects;
         }
-        for (Object filterKey : filterMap.keySet()) {
+        for (String filterKey : filterMap.keySet()) {
             Map<String, Object> returnMap = new HashMap<>();
             Object keyValues = filterMap.get(filterKey);
             returnMap.put("left", "");
@@ -270,7 +267,7 @@ public class DataProcess {
         List<Map<String, Object>> preData = new ArrayList<>();
         List<Map<String, Object>> calcData = Objects.isNull(inData) || inData.isEmpty() ? new ArrayList<>() : inData;
         for (Map<String, Object> calculationLibrary : calculationLibraryList) {//循环算法库
-
+//            long l = System.currentTimeMillis();
             String library_id = calculationLibrary.get("library_id").toString();//算法编号
             if (MapTools.isNotBlank(beginLibraryId) && !beginLibraryId.equals(library_id)) {
                 continue;//如果异常恢复开始算法编号不为空且不等于当前循环的算法编号则跳过
@@ -309,17 +306,12 @@ public class DataProcess {
                     returnData.put("calcData", calcData);
                     return returnData;
                 }
-                Object sourceObjectName = calculationLibrary.get("sourceObjectName");//目标对象名(表名)
+                //目标对象名(表名)
+                String tableName = Objects.isNull(calculationLibrary.get("sourceObjectName")) ? null : calculationLibrary.get("sourceObjectName").toString();
                 Object isActiveTable = calculationLibrary.get("isActiveTable");//是否动态表
-                Object eventStr = calculationLibrary.get("event");//指定当前算法事件
-                String eventFlag;
-                if (Objects.isNull(eventStr)) {//算法未指定事件:表名方式依赖入口否则通过SQL语句进行判断     ------------------sql语句如果换行了呢
-                    eventFlag = Objects.nonNull(sourceObjectName) ? event.toString() : AppConfig.staticEvent.get(Objects.requireNonNull(computing_expression).trim().toLowerCase().substring(0, 6));
-                } else {//算法指定事件
-                    eventFlag = eventStr.toString();
-                }
+                //指定当前算法事件
+                String eventFlag = Objects.isNull(calculationLibrary.get("event")) ? (MapTools.isNotBlank(tableName)? event.toString() : AppConfig.staticEvent.get(Objects.requireNonNull(computing_expression).trim().toLowerCase().substring(0, 6))) : calculationLibrary.get("event").toString();
                 if (null == eventFlag) {
-//                    inData.add();
                     calcData.add(processFail("事件标志为空", library_id));
                     returnData.put("calcData", calcData);
                     return returnData;
@@ -329,14 +321,14 @@ public class DataProcess {
                 Object tempDBPrams = null;
                 try {//添加try捕获异常
                     if (Objects.isNull(calculationLibrary.get("parmIndex"))) {//未配置取参则默认取上一个算法
-                        Map<String, Object> tempMap = inData.get(inData.size() - 1);
+                        Map<String, Object> tempMap = calcData.get(calcData.size() - 1);
                         tempDBPrams = tempMap.containsKey("dataContent") ? tempMap.get("dataContent") : tempMap.get("returnData");
                     } else {//算法取值位置表达式不为空
-                        tempDBPrams = inData;//默认等于全量参数
+                        tempDBPrams = calcData;//默认等于全量参数
                         String[] parmSplit = calculationLibrary.get("parmIndex").toString().split("\\.");//按.进行分割
                         for (String item : parmSplit) {//循环提取参数
                             if (MapTools.isNumber(item)) {//数字代表数组中的位置
-                                tempDBPrams = ((List) tempDBPrams).get(Integer.parseInt(item));
+                                tempDBPrams = ((List<?>) tempDBPrams).get(Integer.parseInt(item));
                             } else {
                                 tempDBPrams = ((Map) tempDBPrams).get(item);
                             }
@@ -354,9 +346,9 @@ public class DataProcess {
                 }
                 // 事件6 在算法表中的event定义,实现自动的新增或更新
                 if (eventFlag.equals("6")) {
-                    currentResult = myDbHelper.insertOrUpdate(Objects.nonNull(sourceObjectName) ? sourceObjectName.toString() : "", dbPrams);
+                    currentResult = myDbHelper.insertOrUpdate(tableName, dbPrams);
                 } else {
-                    currentResult = myDbHelper.generalProcess(eventFlag, Objects.nonNull(sourceObjectName) ? sourceObjectName.toString() : "", computing_expression, null, dbPrams, Objects.nonNull(isActiveTable) && Objects.equals(isActiveTable, "true"), page, pageSize);
+                    currentResult = myDbHelper.generalProcess(eventFlag, tableName, computing_expression, null, dbPrams, Objects.nonNull(isActiveTable) && Objects.equals(isActiveTable, "true"), page, pageSize);
                 }
 
             } else {
@@ -367,6 +359,7 @@ public class DataProcess {
             }
             calcData.add(currentResult);
             returnData.put("calcData", calcData);
+//            System.out.println("算法ID : " + library_id +"  执行时间为:" +(System.currentTimeMillis()-l));
             setServiceErrorCount(library_id, serviceId, "0");    ///  错误次数恢复??
         }
         return returnData;

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

@@ -14,7 +14,7 @@ import org.elasticsearch.client.RequestOptions;
 import org.elasticsearch.client.RestClient;
 import org.elasticsearch.client.RestClientBuilder;
 import org.elasticsearch.client.RestHighLevelClient;
-import org.elasticsearch.common.xcontent.XContentType;
+import org.elasticsearch.xcontent.XContentType;
 
 import java.io.IOException;
 import java.util.Arrays;

+ 1 - 1
mainFactory/src/main/java/org/bfkj/protocol/MyKafKa.java

@@ -30,7 +30,7 @@ public class MyKafKa {
         if (!connectConfigMaps.containsKey("group.id")) {
             connectConfigMaps.put("group.id", "groupid" + (String.format("%s", library_id)));
         }
-        connectConfigMaps.put("max.poll.records", 1);
+        connectConfigMaps.put("max.poll.records", 50);
         connectConfigMaps.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
         connectConfigMaps.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
 

+ 4 - 1
mainFactory/src/main/java/org/bfkj/utils/DataFormat.java

@@ -53,8 +53,9 @@ public class DataFormat {
 
     /**
      * base64解码
+     *
      * @param source 原已编码数据
-     * @return  原始数据
+     * @return 原始数据
      */
     public static String base64DecoderToString(String source){
         return new String(Base64.getDecoder().decode(source));
@@ -62,6 +63,7 @@ public class DataFormat {
 
     /**
      * base64 编码
+     *
      * @param source 原数据
      * @return 编码后数据
      */
@@ -590,6 +592,7 @@ public class DataFormat {
         return returnList;//返回returnList
     }
 
+
     //MAP二维化辅助方法,返回List<map<string,object>>
     private static List<Map<String, Object>> dikaMap(List<Map<String, Object>> parentList, List<Map<String, Object>> childList) {
 //        初始化一个返回数组

+ 8 - 14
mainFactory/src/main/java/org/bfkj/utils/ImportExcelUtils.java

@@ -1,10 +1,7 @@
 package org.bfkj.utils;
 
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.springframework.stereotype.Component;
 
@@ -20,7 +17,7 @@ public class ImportExcelUtils {
     // 将表格中的数据添加到List集合中
     public Map<String, Object> upload(String fileName, InputStream is) {
         try {
-            File file = new File(System.getProperty("user.dir") + File.separator + "ftp" + File.separator + System.currentTimeMillis() + "_" + fileName);
+            File file = new File(System.getProperty("user.dir") + File.separator + "upload" + File.separator + System.currentTimeMillis() + "_" + fileName);
             String isUpLoad = saveFile(file, is);
             if (null != isUpLoad) {
                 return MapTools.processFail(isUpLoad);
@@ -29,6 +26,7 @@ public class ImportExcelUtils {
             Workbook workbook = getWorkbook(file.getName(), fileInputStream);
             List<Map<String, Object>> tempMapList = new ArrayList<>();
             int number = workbook.getNumberOfSheets(); // 获取sheet值
+            DataFormatter formatter = new DataFormatter();
             for (int i = 0; i < number; i++) {
                 Sheet sheet = workbook.getSheetAt(i); // 获取表格页码
                 if (sheet != null) {
@@ -37,10 +35,9 @@ public class ImportExcelUtils {
                     int rowNum1 = row1.getLastCellNum(); // 第一行
                     List<String> colList = new ArrayList<>();
                     for (int k = 0; k < rowNum1; k++) {
-                        Cell cell =row1.getCell(k);
-                        if (cell != null){
-                            cell.setCellType(Cell.CELL_TYPE_STRING);
-                            colList.add(cell.getStringCellValue());
+                        Cell cell = row1.getCell(k);
+                        if (cell != null) {
+                            colList.add(formatter.formatCellValue(cell));
                         }
                     }
                     for (int j = 1; j <= rowNum; j++) {  // 一般来说第一行是标题,所以第二行开始读取
@@ -48,10 +45,7 @@ public class ImportExcelUtils {
                         HashMap<String, Object> tempMap = new HashMap<>();
                         for (int col = 0; col < colList.size(); col++) {
                             Cell cell = row.getCell(col);
-                            if (cell != null){
-                                cell.setCellType(Cell.CELL_TYPE_STRING);
-                            }
-                            tempMap.put(colList.get(col),cell ==null?null: row.getCell(col).getStringCellValue());
+                            tempMap.put(colList.get(col), cell == null ? null : formatter.formatCellValue(cell));
                         }
                         tempMapList.add(tempMap);
                     }
@@ -75,7 +69,7 @@ public class ImportExcelUtils {
         try {
             in = new BufferedInputStream(is);
             out = new BufferedOutputStream(new FileOutputStream(file));
-            int len = -1;
+            int len;
             byte[] b = new byte[1024];
             while ((len = in.read(b)) != -1) {
                 out.write(b, 0, len);

+ 25 - 6
mainFactory/src/main/java/org/bfkj/utils/MyDbHelper.java

@@ -47,7 +47,8 @@ public class MyDbHelper {
                 return;
             }
             HikariConfig config = new HikariConfig();
-            config.setMaximumPoolSize(6);//最大核心数 8*4
+            config.setMaximumPoolSize(Math.max(Runtime.getRuntime().availableProcessors(), 32));//最大核心数 8*4
+//            config.setMaximumPoolSize(32);//最大核心数 8*4
             config.setKeepaliveTime(60000); //用于跟数据库保持心跳连接
             config.setMaxLifetime(60000 * 60 * 4); //4小时 接在池中的最大生存时间,超过该时间强制逐出
             config.addDataSourceProperty("cachePrepStmts", "true"); //是否自定义配置,为true时下面两个参数才生效
@@ -197,7 +198,12 @@ public class MyDbHelper {
         return isNew;
     }
 
-    public Map<String, Object> insertOrUpdate(String tableName, List<Map<String, Object>> paramsList) {  // [{“name”:"111"},[{Value:{},filter:{"name":"111"}]
+    public Map<String, Object> insertOrUpdate(String tableName, List<Map<String, Object>> params) {  // [{“name”:"111"},[{Value:{},filter:{"name":"111"}]
+        List<Map<String, Object>> paramsList = new ArrayList<>(params); /*深拷贝入参*/
+        if (MapTools.isBlank(tableName)) {
+            return processFail("事件标志为6、其表名不能为空", tableName, paramsList);
+        }
+
         List<Map<String, Object>> returnList = new ArrayList<>();
         for (Map<String, Object> signParam : paramsList) {
             String eventStr = "2";
@@ -222,7 +228,8 @@ public class MyDbHelper {
 
 
     //统一数据处理,兼容增删改查
-    public Map<String, Object> generalProcess(String event, String tableName, String sql, String rowCountSQL, List<Map<String, Object>> paramsList, boolean isActive, Object page, Object pageSize) {
+    public Map<String, Object> generalProcess(String event, String tableName, String sql, String rowCountSQL, List<Map<String, Object>> params, boolean isActive, Object page, Object pageSize) {
+        List<Map<String, Object>> paramsList = new ArrayList<>(params); /*深拷贝入参*/
         //-----入参检测
         if (MapTools.isBlank(tableName) && MapTools.isBlank(sql)) {//如果表名为空 且SQL为空则返回错误
             return processFail("generalProcess核心入口参数为空 ", null, paramsList);
@@ -250,9 +257,18 @@ public class MyDbHelper {
             List<String> allPrimaryKey = new ArrayList<>();//初始化所有主键
             if (MapTools.isBlank(tableName)) {//如果SQL不为空
                 if ("0".equals(event)) {//如果是查询则---应该只有复杂select
+                    sql = sql.trim().toLowerCase();
+                    String[] sqlSplit = sql.split("\\s+");
                     if (sql.startsWith("select 1 from")) { //??
-                        String[] sqlSplit = sql.trim().toLowerCase().split("\\s+");
                         tableName = sqlSplit[3];
+                    } else if (sql.startsWith("select count(") || sql.startsWith("select sum(")) { //??
+                        for (int i = 0; i < sqlSplit.length; i++) {
+                            if (sqlSplit[i].equals("from")) {
+                                tableName = sqlSplit[i+1];
+                                break;
+                            }
+                        }
+//                        tableName = sqlSplit[3];
                     } else {
                         Map<String, Object> tempAllColumn = getAllColumnBySql(sql);
                         if (tempAllColumn.get("code").equals("-1")) {
@@ -314,7 +330,7 @@ public class MyDbHelper {
         return updateByCondition(sql, parameterList);
     }
 
-    public  Map<String, Object> JDBCBatch(String sql, List<Object[]> paramList, List<Map<String, Object>> paramsList) {
+    public Map<String, Object> JDBCBatch(String sql, List<Object[]> paramList, List<Map<String, Object>> paramsList) {
         if (!sql.contains("?")) {  // Object[]
             return processSuccess(null, sql, paramsList);
         }
@@ -414,6 +430,9 @@ public class MyDbHelper {
             tempList.add(paramsList.get(0));
             paramsList = tempList;
         }
+        if (paramsList.size() ==0){
+            paramsList.add(new HashMap<>());
+        }
         for (Map<String, Object> itemMap : paramsList) {
             List<Object> cuList = new ArrayList<>();
             List<String> modifyCol = new ArrayList<>();
@@ -739,7 +758,7 @@ public class MyDbHelper {
         Pattern regExpression = Pattern.compile("(?<=《)([^》]+)?(?=》)");
         Matcher parameterNames = regExpression.matcher(sql);
         /*目前是支持批量删除的 || sql.toLowerCase().trim().startsWith("delete")*/
-        if ((sql.toLowerCase().trim().startsWith("select") ) && paramsList.size() > 1) {
+        if ((sql.toLowerCase().trim().startsWith("select")) && paramsList.size() > 1) {
             Map<String, Object> temMap = paramsList.get(0);
             paramsList = new ArrayList<>() {
                 {

+ 8 - 0
mainFactory/src/main/resources/application.yml

@@ -14,6 +14,14 @@ spring:
     view:
       prefix: /
       suffix: .html
+
+mydb:
+  url: jdbc:mysql://10.211.66.16:3163/DISACenter_2
+  title: root
+  cipher: QtrmuqDw^bJu$
+  type: com.mysql.cj.jdbc.Driver
+  serviceURL: 127.0.0.9:8888
+
 service:
   pool:
     maxPoolSize: 512