From cde16e4d86afb08896a8eeaea8f22cf6f5a94aa5 Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期一, 04 十二月 2023 10:25:33 +0800
Subject: [PATCH] 代码提交
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java | 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java | 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/DingTalkController.java | 2
smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java | 489 ++++++++++++++++++++++++
smartor/src/main/java/com/smartor/service/impl/BaseSmsaccountServiceImpl.java | 2
smartor/pom.xml | 18
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/BaseTagController.java | 2
ruoyi-admin/src/main/java/com/ruoyi/web/controller/socket/SocketCommunication.java | 15
smartor/src/main/resources/mapper/smartor/SvyLibTopicdirectionMapper.xml | 66 +++
smartor/src/main/java/com/smartor/mapper/SvyLibTopicdirectionMapper.java | 63 +++
smartor/src/main/java/com/smartor/service/impl/SvyLibTopicdirectionServiceImpl.java | 94 ++++
ruoyi-admin/src/main/java/com/ruoyi/web/test/WeChatService.java | 3
ruoyi-admin/pom.xml | 13
ruoyi-admin/src/main/java/com/ruoyi/web/test/DingTalkService.java | 2
smartor/src/main/java/com/smartor/service/ISvyLibTopicdirectionService.java | 62 +++
ruoyi-admin/src/main/resources/application.yml | 6
smartor/src/main/java/com/smartor/service/PersonVoiceService.java | 24 +
ruoyi-common/pom.xml | 7
/dev/null | 22 -
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/PersonVoiceController.java | 81 ++++
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java | 4
ruoyi-admin/src/main/resources/application-druid.yml | 26 +
ruoyi-common/src/main/java/com/ruoyi/common/html/AnalysisHTML.java | 90 ++++
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java | 2
smartor/src/main/java/com/smartor/domain/SvyLibTopicdirection.java | 79 +++
25 files changed, 1,130 insertions(+), 48 deletions(-)
diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml
index 2c904b4..1d17e3d 100644
--- a/ruoyi-admin/pom.xml
+++ b/ruoyi-admin/pom.xml
@@ -8,7 +8,7 @@
<version>3.8.5</version>
</parent>
<modelVersion>4.0.0</modelVersion>
-<!-- <packaging>war</packaging>-->
+ <!-- <packaging>war</packaging>-->
<packaging>jar</packaging>
<artifactId>smartor-admin</artifactId>
@@ -120,6 +120,17 @@
<version>2.3</version>
</dependency>
+ <dependency>
+ <groupId>org.ssssssss</groupId>
+ <artifactId>magic-api-spring-boot-starter</artifactId>
+ <version>1.3.0</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.alibaba.nls</groupId>
+ <artifactId>nls-sdk-common</artifactId>
+ <version>2.1.6</version>
+ </dependency>
</dependencies>
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/BaseTagController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/BaseTagController.java
index f8d2ac2..0ec41b1 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/BaseTagController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/BaseTagController.java
@@ -45,7 +45,7 @@
@ApiOperation("鏌ヨ鏍囩鍒楄〃")
@PreAuthorize("@ss.hasPermi('system:tag:list')")
@PostMapping("/list")
- public TableDataInfo list(@RequestBody BaseTag baseTag) {
+ public TableDataInfo list(BaseTag baseTag) {
startPage();
List<BaseTag> list = baseTagService.selectBaseTagList(baseTag);
return getDataTable(list);
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SendMessageIn.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SendMessageIn.java
deleted file mode 100644
index e64c668..0000000
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SendMessageIn.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.ruoyi.web.controller.smartor;
-
-import lombok.Data;
-
-import java.util.List;
-
-@Data
-public class SendMessageIn {
-
- //娑堟伅绫诲瀷
- private String msgType;
- //webhook
- private String webhook;
- //瀵嗛挜
- private String secret;
- //鏂囨湰
- private String text;
- //鎸囧畾瀵硅薄
- private List<String> mobileList;
- //鏄惁鎺ㄩ�佹墍鏈変汉
- private boolean isAtAll;
-}
\ No newline at end of file
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/BaseSmsaccountController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java
similarity index 98%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/BaseSmsaccountController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java
index abc76de..679d6e2 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/BaseSmsaccountController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java
@@ -1,6 +1,7 @@
-package com.ruoyi.web.controller.smartor;
+package com.ruoyi.web.controller.smartor.tools;
import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
@@ -102,6 +103,7 @@
*/
@ApiOperation("鐭俊鍙戦��")
@PostMapping("/sendMsg")
+ @RepeatSubmit
public AjaxResult sendMsg(@RequestBody BaseSmsRequest baseSmsRequest) {
if (baseSmsaccountService.sendMsg(baseSmsRequest) == null) {
return error();
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/DingTalkController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/DingTalkController.java
similarity index 96%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/DingTalkController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/DingTalkController.java
index e2d943a..d060ea4 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/DingTalkController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/DingTalkController.java
@@ -1,4 +1,4 @@
-package com.ruoyi.web.controller.smartor;
+package com.ruoyi.web.controller.smartor.tools;
import com.ruoyi.common.core.controller.BaseController;
import com.smartor.domain.DingTalkReqVo;
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/PersonVoiceController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/PersonVoiceController.java
new file mode 100644
index 0000000..b1b312f
--- /dev/null
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/PersonVoiceController.java
@@ -0,0 +1,81 @@
+package com.ruoyi.web.controller.smartor.tools;
+
+import afu.org.checkerframework.checker.oigj.qual.O;
+import com.alibaba.nls.client.AccessToken;
+import com.alibaba.nls.client.protocol.NlsClient;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.annotation.RepeatSubmit;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.smartor.domain.BaseSmsRequest;
+import com.smartor.domain.BaseSmsaccount;
+import com.smartor.domain.BatchBaseSmsRequest;
+import com.smartor.domain.TemplateSmsRequest;
+import com.smartor.service.DingTalkService;
+import com.smartor.service.IBaseSmsaccountService;
+import com.smartor.service.PersonVoiceService;
+import com.taobao.api.ApiException;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 浜哄伐璇煶Controller
+ *
+ * @author ls
+ * @date 2023-11-17
+ */
+@Api(description = "浜哄伐璇煶")
+@RestController
+@RequestMapping("/smartor/voice")
+public class PersonVoiceController extends BaseController {
+ @Autowired
+ private PersonVoiceService personVoiceService;
+
+
+ @ApiOperation("璇煶杞枃瀛�")
+ @GetMapping("/speechtotext")
+ public Map<String, Object> speechtotext(@RequestParam("filePath") String filePath) {
+ String recognizerListener = personVoiceService.speechtotext(filePath);
+ return success(recognizerListener);
+ }
+
+ @ApiOperation("鏂囧瓧杞闊�")
+ @GetMapping("/texttospeech")
+ public Map<String, Object> texttospeech(@RequestParam("textspeech") String textspeech) {
+ String recognizerListener = personVoiceService.texttospeech(textspeech);
+ return success(recognizerListener);
+ }
+
+ @ApiOperation("html鏂囦欢澶勭悊")
+ @GetMapping("/explainHTML")
+ public Map<String, Object> explainHTML() {
+ Boolean aBoolean = personVoiceService.explainHTML();
+ return success(aBoolean);
+ }
+
+}
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/WeChatController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
similarity index 98%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/WeChatController.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
index df021f2..ecbc125 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/WeChatController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
@@ -1,4 +1,4 @@
-package com.ruoyi.web.controller.smartor;
+package com.ruoyi.web.controller.smartor.tools;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/socket/SocketCommunication.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/socket/SocketCommunication.java
index 2fbb8ec..65d84fc 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/socket/SocketCommunication.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/socket/SocketCommunication.java
@@ -85,8 +85,8 @@
//鑾峰彇杩斿洖鏁版嵁
String messageControlID = list.get(9);
String timeOfAnEvent = list.get(6);
- String senderApp = list.get(2);
- String senderFac = list.get(3);
+// String senderApp = list.get(2);
+// String senderFac = list.get(3);
String dataType = list.get(8);
if (StringUtils.isNotEmpty(dataType)) {
@@ -104,10 +104,13 @@
ACK ack = new ACK();
ack.initQuickstart("ACK", "2.4", "P");
// 璁剧疆MSH娈电殑瀛楁
- ack.getMSH().getSendingApplication().getNamespaceID().setValue("HIS");
- ack.getMSH().getSendingFacility().getNamespaceID().setValue(senderFac);
- ack.getMSH().getReceivingApplication().getNamespaceID().setValue(senderApp);
- ack.getMSH().getReceivingFacility().getNamespaceID().setValue(senderFac);
+ ack.getMSH().getSendingApplication().getNamespaceID().setValue("SF");
+// ack.getMSH().getSendingFacility().getNamespaceID().setValue(senderFac);
+ ack.getMSH().getSendingFacility().getNamespaceID().setValue("SF");
+// ack.getMSH().getReceivingApplication().getNamespaceID().setValue(senderApp);
+ ack.getMSH().getReceivingApplication().getNamespaceID().setValue("QN");
+// ack.getMSH().getReceivingFacility().getNamespaceID().setValue(senderFac);
+ ack.getMSH().getReceivingFacility().getNamespaceID().setValue("QN");
ack.getMSH().getDateTimeOfMessage().getTimeOfAnEvent().setValue(timeOfAnEvent);
ack.getMSH().getMessageType().getMessageType().setValue("ACK");
ack.getMSH().getMessageType().getTriggerEvent().setValue("ACK");
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/DingTalkService.java b/ruoyi-admin/src/main/java/com/ruoyi/web/test/DingTalkService.java
similarity index 99%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/DingTalkService.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/test/DingTalkService.java
index d4a9326..945cc11 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/DingTalkService.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/test/DingTalkService.java
@@ -1,4 +1,4 @@
-package com.ruoyi.web.controller.smartor;
+package com.ruoyi.web.test;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/WeChatService.java b/ruoyi-admin/src/main/java/com/ruoyi/web/test/WeChatService.java
similarity index 97%
rename from ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/WeChatService.java
rename to ruoyi-admin/src/main/java/com/ruoyi/web/test/WeChatService.java
index 076057d..5b05d38 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/WeChatService.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/test/WeChatService.java
@@ -1,7 +1,8 @@
-package com.ruoyi.web.controller.smartor;
+package com.ruoyi.web.test;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
+import com.ruoyi.web.controller.smartor.tools.WeChatController;
import com.smartor.domain.WeChatSendVo;
import me.chanjar.weixin.common.exception.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpInMemoryConfigStorage;
diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml
index 0f46331..5f45c63 100644
--- a/ruoyi-admin/src/main/resources/application-druid.yml
+++ b/ruoyi-admin/src/main/resources/application-druid.yml
@@ -6,12 +6,12 @@
druid:
# 涓诲簱鏁版嵁婧�
master:
- url: jdbc:mysql://127.0.0.1:3306/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
-# url: jdbc:mysql://116.62.18.175:6002/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
- username: root
- password: 123456
-# username: hxsoft
-# password: Hxerp2000
+# url: jdbc:mysql://127.0.0.1:3306/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+ # username: root
+ # password: 123456
+ url: jdbc:mysql://116.62.18.175:6002/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+ username: hxsoft
+ password: Hxerp2000
# 浠庡簱鏁版嵁婧�
slave:
# 浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴
@@ -59,6 +59,20 @@
config:
multi-statement-allow: true
+magic-api:
+ web: /magic/web
+ resource:
+ type: database # 閰嶇疆瀛樺偍鍦ㄦ暟鎹簱涓�
+ tableName: magic_config # 鏁版嵁搴撲腑鐨勮〃鍚�
+ prefix: /api
+ readonly: false
+ sql-column-case: camel
+ show-sql: true #閰嶇疆鎵撳嵃SQL
+ page-config:
+ size: size
+ page: page
+ default-page: 1
+ default-size: 10
#寰俊鍏紬鍙风殑瀵嗛挜
appid: wx1c5243d2337753f4
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index eee2def..22c8630 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -18,7 +18,7 @@
# 寮�鍙戠幆澧冮厤缃�
server:
# 鏈嶅姟鍣ㄧ殑HTTP绔彛锛岄粯璁や负8080
- port: 8181
+ port: 8080
servlet:
# 搴旂敤鐨勮闂矾寰�
context-path: /
@@ -70,11 +70,11 @@
# redis 閰嶇疆
redis:
# 鍦板潃
- host: 127.0.0.1
+# host: 127.0.0.1
# 绔彛锛岄粯璁や负6379
# port: 6379
# # 鍦板潃
-# host: 116.62.18.175
+ host: 116.62.18.175
# # 绔彛锛岄粯璁や负6379
port: 6020
# 鏁版嵁搴撶储寮�
diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml
index bb034c6..3bd1426 100644
--- a/ruoyi-common/pom.xml
+++ b/ruoyi-common/pom.xml
@@ -17,6 +17,13 @@
<dependencies>
+ <!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
+ <dependency>
+ <groupId>org.jsoup</groupId>
+ <artifactId>jsoup</artifactId>
+ <version>1.15.3</version>
+ </dependency>
+
<dependency>
<groupId>io.minio</groupId>
<artifactId>minio</artifactId>
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/html/AnalysisHTML.java b/ruoyi-common/src/main/java/com/ruoyi/common/html/AnalysisHTML.java
new file mode 100644
index 0000000..99a7be3
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/html/AnalysisHTML.java
@@ -0,0 +1,90 @@
+package com.ruoyi.common.html;
+
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.util.stream.Collectors;
+
+/**
+ * 瑙f瀽html
+ */
+public class AnalysisHTML {
+
+ public static String explainHTML() throws IOException {
+ String folderPath = "E:\\pc2";
+ // 鑾峰彇鏂囦欢澶逛笅鐨勬墍鏈夋枃浠�
+ File[] files = new File(folderPath).listFiles();
+ // 閬嶅巻鏂囦欢澶逛笅鐨勬墍鏈夋枃浠�
+ int i = 0;
+ int b = 0;
+ a:
+ for (File file : files) {
+ // 鑾峰彇鏂囦欢鍚�
+ String fileName = file.getName();
+ System.out.println(fileName);
+ // 鑾峰彇鏂囦欢鍐呭
+ String fileContent = new String(Files.readAllBytes(file.toPath()));
+
+ Document parse = Jsoup.parse(fileContent);
+
+ String title = parse.title();
+ Element body = parse.body();
+ Elements elementsByClass = body.getElementsByClass("topic__type-body");
+ Elements children = elementsByClass.get(0).children();
+ for (Element element : children) {
+ int legend = element.select("legend").size();
+ File file1 = null;
+ if (legend == 0) {
+ //璺宠繃璇ユ枃浠�
+ file1 = new File("E:\\noexplain");
+ b++;
+ continue a;
+ }
+ if (!element.getElementsByTag("legend").attr("class").equals("topic__type-title")) {
+ //璺宠繃璇ユ枃浠�
+ file1 = new File("E:\\noexplain");
+ b++;
+ continue a;
+ }
+ }
+
+ for (Element element : children) {
+ i++;
+ //鑾峰彇棰樼洰
+ String legend = element.getElementsByTag("legend").text();
+ System.out.println("棰樼洰锛� " + legend);
+ //灏嗛鐩繚瀛樺埌琛ㄤ腑
+
+ //鍒ゆ柇璇ラ鐩笅鏄惁鏈夐�夐」
+ Elements elementsByClass1 = element.getElementsByClass("topic__type-dry");
+ if (elementsByClass1.size() != 0) {
+ Elements spans = elementsByClass1.get(0).getElementsByTag("span");
+ String item = "";
+ for (Element span : spans) {
+ Elements labels = span.getElementsByTag("label");
+ for (Element label : labels) {
+ String text = label.text();
+ //灏嗛鐩瓨搴�
+ item = item + "------" + text;
+ }
+ }
+ System.out.println("閫夐」锛� " + item);
+ }
+
+ }
+
+ }
+ System.out.println(i + " " + b);
+
+ return null;
+ }
+
+ public static void main(String[] args) throws IOException {
+ explainHTML();
+ }
+}
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
index f85c82c..e939194 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
@@ -69,7 +69,7 @@
try
{
String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url;
- log.info("sendGet - {}", urlNameString);
+// log.info("sendGet - {}", urlNameString);
URL realUrl = new URL(urlNameString);
URLConnection connection = realUrl.openConnection();
connection.setRequestProperty("accept", "*/*");
@@ -82,7 +82,7 @@
{
result.append(line);
}
- log.info("recv - {}", result);
+ // log.info("recv - {}", result);
}
catch (ConnectException e)
{
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
index 7b4d3bb..6a0d547 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -108,7 +108,7 @@
// 杩囨护璇锋眰
.authorizeRequests()
// 瀵逛簬鐧诲綍login 娉ㄥ唽register 楠岃瘉鐮乧aptchaImage 鍏佽鍖垮悕璁块棶
- .antMatchers("/login", "/register", "/captchaImage", "/qrcode/generateStaticHtml", "/qrcode/getQRcode", "/qrcode/getFormDate", "/chat", "/system/file/admin/uploadFile", "/smartor/dingtalk/sendNotification", "/patient/read/patientInfo","/socket","/API_ESB_Service","/API_ESB_Service/Run").permitAll()
+ .antMatchers("/login", "/register", "/captchaImage", "/qrcode/generateStaticHtml", "/qrcode/getQRcode", "/qrcode/getFormDate", "/chat", "/system/file/admin/uploadFile", "/smartor/dingtalk/sendNotification", "/patient/read/patientInfo","/socket","/API_ESB_Service","/API_ESB_Service/Run","/magic/web/**").permitAll()
// 闈欐�佽祫婧愶紝鍙尶鍚嶈闂�
.antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll().antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
// 闄や笂闈㈠鐨勬墍鏈夎姹傚叏閮ㄩ渶瑕侀壌鏉冭璇�
diff --git a/smartor/pom.xml b/smartor/pom.xml
index 7babc73..081a1c8 100644
--- a/smartor/pom.xml
+++ b/smartor/pom.xml
@@ -77,6 +77,24 @@
<artifactId>javase</artifactId>
<version>3.5.1</version>
</dependency>
+
+ <dependency>
+ <groupId>com.alibaba.nls</groupId>
+ <artifactId>nls-sdk-recognizer</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>com.alibaba.nls</groupId>
+ <artifactId>nls-sdk-recognizer</artifactId>
+ <version>2.2.1</version>
+ <scope>compile</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.alibaba.nls</groupId>
+ <artifactId>nls-sdk-tts</artifactId>
+ <version>2.2.1</version>
+ </dependency>
</dependencies>
diff --git a/smartor/src/main/java/com/smartor/domain/SvyLibTopicdirection.java b/smartor/src/main/java/com/smartor/domain/SvyLibTopicdirection.java
new file mode 100644
index 0000000..4054891
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/domain/SvyLibTopicdirection.java
@@ -0,0 +1,79 @@
+package com.smartor.domain;
+
+import com.ruoyi.common.annotation.Excel;
+import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+/**
+ * 銆愯濉啓鍔熻兘鍚嶇О銆戝璞� svy_lib_topicdirection
+ *
+ * @author ruoyi
+ * @date 2023-11-28
+ */
+public class SvyLibTopicdirection extends BaseEntity
+{
+ private static final long serialVersionUID = 1L;
+
+ /** $column.columnComment */
+ private Long id;
+
+ /** 棰樼洰琛╥d */
+ @Excel(name = "棰樼洰琛╥d")
+ private Long topicid;
+
+ /** 妯悜鐨� */
+ @Excel(name = "妯悜鐨�")
+ private String transverse;
+
+ /** 绾靛彿鐨� */
+ @Excel(name = "绾靛彿鐨�")
+ private String direction;
+
+ public void setId(Long id)
+ {
+ this.id = id;
+ }
+
+ public Long getId()
+ {
+ return id;
+ }
+ public void setTopicid(Long topicid)
+ {
+ this.topicid = topicid;
+ }
+
+ public Long getTopicid()
+ {
+ return topicid;
+ }
+ public void setTransverse(String transverse)
+ {
+ this.transverse = transverse;
+ }
+
+ public String getTransverse()
+ {
+ return transverse;
+ }
+ public void setDirection(String direction)
+ {
+ this.direction = direction;
+ }
+
+ public String getDirection()
+ {
+ return direction;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
+ .append("id", getId())
+ .append("topicid", getTopicid())
+ .append("transverse", getTransverse())
+ .append("direction", getDirection())
+ .toString();
+ }
+}
diff --git a/smartor/src/main/java/com/smartor/mapper/SvyLibTopicdirectionMapper.java b/smartor/src/main/java/com/smartor/mapper/SvyLibTopicdirectionMapper.java
new file mode 100644
index 0000000..bd9dc95
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/mapper/SvyLibTopicdirectionMapper.java
@@ -0,0 +1,63 @@
+package com.smartor.mapper;
+
+import com.smartor.domain.SvyLibTopicdirection;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * 銆愯濉啓鍔熻兘鍚嶇О銆慚apper鎺ュ彛
+ *
+ * @author ruoyi
+ * @date 2023-11-28
+ */
+@Mapper
+public interface SvyLibTopicdirectionMapper {
+ /**
+ * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿�
+ * @return 銆愯濉啓鍔熻兘鍚嶇О銆�
+ */
+ public SvyLibTopicdirection selectSvyLibTopicdirectionById(Long id);
+
+ /**
+ * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛�
+ *
+ * @param svyLibTopicdirection 銆愯濉啓鍔熻兘鍚嶇О銆�
+ * @return 銆愯濉啓鍔熻兘鍚嶇О銆戦泦鍚�
+ */
+ public List<SvyLibTopicdirection> selectSvyLibTopicdirectionList(SvyLibTopicdirection svyLibTopicdirection);
+
+ /**
+ * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param svyLibTopicdirection 銆愯濉啓鍔熻兘鍚嶇О銆�
+ * @return 缁撴灉
+ */
+ public int insertSvyLibTopicdirection(SvyLibTopicdirection svyLibTopicdirection);
+
+ /**
+ * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param svyLibTopicdirection 銆愯濉啓鍔熻兘鍚嶇О銆�
+ * @return 缁撴灉
+ */
+ public int updateSvyLibTopicdirection(SvyLibTopicdirection svyLibTopicdirection);
+
+ /**
+ * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿�
+ * @return 缁撴灉
+ */
+ public int deleteSvyLibTopicdirectionById(Long id);
+
+ /**
+ * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑鏁版嵁涓婚敭闆嗗悎
+ * @return 缁撴灉
+ */
+ public int deleteSvyLibTopicdirectionByIds(Long[] ids);
+}
diff --git a/smartor/src/main/java/com/smartor/service/ISvyLibTopicdirectionService.java b/smartor/src/main/java/com/smartor/service/ISvyLibTopicdirectionService.java
new file mode 100644
index 0000000..3b8fb98
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/ISvyLibTopicdirectionService.java
@@ -0,0 +1,62 @@
+package com.smartor.service;
+
+import com.smartor.domain.SvyLibTopicdirection;
+
+import java.util.List;
+
+/**
+ * 銆愯濉啓鍔熻兘鍚嶇О銆慡ervice鎺ュ彛
+ *
+ * @author ruoyi
+ * @date 2023-11-28
+ */
+public interface ISvyLibTopicdirectionService
+{
+ /**
+ * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿�
+ * @return 銆愯濉啓鍔熻兘鍚嶇О銆�
+ */
+ public SvyLibTopicdirection selectSvyLibTopicdirectionById(Long id);
+
+ /**
+ * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛�
+ *
+ * @param svyLibTopicdirection 銆愯濉啓鍔熻兘鍚嶇О銆�
+ * @return 銆愯濉啓鍔熻兘鍚嶇О銆戦泦鍚�
+ */
+ public List<SvyLibTopicdirection> selectSvyLibTopicdirectionList(SvyLibTopicdirection svyLibTopicdirection);
+
+ /**
+ * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param svyLibTopicdirection 銆愯濉啓鍔熻兘鍚嶇О銆�
+ * @return 缁撴灉
+ */
+ public int insertSvyLibTopicdirection(SvyLibTopicdirection svyLibTopicdirection);
+
+ /**
+ * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param svyLibTopicdirection 銆愯濉啓鍔熻兘鍚嶇О銆�
+ * @return 缁撴灉
+ */
+ public int updateSvyLibTopicdirection(SvyLibTopicdirection svyLibTopicdirection);
+
+ /**
+ * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑銆愯濉啓鍔熻兘鍚嶇О銆戜富閿泦鍚�
+ * @return 缁撴灉
+ */
+ public int deleteSvyLibTopicdirectionByIds(Long[] ids);
+
+ /**
+ * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆戜俊鎭�
+ *
+ * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿�
+ * @return 缁撴灉
+ */
+ public int deleteSvyLibTopicdirectionById(Long id);
+}
diff --git a/smartor/src/main/java/com/smartor/service/PersonVoiceService.java b/smartor/src/main/java/com/smartor/service/PersonVoiceService.java
new file mode 100644
index 0000000..59b7785
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/PersonVoiceService.java
@@ -0,0 +1,24 @@
+package com.smartor.service;
+
+import com.alibaba.nls.client.protocol.asr.SpeechRecognizerListener;
+
+/**
+ * 瀹f暀鍒嗙被Service鎺ュ彛
+ *
+ * @author smartor
+ * @date 2023-03-04
+ */
+public interface PersonVoiceService {
+ /**
+ * 涓�鍙ヨ瘽璇嗗埆
+ */
+ public String speechtotext(String filePath);
+
+
+ /**
+ * 涓�鍙ヨ瘽璇嗗埆
+ */
+ public String texttospeech(String textspeech);
+
+ public Boolean explainHTML();
+}
diff --git a/smartor/src/main/java/com/smartor/service/impl/BaseSmsaccountServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/BaseSmsaccountServiceImpl.java
index 12aae85..b11049d 100644
--- a/smartor/src/main/java/com/smartor/service/impl/BaseSmsaccountServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/BaseSmsaccountServiceImpl.java
@@ -272,7 +272,7 @@
}
- public Client createClient() throws Exception {
+ private Client createClient() throws Exception {
Config config = new Config()
// 蹇呭~锛屾偍鐨� AccessKey ID
.setAccessKeyId(this.accessKeyId)
diff --git a/smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java
new file mode 100644
index 0000000..95fab99
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java
@@ -0,0 +1,489 @@
+package com.smartor.service.impl;
+
+import com.alibaba.nls.client.AccessToken;
+import com.alibaba.nls.client.protocol.InputFormatEnum;
+import com.alibaba.nls.client.protocol.NlsClient;
+import com.alibaba.nls.client.protocol.OutputFormatEnum;
+import com.alibaba.nls.client.protocol.SampleRateEnum;
+import com.alibaba.nls.client.protocol.asr.SpeechRecognizer;
+import com.alibaba.nls.client.protocol.asr.SpeechRecognizerListener;
+import com.alibaba.nls.client.protocol.asr.SpeechRecognizerResponse;
+import com.alibaba.nls.client.protocol.tts.SpeechSynthesizer;
+import com.alibaba.nls.client.protocol.tts.SpeechSynthesizerListener;
+import com.alibaba.nls.client.protocol.tts.SpeechSynthesizerResponse;
+import com.aliyun.dysmsapi20170525.Client;
+import com.aliyun.dysmsapi20170525.models.*;
+import com.aliyun.tea.TeaException;
+import com.aliyun.teaopenapi.models.Config;
+import com.aliyun.teautil.Common;
+import com.aliyun.teautil.models.RuntimeOptions;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
+import com.smartor.domain.*;
+import com.smartor.mapper.*;
+import com.smartor.service.IBaseSmsaccountService;
+import com.smartor.service.ISvyLibTitleService;
+import com.smartor.service.PersonVoiceService;
+import lombok.extern.slf4j.Slf4j;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
+import org.jsoup.select.Elements;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.io.*;
+import java.nio.ByteBuffer;
+import java.nio.file.Files;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
+
+/**
+ * 鐭俊璐﹀彿Service涓氬姟灞傚鐞�
+ *
+ * @author smartor
+ * @date 2023-03-06
+ */
+@Slf4j
+@Service
+public class PersonVoiceServiceImpl implements PersonVoiceService {
+ @Value("${accessKeyId}")
+ private String accessKeyId;
+
+ @Value("${accessKeySecret}")
+ private String accessKeySecret;
+
+ @Autowired
+ private SvyLibTitleMapper svyLibTitleMapper;
+
+ @Autowired
+ private SvyLibTopicMapper svyLibTopicMapper;
+
+ @Autowired
+ private SvyLibTopicdirectionMapper svyLibTopicdirectionMapper;
+
+ @Autowired
+ private SvyLibTopicoptionMapper svyLibTopicoptionMapper;
+//
+// @Autowired
+// private ISvyLibTitleService svyLibTitleService;
+
+ private NlsClient client;
+
+ private String appKey = "ZurNHpaQLq6P55YS";
+
+ private String returnResult = null;
+
+ String url = System.getenv().getOrDefault("NLS_GATEWAY_URL", "wss://nls-gateway-cn-shanghai.aliyuncs.com/ws/v1");
+
+
+ @Override
+ public String speechtotext(String filePath) {
+ this.accessToken();
+ this.process(filePath, 16000);
+ client.shutdown();
+ return returnResult;
+ }
+
+ @Override
+ public String texttospeech(String textspeech) {
+ this.accessToken();
+ this.process2(textspeech);
+ client.shutdown();
+ return returnResult;
+ }
+
+ @Override
+ public Boolean explainHTML() {
+ try {
+ explainHTML2();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return true;
+ }
+
+ public String explainHTML2() throws IOException {
+ String folderPath = "E:\\pc2";
+ // 鑾峰彇鏂囦欢澶逛笅鐨勬墍鏈夋枃浠�
+ File[] files = new File(folderPath).listFiles();
+ // 閬嶅巻鏂囦欢澶逛笅鐨勬墍鏈夋枃浠�
+ a:
+ for (File file : files) {
+ // 鑾峰彇鏂囦欢鍚�
+ String fileName = file.getName();
+ System.out.println(fileName);
+ // 鑾峰彇鏂囦欢鍐呭
+ String fileContent = new String(Files.readAllBytes(file.toPath()));
+
+ Document parse = Jsoup.parse(fileContent);
+
+ //淇濆瓨title
+ String title = parse.title();
+ SvyLibTitle svyLibTitle = new SvyLibTitle();
+// svyLibTitle.setCategoryid(System.currentTimeMillis());
+ svyLibTitle.setSvyname(title);
+ svyLibTitle.setDelFlag("0");
+ svyLibTitle.setIsupload(0L);
+ svyLibTitleMapper.insertSvyLibTitle(svyLibTitle);
+
+ Element body = parse.body();
+ Elements elementsByClass = body.getElementsByClass("topic__type-body");
+ Elements children = elementsByClass.get(0).children();
+ for (Element element : children) {
+ int legend = element.select("legend").size();
+ if (legend == 0) {
+ //璺宠繃璇ユ枃浠�
+ noExpiain(fileName.substring(0, fileName.length() - 5), fileContent);
+ continue a;
+ }
+ if (!element.getElementsByTag("legend").attr("class").equals("topic__type-title")) {
+ //璺宠繃璇ユ枃浠�
+ noExpiain(fileName.substring(0, fileName.length() - 5), fileContent);
+ continue a;
+ }
+ }
+
+ for (Element element : children) {
+ //鑾峰彇棰樼洰
+ String legend = element.getElementsByTag("legend").text();
+ System.out.println("棰樼洰锛� " + legend);
+ //灏嗛鐩繚瀛樺埌琛ㄤ腑
+ SvyLibTopic svyLibTopic = new SvyLibTopic();
+ svyLibTopic.setSvyid(svyLibTitle.getSvyid());
+
+ //鍒ゆ柇璇ラ鐩笅鏄惁鏈夐�夐」
+ Elements elementsByClass1 = element.getElementsByClass("topic__type-dry");
+ if (elementsByClass1.size() != 0) {
+ Elements spans = elementsByClass1.get(0).getElementsByTag("span");
+ if (spans.size() != 0) {
+ Elements radio__type = spans.get(0).getElementsByClass("radio__type");
+ if (radio__type.size() != 0) {
+ svyLibTopic.setTopictype(1L);
+ } else {
+ Elements checkbox__type = spans.get(0).getElementsByClass("checkbox__type");
+ if (checkbox__type.size() != 0) {
+ svyLibTopic.setTopictype(2L);
+ }
+ }
+
+ }
+ svyLibTopic.setTopiccode(IdUtils.simpleUUID());
+ svyLibTopic.setTopic(legend);
+ svyLibTopic.setDelFlag("0");
+ svyLibTopic.setIsupload(0L);
+ svyLibTopic.setOrgid(fileName);
+ try {
+ svyLibTopicMapper.insertSvyLibTopic(svyLibTopic);
+ } catch (Exception e) {
+ noExpiain(fileName.substring(0, fileName.length() - 5) + "鍑哄紓甯镐簡1", fileContent);
+ continue a;
+ }
+
+
+ String item = "";
+ Long i = 1L;
+ for (Element span : spans) {
+ Elements labels = span.getElementsByTag("label");
+ for (Element label : labels) {
+ String text = label.text();
+ //灏嗛鐩瓨搴�
+// item = item + "------" + text;
+ SvyLibTopicoption svyLibTopicoption = new SvyLibTopicoption();
+ svyLibTopicoption.setTopicid(svyLibTopic.getTopicid());
+ svyLibTopicoption.setSvyid(svyLibTitle.getSvyid());
+ svyLibTopicoption.setSort(i);
+ svyLibTopicoption.setOptioncode(IdUtils.simpleUUID());
+ svyLibTopicoption.setOptioncontent(text);
+ svyLibTopicoption.setDelFlag("0");
+ svyLibTopicoption.setIsupload(0L);
+ try {
+ svyLibTopicoptionMapper.insertSvyLibTopicoption(svyLibTopicoption);
+ } catch (Exception e) {
+ noExpiain(fileName.substring(0, fileName.length() - 5) + "鍑哄紓甯镐簡2", fileContent);
+ continue a;
+ }
+ i++;
+ }
+ }
+ System.out.println("閫夐」锛� " + item);
+ } else {
+
+ //灏嗛鐩繚瀛樺埌琛ㄤ腑
+
+
+ Elements elementsByClass2 = element.getElementsByClass("ui-control-group ui-matrix");
+ if (elementsByClass2.size() > 0) {
+ SvyLibTopic svyLibTopic2 = new SvyLibTopic();
+ svyLibTopic2.setSvyid(svyLibTitle.getSvyid());
+ svyLibTopic2.setTopiccode(IdUtils.simpleUUID());
+ svyLibTopic2.setTopic(legend);
+ svyLibTopic2.setDelFlag("0");
+ svyLibTopic.setIsupload(0L);
+ svyLibTopic2.setTopictype(4L);
+ svyLibTopic2.setOrgid(fileName);
+ try {
+ svyLibTopicMapper.insertSvyLibTopic(svyLibTopic2);
+ } catch (Exception e) {
+ noExpiain(fileName.substring(0, fileName.length() - 5) + "鍑哄紓甯镐簡22", fileContent);
+ continue a;
+ }
+
+
+ Elements lis = elementsByClass2.get(0).getElementsByTag("li");
+ String transverse = "";
+ for (Element element1 : lis) {
+ transverse = transverse + element1.text() + "鈽�";
+ }
+ Elements title1 = elementsByClass2.get(0).getElementsByClass("title");
+ String direction = "";
+ for (Element ele : title1) {
+ direction = direction + ele.text() + "鈽�";
+ }
+ SvyLibTopicdirection svyLibTopicdirection = new SvyLibTopicdirection();
+ svyLibTopicdirection.setTopicid(svyLibTopic2.getTopicid());
+ svyLibTopicdirection.setDirection(direction);
+ svyLibTopicdirection.setTransverse(transverse);
+ svyLibTopicdirectionMapper.insertSvyLibTopicdirection(svyLibTopicdirection);
+ } else {
+
+
+ //灏嗛鐩繚瀛樺埌琛ㄤ腑
+ SvyLibTopic svyLibTopic3 = new SvyLibTopic();
+ svyLibTopic3.setSvyid(svyLibTitle.getSvyid());
+ svyLibTopic3.setTopiccode(IdUtils.simpleUUID());
+ svyLibTopic3.setTopic(legend);
+ svyLibTopic3.setDelFlag("0");
+ svyLibTopic3.setIsupload(0L);
+ svyLibTopic3.setTopictype(3L);
+ svyLibTopic3.setOrgid(fileName);
+ try {
+ svyLibTopicMapper.insertSvyLibTopic(svyLibTopic3);
+ } catch (Exception e) {
+ noExpiain(fileName.substring(0, fileName.length() - 5) + "鍑哄紓甯镐簡33", fileContent);
+ continue a;
+ }
+ }
+ }
+
+ }
+
+ }
+
+ return null;
+ }
+
+ private void noExpiain(String filename, String content) throws IOException {
+ File file = new File("E:\\noexplain\\" + filename + ".html");
+ FileWriter fileWriter = new FileWriter(file);
+ fileWriter.write(content);
+ }
+
+
+ public SpeechRecognizerListener getRecognizerListener(int myOrder, String userParam) {
+ SpeechRecognizerListener speechRecognizerListener = new SpeechRecognizerListener() {
+ @Override
+ public void onRecognitionResultChanged(SpeechRecognizerResponse response) {
+ //getName鏄幏鍙栦簨浠跺悕绉帮紝getStatus鏄幏鍙栫姸鎬佺爜锛実etRecognizedText鏄闊宠瘑鍒枃鏈��
+ System.out.println("name: " + response.getName() + ", status: " + response.getStatus() + ", result: " + response.getRecognizedText());
+ }
+
+ //璇嗗埆瀹屾瘯
+ @Override
+ public void onRecognitionCompleted(SpeechRecognizerResponse response) {
+ //getName鏄幏鍙栦簨浠跺悕绉帮紝getStatus鏄幏鍙栫姸鎬佺爜锛実etRecognizedText鏄闊宠瘑鍒枃鏈��
+ returnResult = response.getRecognizedText();
+ System.out.println("name: " + response.getName() + ", status: " + response.getStatus() + ", result: " + response.getRecognizedText());
+ }
+
+ @Override
+ public void onStarted(SpeechRecognizerResponse response) {
+ System.out.println("myOrder: " + myOrder + "; myParam: " + userParam + "; task_id: " + response.getTaskId());
+ }
+
+ @Override
+ public void onFail(SpeechRecognizerResponse response) {
+ //task_id鏄皟鐢ㄦ柟鍜屾湇鍔$閫氫俊鐨勫敮涓�鏍囪瘑锛屽綋閬囧埌闂鏃讹紝闇�瑕佹彁渚涙task_id銆�
+ System.out.println("task_id: " + response.getTaskId() + ", status: " + response.getStatus() + ", status_text: " + response.getStatusText());
+ }
+ };
+
+ return speechRecognizerListener;
+ }
+
+
+ public void accessToken() {
+ //搴旂敤鍏ㄥ眬鍒涘缓涓�涓狽lsClient瀹炰緥锛岄粯璁ゆ湇鍔″湴鍧�涓洪樋閲屼簯绾夸笂鏈嶅姟鍦板潃銆�
+ //鑾峰彇Token锛屽疄闄呬娇鐢ㄦ椂娉ㄦ剰鍦╝ccessToken.getExpireTime()杩囨湡鍓嶅啀娆¤幏鍙栥��
+ AccessToken accessToken = new AccessToken(accessKeyId, accessKeySecret);
+ try {
+ accessToken.apply();
+ System.out.println("get token: " + accessToken.getToken() + ", expire time: " + accessToken.getExpireTime());
+ if (url.isEmpty()) {
+ client = new NlsClient(accessToken.getToken());
+ } else {
+ client = new NlsClient(url, accessToken.getToken());
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ public void process(String filepath, int sampleRate) {
+ SpeechRecognizer recognizer = null;
+ try {
+ //浼犻�掔敤鎴疯嚜瀹氫箟鍙傛暟
+ String myParam = "user-param";
+ int myOrder = 1234;
+ SpeechRecognizerListener listener = getRecognizerListener(myOrder, myParam);
+ recognizer = new SpeechRecognizer(client, listener);
+ recognizer.setAppKey(appKey);
+ //璁剧疆闊抽缂栫爜鏍煎紡銆傚鏋滄槸OPUS鏂囦欢锛岃璁剧疆涓篒nputFormatEnum.OPUS銆�
+ recognizer.setFormat(InputFormatEnum.PCM);
+ //璁剧疆闊抽閲囨牱鐜�
+ if (sampleRate == 16000) {
+ recognizer.setSampleRate(SampleRateEnum.SAMPLE_RATE_16K);
+ } else if (sampleRate == 8000) {
+ recognizer.setSampleRate(SampleRateEnum.SAMPLE_RATE_8K);
+ }
+ //璁剧疆鏄惁杩斿洖涓棿璇嗗埆缁撴灉
+ recognizer.setEnableIntermediateResult(true);
+ //璁剧疆鏄惁鎵撳紑璇煶妫�娴嬶紙鍗硋ad锛�
+ recognizer.addCustomedParam("enable_voice_detection", true);
+ //姝ゆ柟娉曞皢浠ヤ笂鍙傛暟璁剧疆搴忓垪鍖栦负JSON鍙戦�佺粰鏈嶅姟绔紝骞剁瓑寰呮湇鍔$纭銆�
+ long now = System.currentTimeMillis();
+ recognizer.start();
+ log.info("ASR start latency : " + (System.currentTimeMillis() - now) + " ms");
+ File file = new File(filepath);
+ FileInputStream fis = new FileInputStream(file);
+ byte[] b = new byte[3200];
+ int len;
+ while ((len = fis.read(b)) > 0) {
+ log.info("send data pack length: " + len);
+ recognizer.send(b, len);
+ //鏈渚嬬敤璇诲彇鏈湴鏂囦欢鐨勫舰寮忔ā鎷熷疄鏃惰幏鍙栬闊虫祦锛屽洜涓鸿鍙栭�熷害杈冨揩锛岃繖閲岄渶瑕佽缃畇leep鏃堕暱銆�
+ // 濡傛灉瀹炴椂鑾峰彇璇煶鍒欐棤闇�璁剧疆sleep鏃堕暱锛屽鏋滄槸8k閲囨牱鐜囪闊崇浜屼釜鍙傛暟璁剧疆涓�8000銆�
+ int deltaSleep = getSleepDelta(len, sampleRate);
+// Thread.sleep(deltaSleep);
+ }
+ //閫氱煡鏈嶅姟绔闊虫暟鎹彂閫佸畬姣曪紝绛夊緟鏈嶅姟绔鐞嗗畬鎴愩��
+ now = System.currentTimeMillis();
+ //璁$畻瀹為檯寤惰繜锛岃皟鐢╯top杩斿洖涔嬪悗涓�鑸嵆鏄瘑鍒粨鏋滆繑鍥炴椂闂淬��
+ log.info("ASR wait for complete");
+ recognizer.stop();
+ log.info("ASR stop latency : " + (System.currentTimeMillis() - now) + " ms");
+ fis.close();
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ } finally {
+ //鍏抽棴杩炴帴
+ if (null != recognizer) {
+ recognizer.close();
+ }
+ }
+ }
+
+
+ public int getSleepDelta(int dataSize, int sampleRate) {
+ // 浠呮敮鎸�16浣嶉噰鏍枫��
+ int sampleBytes = 16;
+ // 浠呮敮鎸佸崟閫氶亾銆�
+ int soundChannel = 1;
+ return (dataSize * 10 * 8000) / (160 * sampleRate);
+ }
+
+
+ private SpeechSynthesizerListener getSynthesizerListener() {
+ SpeechSynthesizerListener listener = null;
+ try {
+ listener = new SpeechSynthesizerListener() {
+ File f = new File("tts_test.wav");
+ FileOutputStream fout = new FileOutputStream(f);
+ private boolean firstRecvBinary = true;
+
+ //璇煶鍚堟垚缁撴潫
+ @Override
+ public void onComplete(SpeechSynthesizerResponse response) {
+ //璋冪敤onComplete鏃惰〃绀烘墍鏈塗TS鏁版嵁宸叉帴鏀跺畬鎴愶紝鍥犳涓烘暣涓悎鎴愭暟鎹殑寤惰繜銆傝寤惰繜鍙兘杈冨ぇ锛屼笉涓�瀹氭弧瓒冲疄鏃跺満鏅��
+ System.out.println("name: " + response.getName() + ", status: " + response.getStatus() + ", output file :" + f.getAbsolutePath());
+ }
+
+ //璇煶鍚堟垚鐨勮闊充簩杩涘埗鏁版嵁
+ @Override
+ public void onMessage(ByteBuffer message) {
+ try {
+ if (firstRecvBinary) {
+ //璁$畻棣栧寘璇煶娴佺殑寤惰繜锛屾敹鍒扮涓�鍖呰闊虫祦鏃讹紝鍗冲彲浠ヨ繘琛岃闊虫挱鏀撅紝浠ユ彁鍗囧搷搴旈�熷害锛堢壒鍒槸瀹炴椂浜や簰鍦烘櫙涓嬶級銆�
+ firstRecvBinary = false;
+ long now = System.currentTimeMillis();
+// logger.info("tts first latency : " + (now - SpeechSynthesizerDemo.startTime) + " ms");
+ }
+ byte[] bytesArray = new byte[message.remaining()];
+ message.get(bytesArray, 0, bytesArray.length);
+ fout.write(bytesArray);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void onFail(SpeechSynthesizerResponse response) {
+ //task_id鏄皟鐢ㄦ柟鍜屾湇鍔$閫氫俊鐨勫敮涓�鏍囪瘑锛屽綋閬囧埌闂鏃堕渶瑕佹彁渚泃ask_id浠ヤ究鎺掓煡銆�
+ System.out.println("task_id: " + response.getTaskId() +
+ //鐘舵�佺爜 20000000 琛ㄧず璇嗗埆鎴愬姛
+ ", status: " + response.getStatus() +
+ //閿欒淇℃伅
+ ", status_text: " + response.getStatusText());
+ }
+ };
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return listener;
+ }
+
+
+ public void process2(String text) {
+ SpeechSynthesizer synthesizer = null;
+ try {
+ //鍒涘缓瀹炰緥锛屽缓绔嬭繛鎺ャ��
+ synthesizer = new SpeechSynthesizer(client, getSynthesizerListener());
+ synthesizer.setAppKey(appKey);
+ //璁剧疆杩斿洖闊抽鐨勭紪鐮佹牸寮�
+ synthesizer.setFormat(OutputFormatEnum.WAV);
+ //璁剧疆杩斿洖闊抽鐨勯噰鏍风巼
+ synthesizer.setSampleRate(SampleRateEnum.SAMPLE_RATE_16K);
+ //鍙戦煶浜�
+ synthesizer.setVoice("siyue");
+ //璇皟锛岃寖鍥存槸-500~500锛屽彲閫夛紝榛樿鏄�0銆�
+ synthesizer.setPitchRate(100);
+ //璇�燂紝鑼冨洿鏄�-500~500锛岄粯璁ゆ槸0銆�
+ synthesizer.setSpeechRate(100);
+ //璁剧疆鐢ㄤ簬璇煶鍚堟垚鐨勬枃鏈�
+ synthesizer.setText(text);
+ // 鏄惁寮�鍚瓧骞曞姛鑳斤紙杩斿洖鐩稿簲鏂囨湰鐨勬椂闂存埑锛夛紝榛樿涓嶅紑鍚紝闇�瑕佹敞鎰忓苟闈炴墍鏈夊彂闊充汉閮芥敮鎸佽鍙傛暟銆�
+ synthesizer.addCustomedParam("enable_subtitle", false);
+ //姝ゆ柟娉曞皢浠ヤ笂鍙傛暟璁剧疆搴忓垪鍖栦负JSON鏍煎紡鍙戦�佺粰鏈嶅姟绔紝骞剁瓑寰呮湇鍔$纭銆�
+ long start = System.currentTimeMillis();
+ synthesizer.start();
+// logger.info("tts start latency " + (System.currentTimeMillis() - start) + " ms");
+// SpeechSynthesizerDemo.startTime = System.currentTimeMillis();
+ //绛夊緟璇煶鍚堟垚缁撴潫
+ synthesizer.waitForComplete();
+ log.info("tts stop latency " + (System.currentTimeMillis() - start) + " ms");
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ //鍏抽棴杩炴帴
+ if (null != synthesizer) {
+ synthesizer.close();
+ }
+ }
+ }
+}
diff --git a/smartor/src/main/java/com/smartor/service/impl/SvyLibTopicdirectionServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/SvyLibTopicdirectionServiceImpl.java
new file mode 100644
index 0000000..867f5a3
--- /dev/null
+++ b/smartor/src/main/java/com/smartor/service/impl/SvyLibTopicdirectionServiceImpl.java
@@ -0,0 +1,94 @@
+package com.smartor.service.impl;
+
+import com.smartor.domain.SvyLibTopicdirection;
+import com.smartor.mapper.SvyLibTopicdirectionMapper;
+import com.smartor.service.ISvyLibTopicdirectionService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * 銆愯濉啓鍔熻兘鍚嶇О銆慡ervice涓氬姟灞傚鐞�
+ *
+ * @author ruoyi
+ * @date 2023-11-28
+ */
+@Service
+public class SvyLibTopicdirectionServiceImpl implements ISvyLibTopicdirectionService
+{
+ @Autowired
+ private SvyLibTopicdirectionMapper svyLibTopicdirectionMapper;
+
+ /**
+ * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿�
+ * @return 銆愯濉啓鍔熻兘鍚嶇О銆�
+ */
+ @Override
+ public SvyLibTopicdirection selectSvyLibTopicdirectionById(Long id)
+ {
+ return svyLibTopicdirectionMapper.selectSvyLibTopicdirectionById(id);
+ }
+
+ /**
+ * 鏌ヨ銆愯濉啓鍔熻兘鍚嶇О銆戝垪琛�
+ *
+ * @param svyLibTopicdirection 銆愯濉啓鍔熻兘鍚嶇О銆�
+ * @return 銆愯濉啓鍔熻兘鍚嶇О銆�
+ */
+ @Override
+ public List<SvyLibTopicdirection> selectSvyLibTopicdirectionList(SvyLibTopicdirection svyLibTopicdirection)
+ {
+ return svyLibTopicdirectionMapper.selectSvyLibTopicdirectionList(svyLibTopicdirection);
+ }
+
+ /**
+ * 鏂板銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param svyLibTopicdirection 銆愯濉啓鍔熻兘鍚嶇О銆�
+ * @return 缁撴灉
+ */
+ @Override
+ public int insertSvyLibTopicdirection(SvyLibTopicdirection svyLibTopicdirection)
+ {
+ return svyLibTopicdirectionMapper.insertSvyLibTopicdirection(svyLibTopicdirection);
+ }
+
+ /**
+ * 淇敼銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param svyLibTopicdirection 銆愯濉啓鍔熻兘鍚嶇О銆�
+ * @return 缁撴灉
+ */
+ @Override
+ public int updateSvyLibTopicdirection(SvyLibTopicdirection svyLibTopicdirection)
+ {
+ return svyLibTopicdirectionMapper.updateSvyLibTopicdirection(svyLibTopicdirection);
+ }
+
+ /**
+ * 鎵归噺鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆�
+ *
+ * @param ids 闇�瑕佸垹闄ょ殑銆愯濉啓鍔熻兘鍚嶇О銆戜富閿�
+ * @return 缁撴灉
+ */
+ @Override
+ public int deleteSvyLibTopicdirectionByIds(Long[] ids)
+ {
+ return svyLibTopicdirectionMapper.deleteSvyLibTopicdirectionByIds(ids);
+ }
+
+ /**
+ * 鍒犻櫎銆愯濉啓鍔熻兘鍚嶇О銆戜俊鎭�
+ *
+ * @param id 銆愯濉啓鍔熻兘鍚嶇О銆戜富閿�
+ * @return 缁撴灉
+ */
+ @Override
+ public int deleteSvyLibTopicdirectionById(Long id)
+ {
+ return svyLibTopicdirectionMapper.deleteSvyLibTopicdirectionById(id);
+ }
+}
diff --git a/smartor/src/main/resources/mapper/smartor/SvyLibTopicdirectionMapper.xml b/smartor/src/main/resources/mapper/smartor/SvyLibTopicdirectionMapper.xml
new file mode 100644
index 0000000..43bf085
--- /dev/null
+++ b/smartor/src/main/resources/mapper/smartor/SvyLibTopicdirectionMapper.xml
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.smartor.mapper.SvyLibTopicdirectionMapper">
+
+ <resultMap type="com.smartor.domain.SvyLibTopicdirection" id="SvyLibTopicdirectionResult">
+ <result property="id" column="id" />
+ <result property="topicid" column="topicid" />
+ <result property="transverse" column="transverse" />
+ <result property="direction" column="direction" />
+ </resultMap>
+
+ <sql id="selectSvyLibTopicdirectionVo">
+ select id, topicid, transverse, direction from svy_lib_topicdirection
+ </sql>
+
+ <select id="selectSvyLibTopicdirectionList" parameterType="com.smartor.domain.SvyLibTopicdirection" resultMap="SvyLibTopicdirectionResult">
+ <include refid="selectSvyLibTopicdirectionVo"/>
+ <where>
+ <if test="topicid != null "> and topicid = #{topicid}</if>
+ <if test="transverse != null and transverse != ''"> and transverse = #{transverse}</if>
+ <if test="direction != null and direction != ''"> and direction = #{direction}</if>
+ </where>
+ </select>
+
+ <select id="selectSvyLibTopicdirectionById" parameterType="Long" resultMap="SvyLibTopicdirectionResult">
+ <include refid="selectSvyLibTopicdirectionVo"/>
+ where id = #{id}
+ </select>
+
+ <insert id="insertSvyLibTopicdirection" parameterType="com.smartor.domain.SvyLibTopicdirection" useGeneratedKeys="true" keyProperty="id">
+ insert into svy_lib_topicdirection
+ <trim prefix="(" suffix=")" suffixOverrides=",">
+ <if test="topicid != null">topicid,</if>
+ <if test="transverse != null">transverse,</if>
+ <if test="direction != null">direction,</if>
+ </trim>
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
+ <if test="topicid != null">#{topicid},</if>
+ <if test="transverse != null">#{transverse},</if>
+ <if test="direction != null">#{direction},</if>
+ </trim>
+ </insert>
+
+ <update id="updateSvyLibTopicdirection" parameterType="com.smartor.domain.SvyLibTopicdirection">
+ update svy_lib_topicdirection
+ <trim prefix="SET" suffixOverrides=",">
+ <if test="topicid != null">topicid = #{topicid},</if>
+ <if test="transverse != null">transverse = #{transverse},</if>
+ <if test="direction != null">direction = #{direction},</if>
+ </trim>
+ where id = #{id}
+ </update>
+
+ <delete id="deleteSvyLibTopicdirectionById" parameterType="Long">
+ delete from svy_lib_topicdirection where id = #{id}
+ </delete>
+
+ <delete id="deleteSvyLibTopicdirectionByIds" parameterType="String">
+ delete from svy_lib_topicdirection where id in
+ <foreach item="id" collection="array" open="(" separator="," close=")">
+ #{id}
+ </foreach>
+ </delete>
+</mapper>
\ No newline at end of file
--
Gitblit v1.9.3