pms 2 years ago
parent
commit
d10a3fa5f3

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

@@ -18,6 +18,8 @@ import org.springframework.scheduling.annotation.Scheduled;
 
 import java.io.File;
 import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 /**
  * 初始化
@@ -27,9 +29,9 @@ import java.util.*;
 @EnableScheduling
 public class MainFactoryApplication {
 
-   private final String INSERT_SQL = "INSERT INTO log_success ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
-    private final  String ERROR_SQL = "INSERT INTO log_error ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
-    private final  String FULL_DATA_SQL = "INSERT INTO log_fulldata ( dataObjectId, FULL_DATA_SQL) VALUES (?,?)";
+    private final String INSERT_SQL = "INSERT INTO log_success ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+    private final String ERROR_SQL = "INSERT INTO log_error ( success, location, logContent, createtime, serviceId, workId, event, iNDataContent, outDataContent, calculationLocation, dataObjectId) VALUES (?,?,?,?,?,?,?,?,?,?,?)";
+    private final String FULL_DATA_SQL = "INSERT INTO log_fulldata ( dataObjectId, FULL_DATA_SQL) VALUES (?,?)";
 
     /*服务初始化: 启动服务*/
     public static void main(String[] args) {
@@ -296,21 +298,21 @@ public class MainFactoryApplication {
     public void batchLog() {
         Map<String, List<Object>> logSuccessMap = LogUtils.logSuccessMapList;
         long current = System.currentTimeMillis();
-        List<String> successList = logSuccessMap.keySet().stream().filter(key -> Long.parseLong(key) < current ).toList();
+        List<String> successList = logSuccessMap.keySet().stream().filter(key -> Long.parseLong(key) < current).toList();
         List<Object> logSuccessList = new ArrayList<>();
         for (String currentTime : successList) {
             logSuccessList.addAll(logSuccessMap.get(currentTime));
             logSuccessMap.remove(currentTime);
         }
         Map<String, List<Object>> logErrorMap = LogUtils.logErrorMapList;
-        List<String> errorList = logErrorMap.keySet().stream().filter(key -> Long.parseLong(key) < current ).toList();
+        List<String> errorList = logErrorMap.keySet().stream().filter(key -> Long.parseLong(key) < current).toList();
         List<Object> logErrorList = new ArrayList<>();
         for (String currentTime : errorList) {
             logErrorList.addAll(logErrorMap.get(currentTime));
             logErrorMap.remove(currentTime);
         }
         Map<String, List<Object>> logSourceMap = LogUtils.sourceMapList;
-        List<String> sourceList = logSourceMap.keySet().stream().filter(key -> Long.parseLong(key) < current ).toList();
+        List<String> sourceList = logSourceMap.keySet().stream().filter(key -> Long.parseLong(key) < current).toList();
         List<Object> logSourceList = new ArrayList<>();
         for (String currentTime : sourceList) {
             logSourceList.addAll(logSourceMap.get(currentTime));
@@ -322,13 +324,11 @@ public class MainFactoryApplication {
         if (Objects.nonNull(myDbHelper.getErrorMessage())) {
             System.out.println("获取远程数据库失败:写入日志失败");
         }
-
-
         try {
-            if (logSuccessList.size() > 0) myDbHelper.JDBCBatch(INSERT_SQL, logSuccessList,null);
-            if (logErrorList.size() > 0) myDbHelper.JDBCBatch(ERROR_SQL, logErrorList,null);
+            if (logSuccessList.size() > 0) myDbHelper.JDBCBatch(INSERT_SQL, logSuccessList, null);
+            if (logErrorList.size() > 0) myDbHelper.JDBCBatch(ERROR_SQL, logErrorList, null);
             if (logSourceList.size() > 0) {
-                myDbHelper.JDBCBatch(FULL_DATA_SQL, logSourceList,null);
+                myDbHelper.JDBCBatch(FULL_DATA_SQL, logSourceList, null);
             }
         } catch (Exception e) {
             System.out.println("日志记录异常" + LogUtils.getException(e));

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

@@ -136,7 +136,7 @@ public class DataProcess {//数据处理对象
     }
 
     /*权限检查*/
-    public Map<String, Object> authCheck(Map<String, Object> inputData, String... user_id) {
+    public Map<String, Object> authCheck(Map<String, Object> inputData, String ... user_id) {
         Object appid = inputData.get("appid");//获取应用编号
         if (Objects.nonNull(appid) && !serviceAuthMap.contains(appid.toString())) {//上传了应用编号但是不在当前服务授权的应用列表中则返回错误
             return processFail("服务未授权", null);

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

@@ -31,7 +31,7 @@ public class ImportExcelUtils {
                 Sheet sheet = workbook.getSheetAt(i); // 获取表格页码
                 if (sheet != null) {
                     int rowNum = sheet.getLastRowNum(); // 获取该页表共有多少行
-                    for (int j = 1; j < rowNum; j++) {  // 一般来说第一行是标题,所以第二行开始读取
+                    for (int j = 1; j < rowNum+1; j++) {  // 一般来说第一行是标题,所以第二行开始读取
                         Row row = sheet.getRow(j); // 获取表格行
                         int rowNum1 = row.getLastCellNum(); // 第一行
                         HashMap<String, Object> tempMap = new HashMap<>();

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

@@ -18,6 +18,15 @@ public class LogUtils { // 依据服务编号ID获取服务类型,如果是异
 
     public static void log(String location, String success, Object calculationLocation, String logContent, String serviceId, Object iNDataContent, String dataObjectId, Object OutDataContent, Object event) {
         String inData = MapTools.objToJSONStr(iNDataContent);
+        try {
+            Map<Object, Object> filterMap = Objects.nonNull(iNDataContent) && ((List) iNDataContent).size() == 2 ? (Map) (((List) iNDataContent).get(1)) : null;
+            if (Objects.nonNull(filterMap) && Objects.nonNull(filterMap.get("returnData")) && filterMap.get("returnData").toString().equals("[]")) {
+                return;
+            }
+        } catch (Exception e) {
+            System.out.println("过滤:读取空消息: 出现错误".concat(LogUtils.getException(e)).concat(" iNDataContent: ").concat(inData));
+            return;
+        }
         String shortData = MapTools.isNotBlank(inData) ? (inData.length() > 20480 ? inData.substring(0, 20480) : inData) : null;
         List<Object> logParam = new ArrayList<>() {{
             add(success);
@@ -32,13 +41,14 @@ public class LogUtils { // 依据服务编号ID获取服务类型,如果是异
             add(Objects.isNull(calculationLocation) ? null : calculationLocation.toString());
             add(dataObjectId);
         }};
+        // [{"dataContent":"1","dataObjectId":"168130842269100010042250","event":"1"},{"code":"0","returnData":[]}]
         long l = System.currentTimeMillis() / 1000;
         String key = l + "";
-        if ("0".equals(success)){
+        if (!"0".equals(success)) {
             List<Object> tempLogList = logErrorMapList.containsKey(key) ? logErrorMapList.get(key) : new ArrayList<>();
             tempLogList.add(logParam);
             logErrorMapList.put(key, tempLogList);
-        }else {
+        } else {
             List<Object> tempLogList = logSuccessMapList.containsKey(key) ? logSuccessMapList.get(key) : new ArrayList<>();
             tempLogList.add(logParam);
             logSuccessMapList.put(key, tempLogList);
@@ -63,8 +73,6 @@ public class LogUtils { // 依据服务编号ID获取服务类型,如果是异
     }
 
 
-
-
     /**
      * 获取当前行
      *

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

@@ -352,7 +352,7 @@ public class MyDbHelper {//目前只差主键的条件优化
     }
 
     //依据表名获取所有字段
-    private Map<String, Object> getMetaDataByTable(String tableName, boolean isActive) {
+    public Map<String, Object> getMetaDataByTable(String tableName, boolean isActive) {
         tableName = MapTools.isBlank(tableName) ? "(null)" : tableName;
         if (!(tableColumn.containsKey(tableName)) && !"(null)".equals(tableName)) {//对应表的字段未缓存(且表名不为空)则重新获取
             if (isActive && !tableList.contains(tableName)) {//处理动态表:动态表且未包含在当前库
@@ -562,6 +562,7 @@ public class MyDbHelper {//目前只差主键的条件优化
         Map<String, Object> returnMap = new HashMap<>();
         returnMap.put("dbValue", dbValue);
         returnMap.put("sqlStr", sqlStr);
+        returnMap.put("newSqlStr", sqlStr);
         returnMap.put("rowCountSQL", event.equals("0") ? "select count(1) from ".concat(tableName) : "");
         return returnMap;
     }