|
@@ -9,7 +9,10 @@ import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -24,17 +27,20 @@ public class TestSendKafka {
|
|
|
@Autowired
|
|
|
KafkaProduce kafkaProduce;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ MongoTemplate mongoTemplate;
|
|
|
+
|
|
|
@Test
|
|
|
public void sendKafka() {
|
|
|
String topic = "inc_judicial_case_monitor";
|
|
|
long start = System.currentTimeMillis();
|
|
|
HashMap<Object, Object> map = new HashMap<>();
|
|
|
HashMap<Object, Object> map1 = new HashMap<>();
|
|
|
- map.put("topic_type","1");
|
|
|
- map1.put("justice_case_id","221111486");
|
|
|
- map1.put("dimension_id","b97afac1bc2c9d6755413fa0069699e0");
|
|
|
- map1.put("dimension_type","7");
|
|
|
- map.put("data",map1);
|
|
|
+ map.put("topic_type", "1");
|
|
|
+ map1.put("justice_case_id", "221111486");
|
|
|
+ map1.put("dimension_id", "b97afac1bc2c9d6755413fa0069699e0");
|
|
|
+ map1.put("dimension_type", "7");
|
|
|
+ map.put("data", map1);
|
|
|
String msg = JSON.toJSONString(map);
|
|
|
System.out.println(msg);
|
|
|
//kafkaProduce.produce(topic, msg);
|
|
@@ -44,46 +50,46 @@ public class TestSendKafka {
|
|
|
@Test
|
|
|
public void sendMergePerson() {
|
|
|
String topic = "test3";
|
|
|
- Map<String,String> m = new HashMap<String,String>(){
|
|
|
+ Map<String, String> m = new HashMap<String, String>() {
|
|
|
{
|
|
|
- put("person_id","p2");
|
|
|
- put("name","钱胜前");
|
|
|
- put("topic_type","800");
|
|
|
+ put("person_id", "p2");
|
|
|
+ put("name", "钱胜前");
|
|
|
+ put("topic_type", "800");
|
|
|
}
|
|
|
};
|
|
|
- Map<String,String> m0 = new HashMap<String,String>(){
|
|
|
+ Map<String, String> m0 = new HashMap<String, String>() {
|
|
|
{
|
|
|
- put("person_id","p1");
|
|
|
- put("name","钱胜前");
|
|
|
- put("topic_type","800");
|
|
|
+ put("person_id", "p1");
|
|
|
+ put("name", "钱胜前");
|
|
|
+ put("topic_type", "800");
|
|
|
}
|
|
|
};
|
|
|
- Map<String,String> m1 = new HashMap<String,String>(){
|
|
|
+ Map<String, String> m1 = new HashMap<String, String>() {
|
|
|
{
|
|
|
- put("person_id","p1");
|
|
|
- put("name","钱胜前");
|
|
|
- put("topic_type","800");
|
|
|
+ put("person_id", "p1");
|
|
|
+ put("name", "钱胜前");
|
|
|
+ put("topic_type", "800");
|
|
|
}
|
|
|
};
|
|
|
- Map<String,String> m2 = new HashMap<String,String>(){
|
|
|
+ Map<String, String> m2 = new HashMap<String, String>() {
|
|
|
{
|
|
|
- put("person_id","p6");
|
|
|
- put("name","曾妍");
|
|
|
- put("topic_type","800");
|
|
|
+ put("person_id", "p6");
|
|
|
+ put("name", "曾妍");
|
|
|
+ put("topic_type", "800");
|
|
|
}
|
|
|
};
|
|
|
- Map<String,String> m3 = new HashMap<String,String>(){
|
|
|
+ Map<String, String> m3 = new HashMap<String, String>() {
|
|
|
{
|
|
|
- put("person_id","p4");
|
|
|
- put("name","曾妍");
|
|
|
- put("topic_type","800");
|
|
|
+ put("person_id", "p4");
|
|
|
+ put("name", "曾妍");
|
|
|
+ put("topic_type", "800");
|
|
|
}
|
|
|
};
|
|
|
- Map<String,String> m4 = new HashMap<String,String>(){
|
|
|
+ Map<String, String> m4 = new HashMap<String, String>() {
|
|
|
{
|
|
|
- put("person_id","p5");
|
|
|
- put("name","杨凡");
|
|
|
- put("topic_type","800");
|
|
|
+ put("person_id", "p5");
|
|
|
+ put("name", "杨凡");
|
|
|
+ put("topic_type", "800");
|
|
|
}
|
|
|
};
|
|
|
kafkaProduce.produce(topic, JSONObject.toJSONString(m));
|
|
@@ -109,4 +115,240 @@ public class TestSendKafka {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Test
|
|
|
+ public void sendMergeAllPerson() {
|
|
|
+ String topic = "test3";
|
|
|
+ Map<String, String> m = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c3");
|
|
|
+ put("first_human_name", "钱胜前");
|
|
|
+ put("second_company_id", "c1");
|
|
|
+ put("second_human_name", "钱胜前");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m0 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c3");
|
|
|
+ put("first_human_name", "钱胜前");
|
|
|
+ put("second_company_id", "c3");
|
|
|
+ put("second_human_name", "钱胜前");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m1 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c2");
|
|
|
+ put("first_human_name", "钱胜前");
|
|
|
+ put("second_company_id", "c1");
|
|
|
+ put("second_human_name", "钱胜前");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ Map<String, String> m2 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c1");
|
|
|
+ put("first_human_name", "曾妍");
|
|
|
+ put("second_company_id", "c2");
|
|
|
+ put("second_human_name", "曾妍");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m3 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c1");
|
|
|
+ put("first_human_name", "曾妍");
|
|
|
+ put("second_company_id", "c6");
|
|
|
+ put("second_human_name", "曾妍");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m4 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c2");
|
|
|
+ put("first_human_name", "杨凡");
|
|
|
+ put("second_company_id", "c1");
|
|
|
+ put("second_human_name", "杨凡");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Arrays.asList(m, m0, m1, m2, m3, m4).forEach(x -> {
|
|
|
+// kafkaProduce.produce(topic, JSONObject.toJSONString(x));
|
|
|
+ mongoTemplate.save(x, "pid_all_person_merge_v9");
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void sendMergeAllPerson2() {
|
|
|
+ String topic = "test3";
|
|
|
+ Map<String, String> m = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c6");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m0 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c7");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m1 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c8");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ Map<String, String> m2 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c9");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m3 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c10");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m4 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c6");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c4");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m5 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c4");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m6 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c5");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c1");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("topic_type", "900");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Arrays.asList(m, m0, m1, m2, m3, m4, m5, m6).forEach(x -> {
|
|
|
+ mongoTemplate.save(x, "pid_all_person_merge_v9");
|
|
|
+ //kafkaProduce.produce(topic, JSONObject.toJSONString(x));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void sendMergeAllPerson3() {
|
|
|
+ String topic = "test3";
|
|
|
+ Map<String, String> m = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c6");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("second_human_pid", "p10");
|
|
|
+ put("topic_type", "1000");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m0 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c7");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("second_human_pid", "p9");
|
|
|
+ put("topic_type", "1000");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m1 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c8");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("second_human_pid", "p11");
|
|
|
+ put("topic_type", "1000");
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ Map<String, String> m2 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c9");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("second_human_pid", "p12");
|
|
|
+ put("topic_type", "1000");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m3 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c10");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("second_human_pid", "p13");
|
|
|
+ put("topic_type", "1000");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m4 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c4");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("second_human_pid", "p8");
|
|
|
+ put("topic_type", "1000");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m5 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c4");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c10");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ put("second_human_pid", "p13");
|
|
|
+ put("topic_type", "1000");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Map<String, String> m6 = new HashMap<String, String>() {
|
|
|
+ {
|
|
|
+ put("first_company_id", "c9");
|
|
|
+ put("first_human_name", "周立磐");
|
|
|
+ put("second_company_id", "c1");
|
|
|
+ put("second_human_name", "周立磐");
|
|
|
+ //put("second_human_pid", "p10");
|
|
|
+ put("topic_type", "1000");
|
|
|
+ }
|
|
|
+ };
|
|
|
+ Arrays.asList(m, m0, m1, m2, m3, m4, m5, m6).forEach(x -> {
|
|
|
+ mongoTemplate.save(x, "pid_all_person_merge_v9");
|
|
|
+ //kafkaProduce.produce(topic, JSONObject.toJSONString(x));
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
}
|