From b0da81d9276922b223583807093bd6420d9bf705 Mon Sep 17 00:00:00 2001 From: liusheng <337615773@qq.com> Date: 星期五, 14 二月 2025 17:10:50 +0800 Subject: [PATCH] 优化电话拨打功能 --- ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java | 5 + ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java | 12 ++-- smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java | 22 +++++++ ruoyi-admin/src/main/resources/application-druid.yml | 66 +++++++++++----------- ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java | 20 +++++- smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml | 2 6 files changed, 79 insertions(+), 48 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java index be6aa8b..9d203fd 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/ServiceSubtaskController.java @@ -190,8 +190,8 @@ @PostMapping("/phoneCallBackYQ") public PhoneCallBackYQVO phoneCallBackYQ(@RequestBody PhoneCallReqYQVO phoneCallReqYQVO) { log.error("鐢佃瘽ASR閫氳瘽鍥炶皟(闆ㄧ划) 锛焮}", phoneCallReqYQVO); - SysUser user = getLoginUser().getUser(); - phoneCallReqYQVO.setOrgid(user.getOrgid()); +// SysUser user = getLoginUser().getUser(); +// phoneCallReqYQVO.setOrgid(user.getOrgid()); PhoneCallBackYQVO phoneCallBackYQVO = serviceSubtaskService.phoneCallBackYQ(phoneCallReqYQVO); return phoneCallBackYQVO; } @@ -214,8 +214,8 @@ @ApiOperation("鎮h�呴棶棰樼粨鏋滆褰曪紙鐢佃瘽锛�") @PostMapping("/saveQuestionAnswerPhone") public AjaxResult saveQuestionAnswerPhone(@RequestBody ServiceSubTaskDetailReq serviceSubTaskDetailReq) { - SysUser user = getLoginUser().getUser(); - serviceSubTaskDetailReq.setOrgid(user.getOrgid()); +// SysUser user = getLoginUser().getUser(); +// serviceSubTaskDetailReq.setOrgid(user.getOrgid()); return toAjax(serviceSubtaskService.saveQuestionAnswerPhone(serviceSubTaskDetailReq)); } @@ -236,8 +236,8 @@ public AjaxResult recordAccept(@RequestBody PhoneCallRecordVO phoneCallRecordVO) { log.error("閫氳瘽璁板綍鍥炶皟(闆ㄧ划):{}", phoneCallRecordVO); // return toAjax(serviceSubtaskService.saveQuestionAnswerPhone(serviceSubTaskDetailReq)); - SysUser user = getLoginUser().getUser(); - phoneCallRecordVO.setOrgid(user.getOrgid()); +// SysUser user = getLoginUser().getUser(); +// phoneCallRecordVO.setOrgid(user.getOrgid()); serviceSubtaskService.recordAccept(phoneCallRecordVO); return success(); } diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index 91d9bc9..de89676 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -11,12 +11,12 @@ # username: root # password: 123456 # 鍏徃 - # url: jdbc:mysql://192.168.2.9:3308/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + url: jdbc:mysql://192.168.2.9:3308/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # 涓芥按 # url: jdbc:mysql://127.0.0.1:3308/smartor-lisui?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - # username: smartor - # password: Smartor.2023 - # driverClassName: com.mysql.cj.jdbc.Driver + username: smartor + password: Smartor.2023 + driverClassName: com.mysql.cj.jdbc.Driver # 鏂板崕 # url: jdbc:mysql://192.168.191.181:3308/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # username: smartor @@ -24,26 +24,26 @@ # driverClassName: com.mysql.cj.jdbc.Driver # 鍏徃浜� - url: jdbc:mysql://116.62.18.175:6002/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 - username: hxsoft - password: Hxerp2000 - driverClassName: com.mysql.cj.jdbc.Driver + # url: jdbc:mysql://116.62.18.175:6002/smartor?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 + # username: hxsoft + # password: Hxerp2000 + # driverClassName: com.mysql.cj.jdbc.Driver # 浠庡簱鏁版嵁婧� slave: - # 浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴(鍏徃) - # enabled: true - # url: jdbc:sqlserver://116.62.18.175:6001;DatabaseName=iv-ywey;encrypt=false;SelectMethod=cursor - # username: sa - # password: Hxerp2000 - # driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver + # 浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴(鍏徃) + # enabled: true + # url: jdbc:sqlserver://116.62.18.175:6001;DatabaseName=iv-ywey;encrypt=false;SelectMethod=cursor + # username: sa + # password: Hxerp2000 + # driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver - # 浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴(涔変箤浜岄櫌) - # enabled: true - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=IntelligentVoice;encrypt=false;SelectMethod=cursor - # username: sa - # password: sfxt#2023 - # driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver + # 浠庢暟鎹簮寮�鍏�/榛樿鍏抽棴(涔変箤浜岄櫌) + # enabled: true + # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=IntelligentVoice;encrypt=false;SelectMethod=cursor + # username: sa + # password: sfxt#2023 + # driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver # 鍒濆杩炴帴鏁� initialSize: 5 @@ -151,12 +151,12 @@ qrpath: D:\qrcode #鍏徃鍐呭閾捐姹侷P鍜岀鍙e彿 -#req_path: 8095 -#localIP: 192.168.2.13 +req_path: 8095 +localIP: 192.168.2.13 #鏂板崕鍖婚櫌澶栭摼璇锋眰IP鍜岀鍙e彿 -req_path: 8093 -localIP: https://wx.lihusmart.com +#req_path: 8093 +#localIP: https://wx.lihusmart.com #鑾峰彇鎮h�呬俊鎭疷RL(鍗庡崜鎻愪緵) hosp_info_url: http://esb-core-rest.wowjoy.cn/esb/exchange @@ -165,23 +165,23 @@ uploadSwitch: 1 ## 鎸囧畾asr鍥炶皟鐨剈rl璺緞(鏈湴) -#ASRCallBackPath: http://192.168.2.13:8095/smartor/serviceSubtask/phoneCallBackYQ +ASRCallBackPath: http://192.168.2.13:8095/smartor/serviceSubtask/phoneCallBackYQ ##鎸傛柇IP(鏈湴) -#hangup: http://192.168.2.13:8091/hangup +hangup: http://192.168.2.13:8091/hangup ##fs鎵�浣跨敤鐨勯樋閲岀殑app_key(鏈湴) #app_key_yq: ZurNHpaQLq6P55YS # 鎸囧畾asr鍥炶皟鐨剈rl璺緞(鏂板崕) -ASRCallBackPath: http://192.168.101.135:8095/smartor/serviceSubtask/phoneCallBackYQ +#ASRCallBackPath: http://192.168.101.135:8095/smartor/serviceSubtask/phoneCallBackYQ #鎸傛柇IP(鏂板崕) -hangup: http://192.16.4.220:8091/hangup +#hangup: http://192.16.4.220:8091/hangup #fs鎵�浣跨敤鐨勯樋閲岀殑app_key(鏂板崕) app_key_yq: ZurNHpaQLq6P55YS #鏈� 鍦� 鐭俊璇锋眰鍦板潃(杩欎釜鏈嶅姟鏄垜浠嚜宸卞啓鐨�) -#xhsmsPath: http://192.168.2.13:8092/sendSms +xhsmsPath: http://192.168.2.13:8092/sendSms #鏂板崕鐭俊璇锋眰鍦板潃(杩欎釜鏈嶅姟鏄垜浠嚜宸卞啓鐨�) -xhsmsPath: http://192.16.4.220:8092/sendSms +#xhsmsPath: http://192.16.4.220:8092/sendSms #甯愬彿 xhsmsAccount: 911124 #鎺ュ彛瀵嗙爜 @@ -200,12 +200,12 @@ FTP_PASSWORD: xh@2023 #璇煶鍦板潃璁块棶鍓嶇紑(鏂板崕) -voicePathPrefix: http://192.168.191.181:8095/profile/upload/vadio/ +#voicePathPrefix: http://192.168.191.181:8095/profile/upload/vadio/ #璇煶鍦板潃璁块棶鍓嶇紑(鍏徃) -#voicePathPrefix: http://192.168.2.13:8095/profile/upload/vadio/ +voicePathPrefix: http://192.168.2.13:8095/profile/upload/vadio/ #鍏佽鑷姩鐢熸垚浠诲姟 createTaskServiceType: 2 #姣忓ぉ鐢佃瘽绔嬪嵆鎵ц鐨勪笂闄� -phoneUpEveryHour: 120 +phoneUpEveryHour: 10 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java index 13210c8..6d48711 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java @@ -8,10 +8,7 @@ import java.util.concurrent.TimeUnit; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.BoundSetOperations; -import org.springframework.data.redis.core.HashOperations; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ValueOperations; +import org.springframework.data.redis.core.*; import org.springframework.stereotype.Component; /** @@ -19,7 +16,7 @@ * * @author ruoyi **/ -@SuppressWarnings(value = {"unchecked" , "rawtypes"}) +@SuppressWarnings(value = {"unchecked", "rawtypes"}) @Component public class RedisCache { @Autowired @@ -245,6 +242,19 @@ } /** + * 鍒犻櫎缂撳瓨LIST涓殑鏌愪釜鏁版嵁 + * + * @param key Redis閿� + * @param valueToRemove 闇�瑕佸垹闄ょ殑鍊� + * @return Long 澶т簬0琛ㄧず鍒犻櫎浜嗗嚑涓紝绛変簬0琛ㄧず娌℃湁鍒犻櫎锛屽皬浜�0琛ㄧず鍦ㄦ墽琛屽垹闄ゆ搷浣滄椂鍙戠敓浜嗛敊璇� + */ + public Long removeElementFromList(String key, String valueToRemove) { + ListOperations<String, String> listOps = redisTemplate.opsForList(); + Long remove = listOps.remove(key, 0, valueToRemove); + return remove; + } + + /** * 鑾峰緱缂撳瓨鐨勫熀鏈璞″垪琛� * * @param pattern 瀛楃涓插墠缂� diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java index 801c238..00c9162 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java @@ -343,8 +343,9 @@ } } //灏嗚鎵ц鐨勬斁鍒扮紦瀛樹腑 - redisCache.setCacheList("cache-0", list); - + if (list.size() > 0) { + redisCache.setCacheList("cache-0", list); + } } else if (descByCode.equals("澶氬獟浣�")) { //澶氬獟浣� } else if (descByCode.equals("绾歌川")) { 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 56f5de4..c82af7b 100644 --- a/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java +++ b/smartor/src/main/java/com/smartor/service/impl/ServiceSubtaskServiceImpl.java @@ -819,6 +819,9 @@ */ @Override public PhoneCallBackYQVO phoneCallBackYQ(PhoneCallReqYQVO phoneCallReqYQVO) { + //鍏堟妸璇ubId浠巆ache_exist涓墧闄わ紝鍙鏈夊洖璋冨氨鍓旈櫎锛堢洰鐨勬槸锛屽敖蹇cache-exist涓虹┖锛屽幓缂撳瓨涓嬩竴鎵硅鎵撶殑鐢佃瘽;杩欓噷鍓旈櫎涓嶅奖鍝嶇數璇濈殑姝e父涓氬姟锛� + redisCache.removeElementFromList("cache-exist", phoneCallReqYQVO.getTaskid()); + //鍒ゆ柇鏄惁鎸傛満 String hangupState = redisCache.getCacheObject(phoneCallReqYQVO.getUuid() + "- hangup"); Object cacheObject1 = redisCache.getCacheObject(phoneCallReqYQVO.getTaskid() + "recordAccept-hungup"); @@ -833,6 +836,12 @@ if (ObjectUtils.isNotEmpty(cacheObject) && String.valueOf(cacheObject).equals("1")) { return new PhoneCallBackYQVO(); } + //濡傛灉鍙戦�佺姸鎬佷负6锛屽氨璇存槑宸茬粡鎵撳畬浜嗭紝涔熸病鏈夊繀瑕佺户缁線涓嬭蛋浜� + if (StringUtils.isNotEmpty(phoneCallReqYQVO.getTaskid())) { + ServiceSubtask serviceSubtask = serviceSubtaskMapper.selectServiceSubtaskById(Long.valueOf(phoneCallReqYQVO.getTaskid())); + if (serviceSubtask.getSendstate() == 6L) return new PhoneCallBackYQVO(); + } + ServiceSubtask serviceSubtask2 = new ServiceSubtask(); serviceSubtask2.setRemark("鐢佃瘽鍙戦�佹垚鍔燂紙鎮h�呮寕鏂級"); serviceSubtask2.setSenduuid(phoneCallReqYQVO.getUuid()); @@ -1429,9 +1438,13 @@ @Override public List<PullTaskVO> taskPull() { //pullTaskVOList鐢ㄤ簬鏁版嵁杩斿洖 - List<PullTaskVO> pullTaskVOList = null; + List<PullTaskVO> pullTaskVOList = new ArrayList<>(); List<String> cacheList = new ArrayList<>(); ListOperations<String, String> listOps = redisTemplate.opsForList(); + //蹇呴』绛塧che-exist鍏ㄩ儴鎵撳畬鎵嶈兘鎷夊彇涓嬩竴鎵癸紙涓昏鏄�曟墍鏈夌殑鏁版嵁閮藉爢鍦ㄧ數璇濈殑缂撳瓨閲岋紝鍦ㄨ瀹氱殑鏃堕棿鎵撲笉瀹岋級 + long existSize = listOps.size("cache-exist"); + if (existSize > 0) return pullTaskVOList; + long size = listOps.size("cache-0"); log.error("---------鎵撶數璇濅箣鍓嶇紦瀛樹腑鐨勬暟鎹噺锛歿}", size); int count = 0; @@ -1465,12 +1478,16 @@ listOps.trim("cache-0" + i, count1, -1); } } + //existList鐢ㄦ潵璁板綍鎺ヤ笅鏉ラ渶瑕佹墽琛岀殑瀛愪换鍔D + List<String> existList = new ArrayList<>(); if (CollectionUtils.isNotEmpty(pullTaskVOList)) { //缁欏洖璋冨弬鏁拌祴鍊� for (PullTaskVO pullTaskVO : pullTaskVOList) { + existList.add(pullTaskVO.getTaskid()); pullTaskVO.setAsrcallback(ASRCallBackPath); } } + if (existList.size() != 0) redisCache.setCacheList("cache-exist", existList); log.error("-----------瀹為檯鎷夊彇鐨勭數璇濇暟鎹噺锛歿}", pullTaskVOList.size()); return pullTaskVOList; } @@ -1853,6 +1870,7 @@ ServiceSubtask serviceSubtask = new ServiceSubtask(); serviceSubtask.setRemark("鐢佃瘽鎺ラ�氭垚鍔燂紝鎮h�呮嫆缁濋殢璁�"); serviceSubtask.setId(Long.valueOf(phoneCallRecordVO.getTaskid())); + serviceSubtask.setSendstate(6L); serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); int startIndex = phoneCallRecordVO.getRecord_path().indexOf("voice") + "voice".length() + 1; // 鍔�1鏄烦杩�/绗﹀彿 int endIndex = phoneCallRecordVO.getRecord_path().lastIndexOf("/"); @@ -2051,7 +2069,9 @@ redisCache.setCacheObject(subTaskId + "recordAccept-hungup", "1", 10, TimeUnit.MINUTES); if (StringUtils.isNotEmpty(serviceSubtask.getRemark())) serviceSubtask.setRemark("鐢佃瘽鍙戦�佹嫆鎺�,鐭俊琛ュ伩鍙戦�佹垚鍔�"); else serviceSubtask.setRemark("鐭俊琛ュ伩鍙戦�佹垚鍔�"); + serviceSubtask.setSendstate(3L); serviceSubtaskMapper.updateServiceSubtask(serviceSubtask); + } //閫氳繃褰撳墠鏃堕棿锛屾媺鍙栫數璇濇�绘暟 diff --git a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml index f636f09..8c975d2 100644 --- a/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml +++ b/smartor/src/main/resources/mapper/smartor/ServiceSubtaskMapper.xml @@ -254,7 +254,7 @@ </if> <if test="serviceType != null and serviceType != ''and serviceType == '2'">order by endtime desc</if> <if test="serviceType != null and serviceType != ''and serviceType == '3'">order by admindate desc</if> - -- order by update_time desc,id desc + <!-- order by update_time desc,id desc --> </select> <select id="selectServiceSubtaskById" parameterType="Long" resultMap="ServiceSubtaskResult"> -- Gitblit v1.9.3