From 29d027349c605bda0b7944301cd82a25ec9c1d7a Mon Sep 17 00:00:00 2001
From: liusheng <337615773@qq.com>
Date: 星期二, 07 五月 2024 16:42:03 +0800
Subject: [PATCH] 代码提交

---
 smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java |   97 +++++++++++++++++++++++++++++++++---------------
 1 files changed, 66 insertions(+), 31 deletions(-)

diff --git a/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java b/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java
index 9ab3ad8..1d5c720 100644
--- a/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java
+++ b/smartor/src/main/java/com/smartor/service/impl/IvrTaskSingleServiceImpl.java
@@ -49,6 +49,9 @@
     private IvrLibaTemplateTargetoptionMapper ivrLibaScriptTargetoptionMapper;
 
     @Autowired
+    private IvrTaskVisitResultMapper ivrTaskVisitResultMapper;
+
+    @Autowired
     private RedisCache redisCache;
 
     @Autowired
@@ -326,7 +329,8 @@
     }
 
     @Override
-    public void phoneCallBack(PhoneCallBackVO phoneCallBackVO) {phoneCallBackVO.setTextResult(phoneCallBackVO.getTextResult().substring(0, phoneCallBackVO.getTextResult().length() - 1));
+    public void phoneCallBack(PhoneCallBackVO phoneCallBackVO) {
+        phoneCallBackVO.setTextResult(phoneCallBackVO.getTextResult().substring(0, phoneCallBackVO.getTextResult().length() - 1));
 
         //鑾峰彇鏁版嵁
         Boolean aBoolean = redisCache.hasKey(phoneCallBackVO.getUuid());
@@ -338,8 +342,7 @@
         if (hangupValue != null && hangupValue == 1) {
             log.info("鐢佃瘽瑕佹寕鏂簡");
             //hangupValue == 1  闅忚缁撴潫锛岀洿鎺ュ彲浠ユ寕鐢佃瘽
-            phoneUtils.hangup(null, null, null, null, null, null, null, phoneCallBackVO.getUuid());
-            log.info("鐢佃瘽鎸傛柇----------------------------");
+            phoneUtils.hangup("", "", "", "", "", "", "", phoneCallBackVO.getUuid());
             return;
         }
 
@@ -388,6 +391,8 @@
             }
 
         } else {
+            //isppd鐢ㄦ潵璁板綍鏄惁鍖归厤鍒�
+            Boolean isppd = false;
             //鏈夊洖璇濓紝瀵瑰洖绛旂殑闂,杩涜姝e垯鍖归厤锛堣繖閲屽彧閽堝閫夋嫨棰橈紝鍏跺畠棰樺瀷涓嶈锛�
             for (int j = 0; j < nowQuestion.getIvrLibaScriptTargetoptionList().size(); j++) {
                 //鍖呭惈
@@ -403,7 +408,9 @@
                     matcher2 = pattern2.matcher(phoneCallBackVO.getTextResult());
                 }
                 log.info("phoneCallBack--Targetregex鐨勫�间负锛歿}, phoneCallBack--Targetregex2鐨勫�间负锛歿}", nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex(), nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2());
-                if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches() && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
+                if (StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches() && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()
+                        || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && matcher2.matches()
+                        || StringUtils.isEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex2()) && StringUtils.isNotEmpty(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetregex()) && matcher.matches()) {
                     //璇存槑鍖归厤姝g‘浜�
                     //杩欓噷搴旇鍏堝垽鏂被鍨嬶紝鍘诲啀淇敼锛岃缃甀sUserOperation鏄崟閫夐鐨勬敼娉�
                     nowQuestion.getIvrLibaScriptTargetoptionList().get(j).setIsUserOperation(true);
@@ -412,6 +419,19 @@
                     //灏嗛潤榛樼疆涓�0
                     redisCache.setCacheObject(phoneCallBackVO.getUuid() + "noVoice", 0, 120, TimeUnit.MINUTES);
                     redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES);
+
+                    //灏嗘偅鑰呯殑鍥炵鍐欒繘琛ㄩ噷
+                    IvrTaskVisitResult ivrTaskVisitResult = DtoConversionUtils.sourceToTarget(ivrTaskcall, IvrTaskVisitResult.class);
+                    ivrTaskVisitResult.setId(null);
+                    ivrTaskVisitResult.setQuestion(nowQuestion.getQuestionText());
+                    ivrTaskVisitResult.setPatientAnswer(phoneCallBackVO.getTextResult());
+                    ivrTaskVisitResult.setCreateTime(new Date());
+                    ivrTaskVisitResult.setOptionResult(nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getTargetvalue());
+                    ivrTaskVisitResultMapper.insertIvrTaskVisitResult(ivrTaskVisitResult);
+
+                    //灏嗗尮閰嶅埌鐨勬爣璇嗘敼鎴恡rue
+                    isppd = true;
+
                     //鑾峰彇涓嬩竴棰�
                     Integer nextQuestion = nowQuestion.getIvrLibaScriptTargetoptionList().get(j).getNextQuestion();
                     for (IvrLibaTemplateScriptVO script : ivrLibaTemplateScriptVOs) {
@@ -426,40 +446,55 @@
                             //娌℃湁涓嬩竴棰樹簡锛屽氨缁撴潫浜�
                             redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES);
                             phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid());
