Parcourir la source

2.0 from 处理 不支持字段中包含from

pms il y a 1 an
Parent
commit
a04e1582a9

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

@@ -1,6 +1,8 @@
 package org.bfkj.protocol;
 
 import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
 import org.apache.kafka.clients.consumer.ConsumerRecord;
 import org.apache.kafka.clients.consumer.ConsumerRecords;
 import org.apache.kafka.clients.consumer.KafkaConsumer;
@@ -18,6 +20,12 @@ public class MyKafKa {
 
     private boolean isPool =false;
 
+    private static ObjectMapper mapper = new ObjectMapper();
+    static {
+        mapper.registerModule(new JavaTimeModule());
+        mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false); //关闭
+    }
+
     /**
      * 采集kafka数据
      *
@@ -75,11 +83,10 @@ public class MyKafKa {
         connectConfigMaps.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
 
         if (Objects.isNull(producer)) producer = new KafkaProducer<>(connectConfigMaps);
-        ObjectMapper objectMapper = new ObjectMapper();
         List<Object> sendResult = new ArrayList<>();
         for (Object o : dataContent) {
             try {
-                sendResult.add(producer.send(new ProducerRecord<>(sourceObjectName, objectMapper.writeValueAsString(o))));
+                sendResult.add(producer.send(new ProducerRecord<>(sourceObjectName, mapper.writeValueAsString(o))));
             } catch (Exception e) {
                 sendResult.add(producer.send(new ProducerRecord<>(sourceObjectName, o.toString())));
             }

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

@@ -477,7 +477,7 @@ public class DataFormat {
         }
         List<Map<String, Object>> batchList = new ArrayList<>();
         xmlList.forEach(xml -> {
-            Map<String, Object> stringObjectMap = customMadexmlToMap(xmlList.get(0), isTwoDimensionalization, noDiKaList, translateName);
+            Map<String, Object> stringObjectMap = customMadexmlToMap(xml, isTwoDimensionalization, noDiKaList, translateName);
             if ("-1".equals(stringObjectMap.get("code").toString())) {
                 stringObjectMap.put("returnData", new ArrayList<>());
             }

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

@@ -26,7 +26,7 @@ public class ImportExcelUtils {
             FileInputStream fileInputStream = new FileInputStream(file);
             Workbook workbook = getWorkbook(file.getName(), fileInputStream);
             List<Map<String, Object>> tempMapList = new ArrayList<>();
-            int number = workbook.getNumberOfSheets(); // 如果sheet为空则
+            int number = Math.min(workbook.getNumberOfSheets(),1); // 如果sheet为空则
             DataFormatter formatter = new DataFormatter();
             for (int i = 0; i < number; i++) {
                 Sheet sheet = workbook.getSheetAt(i); // 获取表格页码

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

@@ -39,6 +39,14 @@ public class MapTools implements Serializable {
         }
     }
 
+    public static void main(String[] args) {
+        HashMap<Object, Object> hashMap = new HashMap<>();
+        hashMap.put("da",new Date());
+        System.out.println(objToJSONStr(hashMap));
+    }
+
+
+
     /*字符串转对象*/
     public static Object strToObj(String inStr) {
         try {

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

@@ -683,7 +683,7 @@ public class MyDbHelper {//目前只差主键的条件优化
 
     //JDBC更新
     public Map<String, Object> JDBCBatch(String sqlStr, List<Object> dbValue, Object signParam) {
-        if (sqlStr.contains("?") && dbValue.size() == 0) {  //要求参数但是参数为空则返回
+        if ((sqlStr.startsWith("update") ||sqlStr.contains("?")) && (dbValue.size() == 0 || (dbValue.get(0) instanceof List<?> list && list.isEmpty()) )) {  //要求参数但是参数为空则返回
             return processSuccess(null);
         }
         Connection connection = null;