tanlie 4 settimane fa
parent
commit
063c2fc006

+ 1 - 0
.gitignore

@@ -20,3 +20,4 @@ wishing-platform/platform-core/.idea/
 wishing-platform/platform-entity/.idea/
 wishing-platform/platform-gateway/.idea/
 wishing-platform/platform-service/.idea/
+wishing-platform/platform-base/.idea/

+ 8 - 0
wishing-platform/platform-base/pom.xml

@@ -18,6 +18,7 @@
         <hutool-all-version>5.8.32</hutool-all-version>
         <mysql-connector-version>8.0.33</mysql-connector-version>
         <alibaba.ttl.version>2.14.2</alibaba.ttl.version>
+        <spring-ai.version>1.1.7</spring-ai.version>
     </properties>
     <dependencyManagement>
         <dependencies>
@@ -92,6 +93,13 @@
                 <artifactId>transmittable-thread-local</artifactId>
                 <version>${alibaba.ttl.version}</version>
             </dependency>
+            <dependency>
+                <groupId>org.springframework.ai</groupId>
+                <artifactId>spring-ai-bom</artifactId>
+                <version>${spring-ai.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
         </dependencies>
     </dependencyManagement>
 </project>

+ 2 - 0
wishing-platform/platform-entity/platform-entity-wishing/src/main/java/cn/qinys/platform/entity/wishing/WishingTree.java

@@ -25,6 +25,8 @@ public class WishingTree extends BaseEntity  {
 
     private String description;
 
+    private String summary;
+
     private BigDecimal longitude;
 
     private BigDecimal latitude;

BIN
wishing-platform/platform-entity/platform-entity-wishing/target/classes/cn/qinys/platform/entity/wishing/WishingTree.class


BIN
wishing-platform/platform-entity/platform-entity-wishing/target/platform-entity-wishing-1.0.0-SNAPSHOT.jar


+ 4 - 0
wishing-platform/platform-service/platform-service-admin/pom.xml

@@ -61,6 +61,10 @@
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-loadbalancer</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.springframework.ai</groupId>
+            <artifactId>spring-ai-starter-model-deepseek</artifactId>
+        </dependency>
     </dependencies>
     <build>
         <finalName>wishing-admin</finalName>

+ 18 - 0
wishing-platform/platform-service/platform-service-admin/src/main/java/cn/qinys/platform/admin/service/impl/WishTreeServiceImpl.java

@@ -13,6 +13,7 @@ import cn.qinys.platform.openfeign.UpmsFeignClient;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import jakarta.annotation.Resource;
+import org.springframework.ai.chat.client.ChatClient;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -29,6 +30,9 @@ public class WishTreeServiceImpl implements WishTreeService {
 
     @Resource
     UpmsFeignClient upmsFeignClient;
+    @Resource
+    ChatClient chatClient;
+
 
     @Override
     public Long createWishTree(WishingTreeCreateReq req) {
@@ -38,6 +42,11 @@ public class WishTreeServiceImpl implements WishTreeService {
             Result<String> address = upmsFeignClient.getAddressByAltitudeAndLongitude(new GeoAddressReq(req.getLongitude(), req.getLatitude()));
             tree.setAddress(address.getData());
         }
+        String summary = this.getDescription(tree.getAddress());
+        tree.setSummary(summary);
+        if (!StringUtils.hasText(tree.getDescription())) {
+            tree.setDescription(summary);
+        }
         wishingTreeMapper.insert(tree);
         return tree.getId();
     }
@@ -51,4 +60,13 @@ public class WishTreeServiceImpl implements WishTreeService {
                 .orderByDesc("id");
         return wishingTreeMapper.selectTreePage(page, wrapper);
     }
+
+    private String getDescription(String address) {
+        if (!StringUtils.hasText(address)) {
+            return null;
+        }
+        return chatClient.prompt().user(address).call().content();
+    }
+
+
 }

+ 33 - 0
wishing-platform/platform-service/platform-service-admin/src/main/java/cn/qinys/platform/config/ChatClientConfig.java

@@ -0,0 +1,33 @@
+package cn.qinys.platform.config;
+
+import org.springframework.ai.chat.client.ChatClient;
+import org.springframework.ai.chat.model.ChatModel;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * @author lie tan
+ * @description
+ * @date 2026-05-30 13:29
+ **/
+@Configuration
+public class ChatClientConfig {
+
+
+    @Bean
+    ChatClient chatClient(ChatModel chatModel) {
+
+        return ChatClient.builder(chatModel)
+                .defaultSystem("""
+                        你是一个人文地理知识库助手,用户给你一个地址,你根据地址信息给出200 - 300字左右的描述。
+                        如果地址是一座城市,给出城市的描述信息如历史,人文景观等;
+                        如果是一个小区,简单介绍小区的信息,如开发商,小区建成时间,小区周边等;
+                        如果是一个公司,介绍公司的情况,如果是一个旅游景点,也请给出一些描述信息
+                        以此类推
+                        
+                        """)
+                .build();
+
+    }
+
+}

+ 2 - 0
wishing-platform/platform-service/platform-service-admin/src/main/java/cn/qinys/platform/config/MyBatisPlusConfig.java

@@ -3,6 +3,7 @@ package cn.qinys.platform.config;
 
 import com.baomidou.mybatisplus.annotation.DbType;
 import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
 import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -26,6 +27,7 @@ public class MyBatisPlusConfig {
     public MybatisPlusInterceptor mybatisPlusInterceptor() {
         MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
         interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL)); // 如果配置多个插件, 切记分页最后添加
+        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
         // 如果有多数据源可以不配具体类型, 否则都建议配上具体的 DbType
         return interceptor;
     }

+ 7 - 0
wishing-platform/platform-service/platform-service-admin/src/main/resources/application.yml

@@ -7,6 +7,13 @@ spring:
     time-zone: GMT+8
   application:
     name: wishing-admin
+  ai:
+    deepseek:
+      api-key: sk-7de46bc6a5c845fcb5ec060e5e3f1441
+      chat:
+        options:
+          model: deepseek-chat
+          temperature: 0.7
   profiles:
     active: local
   servlet:

+ 62 - 0
wishing-platform/platform-service/platform-service-admin/src/test/java/cn/qinys/platform/config/ChatClientConfigTest.java

@@ -0,0 +1,62 @@
+package cn.qinys.platform.config;
+
+import cn.qinys.platform.admin.mapper.WishingTreeMapper;
+import cn.qinys.platform.entity.wishing.WishingTree;
+import jakarta.annotation.Resource;
+import org.junit.jupiter.api.Test;
+import org.springframework.ai.chat.client.ChatClient;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+/**
+ * @author lie tan
+ * @description
+ * @date 2026-05-30 13:39
+ **/
+@SpringBootTest
+class ChatClientConfigTest {
+
+    @Resource
+    ChatClient chatClient;
+    @Resource
+    WishingTreeMapper treeMapper;
+
+    @Test
+    void chatModelTest() {
+
+        String resp = chatClient.prompt()
+                .user("天津市滨海新区泰达街道渣打环球商业服务有限公司(西南门)渣打科营中心")
+                .call().content();
+        System.out.println(resp);
+
+    }
+
+    /***
+     * 渣打环球商业服务有限公司(西南门)渣打科营中心位于天津市滨海新区泰达街道,是渣打银行在华设立的重要战略运营中心之一。泰达街道地处天津经济技术开发区(TEDA)核心区域,这一地区自1984年设立以来,一直是中国北方最具活力的开放型经济高地之一,聚集了大量跨国企业和高端服务业。
+     *
+     * 渣打科营中心作为渣打银行全球运营网络的重要组成部分,主要承担后台支持、数据处理、金融科技研发及客户服务等职能,体现了滨海新区在金融创新和数字化转型方面的优势。中心周边配套设施完善,临近泰达MSD、泰达足球场等商务与生活地标,交通便利,紧邻京津塘高速与滨海新区核心交通枢纽。
+     *
+     * 该区域历史底蕴与现代气息交融,附近有塘沽炮台遗址等历史遗迹,同时亦毗邻滨海文化中心、海河外滩公园等现代人文景观,展现出天津作为沿海开放城市的多元魅力。对于在此工作的金融从业者而言,这里既是高效商务办公的场所,也是感受滨海新区国际化发展脉搏的窗口。s
+     */
+    @Test
+    void updateDescription() {
+        List<WishingTree> wishingTrees = treeMapper.selectList(null);
+        wishingTrees.forEach(tree -> {
+            String summary = this.getDescription(tree.getAddress());
+            tree.setSummary(summary);
+            tree.setDescription(summary);
+            treeMapper.updateById(tree);
+            System.out.println(summary);
+        });
+    }
+
+    private String getDescription(String address) {
+        return chatClient.prompt()
+                .user(address)
+                .call().content();
+    }
+
+}