-                            phoneUtils.hangup(null, null, null, null, null, null, null, phoneCallBackVO.getUuid());
+                            try {
+                                Thread.sleep(3000);
+                            } catch (InterruptedException e) {
+                                e.printStackTrace();
+                            }
+                            phoneUtils.hangup("", "", ivrLibaTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid());
                             return;
                         }
                     }
                     return;
                 } else {
-                    //娌℃湁鍖归厤鍒�
-                    Integer mateNum = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "mateNum");
-                    if (mateNum == null) mateNum = 0;
-                    //鏃犲尮閰嶆鏁板幓鍒ゆ柇鏄惁鍒版渶澶ц闂鏁帮紝骞朵笖鎵�鏈夌殑閫夐」閮藉尮閰嶅畬浜�
-                    if (mateNum == ivrLibaTemplateVO.getMateNum().intValue() && j == nowQuestion.getIvrLibaScriptTargetoptionList().size() - 1) {
-                        //濡傛灉涓嬩竴棰樹负绌�.鍒欐柊鐨勬暟鎹繑鍥�,骞跺姞涓婃劅璋㈣
-                        if (nowQuestion.getTargetid() < ivrLibaTemplateScriptVOs.size()) {
-                            QuestionMessage questionMessage = new QuestionMessage();
-                            IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion);
-                            questionMessage.setQuestionList(ivrLibaTemplateScriptVOs);
-                            questionMessage.setNowQuestion(nextQuestion);
-                            redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES);
-                            redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES);
-                            phoneUtils.ttsPlayback(nextQuestion.getQuestionText(), phoneCallBackVO.getUuid());
-                            return;
-                        } else {
-                            //灏卞彲浠ユ寕鏂數璇濅簡
-                            redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES);
-                            phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid());
-                            phoneUtils.hangup(null, null, null, null, null, null, null, phoneCallBackVO.getUuid());
-                            return;
-                        }
-                    } else if (mateNum < ivrLibaTemplateVO.getMateNum().intValue() && j == nowQuestion.getIvrLibaScriptTargetoptionList().size() - 1) {
-                        //娌℃湁闂埌瑙勫畾娆℃暟
-                        mateNum = mateNum + 1;
-                        redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", mateNum, 120, TimeUnit.MINUTES);
+                    //娌℃湁鍖归厤涓婂綋鍓峯ption
+                    //Targetregex2 涓篺alse锛岃〃绀哄湪Targetregex2涓瓨鍦�  璇彞涓殑鍏抽敭瀛楋紝杩欎釜option灏变笉鐢ㄥ啀缁х画鍖归厤浜嗭紝鐩存帴鍖归厤涓嬩竴涓猳ption
+                    continue;
+                }
+            }
 
+            if (isppd != true) {
+                //娌℃湁鍖归厤鍒�
+                Integer mateNum = redisCache.getCacheObject(phoneCallBackVO.getUuid() + "mateNum");
+                if (mateNum == null) mateNum = 0;
+                //鏃犲尮閰嶆鏁板幓鍒ゆ柇鏄惁鍒版渶澶ц闂鏁帮紝骞朵笖鎵�鏈夌殑閫夐」閮藉尮閰嶅畬浜�
+                if (mateNum == ivrLibaTemplateVO.getMateNum().intValue()) {
+                    //濡傛灉涓嬩竴棰樹负绌�.鍒欐柊鐨勬暟鎹繑鍥�,骞跺姞涓婃劅璋㈣
+                    if (nowQuestion.getTargetid() < ivrLibaTemplateScriptVOs.size()) {
+                        QuestionMessage questionMessage = new QuestionMessage();
+                        IvrLibaTemplateScriptVO nextQuestion = getNextQuestion(ivrLibaTemplateScriptVOs, nowQuestion);
+                        questionMessage.setQuestionList(ivrLibaTemplateScriptVOs);
+                        questionMessage.setNowQuestion(nextQuestion);
+                        redisCache.setCacheObject(phoneCallBackVO.getUuid() + "returnQues", questionMessage, 120, TimeUnit.MINUTES);
+                        redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", 0, 120, TimeUnit.MINUTES);
+                        phoneUtils.ttsPlayback(nextQuestion.getQuestionText(), phoneCallBackVO.getUuid());
+                        return;
+                    } else {
+                        //灏卞彲浠ユ寕鏂數璇濅簡
+                        redisCache.setCacheObject(phoneCallBackVO.getUuid() + "hangup", 1, 120, TimeUnit.MINUTES);
+                        phoneUtils.ttsPlayback(ivrLibaTemplateVO.getRevisitAfter(), phoneCallBackVO.getUuid());
+                        try {
+                            Thread.sleep(3000);
+                        } catch (InterruptedException e) {
+                            e.printStackTrace();
+                        }
+                        phoneUtils.hangup("", "", ivrLibaTemplateVO.getRevisitAfter(), "", "", "", "", phoneCallBackVO.getUuid());
+                        return;
                     }
+                } else if (mateNum < ivrLibaTemplateVO.getMateNum().intValue()) {
+                    //娌℃湁闂埌瑙勫畾娆℃暟
+                    mateNum = mateNum + 1;
+                    redisCache.setCacheObject(phoneCallBackVO.getUuid() + "mateNum", mateNum, 120, TimeUnit.MINUTES);
                 }
             }
             //閫夐」鍖归厤瀹屾垚鍚庯紝闇�瑕佸啀鍘婚�氳繃搴撳啀杩涜鍖归厤涓�娆�

--
Gitblit v1.9.3