From e5b92b5759296b3f2ce1a59578cbd752d607259d Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 22 Jan 2024 16:00:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=BE=AE=E6=9C=8D=E5=8A=A1=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 26 ++++++ virtual-patient-manage/pom.xml | 25 ++++++ .../VirtualPatientManageApplication.java | 2 + .../src/main/resources/application-dev.yml | 63 ------------- .../src/main/resources/application-test.yml | 63 ------------- .../src/main/resources/application.yml | 49 +++++++++- .../src/main/resources/bootstrap-dev.yml | 10 +++ .../src/main/resources/bootstrap-test.yml | 10 +++ .../src/main/resources/bootstrap.yml | 5 ++ virtual-patient-rasa/pom.xml | 24 +++++ .../rasa/VirtualPatientRasaApplication.java | 2 + .../src/main/resources/application-dev.yml | 66 -------------- .../src/main/resources/application-test.yml | 66 -------------- .../src/main/resources/application.yml | 47 +++++++++- .../src/main/resources/bootstrap-dev.yml | 10 +++ .../src/main/resources/bootstrap-test.yml | 10 +++ .../src/main/resources/bootstrap.yml | 5 ++ virtual-patient-web/pom.xml | 26 ++++++ .../VirtualPatientApplication.java | 3 +- .../src/main/resources/application-dev.yml | 85 ------------------ .../src/main/resources/application-local.yml | 85 ------------------ .../src/main/resources/application-test.yml | 89 ------------------- .../src/main/resources/application.yml | 47 +++++++++- .../src/main/resources/bootstrap-dev.yml | 10 +++ .../src/main/resources/bootstrap-test.yml | 10 +++ .../src/main/resources/bootstrap.yml | 5 ++ 26 files changed, 319 insertions(+), 524 deletions(-) delete mode 100644 virtual-patient-manage/src/main/resources/application-dev.yml delete mode 100644 virtual-patient-manage/src/main/resources/application-test.yml create mode 100644 virtual-patient-manage/src/main/resources/bootstrap-dev.yml create mode 100644 virtual-patient-manage/src/main/resources/bootstrap-test.yml create mode 100644 virtual-patient-manage/src/main/resources/bootstrap.yml delete mode 100644 virtual-patient-rasa/src/main/resources/application-dev.yml delete mode 100644 virtual-patient-rasa/src/main/resources/application-test.yml create mode 100644 virtual-patient-rasa/src/main/resources/bootstrap-dev.yml create mode 100644 virtual-patient-rasa/src/main/resources/bootstrap-test.yml create mode 100644 virtual-patient-rasa/src/main/resources/bootstrap.yml delete mode 100644 virtual-patient-web/src/main/resources/application-dev.yml delete mode 100644 virtual-patient-web/src/main/resources/application-local.yml delete mode 100644 virtual-patient-web/src/main/resources/application-test.yml create mode 100644 virtual-patient-web/src/main/resources/bootstrap-dev.yml create mode 100644 virtual-patient-web/src/main/resources/bootstrap-test.yml create mode 100644 virtual-patient-web/src/main/resources/bootstrap.yml diff --git a/pom.xml b/pom.xml index a5e2bc5f..fef3b9f0 100644 --- a/pom.xml +++ b/pom.xml @@ -31,6 +31,10 @@ 1.8 1.8 + + 2.2.5.RELEASE + Hoxton.SR6 + 1.4.1 2.3.5.RELEASE 1.2.76 3.3.1 @@ -52,6 +56,28 @@ + + com.alibaba.cloud + spring-cloud-alibaba-dependencies + ${alibaba.cloud.version} + pom + import + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring.cloud.version} + pom + import + + + + com.alibaba.nacos + nacos-common + ${nacos.common.version} + mysql diff --git a/virtual-patient-manage/pom.xml b/virtual-patient-manage/pom.xml index 46fecf9f..eb948320 100644 --- a/virtual-patient-manage/pom.xml +++ b/virtual-patient-manage/pom.xml @@ -14,6 +14,31 @@ + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba + fastjson + + + com.alibaba.nacos + nacos-common + + + + + com.alibaba.nacos + nacos-common + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + com.supervision virtual-patient-model diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/VirtualPatientManageApplication.java b/virtual-patient-manage/src/main/java/com/supervision/manage/VirtualPatientManageApplication.java index f4fa85e6..b9160a39 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/VirtualPatientManageApplication.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/VirtualPatientManageApplication.java @@ -3,12 +3,14 @@ package com.supervision.manage; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScans; @SpringBootApplication @MapperScan(basePackages = {"com.supervision.**.mapper"}) @ComponentScan(basePackages = {"com.supervision.**"}) +@EnableDiscoveryClient public class VirtualPatientManageApplication { public static void main(String[] args) { diff --git a/virtual-patient-manage/src/main/resources/application-dev.yml b/virtual-patient-manage/src/main/resources/application-dev.yml deleted file mode 100644 index 09e18f51..00000000 --- a/virtual-patient-manage/src/main/resources/application-dev.yml +++ /dev/null @@ -1,63 +0,0 @@ -#服务器端口 -server: - port: 8891 - servlet: - context-path: /virtual-patient-manage - undertow: - # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 - max-http-post-size: -1 - # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 - # 每块buffer的空间大小,越小的空间被利用越充分 - buffer-size: 512 - # 是否分配的直接内存 - direct-buffers: true - -spring: - application: - name: virtual-patient-manage - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - ##数据源配置 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - druid: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.10.137:3306/virtual_patient?useUnicode=true&characterEncoding=utf-8&useSSL=true&nullCatalogMeansCurrent=true&serverTimezone=GMT%2B8 - username: root - password: '123456' - initial-size: 5 # 初始化大小 - min-idle: 10 # 最小连接数 - max-active: 20 # 最大连接数 - max-wait: 60000 # 获取连接时的最大等待时间 - min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 - time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 - filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 - validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 - test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 - test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 - test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 - stat-view-servlet: - enabled: false # 是否开启 StatViewServlet - filter: - stat: - enabled: true # 是否开启 FilterStat,默认true - log-slow-sql: true # 是否开启 慢SQL 记录,默认false - slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 - merge-sql: false # 合并多个连接池的监控数据,默认false - redis: - host: 192.168.10.137 - port: 6379 - password: 123456 - -mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - -minio: - url: http://192.168.10.137:9002 - accessKey: admin - secretKey: 12345678 - bucketName: virtual-patient-bucket-dev \ No newline at end of file diff --git a/virtual-patient-manage/src/main/resources/application-test.yml b/virtual-patient-manage/src/main/resources/application-test.yml deleted file mode 100644 index 5541b1fe..00000000 --- a/virtual-patient-manage/src/main/resources/application-test.yml +++ /dev/null @@ -1,63 +0,0 @@ -#服务器端口 -server: - port: 8891 - servlet: - context-path: /virtual-patient-manage - undertow: - # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 - max-http-post-size: -1 - # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 - # 每块buffer的空间大小,越小的空间被利用越充分 - buffer-size: 512 - # 是否分配的直接内存 - direct-buffers: true - - -spring: - application: - name: virtual-patient-manage - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - ##数据源配置 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - druid: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.10.138:3306/virtual_patient_test?useUnicode=true&characterEncoding=utf-8&useSSL=true&nullCatalogMeansCurrent=true&serverTimezone=GMT%2B8 - username: root - password: '123456' - initial-size: 5 # 初始化大小 - min-idle: 10 # 最小连接数 - max-active: 20 # 最大连接数 - max-wait: 60000 # 获取连接时的最大等待时间 - min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 - time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 - filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 - validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 - test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 - test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 - test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 - stat-view-servlet: - enabled: false # 是否开启 StatViewServlet - filter: - stat: - enabled: true # 是否开启 FilterStat,默认true - log-slow-sql: true # 是否开启 慢SQL 记录,默认false - slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 - merge-sql: false # 合并多个连接池的监控数据,默认false - redis: - host: 192.168.10.138 - port: 6379 - password: 123456 - -mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl -minio: - url: http://192.168.10.138:9002 - accessKey: admin - secretKey: 12345678 - bucketName: virtual-patient-bucket-test \ No newline at end of file diff --git a/virtual-patient-manage/src/main/resources/application.yml b/virtual-patient-manage/src/main/resources/application.yml index 027b4e36..8d8f4111 100644 --- a/virtual-patient-manage/src/main/resources/application.yml +++ b/virtual-patient-manage/src/main/resources/application.yml @@ -1,3 +1,48 @@ +#服务器端口 +server: + port: 8891 + servlet: + context-path: /virtual-patient-manage + undertow: + # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 + max-http-post-size: -1 + # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 + # 每块buffer的空间大小,越小的空间被利用越充分 + buffer-size: 512 + # 是否分配的直接内存 + direct-buffers: true + spring: - profiles: - active: test \ No newline at end of file + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB + ##数据源配置 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + initial-size: 5 # 初始化大小 + min-idle: 10 # 最小连接数 + max-active: 20 # 最大连接数 + max-wait: 60000 # 获取连接时的最大等待时间 + min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 + time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 + filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 + validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 + test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 + test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 + test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 + stat-view-servlet: + enabled: false # 是否开启 StatViewServlet + filter: + stat: + enabled: true # 是否开启 FilterStat,默认true + log-slow-sql: true # 是否开启 慢SQL 记录,默认false + slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 + merge-sql: false # 合并多个连接池的监控数据,默认false + + +mybatis-plus: + mapper-locations: classpath*:mapper/**/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/virtual-patient-manage/src/main/resources/bootstrap-dev.yml b/virtual-patient-manage/src/main/resources/bootstrap-dev.yml new file mode 100644 index 00000000..b43e8800 --- /dev/null +++ b/virtual-patient-manage/src/main/resources/bootstrap-dev.yml @@ -0,0 +1,10 @@ +spring: + cloud: + nacos: + config: + server-addr: 192.168.10.137:8848 + file-extension: yml + namespace: b9eea377-79ec-4ba5-9cc2-354f7bd5181e + discovery: + server-addr: 192.168.10.137:8848 + namespace: b9eea377-79ec-4ba5-9cc2-354f7bd5181e diff --git a/virtual-patient-manage/src/main/resources/bootstrap-test.yml b/virtual-patient-manage/src/main/resources/bootstrap-test.yml new file mode 100644 index 00000000..71468fab --- /dev/null +++ b/virtual-patient-manage/src/main/resources/bootstrap-test.yml @@ -0,0 +1,10 @@ +spring: + cloud: + nacos: + config: + server-addr: 192.168.10.137:8848 + file-extension: yml + namespace: 88e1f674-1fbc-4021-9ff1-60b94ee13ef0 + discovery: + server-addr: 192.168.10.137:8848 + namespace: 88e1f674-1fbc-4021-9ff1-60b94ee13ef0 \ No newline at end of file diff --git a/virtual-patient-manage/src/main/resources/bootstrap.yml b/virtual-patient-manage/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..55945d90 --- /dev/null +++ b/virtual-patient-manage/src/main/resources/bootstrap.yml @@ -0,0 +1,5 @@ +spring: + profiles: + active: test + application: + name: virtual-patient-manage \ No newline at end of file diff --git a/virtual-patient-rasa/pom.xml b/virtual-patient-rasa/pom.xml index f934f761..9f62f611 100644 --- a/virtual-patient-rasa/pom.xml +++ b/virtual-patient-rasa/pom.xml @@ -21,6 +21,30 @@ + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba + fastjson + + + com.alibaba.nacos + nacos-common + + + + + com.alibaba.nacos + nacos-common + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + com.supervision virtual-patient-common diff --git a/virtual-patient-rasa/src/main/java/com/supervision/rasa/VirtualPatientRasaApplication.java b/virtual-patient-rasa/src/main/java/com/supervision/rasa/VirtualPatientRasaApplication.java index 041efa1d..e83e6ec7 100644 --- a/virtual-patient-rasa/src/main/java/com/supervision/rasa/VirtualPatientRasaApplication.java +++ b/virtual-patient-rasa/src/main/java/com/supervision/rasa/VirtualPatientRasaApplication.java @@ -6,6 +6,7 @@ import com.supervision.rasa.service.Text2vecService; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.FilterType; @@ -16,6 +17,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; @MapperScan(basePackages = {"com.supervision.**.mapper"}) // 排除JWT权限校验 @ComponentScan(basePackages = {"com.supervision"},excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {WebConfig.class})) +@EnableDiscoveryClient public class VirtualPatientRasaApplication { public static void main(String[] args) { diff --git a/virtual-patient-rasa/src/main/resources/application-dev.yml b/virtual-patient-rasa/src/main/resources/application-dev.yml deleted file mode 100644 index cc3fc54d..00000000 --- a/virtual-patient-rasa/src/main/resources/application-dev.yml +++ /dev/null @@ -1,66 +0,0 @@ -server: - port: 8890 - servlet: - context-path: /virtual-patient-rasa - undertow: - # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 - max-http-post-size: -1 - # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 - # 每块buffer的空间大小,越小的空间被利用越充分 - buffer-size: 512 - # 是否分配的直接内存 - direct-buffers: true - -rasa: - data-path: /data/vp/rasa/model_resource/ # 文件解压后存放位置 - models-path: /data/vp/rasa/models/ - endpoints: /rasa/endpoints.yml # 启动的配置项,应该是写在配置文件里面 - config: /rasa/config.yml # 启动rasa需要的配置文件,在配置文件中配置 - url: 127.0.0.1:{}/webhooks/rest/webhook - wakeup: - cron: 0 */10 * * * ? #每十分钟执行一次 - -text2vec: - service: - domain: http://127.0.0.1:5000/ - -spring: - application: - name: virtual-patient - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - - ##数据源配置 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - druid: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.10.137:3306/virtual_patient?useUnicode=true&characterEncoding=utf-8&useSSL=true&nullCatalogMeansCurrent=true&serverTimezone=GMT%2B8 - username: root - password: '123456' - initial-size: 5 # 初始化大小 - min-idle: 10 # 最小连接数 - max-active: 20 # 最大连接数 - max-wait: 60000 # 获取连接时的最大等待时间 - min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 - time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 - filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 - validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 - test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 - test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 - test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 - stat-view-servlet: - enabled: false # 是否开启 StatViewServlet - filter: - stat: - enabled: true # 是否开启 FilterStat,默认true - log-slow-sql: true # 是否开启 慢SQL 记录,默认false - slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 - merge-sql: false # 合并多个连接池的监控数据,默认false - -mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/virtual-patient-rasa/src/main/resources/application-test.yml b/virtual-patient-rasa/src/main/resources/application-test.yml deleted file mode 100644 index e0240095..00000000 --- a/virtual-patient-rasa/src/main/resources/application-test.yml +++ /dev/null @@ -1,66 +0,0 @@ -server: - port: 8890 - servlet: - context-path: /virtual-patient-rasa - undertow: - # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 - max-http-post-size: -1 - # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 - # 每块buffer的空间大小,越小的空间被利用越充分 - buffer-size: 512 - # 是否分配的直接内存 - direct-buffers: true - -rasa: - data-path: /data/vp/rasa/model_resource/ # 文件解压后存放位置 - models-path: /data/vp/rasa/models/ - endpoints: /rasa/endpoints.yml # 启动的配置项,应该是写在配置文件里面 - config: /rasa/config.yml # 启动rasa需要的配置文件,在配置文件中配置 - url: 127.0.0.1:{}/webhooks/rest/webhook - wakeup: - cron: 0 */10 * * * ? #每十分钟执行一次 - -text2vec: - service: - domain: http://127.0.0.1:5000/ - -spring: - application: - name: virtual-patient - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - - ##数据源配置 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - druid: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.10.138:3306/virtual_patient_test?useUnicode=true&characterEncoding=utf-8&useSSL=true&nullCatalogMeansCurrent=true&serverTimezone=GMT%2B8 - username: root - password: '123456' - initial-size: 5 # 初始化大小 - min-idle: 10 # 最小连接数 - max-active: 20 # 最大连接数 - max-wait: 60000 # 获取连接时的最大等待时间 - min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 - time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 - filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 - validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 - test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 - test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 - test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 - stat-view-servlet: - enabled: false # 是否开启 StatViewServlet - filter: - stat: - enabled: true # 是否开启 FilterStat,默认true - log-slow-sql: true # 是否开启 慢SQL 记录,默认false - slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 - merge-sql: false # 合并多个连接池的监控数据,默认false - -mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/virtual-patient-rasa/src/main/resources/application.yml b/virtual-patient-rasa/src/main/resources/application.yml index caf4dfcd..02278bbf 100644 --- a/virtual-patient-rasa/src/main/resources/application.yml +++ b/virtual-patient-rasa/src/main/resources/application.yml @@ -1,3 +1,46 @@ +server: + port: 8890 + servlet: + context-path: /virtual-patient-rasa + undertow: + # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 + max-http-post-size: -1 + # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 + # 每块buffer的空间大小,越小的空间被利用越充分 + buffer-size: 512 + # 是否分配的直接内存 + direct-buffers: true + spring: - profiles: - active: dev \ No newline at end of file + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB + ##数据源配置 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + initial-size: 5 # 初始化大小 + min-idle: 10 # 最小连接数 + max-active: 20 # 最大连接数 + max-wait: 60000 # 获取连接时的最大等待时间 + min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 + time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 + filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 + validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 + test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 + test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 + test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 + stat-view-servlet: + enabled: false # 是否开启 StatViewServlet + filter: + stat: + enabled: true # 是否开启 FilterStat,默认true + log-slow-sql: true # 是否开启 慢SQL 记录,默认false + slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 + merge-sql: false # 合并多个连接池的监控数据,默认false + +mybatis-plus: + mapper-locations: classpath*:mapper/**/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/virtual-patient-rasa/src/main/resources/bootstrap-dev.yml b/virtual-patient-rasa/src/main/resources/bootstrap-dev.yml new file mode 100644 index 00000000..b43e8800 --- /dev/null +++ b/virtual-patient-rasa/src/main/resources/bootstrap-dev.yml @@ -0,0 +1,10 @@ +spring: + cloud: + nacos: + config: + server-addr: 192.168.10.137:8848 + file-extension: yml + namespace: b9eea377-79ec-4ba5-9cc2-354f7bd5181e + discovery: + server-addr: 192.168.10.137:8848 + namespace: b9eea377-79ec-4ba5-9cc2-354f7bd5181e diff --git a/virtual-patient-rasa/src/main/resources/bootstrap-test.yml b/virtual-patient-rasa/src/main/resources/bootstrap-test.yml new file mode 100644 index 00000000..71468fab --- /dev/null +++ b/virtual-patient-rasa/src/main/resources/bootstrap-test.yml @@ -0,0 +1,10 @@ +spring: + cloud: + nacos: + config: + server-addr: 192.168.10.137:8848 + file-extension: yml + namespace: 88e1f674-1fbc-4021-9ff1-60b94ee13ef0 + discovery: + server-addr: 192.168.10.137:8848 + namespace: 88e1f674-1fbc-4021-9ff1-60b94ee13ef0 \ No newline at end of file diff --git a/virtual-patient-rasa/src/main/resources/bootstrap.yml b/virtual-patient-rasa/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..2d92234b --- /dev/null +++ b/virtual-patient-rasa/src/main/resources/bootstrap.yml @@ -0,0 +1,5 @@ +spring: + profiles: + active: test + application: + name: virtual-patient-rasa \ No newline at end of file diff --git a/virtual-patient-web/pom.xml b/virtual-patient-web/pom.xml index 96573a46..54172159 100644 --- a/virtual-patient-web/pom.xml +++ b/virtual-patient-web/pom.xml @@ -18,6 +18,32 @@ + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + + com.alibaba + fastjson + + + com.alibaba.nacos + nacos-common + + + + + com.alibaba.nacos + nacos-common + + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-config + + + + com.supervision virtual-patient-model diff --git a/virtual-patient-web/src/main/java/com/supervision/VirtualPatientApplication.java b/virtual-patient-web/src/main/java/com/supervision/VirtualPatientApplication.java index 58cf6d1d..1244c7a3 100644 --- a/virtual-patient-web/src/main/java/com/supervision/VirtualPatientApplication.java +++ b/virtual-patient-web/src/main/java/com/supervision/VirtualPatientApplication.java @@ -4,6 +4,7 @@ import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScans; import org.springframework.scheduling.annotation.EnableScheduling; @@ -11,8 +12,8 @@ import org.springframework.web.socket.config.annotation.EnableWebSocket; @SpringBootApplication @MapperScan(basePackages = {"com.supervision.**.mapper"}) -@EnableWebSocket @EnableScheduling +@EnableDiscoveryClient public class VirtualPatientApplication { public static void main(String[] args) { diff --git a/virtual-patient-web/src/main/resources/application-dev.yml b/virtual-patient-web/src/main/resources/application-dev.yml deleted file mode 100644 index f1587089..00000000 --- a/virtual-patient-web/src/main/resources/application-dev.yml +++ /dev/null @@ -1,85 +0,0 @@ -#服务器端口 -server: - port: 8899 - servlet: - context-path: /virtual-patient - undertow: - # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 - max-http-post-size: -1 - # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 - # 每块buffer的空间大小,越小的空间被利用越充分 - buffer-size: 512 - # 是否分配的直接内存 - direct-buffers: true - -spring: - application: - name: virtual-patient - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - ##数据源配置 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - druid: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.10.137:3306/virtual_patient?useUnicode=true&characterEncoding=utf-8&useSSL=true&nullCatalogMeansCurrent=true&serverTimezone=GMT%2B8 - username: root - password: '123456' - initial-size: 5 # 初始化大小 - min-idle: 10 # 最小连接数 - max-active: 20 # 最大连接数 - max-wait: 60000 # 获取连接时的最大等待时间 - min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 - time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 - filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 - validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 - test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 - test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 - test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 - stat-view-servlet: - enabled: false # 是否开启 StatViewServlet - filter: - stat: - enabled: true # 是否开启 FilterStat,默认true - log-slow-sql: true # 是否开启 慢SQL 记录,默认false - slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 - merge-sql: false # 合并多个连接池的监控数据,默认false - redis: - host: 192.168.10.137 - port: 6379 - password: 123456 - -minio: - url: http://192.168.10.137:9002 - accessKey: admin - secretKey: 12345678 - bucketName: virtual-patient-bucket-dev - - -mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - -paddle-speech: - # https://github.com/PaddlePaddle/PaddleSpeech/wiki/PaddleSpeech-Server-RESTful-API - tts: http://192.168.10.137:8090/paddlespeech/tts - asr: http://192.168.10.137:8090/paddlespeech/asr -rasa: - base-url: http://192.168.10.137:8890/virtual-patient-rasa/ - talk: rasa/talkRasa - saveRasaFile: rasaFile/saveRasaFile - train: rasaCmd/trainExec - run: rasaCmd/runExec -human: - base-url: https://digital-human.jd.com - room-id: /getRoomId - text-driven: /text_driven - talk-status: /talkStatus - resourceMaxNumber: 5 -answer: - # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID - defaultNoMatchId: 1739173836351885313 - defaultNoMatchAnswerMessage: 你好,医生 \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/application-local.yml b/virtual-patient-web/src/main/resources/application-local.yml deleted file mode 100644 index 2e51914d..00000000 --- a/virtual-patient-web/src/main/resources/application-local.yml +++ /dev/null @@ -1,85 +0,0 @@ -#服务器端口 -server: - port: 8899 - servlet: - context-path: /virtual-patient - undertow: - # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 - max-http-post-size: -1 - # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 - # 每块buffer的空间大小,越小的空间被利用越充分 - buffer-size: 512 - # 是否分配的直接内存 - direct-buffers: true - -spring: - application: - name: virtual-patient - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - ##数据源配置 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - druid: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.10.138:3306/virtual_patient?useUnicode=true&characterEncoding=utf-8&useSSL=true&nullCatalogMeansCurrent=true&serverTimezone=GMT%2B8 - username: root - password: '123456' - initial-size: 5 # 初始化大小 - min-idle: 10 # 最小连接数 - max-active: 20 # 最大连接数 - max-wait: 60000 # 获取连接时的最大等待时间 - min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 - time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 - filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 - validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 - test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 - test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 - test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 - stat-view-servlet: - enabled: false # 是否开启 StatViewServlet - filter: - stat: - enabled: true # 是否开启 FilterStat,默认true - log-slow-sql: true # 是否开启 慢SQL 记录,默认false - slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 - merge-sql: false # 合并多个连接池的监控数据,默认false - redis: - host: 192.168.10.137 - port: 6379 - password: 123456 - -minio: - url: http://192.168.10.138:9002 - accessKey: admin - secretKey: 12345678 - bucketName: virtual-patient-bucket-dev - -mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - -paddle-speech: - # https://github.com/PaddlePaddle/PaddleSpeech/wiki/PaddleSpeech-Server-RESTful-API - tts: http://192.168.10.137:8090/paddlespeech/tts - asr: http://192.168.10.137:8090/paddlespeech/asr -rasa: - base-url: http://192.168.10.138:8890/virtual-patient-rasa/ - talk: rasa/talkRasa - saveRasaFile: rasaFile/saveRasaFile - train: rasaCmd/trainExec - run: rasaCmd/runExec -human: - base-url: https://digital-human.jd.com - room-id: /getRoomId - text-driven: /text_driven - talk-status: /talkStatus - resourceMaxNumber: 5 - -answer: - # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID - defaultNoMatchId: 1739173836351885313 - defaultNoMatchAnswerMessage: 你好,医生 \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/application-test.yml b/virtual-patient-web/src/main/resources/application-test.yml deleted file mode 100644 index 9b57263c..00000000 --- a/virtual-patient-web/src/main/resources/application-test.yml +++ /dev/null @@ -1,89 +0,0 @@ -#服务器端口 -server: - port: 8899 - servlet: - context-path: /virtual-patient - undertow: - # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 - max-http-post-size: -1 - # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 - # 每块buffer的空间大小,越小的空间被利用越充分 - buffer-size: 512 - # 是否分配的直接内存 - direct-buffers: true - - -spring: - application: - name: virtual-patient - servlet: - multipart: - max-file-size: 100MB - max-request-size: 100MB - ##数据源配置 - datasource: - type: com.alibaba.druid.pool.DruidDataSource - druid: - driver-class-name: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.10.138:3306/virtual_patient_test?useUnicode=true&characterEncoding=utf-8&useSSL=true&nullCatalogMeansCurrent=true&serverTimezone=GMT%2B8 - username: root - password: '123456' - initial-size: 5 # 初始化大小 - min-idle: 10 # 最小连接数 - max-active: 20 # 最大连接数 - max-wait: 60000 # 获取连接时的最大等待时间 - min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 - time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 - filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 - validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 - test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 - test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 - test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 - stat-view-servlet: - enabled: false # 是否开启 StatViewServlet - filter: - stat: - enabled: true # 是否开启 FilterStat,默认true - log-slow-sql: true # 是否开启 慢SQL 记录,默认false - slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 - merge-sql: false # 合并多个连接池的监控数据,默认false - redis: - host: 192.168.10.138 - port: 6379 - password: 123456 - -minio: - url: http://192.168.10.138:9002 - accessKey: admin - secretKey: 12345678 - bucketName: virtual-patient-bucket-test - -mybatis-plus: - mapper-locations: classpath*:mapper/**/*.xml - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl - -paddle-speech: - # https://github.com/PaddlePaddle/PaddleSpeech/wiki/PaddleSpeech-Server-RESTful-API - tts: http://192.168.10.138:8090/paddlespeech/tts - asr: http://192.168.10.138:8090/paddlespeech/asr -rasa: - base-url: http://192.168.10.138:8790/virtual-patient-rasa/ - talk: rasa/talkRasa - saveRasaFile: rasaFile/saveRasaFile - train: rasaCmd/trainExec - run: rasaCmd/runExec -human: - base-url: https://digital-human.jd.com - room-id: /getRoomId - text-driven: /text_driven - talk-status: /talkStatus - resourceMaxNumber: 5 -ws: - # nginx的wss地址(如果是wss的,那么带不带s都可以访问) - nginx-ip: 192.168.10.138 - nginx-port: 443 -answer: - # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID - defaultNoMatchId: 1739945100730986498 - defaultNoMatchAnswerMessage: 你好,医生 \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/application.yml b/virtual-patient-web/src/main/resources/application.yml index ef46c2ad..1ed209a9 100644 --- a/virtual-patient-web/src/main/resources/application.yml +++ b/virtual-patient-web/src/main/resources/application.yml @@ -1,3 +1,46 @@ +#服务器端口 +server: + port: 8899 + servlet: + context-path: /virtual-patient + undertow: + # HTTP post内容的最大大小。当值为-1时,默认值为大小是无限的 + max-http-post-size: -1 + # 以下的配置会影响buffer,这些buffer会用于服务器连接的IO操作,有点类似netty的池化内存管理 + # 每块buffer的空间大小,越小的空间被利用越充分 + buffer-size: 512 + # 是否分配的直接内存 + direct-buffers: true spring: - profiles: - active: local \ No newline at end of file + servlet: + multipart: + max-file-size: 100MB + max-request-size: 100MB + ##数据源配置 + datasource: + type: com.alibaba.druid.pool.DruidDataSource + druid: + initial-size: 5 # 初始化大小 + min-idle: 10 # 最小连接数 + max-active: 20 # 最大连接数 + max-wait: 60000 # 获取连接时的最大等待时间 + min-evictable-idle-time-millis: 300000 # 一个连接在池中最小生存的时间,单位是毫秒 + time-between-eviction-runs-millis: 60000 # 多久才进行一次检测需要关闭的空闲连接,单位是毫秒 + filters: stat,wall # 配置扩展插件:stat-监控统计,log4j-日志,wall-防火墙(防止SQL注入),去掉后,监控界面的sql无法统计 + validation-query: SELECT 1 # 检测连接是否有效的 SQL语句,为空时以下三个配置均无效 + test-on-borrow: true # 申请连接时执行validationQuery检测连接是否有效,默认true,开启后会降低性能 + test-on-return: true # 归还连接时执行validationQuery检测连接是否有效,默认false,开启后会降低性能 + test-while-idle: true # 申请连接时如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效,默认false,建议开启,不影响性能 + stat-view-servlet: + enabled: false # 是否开启 StatViewServlet + filter: + stat: + enabled: true # 是否开启 FilterStat,默认true + log-slow-sql: true # 是否开启 慢SQL 记录,默认false + slow-sql-millis: 5000 # 慢 SQL 的标准,默认 3000,单位:毫秒 + merge-sql: false # 合并多个连接池的监控数据,默认false + +mybatis-plus: + mapper-locations: classpath*:mapper/**/*.xml + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/bootstrap-dev.yml b/virtual-patient-web/src/main/resources/bootstrap-dev.yml new file mode 100644 index 00000000..e671cab3 --- /dev/null +++ b/virtual-patient-web/src/main/resources/bootstrap-dev.yml @@ -0,0 +1,10 @@ +spring: + cloud: + nacos: + config: + server-addr: 192.168.10.137:8848 + file-extension: yml + namespace: b9eea377-79ec-4ba5-9cc2-354f7bd5181e + discovery: + server-addr: 192.168.10.137:8848 + namespace: b9eea377-79ec-4ba5-9cc2-354f7bd5181e \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/bootstrap-test.yml b/virtual-patient-web/src/main/resources/bootstrap-test.yml new file mode 100644 index 00000000..71468fab --- /dev/null +++ b/virtual-patient-web/src/main/resources/bootstrap-test.yml @@ -0,0 +1,10 @@ +spring: + cloud: + nacos: + config: + server-addr: 192.168.10.137:8848 + file-extension: yml + namespace: 88e1f674-1fbc-4021-9ff1-60b94ee13ef0 + discovery: + server-addr: 192.168.10.137:8848 + namespace: 88e1f674-1fbc-4021-9ff1-60b94ee13ef0 \ No newline at end of file diff --git a/virtual-patient-web/src/main/resources/bootstrap.yml b/virtual-patient-web/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..09f83caa --- /dev/null +++ b/virtual-patient-web/src/main/resources/bootstrap.yml @@ -0,0 +1,5 @@ +spring: + profiles: + active: test + application: + name: virtual-patient-web \ No newline at end of file From 1e2b755174515b264450203f5a746aa0192c342b Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 22 Jan 2024 16:31:55 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=BE=AE=E6=9C=8D=E5=8A=A1=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- virtual-patient-manage/pom.xml | 14 +- .../VirtualPatientManageApplication.java | 2 + .../com/supervision/vo/rasa/RasaTalkVo.java | 2 +- virtual-patient-rasa/pom.xml | 5 + virtual-patient-web/pom.xml | 5 + .../VirtualPatientApplication.java | 2 + .../controller/RasaController.java | 44 ---- .../feign/RasaManageFeignClient.java | 17 ++ .../com/supervision/service/AskService.java | 2 - .../com/supervision/service/RasaService.java | 13 - .../service/impl/AskServiceImpl.java | 112 ++------ .../service/impl/RasaServiceImpl.java | 247 ------------------ .../java/com/supervision/util/RasaUtil.java | 49 ---- .../src/main/resources/application-prod.yml | 17 +- 14 files changed, 73 insertions(+), 458 deletions(-) delete mode 100644 virtual-patient-web/src/main/java/com/supervision/controller/RasaController.java create mode 100644 virtual-patient-web/src/main/java/com/supervision/feign/RasaManageFeignClient.java delete mode 100644 virtual-patient-web/src/main/java/com/supervision/service/RasaService.java delete mode 100644 virtual-patient-web/src/main/java/com/supervision/service/impl/RasaServiceImpl.java delete mode 100644 virtual-patient-web/src/main/java/com/supervision/util/RasaUtil.java diff --git a/virtual-patient-manage/pom.xml b/virtual-patient-manage/pom.xml index eb948320..d104417f 100644 --- a/virtual-patient-manage/pom.xml +++ b/virtual-patient-manage/pom.xml @@ -34,6 +34,11 @@ nacos-common + + org.springframework.cloud + spring-cloud-starter-openfeign + + com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config @@ -65,9 +70,12 @@ org.springframework.boot spring-boot-maven-plugin - - paketobuildpacks/builder-jammy-base:latest - + + + org.projectlombok + lombok + + diff --git a/virtual-patient-manage/src/main/java/com/supervision/manage/VirtualPatientManageApplication.java b/virtual-patient-manage/src/main/java/com/supervision/manage/VirtualPatientManageApplication.java index b9160a39..fb09bda9 100644 --- a/virtual-patient-manage/src/main/java/com/supervision/manage/VirtualPatientManageApplication.java +++ b/virtual-patient-manage/src/main/java/com/supervision/manage/VirtualPatientManageApplication.java @@ -4,12 +4,14 @@ import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScans; @SpringBootApplication @MapperScan(basePackages = {"com.supervision.**.mapper"}) @ComponentScan(basePackages = {"com.supervision.**"}) +@EnableFeignClients(basePackages = "com.supervision") @EnableDiscoveryClient public class VirtualPatientManageApplication { diff --git a/virtual-patient-model/src/main/java/com/supervision/vo/rasa/RasaTalkVo.java b/virtual-patient-model/src/main/java/com/supervision/vo/rasa/RasaTalkVo.java index f3078789..08a4f6c8 100644 --- a/virtual-patient-model/src/main/java/com/supervision/vo/rasa/RasaTalkVo.java +++ b/virtual-patient-model/src/main/java/com/supervision/vo/rasa/RasaTalkVo.java @@ -19,6 +19,6 @@ public class RasaTalkVo { * 模型id */ @ApiModelProperty(hidden = true) - private String modelId; + private String modelId = "1"; } diff --git a/virtual-patient-rasa/pom.xml b/virtual-patient-rasa/pom.xml index 9f62f611..00705150 100644 --- a/virtual-patient-rasa/pom.xml +++ b/virtual-patient-rasa/pom.xml @@ -40,6 +40,11 @@ nacos-common + + org.springframework.cloud + spring-cloud-starter-openfeign + + com.alibaba.cloud spring-cloud-starter-alibaba-nacos-config diff --git a/virtual-patient-web/pom.xml b/virtual-patient-web/pom.xml index 54172159..bd7054aa 100644 --- a/virtual-patient-web/pom.xml +++ b/virtual-patient-web/pom.xml @@ -42,6 +42,11 @@ spring-cloud-starter-alibaba-nacos-config + + org.springframework.cloud + spring-cloud-starter-openfeign + + diff --git a/virtual-patient-web/src/main/java/com/supervision/VirtualPatientApplication.java b/virtual-patient-web/src/main/java/com/supervision/VirtualPatientApplication.java index 1244c7a3..f1732f2c 100644 --- a/virtual-patient-web/src/main/java/com/supervision/VirtualPatientApplication.java +++ b/virtual-patient-web/src/main/java/com/supervision/VirtualPatientApplication.java @@ -5,6 +5,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.ComponentScans; import org.springframework.scheduling.annotation.EnableScheduling; @@ -13,6 +14,7 @@ import org.springframework.web.socket.config.annotation.EnableWebSocket; @SpringBootApplication @MapperScan(basePackages = {"com.supervision.**.mapper"}) @EnableScheduling +@EnableFeignClients(basePackages = "com.supervision") @EnableDiscoveryClient public class VirtualPatientApplication { diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/RasaController.java b/virtual-patient-web/src/main/java/com/supervision/controller/RasaController.java deleted file mode 100644 index 761a2bfd..00000000 --- a/virtual-patient-web/src/main/java/com/supervision/controller/RasaController.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.supervision.controller; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.supervision.domain.GlobalResult; -import com.supervision.service.RasaService; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.annotations.ApiOperation; -import lombok.RequiredArgsConstructor; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * @Description: @since 2.0.0接口功能已经过期,功能迁移到rasaManage RasaCmdService.deployRasa 服务中 - */ -@Deprecated -@RestController -@RequestMapping("rasa") -@RequiredArgsConstructor -public class RasaController { - - private final RasaService rasaService; - - @ApiOperation("生成rasa的yml文件") - @GetMapping("generateRasaYml") - public GlobalResult generateRasaYml(String patientId) { - return rasaService.generateRasaYml(patientId); - } - - @ApiOperation("训练rasa") - @GetMapping("trainRasa") - public GlobalResult trainRasa(String patientId) throws JsonProcessingException { - return rasaService.trainRasa(patientId); - } - - @ApiOperation("运行Rasa") - @GetMapping("runRasa") - public GlobalResult runRasa(String patientId) throws JsonProcessingException { - return rasaService.runRasa(patientId); - } - - -} diff --git a/virtual-patient-web/src/main/java/com/supervision/feign/RasaManageFeignClient.java b/virtual-patient-web/src/main/java/com/supervision/feign/RasaManageFeignClient.java new file mode 100644 index 00000000..dda8c97b --- /dev/null +++ b/virtual-patient-web/src/main/java/com/supervision/feign/RasaManageFeignClient.java @@ -0,0 +1,17 @@ +package com.supervision.feign; + +import com.supervision.domain.GlobalResult; +import com.supervision.vo.rasa.RasaTalkVo; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +import java.util.List; + +@FeignClient(name = "virtual-patient-rasa", contextId = "VirtualPatientRasa") +public interface RasaManageFeignClient { + @PostMapping("/rasa/talkRasa") + GlobalResult> talk(@RequestBody RasaTalkVo rasaTalkVo); + + +} diff --git a/virtual-patient-web/src/main/java/com/supervision/service/AskService.java b/virtual-patient-web/src/main/java/com/supervision/service/AskService.java index aec660f6..48791bf3 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/AskService.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/AskService.java @@ -15,8 +15,6 @@ public interface AskService { String receiveVoiceFile(MultipartFile file); - TalkResultResVO talk(TalkReqVO talkReqVO) throws IOException; - TalkResultResVO talkByVideo(TalkVideoReqVO talkReqVO) throws IOException; diff --git a/virtual-patient-web/src/main/java/com/supervision/service/RasaService.java b/virtual-patient-web/src/main/java/com/supervision/service/RasaService.java deleted file mode 100644 index ffc6977f..00000000 --- a/virtual-patient-web/src/main/java/com/supervision/service/RasaService.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.supervision.service; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.supervision.domain.GlobalResult; - -public interface RasaService { - - GlobalResult generateRasaYml(String diseaseId); - - GlobalResult trainRasa(String patientId) throws JsonProcessingException; - - GlobalResult runRasa(String patientId) throws JsonProcessingException; -} diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java index 60b17864..0038e6b9 100644 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java +++ b/virtual-patient-web/src/main/java/com/supervision/service/impl/AskServiceImpl.java @@ -1,13 +1,19 @@ package com.supervision.service.impl; import cn.hutool.core.codec.Base64Encoder; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.io.IoUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.crypto.digest.MD5; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import cn.hutool.setting.dialect.Props; +import com.supervision.domain.GlobalResult; import com.supervision.exception.BusinessException; +import com.supervision.feign.RasaManageFeignClient; import com.supervision.model.Process; import com.supervision.model.*; import com.supervision.pojo.vo.TalkReqVO; @@ -15,6 +21,7 @@ import com.supervision.pojo.vo.TalkResultResVO; import com.supervision.pojo.vo.TalkVideoReqVO; import com.supervision.service.*; import com.supervision.util.*; +import com.supervision.vo.rasa.RasaTalkVo; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; @@ -46,6 +53,8 @@ public class AskServiceImpl implements AskService { private final FileResourceService fileResourceService; + private final RasaManageFeignClient rasaManageFeignClient; + @Value("${answer.defaultNoMatchId}") private String defaultNoMatchId; @@ -70,87 +79,6 @@ public class AskServiceImpl implements AskService { return text; } - @Override - @Transactional(rollbackFor = Exception.class) - public TalkResultResVO talk(TalkReqVO talkReqVO) { - // 根据processId找到对应的病人 - Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程")); - // 调用rasa获取文字内容 - String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId()); - // 如果rasa没有识别出来,则返回默认值 - if (StrUtil.isBlank(rasaResult)) { - // 这里调用京东数字人接口首先根据token获取房间号 - String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken()); - HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); - saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); - } - TalkResultResVO talkResultResVO = new TalkResultResVO(); - // 这里校验,rasa回复的结果是不是action - // 这里设置的模板,对于action的动作全部是用ancillary_ | tool_进行标记,详情看生成rasa的yml的代码:RasaServiceImpl.generateDomain - // ancillary_ | tool_ - if (rasaResult.startsWith("ancillary_") || rasaResult.startsWith("tool_")) { - log.info("呼出语句:{}", rasaResult); - List actionList = StrUtil.split(rasaResult, '_'); - if (actionList.size() > 1) { - // 在这里给socket回复,设置为动作 - talkResultResVO.setActionId(actionList.get(1)); - talkResultResVO.setType("ancillary".equals(actionList.get(0)) ? 3 : 2); - setActionRelation(talkResultResVO); - return talkResultResVO; - } - } else { - String roomId = HumanUtil.queryRoomId(talkReqVO.getRoomKey(), talkReqVO.getRoomToken()); - AskTemplateQuestionLibrary library = askTemplateQuestionLibraryService.getById(rasaResult); - if (ObjectUtil.isEmpty(library)) { - log.info("{}:未从问题库中找到,回答未识别语句", rasaResult); - HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); - saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), null, "您好,我没有听懂您说什么"); - } else { - AskPatientAnswer askPatientAnswer = askPatientAnswerService.lambdaQuery().eq(AskPatientAnswer::getMedicalId, process.getMedicalRecId()) - .eq(AskPatientAnswer::getLibraryQuestionId, library.getId()).last("limit 1").one(); - // 如果没有找到回答,去默认回答里面看看有没有 - if (ObjectUtil.isEmpty(askPatientAnswer)) { - log.info("{}:病历配置,未从AskPatientAnswer中找到回答结果,尝试回答默认答案", rasaResult); - // 首先看看default里面是不是存在,如果存在,就从default里面去找 - if (StrUtil.isNotEmpty(library.getDefaultAnswer())) { - String resText = library.getDefaultAnswer(); - HumanUtil.textDriven(resText, roomId); - // 保存记录 - saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); - log.info("{}:找到了默认答案:{}", rasaResult, talkReqVO.getText()); - } else { - log.info("{}:没有从默认答案中找到找到默认内容,回复未识别语句", rasaResult); - HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); - saveQaRecord(talkReqVO.getProcessId(), "default", null, talkReqVO.getText(), library, "您好,我没有听懂您说什么"); - } - } else { - if (StrUtil.isEmpty(askPatientAnswer.getAnswer())) { - log.info("{}:病历配置的回答:{}:为空不为空,但在获取的时候,答案为空,尝试回复默认语句", rasaResult, askPatientAnswer.getId()); - if (StrUtil.isNotEmpty(library.getDefaultAnswer())) { - String resText = library.getDefaultAnswer(); - log.info("{}:病历配置的回答:{}:为空不为空不为空,但在获取的时候,答案为空,开始回复默认语句,默认语句内容:{}", rasaResult, askPatientAnswer.getId(), resText); - HumanUtil.textDriven(resText, roomId); - // 保存记录 - saveQaRecord(talkReqVO.getProcessId(), "default", library.getId(), talkReqVO.getText(), library, resText); - } else { - log.info("{}:病历配置的回答:{}:为空不为空,但在获取的时候,答案为空,但是获取默认语句也为空,那么回复未识别语句", rasaResult, askPatientAnswer.getId()); - HumanUtil.textDriven("您好,我没有听懂您说什么", roomId); - } - - } else { - String resText = askPatientAnswer.getAnswer(); - log.info("{}:找到了病历配置的回答语句:{},回答内容:{}", rasaResult, askPatientAnswer.getId(), resText); - HumanUtil.textDriven(resText, roomId); - // 保存记录 - saveQaRecord(talkReqVO.getProcessId(), "patient", askPatientAnswer.getId(), talkReqVO.getText(), library, resText); - } - - } - } - } - talkResultResVO.setType(1); - return talkResultResVO; - } private void saveQaRecord(String processId, String answerType, String answerId, String question, AskTemplateQuestionLibrary library, String resText) { DiagnosisQaRecord record = new DiagnosisQaRecord(); @@ -195,7 +123,6 @@ public class AskServiceImpl implements AskService { talkResultResVO.setActionType(new MD5().digestHex16(configAncillaryItem.getType())); } } - } @Override @@ -203,7 +130,7 @@ public class AskServiceImpl implements AskService { // 根据processId找到对应的病人 Process process = Optional.ofNullable(processService.getById(talkReqVO.getProcessId())).orElseThrow(() -> new BusinessException("未找到诊疗进程")); // 调用rasa获取文字内容 - String rasaResult = RasaUtil.talkRasa(talkReqVO.getText(), UserUtil.getUser().getId()); + String rasaResult = talkRasa(talkReqVO.getText(), UserUtil.getUser().getId()); log.info("rasa的回复是:{}", rasaResult); TalkResultResVO talkResultResVO = new TalkResultResVO(); // 如果rasa没有识别出来,则返回默认值 @@ -287,6 +214,25 @@ public class AskServiceImpl implements AskService { return talkResultResVO; } + public String talkRasa(String question, String sessionId) { + RasaTalkVo rasaTalkVo = new RasaTalkVo(); + rasaTalkVo.setQuestion(question); + rasaTalkVo.setSessionId(sessionId); + // 默认为1 + rasaTalkVo.setModelId("1"); + GlobalResult> talk = rasaManageFeignClient.talk(rasaTalkVo); + log.info("调用rasa对话返回结果:{}", talk); + try { + if (talk.getCode() != 200 || CollUtil.isEmpty(talk.getData())) { + return "对不起,我没有听懂您说的是什么意思"; + } + return CollUtil.getFirst(talk.getData()); + } catch (Exception e) { + log.error("talkRasa error ", e); + } + return "对不起,我没有听懂您说的是什么意思"; + } + /** * 获取应答视频的base64位编码 diff --git a/virtual-patient-web/src/main/java/com/supervision/service/impl/RasaServiceImpl.java b/virtual-patient-web/src/main/java/com/supervision/service/impl/RasaServiceImpl.java deleted file mode 100644 index 9d849132..00000000 --- a/virtual-patient-web/src/main/java/com/supervision/service/impl/RasaServiceImpl.java +++ /dev/null @@ -1,247 +0,0 @@ -package com.supervision.service.impl; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.io.FileUtil; -import cn.hutool.core.io.IoUtil; -import cn.hutool.core.util.StrUtil; -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; -import cn.hutool.http.HttpUtil; -import cn.hutool.json.JSONUtil; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.supervision.domain.GlobalResult; -import com.supervision.exception.BusinessException; -import com.supervision.model.*; -import com.supervision.pojo.rasa.train.DomainYmlTemplate; -import com.supervision.pojo.rasa.train.NluYmlTemplate; -import com.supervision.pojo.rasa.train.QuestionAnswerDTO; -import com.supervision.pojo.rasa.train.RuleYmlTemplate; -import com.supervision.service.*; -import freemarker.template.Configuration; -import freemarker.template.Template; -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.stereotype.Service; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.PrintWriter; -import java.util.*; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.zip.ZipEntry; -import java.util.zip.ZipOutputStream; - -@Slf4j -@Service -@RequiredArgsConstructor -public class RasaServiceImpl implements RasaService { - - private final ConfigPhysicalToolService configPhysicalToolService; - - private final ConfigAncillaryItemService configAncillaryItemService; - - private final AskTemplateQuestionLibraryService askTemplateQuestionLibraryService; - - - private static final ObjectMapper objectMapper = new ObjectMapper(); - - @Value("${rasa.base-url}${rasa.saveRasaFile}") - private String saveRasaFileUrl; - - @Value("${rasa.base-url}${rasa.train}") - private String trainRasaUrl; - - @Value("${rasa.base-url}${rasa.run}") - private String runRasaUrl; - - @Override - public GlobalResult generateRasaYml(String patientId) { - - Map ymalFileMap = new HashMap<>(); - // 默认问答MAP - Map questionCodeAndIdMap = new HashMap<>(); - - List ruleList = new ArrayList<>(); - - // 开始生成各种yaml文件 - generateNlu(patientId, questionCodeAndIdMap, ymalFileMap); - generateDomain(questionCodeAndIdMap, ruleList, ymalFileMap); - generateRule(ruleList, ymalFileMap); - // 生成压缩文件 - List tempFile = new ArrayList<>(); - File tempZipFile = FileUtil.createTempFile(".zip", true); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - try (ZipOutputStream zipOutputStream = new ZipOutputStream(bos)) { - for (Map.Entry fileEntry : ymalFileMap.entrySet()) { - zipOutputStream.putNextEntry(new ZipEntry(fileEntry.getKey())); - IoUtil.copy(FileUtil.getInputStream(fileEntry.getValue()), zipOutputStream); - zipOutputStream.closeEntry(); - tempFile.add(fileEntry.getValue()); - } - zipOutputStream.finish(); - // 调用接口传文件 - HttpRequest request = HttpRequest.post(saveRasaFileUrl); - IoUtil.copy(new ByteArrayInputStream(bos.toByteArray()), FileUtil.getOutputStream(tempZipFile)); - request.form("file", tempZipFile); - request.form("modelId", patientId); - HttpResponse response = request.execute(); - String responseBody = response.body(); - log.info(responseBody); - return objectMapper.readValue(responseBody, new TypeReference>() { - }); - } catch (Exception e) { - log.error("生成ZIP文件失败", e); - throw new BusinessException("生成ZIP文件失败"); - } finally { - // 最后把临时文件删除 - tempFile.forEach(FileUtil::del); - FileUtil.del(tempZipFile); - } - } - - private void generateNlu(String patientId, - Map intentCodeAndIdMap, - Map ymalFileMap) { - // 首先生成根据意图查找到nlu文件 - List nluList = new ArrayList<>(); - - // 默认意图 - List askTemplateQuestionLibraryList = askTemplateQuestionLibraryService.lambdaQuery().list(); - // 生成默认意图的nlu - for (AskTemplateQuestionLibrary questionLibrary : askTemplateQuestionLibraryList) { - // 开始生成 - NluYmlTemplate.Nlu nlu = new NluYmlTemplate.Nlu(); - // 拼接格式:code_id(防止重复) - String intentCode = questionLibrary.getCode() + "_" + questionLibrary.getId(); - nlu.setIntent(intentCode); - nlu.setExamples(questionLibrary.getQuestion()); - nluList.add(nlu); - // 添加到map中,key为意图编码,value为意图ID - intentCodeAndIdMap.put(intentCode, new QuestionAnswerDTO(questionLibrary.getQuestion(), CollUtil.newArrayList( questionLibrary.getId()), questionLibrary.getDescription())); - } - - // 这里处理呼出的问题(code和问题不能为空) - List physicalToolList = configPhysicalToolService.lambdaQuery() - .isNotNull(ConfigPhysicalTool::getCode) - .isNotNull(ConfigPhysicalTool::getCallOutQuestion).list(); - - for (ConfigPhysicalTool tool : physicalToolList) { - // 把呼出的问题全部加进去 - NluYmlTemplate.Nlu nlu = new NluYmlTemplate.Nlu(); - String toolIntent = "tool_" + tool.getCode(); - nlu.setIntent(toolIntent); - nlu.setExamples(tool.getCallOutQuestion()); - nluList.add(nlu); - // answer格式为:---tool---工具ID - intentCodeAndIdMap.put(toolIntent, - new QuestionAnswerDTO(tool.getCallOutQuestion(), - CollUtil.newArrayList("tool_" + tool.getId()), "tool-" + tool.getToolName())); - } - - // 生成呼出的辅助检查 - List ancillaryItemList = configAncillaryItemService.lambdaQuery() - .isNotNull(ConfigAncillaryItem::getCode) - .isNotNull(ConfigAncillaryItem::getCallOutQuestion).list(); - - for (ConfigAncillaryItem ancillary : ancillaryItemList) { - // 把辅助问诊的问题全部加进去 - NluYmlTemplate.Nlu nlu = new NluYmlTemplate.Nlu(); - String itemIntent = "ancillary_" + ancillary.getCode(); - nlu.setIntent(itemIntent); - nlu.setExamples(ancillary.getCallOutQuestion()); - nluList.add(nlu); - // answer格式为:---ancillary---工具ID - intentCodeAndIdMap.put(itemIntent, - new QuestionAnswerDTO(ancillary.getCallOutQuestion(), - CollUtil.newArrayList("ancillary_" + ancillary.getId()), "呼出-ancillary-" + ancillary.getItemName())); - } - NluYmlTemplate nluYmlTemplate = new NluYmlTemplate(); - nluYmlTemplate.setNlu(nluList); - - // 生成后生成yml文件 - createYmlFile(NluYmlTemplate.class, "nlu.ftl", nluYmlTemplate, "nlu.yml", ymalFileMap); - - } - - - public void generateDomain(Map questionCodeAndIdMap, - List ruleList, Map ymalFileMap) { - LinkedHashMap> responses = new LinkedHashMap<>(); - for (Map.Entry entry : questionCodeAndIdMap.entrySet()) { - String intentCode = entry.getKey(); - QuestionAnswerDTO value = entry.getValue(); - String utter = "utter_" + intentCode; - responses.put(utter, CollUtil.newArrayList(value.getAnswerList())); - ruleList.add(new RuleYmlTemplate.Rule(value.getDesc(), intentCode, utter)); - } - - - DomainYmlTemplate domainYmlTemplate = new DomainYmlTemplate(); - // 意图 - List intentList = new ArrayList<>(questionCodeAndIdMap.keySet()); - domainYmlTemplate.setIntents(intentList); - // 回复 - domainYmlTemplate.setResponses(responses); - // action - List actionList = new ArrayList<>(responses.keySet()); - domainYmlTemplate.setActions(actionList); - // 生成yml文件 - createYmlFile(DomainYmlTemplate.class, "domain.ftl", domainYmlTemplate, "domain.yml", ymalFileMap); - } - - /** - * 生成rule - */ - public void generateRule(List ruleList, Map ymalFileMap) { - RuleYmlTemplate ruleYmlTemplate = new RuleYmlTemplate(); - ruleYmlTemplate.setRules(ruleList); - // 生成yml文件 - createYmlFile(RuleYmlTemplate.class, "rules.ftl", ruleYmlTemplate, "rules.yml", ymalFileMap); - } - - private void createYmlFile(Class clazz, String ftlName, Object data, String ymlName, Map ymalFileMap) { - try { - // 这个版本和maven依赖的版本一致 - Configuration configuration = new Configuration(Configuration.VERSION_2_3_31); - configuration.setClassForTemplateLoading(clazz, "/templates"); // 模板文件的所在目录 - // 获取模板 - Template template = configuration.getTemplate(ftlName); - File tempFile = FileUtil.createTempFile(".yml", true); - // 创建输出文件 - try (PrintWriter out = new PrintWriter(tempFile);) { - // 填充并生成输出 - template.process(data, out); - } catch (Exception e) { - log.error("文件生成失败"); - } - ymalFileMap.put(ymlName, tempFile); - } catch (Exception e) { - log.error("导出模板失败", e); - } - - - } - - @Override - public GlobalResult trainRasa(String patientId) throws JsonProcessingException { - Map param = new HashMap<>(); - param.put("modelId", patientId); - String responseBody = HttpUtil.post(trainRasaUrl, JSONUtil.toJsonStr(param)); - return objectMapper.readValue(responseBody, new TypeReference>() { - }); - } - - @Override - public GlobalResult runRasa(String patientId) throws JsonProcessingException { - Map param = new HashMap<>(); - param.put("modelId", patientId); - String responseBody = HttpUtil.post(runRasaUrl, JSONUtil.toJsonStr(param)); - return objectMapper.readValue(responseBody, new TypeReference>() { - }); - } -} diff --git a/virtual-patient-web/src/main/java/com/supervision/util/RasaUtil.java b/virtual-patient-web/src/main/java/com/supervision/util/RasaUtil.java deleted file mode 100644 index 644545b7..00000000 --- a/virtual-patient-web/src/main/java/com/supervision/util/RasaUtil.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.supervision.util; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.ObjectUtil; -import cn.hutool.http.HttpUtil; -import cn.hutool.json.JSONObject; -import cn.hutool.json.JSONUtil; -import com.fasterxml.jackson.core.type.TypeReference; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.supervision.pojo.paddlespeech.res.AsrResultDTO; -import com.supervision.pojo.paddlespeech.res.PaddleSpeechResDTO; -import com.supervision.pojo.rasa.train.dto.RasaReqDTO; -import com.supervision.pojo.rasa.train.dto.RasaResDTO; -import com.supervision.vo.rasa.RasaTalkVo; -import lombok.extern.slf4j.Slf4j; -import org.springframework.core.env.Environment; - -import java.util.List; -import java.util.stream.Collectors; - -@Slf4j -public class RasaUtil { - - private static final Environment environment = SpringBeanUtil.getBean(Environment.class); - private static final String RASA_TALK_URL = environment.getProperty("rasa.base-url") + environment.getProperty("rasa.talk"); - - public static String talkRasa(String question, String sessionId) { - RasaTalkVo rasaTalkVo = new RasaTalkVo(); - rasaTalkVo.setQuestion(question); - rasaTalkVo.setSessionId(sessionId); - // 默认为1 - rasaTalkVo.setModelId("1"); - String post = HttpUtil.post(RASA_TALK_URL, JSONUtil.toJsonStr(rasaTalkVo)); - log.info("调用rasa对话返回结果:{}", post); - try { - JSONObject entries = JSONUtil.parseObj(post); - List list = JSONUtil.toList(entries.getStr("data"), String.class); - if (CollUtil.isEmpty(list)) { - return "对不起,我没有听懂您说的是什么意思"; - } - return CollUtil.getFirst(list); - } catch (Exception e) { - log.error("talkRasa error ", e); - } - return "对不起,我没有听懂您说的是什么意思"; - } - - -} diff --git a/virtual-patient-web/src/main/resources/application-prod.yml b/virtual-patient-web/src/main/resources/application-prod.yml index 398222d1..4bce6a98 100644 --- a/virtual-patient-web/src/main/resources/application-prod.yml +++ b/virtual-patient-web/src/main/resources/application-prod.yml @@ -67,22 +67,7 @@ paddle-speech: # https://github.com/PaddlePaddle/PaddleSpeech/wiki/PaddleSpeech-Server-RESTful-API tts: http://virtual-patient-paddle-speech:8090/paddlespeech/tts asr: http://virtual-patient-paddle-speech:8090/paddlespeech/asr -rasa: - base-url: http://virtual-patient-rasa:8890/virtual-patient-rasa/ - talk: rasa/talkRasa - saveRasaFile: rasaFile/saveRasaFile - train: rasaCmd/trainExec - run: rasaCmd/runExec -human: - base-url: https://digital-human.jd.com - room-id: /getRoomId - text-driven: /text_driven - talk-status: /talkStatus - resourceMaxNumber: 5 -ws: - # nginx的wss地址(如果是wss的,那么带不带s都可以访问) - nginx-ip: virtual-patient-nginx - nginx-port: 443 + answer: # 对于没有匹配上的缺省回答ID,关联的是vp_file_resource的ID defaultNoMatchId: 1739173836351885313 From f0cba05f4e68d2f726a09489ef34c61374f2ee9a Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 22 Jan 2024 16:33:43 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=BE=AE=E6=9C=8D=E5=8A=A1=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/supervision/controller/AskController.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java index acdba171..4d85a763 100644 --- a/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java +++ b/virtual-patient-web/src/main/java/com/supervision/controller/AskController.java @@ -31,11 +31,6 @@ public class AskController { return askService.receiveVoiceFile(file); } - @ApiOperation("使用京东数字人进行对话(这个接口使用京东数字人接口来做)") - @PostMapping("/talk") - public TalkResultResVO talk(@RequestBody TalkReqVO talkReqVO) throws IOException { - return askService.talk(talkReqVO); - } @ApiOperation("使用本地视频的形式来做") @PostMapping("/talkByVideo") From 6c2c99069d01f7d990ef3b3022a04c9a3cecd2e4 Mon Sep 17 00:00:00 2001 From: liu Date: Mon, 22 Jan 2024 17:03:00 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=BE=AE=E6=9C=8D=E5=8A=A1=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/supervision/feign/RasaManageFeignClient.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/virtual-patient-web/src/main/java/com/supervision/feign/RasaManageFeignClient.java b/virtual-patient-web/src/main/java/com/supervision/feign/RasaManageFeignClient.java index dda8c97b..cfa44a1b 100644 --- a/virtual-patient-web/src/main/java/com/supervision/feign/RasaManageFeignClient.java +++ b/virtual-patient-web/src/main/java/com/supervision/feign/RasaManageFeignClient.java @@ -10,7 +10,7 @@ import java.util.List; @FeignClient(name = "virtual-patient-rasa", contextId = "VirtualPatientRasa") public interface RasaManageFeignClient { - @PostMapping("/rasa/talkRasa") + @PostMapping("/virtual-patient-rasa/rasa/talkRasa") GlobalResult> talk(@RequestBody RasaTalkVo rasaTalkVo);