From 5db7759db3fa6792155d72139f9d5d9e56eb3436 Mon Sep 17 00:00:00 2001
From: 陈昶聿 <chychen@nbjetron.com>
Date: 星期四, 23 七月 2026 17:05:15 +0800
Subject: [PATCH] 【丽水】回写语言判断 增加AI识别

---
 smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java |   46 ++++++++++++++++------
 smartor/src/main/java/com/smartor/common/DeepSeekApi.java                     |   34 ++++++++++++++++-
 2 files changed, 65 insertions(+), 15 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/common/DeepSeekApi.java b/smartor/src/main/java/com/smartor/common/DeepSeekApi.java
index 6f20955..aafd84f 100644
--- a/smartor/src/main/java/com/smartor/common/DeepSeekApi.java
+++ b/smartor/src/main/java/com/smartor/common/DeepSeekApi.java
@@ -19,8 +19,9 @@
     public static void main(String[] args) {
         String questionText = "鎮ㄥソ,璇烽棶鎮ㄦ槸鎮h�呮湰浜鸿繕鏄灞烇紵\n";
         String voiceText = "鎴戣嚜宸�";
-        List<String> options = new ArrayList<>(Arrays.asList("鏈汉","浜插睘","鍏朵粬"));
-        Integer resp = matchOptionIndex(questionText, voiceText, options);
+//        List<String> options = new ArrayList<>(Arrays.asList("鏈汉","浜插睘","鍏朵粬"));
+        String optionText = "浜插睘";
+        Integer resp = matchQuestionAnswer(questionText, voiceText, optionText);
         System.out.println("DeepSeek杩斿洖缁撴灉锛歕n" + resp);
     }
 
