Browse Source

代码提交

SGTY 5 tháng trước cách đây
mục cha
commit
f53090bb9f

+ 2 - 0
src/main/java/com/qizhen/healsphere/Application.java

@@ -9,12 +9,14 @@ import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfigurat
 import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafAutoConfiguration;
 import org.springframework.boot.context.properties.ConfigurationPropertiesScan;
 import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 @SpringBootApplication(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
         JmxAutoConfiguration.class, ThymeleafAutoConfiguration.class },scanBasePackages = "com.qizhen.healsphere")
 @ConfigurationPropertiesScan
 @MapperScan("com.qizhen.healsphere.repository.mapper")
 @EnableNeo4jRepositories
+@EnableSwagger2
 public class Application {
 
     public static void main(String[] args) {

+ 2 - 1
src/main/java/com/qizhen/healsphere/common/ai/BaidubceUtil.java

@@ -7,7 +7,8 @@ import java.util.*;
 
 public class BaidubceUtil {
     //private static String apiUrl = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/ernie-speed-pro-128k";
-    private static String apiUrl = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro";
+    //private static String apiUrl = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions_pro";
+    private static String apiUrl = "https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/completions";
     private static String apiKey = "JYVEqcv7o6IK7kgAw6fYkmZL";
  
     private static String apiSecret = "b15G2pqwVWIHDKHsAdN5yHouIzhe3J1H";

+ 9 - 8
src/main/java/com/qizhen/healsphere/common/ai/QizhenAssistant2.java

@@ -22,7 +22,7 @@ import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-public class QizhenAssistant2 {
+public class CRQizhenAssistant {
 
     public static String appId= "454b1634-91ad-4dde-9d2f-f9a3302fdcbe";
     //public static String appId= "894e7e0f-c7db-497c-a96f-a533f9230431";//调试
@@ -134,7 +134,7 @@ public class QizhenAssistant2 {
 
         String propertyStr = "";
 
-        propertyStr = "传播媒介\t的传播媒介有哪些媒介" +
+    /*    propertyStr = "传播媒介\t的传播媒介有哪些媒介" +
                 ",传播途径\t的传播途径有哪些传播途径" +
                 ",传染率\t的传染率或传染比例是多少" +
                 ",传染源\t的传染源有哪些传染源" +
@@ -153,7 +153,10 @@ public class QizhenAssistant2 {
                 ",是否具有传染性\t是否具有传染性(只需回答:“是”或“否”,不要其它任何信息)" +
                 ",相关人群\t的高相关人群有哪些人群" +
                 ",易感人群\t的易感人群有哪些人群" +
-                ",易患人群\t的易患人群有哪些人群";;
+                ",易患人群\t的易患人群有哪些人群";*/
+
+        propertyStr = "是否传染病\t是否为传染病(只需回答:“是”或“否”,不要其它任何信息)" +
+                ",是否具有传染性\t是否具有传染性(只需回答:“是”或“否”,不要其它任何信息)";
 
         saveExel(propertyStr, conversationId, accessToken,"传染");
     }
@@ -198,7 +201,7 @@ public class QizhenAssistant2 {
     private static List<Knowlege> getData(String conversationId, String accessToken,String property) {
         List<Knowlege> list = new ArrayList<>();
         try {
-            QizhenAssistant2 qizhenAssistant = new QizhenAssistant2();
+            CRQizhenAssistant qizhenAssistant = new CRQizhenAssistant();
             BaidubceUtil baidubceUtil = new BaidubceUtil();
 
             String diseaseStr = "霍乱" +
@@ -266,16 +269,14 @@ public class QizhenAssistant2 {
                     }
                     String quetionParty = split[1];
                     String relation = split[0];
-                    String question = "你是一个医生。请回答:" + disease + quetionParty + "?\n请按如下要求回答:\n" +
-                            "1、只根据知识库里的知识回答,不要发散!"+
-                            "\n2、知识库里没有找到相应的知识,则返回\"未找到相关知识\"!";
+                    String question = disease + quetionParty + "?";
                     Map<String, String> result = qizhenAssistant.getChatResponse(question, conversationId);
                     String answer = result.get("answer");
                     String references = result.get("references");
                     String defaultReferences = result.get("defaultReferences");
                     String chatResponse = "";
                     if (!("failed".equals(answer) || answer.contains(noAnswer))) {
-                        String format = "你是专门处理医学领域文本的关系抽取专家。你将在指定的文本中抽取其中“"+disease+"的"+relation+"。\n" +
+                        String format = "你是专门处理医学领域文本的关系抽取专家。你将在指定的文本中抽取其中“"+disease+"的"+relation+"。\n" +
                                 "\n" +
                                 "#要求\n" +
                                 "1、抽取的结果将以JSON数组的形式呈现。每个抽取的“"+relation+"”高度简洁、高度概括,不要要描述性的文字,文字尽量保持在12个字符以内!\n" +

+ 4 - 4
src/main/java/com/qizhen/healsphere/common/ai/QizhenAssistant.java

@@ -131,8 +131,8 @@ public class QizhenAssistant {
     public static void main(String[] args) {
         String conversationId = getConversationId();
         String accessToken = BaidubceUtil.getAccessToken();
-        String propertyStr = "并发症\t的并发症有哪些疾病" +
-                ",常见并发症\t的常见并发症有哪些疾病" +
+        String propertyStr = "并发症\t的并发症有哪些疾病"
+               /* ",常见并发症\t的常见并发症有哪些疾病" +
                 ",提示病情加重或进展的临床指标\t的诊疗过程或病程中出现哪些指标或情况,可能提示疾病进一步进展、加重或恶化。" +
                 ",早期预警指标\t的早期临床预警指标有哪些" +
                 ",病因\t的病因或常见病因有哪些病因或致病原因" +
@@ -176,7 +176,7 @@ public class QizhenAssistant {
                 ",常见症状\t的常见症状有哪些症状" +
                 ",典型症状\t的典型症状有哪些症状" +
                 ",前驱症状\t的前驱症状或先兆症状有哪些症状" +
-                ",主要症状\t的主要症状有哪些症状";
+                ",主要症状\t的主要症状有哪些症状"*/;
 
         saveExel(propertyStr, conversationId, accessToken,"前半生");
     }
@@ -347,7 +347,7 @@ public class QizhenAssistant {
                     String defaultReferences = result.get("defaultReferences");
                     String chatResponse = "";
                     if (!("failed".equals(answer) || answer.contains(noAnswer))) {
-                        String format = "你是专门处理医学领域文本的关系抽取专家。你将在指定的文本中抽取其中“"+disease+"的"+relation+"。\n" +
+                        String format = "你是专门处理医学领域文本的关系抽取专家。你将在指定的文本中抽取其中“"+disease+"的"+relation+"。\n" +
                                 "\n" +
                                 "#要求\n" +
                                 "1、抽取的结果将以JSON数组的形式呈现。每个抽取的“"+relation+"”高度简洁、高度概括,不要要描述性的文字,文字尽量保持在12个字符以内!\n" +

+ 1 - 1
src/main/java/com/qizhen/healsphere/common/ai/QizhenAssistant1.java

@@ -345,7 +345,7 @@ public class QizhenAssistant1 {
                     String defaultReferences = result.get("defaultReferences");
                     String chatResponse = "";
                     if (!("failed".equals(answer) || answer.contains(noAnswer))) {
-                        String format = "你是专门处理医学领域文本的关系抽取专家。你将在指定的文本中抽取其中“"+disease+"的"+relation+"。\n" +
+                        String format = "你是专门处理医学领域文本的关系抽取专家。你将在指定的文本中抽取其中“"+disease+"的"+relation+"。\n" +
                                 "\n" +
                                 "#要求\n" +
                                 "1、抽取的结果将以JSON数组的形式呈现。每个抽取的“"+relation+"”高度简洁、高度概括,不要要描述性的文字,文字尽量保持在12个字符以内!\n" +

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 487 - 0
src/main/java/com/qizhen/healsphere/common/ai/SFCRQizhenAssistant.java


+ 76 - 0
src/main/java/com/qizhen/healsphere/config/SwaggerConfigurer.java

@@ -1,2 +1,78 @@
+package com.qizhen.healsphere.config;
 
 
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import springfox.documentation.builders.ApiInfoBuilder;
+import springfox.documentation.builders.ParameterBuilder;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.schema.ModelRef;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.service.Contact;
+import springfox.documentation.service.Parameter;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
+import springfox.documentation.swagger2.annotations.EnableSwagger2;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * @Description: Swagger配置类
+ * @author: gaodm
+ * @time: 2018/8/2 14:21
+ */
+@Configuration
+@EnableSwagger2
+public class SwaggerConfigurer {
+
+    @Bean
+    public Docket api() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .select()
+                .apis(RequestHandlerSelectors.any())
+                .paths(PathSelectors.any())
+                .build();
+    }
+   /* *//**
+     * 全局参数
+     *
+     * @return
+     *//*
+    private List<Parameter> parameter() {
+        List<Parameter> params = new ArrayList<>();
+        params.add(new ParameterBuilder().name("Authorization")
+                .description("Authorization Bearer token")
+                .modelRef(new ModelRef("string"))
+                .parameterType("header")
+                .required(false).build());
+        return params;
+    }
+
+
+    @Bean
+    public Docket sysApi() {
+        return new Docket(DocumentationType.SWAGGER_2)
+                .apiInfo(apiInfo())
+                .select()
+                .apis(RequestHandlerSelectors.basePackage("com.qizhen.healsphere.web"))
+                .paths(PathSelectors.any())
+                .build().globalOperationParameters(parameter());
+        //.securitySchemes(newArrayList(oauth()))
+        // .securityContexts(newArrayList(securityContext()));
+    }
+
+    private ApiInfo apiInfo() {
+        return new ApiInfoBuilder()
+                .title("知识图谱api ")
+                .description("知识图谱服务")
+                .termsOfServiceUrl("")
+                .contact(new Contact("healsphere","",""))
+                .version("1.0")
+                .build();
+    }*/
+
+}

+ 24 - 0
src/main/java/com/qizhen/healsphere/config/WebMvcConfigurer.java

@@ -0,0 +1,24 @@
+package com.qizhen.healsphere.config;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+
+@Configuration
+public class WebMvcConfigurer extends WebMvcConfigurationSupport {
+
+    /**
+     * 发现如果继承了WebMvcConfigurationSupport,则在yml中配置的相关内容会失效。 需要重新指定静态资源
+     */
+    @Override
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
+        registry.addResourceHandler("/**").addResourceLocations(
+                "classpath:/static/");
+        registry.addResourceHandler("swagger-ui.html", "doc.html").addResourceLocations(
+                "classpath:/META-INF/resources/");
+        registry.addResourceHandler("/webjars/**").addResourceLocations(
+                "classpath:/META-INF/resources/webjars/");
+        super.addResourceHandlers(registry);
+    }
+
+}

+ 0 - 9
src/main/resources/application.yml

@@ -1,12 +1,3 @@
-server:
-  port: 8080
-  max-http-header-size: 10MB
-
-
-swagger:
-  enable: true
-
-
 spring:
   datasource:
 #    dynamic:

+ 63 - 0
src/main/resources/application-test.yml

@@ -0,0 +1,63 @@
+spring:
+  datasource:
+#    dynamic:
+#      primary: neo4j
+#      # 数据库配置
+#      datasource:
+#        neo4j:
+#          driver-class-name: org.neo4j.jdbc.Driver
+#          url: jdbc:neo4j:http://173.18.12.194:7474
+#          username: neo4j
+#          password: 12345678
+#        mysql:
+#          driver-class-name: com.mysql.cj.jdbc.Driver
+#          url: jdbc:mysql://173.18.12.194:3306/sys-ltkg?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
+#          username: root
+#          password: dsYun8!@#
+    driver-class-name: com.mysql.jdbc.Driver
+    url: jdbc:mysql://173.18.12.194:3306/sys-ltkg?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useSSL=false
+    username: root
+    password: dsYun8!@#
+  neo4j:
+    uri: bolt://173.18.12.206:7687
+    authentication:
+      username: neo4j
+      password: 12345678
+
+#mybatis
+mybatis:
+  type-aliases-package: com.qizhen.healsphere.repository.mapper.entity
+  mapper-locations: classpath:mapper/*.xml
+
+#mybatis-plus
+mybatis-plus:
+  mapper-locations: classpath:/mapper/*Mapper.xml
+  #实体扫描,多个package用逗号或者分号分隔
+  typeAliasesPackage: com.qizhen.healsphererepository.mapper.entity
+  global-config:
+    #刷新mapper 调试神器
+    db-config:
+      #主键类型  0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID";
+      id-type: id_worker
+      #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断"
+      field-strategy: not_empty
+      #驼峰下划线转换
+      column-underline: true
+      #数据库大写下划线转换
+      #capital-mode: true
+      #刷新mapper 调试神器
+      refresh-mapper: true
+      #逻辑删除配置
+      logic-delete-value: 0
+      logic-not-delete-value: 1
+      #自定义填充策略接口实现
+      #meta-object-handler: com.baomidou.springboot.xxx
+      #自定义SQL注入器
+      #sql-injector: com.baomidou.springboot.xxx
+  configuration:
+    map-underscore-to-camel-case: true
+    cache-enabled: false
+
+springfox:
+  documentation:
+    enabled: true

+ 16 - 0
src/main/resources/bootstrap.yml

@@ -0,0 +1,16 @@
+spring:
+  profiles:
+    active: local
+  application:
+    name: healsphere
+#  mvc:
+#    pathmatch:
+#      matching-strategy: ant_path_matcher
+#  jackson:
+#    default-property-inclusion: non_null
+#    deserialization:
+#      ACCEPT_FLOAT_AS_INT: false
+server:
+  port: 8080
+  max-http-header-size: 10MB
+