diff --git a/projects/fangjia-bkoff/pom.xml b/projects/fangjia-bkoff/pom.xml
index 69e2d3b60..6c40448a0 100644
--- a/projects/fangjia-bkoff/pom.xml
+++ b/projects/fangjia-bkoff/pom.xml
@@ -183,6 +183,17 @@
easyexcel
4.0.1
+
+ org.springframework.kafka
+ spring-kafka
+ 2.8.9
+
+
+ org.projectlombok
+ lombok
+ 1.18.28
+ provided
+
diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DistrictController.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DistrictController.java
index e58c94365..bc33eddc6 100644
--- a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DistrictController.java
+++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/controllers/DistrictController.java
@@ -5,6 +5,7 @@ import com.fangjia.bkoff.model.DistrictModel;
import com.fangjia.bkoff.model.JsonModel;
import com.fangjia.bkoff.util.AddressParser;
import com.fangjia.bkoff.util.GeocodeUtils;
+import com.fangjia.bkoff.util.KafkaUtils;
import com.fangjia.core.Constants;
import com.fangjia.core.RegionData;
import com.fangjia.core.util.*;
@@ -89,6 +90,9 @@ public class DistrictController {
private DealPriceService dealPriceService;
private AverageStatisticsService averageStatisticsService;
+ private KafkaUtils kafkaUtils;
+
+
private static List distTypes = Arrays.asList("¶à²ã", "С¸ß²ã", "³¬¸ß²ã", "¸ß²ã", "»¨Ô°Ñó·¿", "ÀÏÑó·¿", "ËĺÏÔº");
private static List villaTypes = Arrays.asList("¶À¶°", "˫ƴ", "ÁªÅÅ", "µþ¼Ó");
private static List shopTypes = Arrays.asList("¶à²ã", "С¸ß²ã", "³¬¸ß²ã", "¸ß²ã", "¶À¶°", "˫ƴ", "ÁªÅÅ", "µþ¼Ó");
@@ -2284,7 +2288,14 @@ public class DistrictController {
data.put("markMap", markMap);
data.put("modificationDate", new Date());
districtService.updateById(data, district.getId());
-
+ JSONObject massage = new JSONObject();
+ massage.put("city",district.getCity());
+ massage.put("region",district.getRegion());
+ massage.put("name",district.getName());
+ massage.put("estateType2",district.getEstateType2());
+ massage.put("id",district.getId());
+ massage.put("type",2);
+ kafkaUtils.sendMessage("seaweed-data-topic", massage.toString());
//´´½¨¸üÐÂÈÎÎñ£¬ÓÃΪ¸üг£ÖÝÅ©ÉÌÐÐÊý¾Ý
createJnTask(district.getId(), null);
msg = "±£´æ³É¹¦ÁË£¡£¡£¡";
@@ -4212,4 +4223,7 @@ public class DistrictController {
this.averageStatisticsService = averageStatisticsService;
}
+ public void setKafkaUtils(KafkaUtils kafkaUtils) {
+ this.kafkaUtils = kafkaUtils;
+ }
}
diff --git a/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/util/KafkaUtils.java b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/util/KafkaUtils.java
new file mode 100644
index 000000000..31a48baa3
--- /dev/null
+++ b/projects/fangjia-bkoff/src/main/java/com/fangjia/bkoff/util/KafkaUtils.java
@@ -0,0 +1,67 @@
+package com.fangjia.bkoff.util;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.kafka.core.KafkaTemplate;
+import org.springframework.kafka.support.SendResult;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+
+/**
+ * ͨÓà Kafka ¹¤¾ßÀà
+ * ÌṩÒì²½·¢ËÍ Kafka ÏûÏ¢µÄ¹¦ÄÜ
+ *
+ * @author shenjian
+ * @since 2024/06/21
+ */
+@Slf4j
+@Component // ½«Æä±êעΪ Spring ¹ÜÀíµÄ×é¼þ
+public class KafkaUtils {
+
+ private final KafkaTemplate kafkaTemplate;
+ private final ExecutorService executorService; // ÓÃÓÚÒì²½Ö´ÐÐ
+
+ /**
+ * ¹¹Ôì·½·¨
+ * Spring »á×Ô¶¯×¢Èë KafkaTemplate
+ *
+ * @param kafkaTemplate KafkaTemplate ÓÃÓÚ·¢ËÍÏûÏ¢
+ */
+ public KafkaUtils(KafkaTemplate kafkaTemplate) {
+ this.kafkaTemplate = kafkaTemplate;
+ // ³õʼ»¯Ò»¸öÏ̳߳أ¬Ê¹Óà 10 ¸öÏß³Ì
+ this.executorService = Executors.newFixedThreadPool(10);
+ }
+
+ /**
+ * Òì²½·¢ËÍÏûÏ¢µ½Ö¸¶¨µÄ Kafka Ö÷Ìâ
+ *
+ * @param topic Kafka Ö÷Ìâ
+ * @param data ÏûÏ¢ÄÚÈÝ
+ */
+ public void sendMessage(final String topic, final String data) {
+ executorService.submit(new Callable() {
+ @Override
+ public Void call() throws Exception {
+ try {
+ SendResult sendResult = kafkaTemplate.send(topic, data).get(); // ×èÈûÖ±µ½·¢ËÍÍê³É
+ log.info("Message sent successfully: {}", sendResult);
+ } catch (Exception ex) {
+ log.error("Kafka send message error = {}, topic = {}", ex.getMessage(), topic);
+ log.error("Data: {}", data);
+ }
+ return null;
+ }
+ });
+ }
+
+ /**
+ * ¹Ø±ÕÏ̳߳Ø
+ * ÔÚ³ÌÐò½áÊøÊ±ÐèÒªµ÷Óø÷½·¨ÒÔÊÍ·Å×ÊÔ´
+ */
+ public void shutdown() {
+ executorService.shutdown();
+ }
+}
diff --git a/projects/fangjia-bkoff/src/main/resources/fangjia-bkoff.properties b/projects/fangjia-bkoff/src/main/resources/fangjia-bkoff.properties
index 10f97fc98..bcc1ddcf9 100644
--- a/projects/fangjia-bkoff/src/main/resources/fangjia-bkoff.properties
+++ b/projects/fangjia-bkoff/src/main/resources/fangjia-bkoff.properties
@@ -78,3 +78,29 @@ merchantno=10000469946
appKey=SQKK10000469946
#\u7EDF\u4E00\u9274\u6743\u7ED1\u5361\u8BF7\u6C42
authbindcardreqUri=/rest/v1.0/paperorder/unified/pay
+
+# Kafka bootstrap servers
+kafka.bootstrap-servers=192.168.0.89:19092,192.168.0.90:19092,192.168.0.91:19092
+
+# Producer configuration
+kafka.producer.retries=0
+kafka.producer.batch-size=16384
+kafka.producer.buffer-memory=254288
+kafka.producer.key-serializer=org.apache.kafka.common.serialization.StringSerializer
+kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
+kafka.producer.auto-topic-creation.auto-create=true
+kafka.producer.properties.linger.ms=1
+kafka.producer.properties.session.timeout.ms=15000
+kafka.producer.properties.sasl.mechanism=PLAIN
+kafka.producer.properties.security.protocol=SASL_PLAINTEXT
+kafka.producer.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="Goojia123456";
+
+# Consumer configuration
+kafka.consumer.key-deserializer=org.apache.kafka.common.serialization.StringDeserializer
+kafka.consumer.value-deserializer=org.apache.kafka.common.serialization.StringDeserializer
+kafka.consumer.group-id=log-data-group
+kafka.consumer.auto-offset-reset=earliest
+kafka.consumer.properties.session.timeout.ms=15000
+kafka.consumer.properties.sasl.mechanism=PLAIN
+kafka.consumer.properties.security.protocol=SASL_PLAINTEXT
+kafka.consumer.properties.sasl.jaas.config=org.apache.kafka.common.security.plain.PlainLoginModule required username="admin" password="Goojia123456";