liusheng
2023-12-04 cde16e4d86afb08896a8eeaea8f22cf6f5a94aa5
代码提交
已删除1个文件
已添加9个文件
已修改10个文件
已重命名5个文件
1178 ■■■■■ 文件已修改
ruoyi-admin/pom.xml 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/BaseTagController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SendMessageIn.java 22 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/DingTalkController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/PersonVoiceController.java 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/socket/SocketCommunication.java 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/test/DingTalkService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/test/WeChatService.java 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-druid.yml 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application.yml 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/pom.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/html/AnalysisHTML.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/pom.xml 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/SvyLibTopicdirection.java 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/mapper/SvyLibTopicdirectionMapper.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/ISvyLibTopicdirectionService.java 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/PersonVoiceService.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/BaseSmsaccountServiceImpl.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/PersonVoiceServiceImpl.java 489 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/SvyLibTopicdirectionServiceImpl.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/SvyLibTopicdirectionMapper.xml 66 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
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>
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);
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/SendMessageIn.java
ÎļþÒÑɾ³ý
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/BaseSmsaccountController.java
ÎļþÃû´Ó ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/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();
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/DingTalkController.java
ÎļþÃû´Ó ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/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;
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);
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/tools/WeChatController.java
ÎļþÃû´Ó ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/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;
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");
ruoyi-admin/src/main/java/com/ruoyi/web/test/DingTalkService.java
ÎļþÃû´Ó ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/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;
ruoyi-admin/src/main/java/com/ruoyi/web/test/WeChatService.java
ÎļþÃû´Ó ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/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;
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
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
    # æ•°æ®åº“索引
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>
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;
/**
 * è§£æž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();
    }
}
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)
        {
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -108,7 +108,7 @@
                // è¿‡æ»¤è¯·æ±‚
                .authorizeRequests()
                // å¯¹äºŽç™»å½•login æ³¨å†Œregister éªŒè¯ç captchaImage å…è®¸åŒ¿åè®¿é—®
                .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()
                // é™¤ä¸Šé¢å¤–的所有请求全部需要鉴权认证
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>
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;
    /** é¢˜ç›®è¡¨id */
    @Excel(name = "题目表id")
    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();
    }
}
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;
/**
 * ã€è¯·å¡«å†™åŠŸèƒ½åç§°ã€‘Mapper接口
 *
 * @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);
}
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;
/**
 * ã€è¯·å¡«å†™åŠŸèƒ½åç§°ã€‘Service接口
 *
 * @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);
}
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;
/**
 * å®£æ•™åˆ†ç±»Service接口
 *
 * @author smartor
 * @date 2023-03-04
 */
public interface PersonVoiceService {
    /**
     * ä¸€å¥è¯è¯†åˆ«
     */
    public String speechtotext(String filePath);
    /**
     * ä¸€å¥è¯è¯†åˆ«
     */
    public String texttospeech(String textspeech);
    public Boolean explainHTML();
}
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)
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是获取状态码,getRecognizedText是语音识别文本。
                System.out.println("name: " + response.getName() + ", status: " + response.getStatus() + ", result: " + response.getRecognizedText());
            }
            //识别完毕
            @Override
            public void onRecognitionCompleted(SpeechRecognizerResponse response) {
                //getName是获取事件名称,getStatus是获取状态码,getRecognizedText是语音识别文本。
                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() {
        //应用全局创建一个NlsClient实例,默认服务地址为阿里云线上服务地址。
        //获取Token,实际使用时注意在accessToken.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文件,请设置为InputFormatEnum.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);
            //设置是否打开语音检测(即vad)
            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);
                //本案例用读取本地文件的形式模拟实时获取语音流,因为读取速度较快,这里需要设置sleep时长。
                // å¦‚果实时获取语音则无需设置sleep时长,如果是8k采样率语音第二个参数设置为8000。
                int deltaSleep = getSleepDelta(len, sampleRate);
//                Thread.sleep(deltaSleep);
            }
            //通知服务端语音数据发送完毕,等待服务端处理完成。
            now = System.currentTimeMillis();
            //计算实际延迟,调用stop返回之后一般即是识别结果返回时间。
            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时表示所有TTS数据已接收完成,因此为整个合成数据的延迟。该延迟可能较大,不一定满足实时场景。
                    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是调用方和服务端通信的唯一标识,当遇到问题时需要提供task_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();
            }
        }
    }
}
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;
/**
 * ã€è¯·å¡«å†™åŠŸèƒ½åç§°ã€‘Service业务层处理
 *
 * @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);
    }
}
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>