@@ -120,6 +121,35 @@
     }
 
     /**
+     * 鍒ゆ柇璇煶鏂囨湰鏈�鎺ヨ繎鍝釜閫夐」锛岃繑鍥為�夐」鍦ㄥ垪琛ㄤ腑鐨勪笅鏍囥��
+     *
+     * @param questionText 璇煶璇嗗埆寰楀埌鐨勬枃鏈�
+     * @param answerText   绛旀鏂囨湰
+     * @param optionText   閫夐」鏂囨湰
+     * @return 鍛戒腑閫夐」鐨勪笅鏍囷紙浠� 0 寮�濮嬶級锛涙棤娉曞尮閰嶄换涓�閫夐」鏃惰繑鍥� {@code -1}
+     */
+    public static int matchQuestionAnswer(String questionText, String answerText, String optionText) {
+        if (StringUtils.isBlank(questionText) || StringUtils.isBlank(answerText) || StringUtils.isBlank(optionText)) {
+            return -1;
+        }
+
+        String systemPrompt = "\"浣犳槸涓�涓笓涓氱殑璇煶璇嗗埆鏂囨湰璇箟鍖归厤鍔╂墜銆備綘鐨勪换鍔℃槸鍒ゆ柇鐢ㄦ埛鐨勮闊虫枃鏈湪璇箟涓婃渶绗﹀悎鐨勯�夐」銆傜敤鎴蜂細缁欏嚭涓�娈佃闊宠瘑鍒枃鏈拰閫夐」鏂囨湰锛�"
+                + "璇峰垽鏂繖娈垫枃鏈湪璇箟涓婃槸鍚﹀尮閰嶉�夐」, 鍖归厤鍒欒緭鍑� 1锛屾病鏈夊尮閰嶅垯杈撳嚭 0, 鍙厑璁歌緭鍑�1鎴栬��0锛�"
+                + "涓嶈鍋氫换浣曡В閲娿�傜洿鎺ヨ緭鍑烘渶鍖归厤閫夐」鐨勭紪鍙锋暟瀛楋紱鑻ユ病鏈変换浣曢�夐」涓庢枃鏈浉鍏筹紝鍒欒緭鍑� 0銆�";
+        String userPrompt = "璇锋牴鎹互涓嬩俊鎭繘琛岃涔夊尮閰嶅垽鏂細\n" +
+                "- 闂鏂囨湰锛�" + questionText + "\n\n"
+                + "- 璇█璇嗗埆鏂囨湰锛�" + answerText + "\n\n"
+                + "- 閫夐」鏂囨湰锛�" + optionText + "\n\n"
+                + "\n璇峰彧杈撳嚭涓�涓暟瀛楋紙鍖归厤鍒欒緭鍑� 1锛屾病鏈夊尮閰嶅垯杈撳嚭 0,鍙厑璁歌緭鍑�1鎴栬��0锛夈��";
+
+        String content = chatCompletion(systemPrompt, userPrompt);
+        if (StringUtils.isBlank(content)) {
+            return -1;
+        }
+        return extractFirstNumber(content);
+    }
+
+    /**
      * 浠庢ā鍨嬪洖澶嶄腑鎻愬彇绗竴涓暣鏁般�傛ā鍨嬪伓灏斾細鍥炲 鈥滈�夐」2鈥� 鈥�2銆傗�� 涔嬬被锛屽仛涓�娆″厹搴曡В鏋愩��
      */
     private static Integer extractFirstNumber(String text) {
diff --git a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
index e7d2dc6..36f658e 100644
--- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java
@@ -16,6 +16,7 @@
 import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.system.domain.SysConfig;
 import com.ruoyi.system.mapper.SysConfigMapper;
+import com.smartor.common.DeepSeekApi;
 import com.smartor.common.FtpService;
 import com.smartor.common.MtSubmitSmUtil;
 import com.smartor.config.PhoneUtils;
@@ -1666,20 +1667,39 @@
                     if (StringUtils.isEmpty(phoneCallReqYQVO.getAsrtext())) {
                         continue;
                     }
-                    //鍖呭惈
-                    Matcher matcher = null;
-                    if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex())) {
-                        Pattern pattern = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex());
-                        matcher = pattern.matcher(phoneCallReqYQVO.getAsrtext());
+                    //2-AI璇嗗埆
+                    SysConfig configVoiceMatchType = new SysConfig();
+                    configVoiceMatchType.setOrgid(phoneCallReqYQVO.getOrgid());
+                    configVoiceMatchType.setConfigKey("sys.voice.match.type");
+                    SysConfig matchType = sysConfigMapper.selectConfig(configVoiceMatchType);
+                    boolean matchedFlag = false;
+                    if(ObjectUtils.isNotEmpty(matchType) && StringUtils.isNotEmpty(matchType.getConfigValue()) && matchType.getConfigValue().equals("2")){
+                        int checkFlag = DeepSeekApi.matchQuestionAnswer(ivrTaskTemplateScriptVO.getScriptContent(),
+                                phoneCallReqYQVO.getAsrtext(),
+                                ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetvalue());
+                        if(checkFlag == 1){
+                            matchedFlag = true;
+                        }
+                    }else {
+                        //鍖呭惈
+                        Matcher matcher = null;
+                        if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex())) {
+                            Pattern pattern = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex());
+                            matcher = pattern.matcher(phoneCallReqYQVO.getAsrtext());
+                        }
+                        //涓嶅寘鍚�
+                        Matcher matcher2 = null;
+                        if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2())) {
+                            Pattern pattern2 = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2());
+                            matcher2 = pattern2.matcher(phoneCallReqYQVO.getAsrtext());
+                        }
+
+                        if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
+                            matchedFlag = true;
+                        }
                     }
-                    //涓嶅寘鍚�
-                    Matcher matcher2 = null;
-                    if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2())) {
-                        Pattern pattern2 = Pattern.compile(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2());
-                        matcher2 = pattern2.matcher(phoneCallReqYQVO.getAsrtext());
-                    }
-                    if (StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
-                        //璇存槑鍖归厤姝g‘浜�
+                    //璇存槑鍖归厤姝g‘浜�
+                    if(matchedFlag){
                         //杩欓噷搴旇鍏堝垽鏂被鍨嬶紝鍘诲啀淇敼锛岃缃甀sUserOperation鏄崟閫夐鐨勬敼娉�
                         log.info("鍖归厤姝g‘浜嗗悧--------------");
                         ivrTaskTemplateScriptVO.getIvrTaskScriptTargetoptionList().get(j).setIsUserOperation(1);

--
Gitblit v1.9.3