Browse Source

异常修复

pms 2 years ago
parent
commit
266ed64be5

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

@@ -341,18 +341,18 @@ public class DataProcess {
                         }
                     }
                     if (tempDBPrams instanceof Map tempMap) {//最终参数是Map则转换为List<Map<String, Object>>
-                        if (tempMap.isEmpty()) {
-                            calcData.add(new HashMap<>());
-                            returnData.put("calcData", calcData);
-                            return returnData;
-                        }
+//                        if (tempMap.isEmpty()) {
+//                            calcData.add(new HashMap<>());
+//                            returnData.put("calcData", calcData);
+//                            return returnData;
+//                        }
                         dbPrams.add(tempMap);
-                    } else if (tempDBPrams instanceof List tempList && tempList.get(0) instanceof Map<?,?> tempMap) {
-                        if (tempMap.isEmpty()) {
-                            calcData.add(new HashMap<>());
-                            returnData.put("calcData", calcData);
-                            return returnData;
-                        }
+                    } else if (tempDBPrams instanceof List tempList) {
+//                        if (tempMap.isEmpty()) {
+//                            calcData.add(new HashMap<>());
+//                            returnData.put("calcData", calcData);
+//                            return returnData;
+//                        }
                         dbPrams = tempList;
                     }
                 } catch (Exception e) {

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

@@ -21,7 +21,7 @@ public class MyKafKa {
      *
      * @return 读取内容信息
      */
-    public Map<String, Object> readMethod(String sourceObjectName, String library_id, String connectConfig, String  pollNumber) {
+    public Map<String, Object> readMethod(String sourceObjectName, String library_id, String connectConfig, String  pollNumber,String fetch) {
         if (Objects.isNull(sourceObjectName)) {
             return MapTools.processFail("队列为空");
         }
@@ -33,8 +33,9 @@ public class MyKafKa {
         connectConfigMaps.put("max.poll.records", pollNumber == null ? 1 : Integer.parseInt(pollNumber));
         connectConfigMaps.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
         connectConfigMaps.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
-        connectConfigMaps.put("max.partition.fetch.bytes", 11534336);
-
+        if (MapTools.isNotBlank(fetch)){
+            connectConfigMaps.put("max.partition.fetch.bytes", 11534336);
+        }
         if (Objects.isNull(consumer)) {
             consumer = new KafkaConsumer<>(connectConfigMaps);
             consumer.subscribe(Collections.singleton(sourceObjectName));

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

@@ -94,7 +94,7 @@ public class DataFormat {
 
     public static Map<String, Object> typeBToMap(String typeStr, String dataObjectId, Map<String, String> transMaps) {
         try {
-            if (Objects.isNull(typeStr)) {
+            if (MapTools.isBlank(typeStr)) {
                 return MapTools.processSuccess(null);
             }
             if (Objects.isNull(transMaps)) {
@@ -161,7 +161,7 @@ public class DataFormat {
                                 colValue = replaceWrap(colValue);
                                 //如果是日期则使用日期转换方法进行转换(08APR)(注意跨年处理)".F/"".I/"".O/"有日期,".D/"".J/"有日期和时间
                                 if (".F/.I/.O/.D/.J/".contains(rowType)) {
-                                    String patternValue = MapTools.patternKey(colValue, "[0-2]{1}[0-9]{1}(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)");
+                                    String patternValue = MapTools.patternKey(colValue, "[0-3]{1}[0-9]{1}(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)");
                                     if (!MapTools.isBlank(patternValue)) {
                                         colValue = TypeBDateChange(patternValue, null);
                                         signDataMap.put(rowType.equals(".D/") ? ".D/3" : (rowType.equals(".J/") ? ".J/4" : (rowType + "2")), colValue);//写入当前行MAP{"对应数据库字段名",值(不覆盖)}
@@ -383,6 +383,10 @@ public class DataFormat {
                 returnMap = translateMapName((List) returnData, translateName); // code message retrunData
             }
         }
+        for (Map<String, Object> tempMap : (List<Map<String, Object>>) returnMap.get("returnData")) {
+            tempMap.values().removeAll(Collections.singleton(null));
+            tempMap.values().removeAll(Collections.singleton(""));
+        }
         return returnMap;
     }
 
@@ -424,8 +428,7 @@ public class DataFormat {
             Document doc = DocumentHelper.parseText(xml);
             Element root = doc.getRootElement();
             Map<String, Object> returnMap = xmlToMap(root);
-            returnMap.values().removeAll(Collections.singleton(null));
-            returnMap.values().removeAll(Collections.singleton(""));
+
             return processSuccess(returnMap);
         } catch (Exception e) {
             return processFail("入参不是规则的xml :" + xml);

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

@@ -378,15 +378,15 @@ public class MapTools implements Serializable {
     public static String jacksonObjToStr(Object obj) { //"[1111]","[{"A":"B"}]"
         ObjectMapper mapper = new ObjectMapper();
         try {
-            if (null == obj) {
+            if (null ==  obj){
                 return "";
             }
-            if (obj instanceof String str) {
-                return str;
-            }
             mapper.registerModule(new JavaTimeModule());
-            mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); //关闭
-            return  mapper.writeValueAsString(obj);
+            if (!(obj instanceof String) && obj.toString().contains("{") && obj.toString().contains("}")||
+                    !(obj instanceof String) && obj.toString().contains("[") && obj.toString().contains("]")){
+                return mapper.writeValueAsString(obj);
+            }
+             return obj.toString();
         } catch (JsonProcessingException e) {
             return "日志数据转json字符串异常: " + e.getMessage() + ": " + obj.toString();
         }

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

@@ -217,8 +217,12 @@ public class MyDbHelper {
                 String whereStr = "";
                 List<Object> tempCheckValue = new ArrayList<>();
                 for (String key : tempFilterMap.keySet()) {
-                    whereStr = whereStr + " " + key + " = ? and ";
-                    tempCheckValue.add(tempFilterMap.get(key));
+                    if (Objects.isNull(tempFilterMap.get(key))){
+                        whereStr = whereStr + " " + key + " is null and ";
+                    }else {
+                        whereStr = whereStr + " " + key + " = ? and ";
+                        tempCheckValue.add(tempFilterMap.get(key));
+                    }
                 }
                 whereStr = whereStr.substring(0, whereStr.length() - 4);
                 String checkSQL = "select 1 from " + tableName + " where " + whereStr + " limit 1";