Bladeren bron

fix: dynamic update

许家凯 3 jaren geleden
bovenliggende
commit
e8f5247e59
1 gewijzigde bestanden met toevoegingen van 6 en 3 verwijderingen
  1. 6 3
      src/main/java/com/winhc/bigdata/task/jobs/DynamicPersonIdUpdateJob.java

+ 6 - 3
src/main/java/com/winhc/bigdata/task/jobs/DynamicPersonIdUpdateJob.java

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.mongodb.client.MongoCollection;
 import com.winhc.bigdata.task.service.DingTalkService;
+import com.winhc.bigdata.task.util.DateUtils;
 import com.winhc.bigdata.task.util.ElasticsearchQueryUtil;
 import com.winhc.bigdata.task.util.ThrowableUtils;
 import lombok.Data;
@@ -233,6 +234,7 @@ public class DynamicPersonIdUpdateJob {
         document.put("keyno", keyno);
         document.put("validId", validId);
         document.put("content", data);
+        document.put("update_time", new Date());
         try {
             coll.insertOne(document);
         } catch (Exception e) {
@@ -269,7 +271,7 @@ public class DynamicPersonIdUpdateJob {
                     return true;
                 }
             }).collect(Collectors.toList());
-            Date date = new Date();
+            String date = DateUtils.getMinusDay(0);
             if (collect.isEmpty()) {
                 Map<String, Object> map = new HashMap<>();
                 map.put("deleted", "9");
@@ -279,10 +281,11 @@ public class DynamicPersonIdUpdateJob {
                 processor.updateData(index, "dynamic", map, clientOptions);
             } else {
                 jsonObject.put("content", collect);
-                jsonObject.put("update_time",date);
+                jData.put("update_time",date);
+                jData.put("dynamic_info", jsonObject.toJSONString());
                 ClientOptions clientOptions = new ClientOptions();
                 clientOptions.setId(id);
-                processor.insertData(index, "dynamic", jsonObject, clientOptions);
+                processor.insertData(index, "dynamic", jData, clientOptions);
             }
         } catch (Exception e) {
             log.error("parse json error", e);