|
@@ -1,8 +1,11 @@
|
|
|
package com.winhc.utils;
|
|
|
|
|
|
+import cn.hutool.core.lang.Tuple;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.serializer.SerializerFeature;
|
|
|
+import com.google.common.collect.ImmutableMap;
|
|
|
import com.winhc.common.enums.CompanyEnum;
|
|
|
import com.winhc.db.mongodb.dataobject.NodeRelationError;
|
|
|
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
|
@@ -72,6 +75,21 @@ public class CompanyUtils {
|
|
|
return list.stream().filter(r -> (r.getOrDefault("topic_type", "-1").equals(type))).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+ public static List<String> getMergeIds(List<Map<String, Object>> list) {
|
|
|
+ return list.stream()
|
|
|
+ .filter(r -> r.getOrDefault("start_id", "0").toString().length() == 33)
|
|
|
+ .collect(Collectors.toMap(t -> t.getOrDefault("start_id", "0").toString(), t -> t, (n, o) -> n))
|
|
|
+ .values().stream().map(x -> {
|
|
|
+ Map<String, String> m = (Map) x;
|
|
|
+ ImmutableMap<String, String> m2 = ImmutableMap.of(
|
|
|
+ "person_id", m.get("start_id")
|
|
|
+ , "name", m.get("start_name")
|
|
|
+ , "topic_type", "800"
|
|
|
+ );
|
|
|
+ return JSONObject.toJSONString(m2, SerializerFeature.WriteMapNullValue);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
public static List<NodeRelationError> toMessage(List<ConsumerRecord> records, String errorMessage) {
|
|
|
return records.stream().filter(r -> (r != null && r.value() != null)).map(r -> {
|
|
|
String consumerMessage = r.value().toString();
|
|
@@ -124,7 +142,7 @@ public class CompanyUtils {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- System.out.println(getIncrPersonLabelV2("新增",10));
|
|
|
+ System.out.println(getIncrPersonLabelV2("新增", 10));
|
|
|
System.out.println(getIncrPersonLabelV2("新增"));
|
|
|
}
|
|
|
}
|