From 3fc51e7cbdabb7dcd1615c6efac52323f6ca8adb Mon Sep 17 00:00:00 2001 From: liusheng <337615773@qq.com> Date: 星期三, 03 七月 2024 18:28:34 +0800 Subject: [PATCH] 代码提交 --- ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java | 207 ++++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 185 insertions(+), 22 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java index 28b5edb..d5e72b6 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java @@ -10,11 +10,12 @@ import com.smartor.common.SendService; import com.smartor.config.RobotPhoneUtils; import com.smartor.domain.*; -import com.smartor.mapper.IvrTaskMapper; -import com.smartor.mapper.IvrTaskSingleMapper; +import com.smartor.mapper.ServiceSubtaskMapper; +import com.smartor.mapper.ServiceTaskMapper; import com.smartor.mapper.SvyTaskMapper; import com.smartor.mapper.SvyTaskSingleMapper; import com.smartor.service.IIvrTaskTemplateService; +import com.smartor.service.IServiceSubtaskRecordService; import com.smartor.service.ISvyTaskTemplateService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -24,9 +25,7 @@ import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.stereotype.Component; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -46,9 +45,9 @@ private static IIvrTaskTemplateService ivrTaskTemplateService; - private static IvrTaskSingleMapper ivrTaskcallMapper; + private static ServiceSubtaskMapper ivrTaskcallMapper; - private static IvrTaskMapper ivrTaskMapper; + private static ServiceTaskMapper ivrTaskMapper; private static SendService sendService; @@ -64,6 +63,9 @@ @Autowired private ISvyTaskTemplateService iSvyTaskTemplateService; + + @Autowired + private IServiceSubtaskRecordService serviceSubtaskRecordService; // 鍒涘缓鍥哄畾澶у皬鐨勭嚎绋嬫睜 private static final ExecutorService executorService = Executors.newFixedThreadPool(10); @@ -89,12 +91,12 @@ } @Autowired - public void setIvrTaskcallMapper(IvrTaskSingleMapper ivrTaskcallMapper) { + public void setIvrTaskcallMapper(ServiceSubtaskMapper ivrTaskcallMapper) { RedisMqReceiver.ivrTaskcallMapper = ivrTaskcallMapper; } @Autowired - public void setIvrTaskMapper(IvrTaskMapper ivrTaskMapper) { + public void setIvrTaskMapper(ServiceTaskMapper ivrTaskMapper) { RedisMqReceiver.ivrTaskMapper = ivrTaskMapper; } @@ -155,7 +157,7 @@ */ private void sfHandle(CommonTaskcallMQ commonTaskcallMQ) { //鍒ゆ柇涓�涓媍ommonTaskcallMQ涓殑stopstate鏄惁涓巌vr_task涓殑涓�鑷达紝涓嶄竴鑷达紝鍒欒鏄庢槸鏆傚仠浜� - IvrTask ivrTask1 = ivrTaskMapper.selectIvrTaskByTaskid(commonTaskcallMQ.getTaskid()); + ServiceTask ivrTask1 = ivrTaskMapper.selectServiceTaskByTaskid(commonTaskcallMQ.getTaskid()); if (ivrTask1.getStopState() != commonTaskcallMQ.getStopState()) { //灏嗘秷鎭粠闃熷垪涓墧闄� return; @@ -175,16 +177,26 @@ IvrTaskTemplateVO ivrTaskTemplateVO1 = ivrTaskTemplateService.selectInfoByCondition(ivrTaskTemplateVO); //閫氳繃浠诲姟ID鎷垮埌鎮h�呬俊鎭� - IvrTaskSingle ivrTaskcall = new IvrTaskSingle(); + ServiceSubtask ivrTaskcall = new ServiceSubtask(); ivrTaskcall.setTaskid(commonTaskcallMQ.getTaskid()); - List<IvrTaskSingle> ivrTaskcalls = ivrTaskcallMapper.selectIvrTaskcallList(ivrTaskcall); + List<ServiceSubtask> ivrTaskcalls = ivrTaskcallMapper.selectServiceSubtaskList(ivrTaskcall); if (descByCode.equals("鐢佃瘽")) { - for (IvrTaskSingle ivrTaskcall1 : ivrTaskcalls) { - IvrTask ivrTask = ivrTaskMapper.selectIvrTaskByTaskid(ivrTaskcall1.getTaskid()); + for (ServiceSubtask ivrTaskcall1 : ivrTaskcalls) { + ServiceTask ivrTask = ivrTaskMapper.selectServiceTaskByTaskid(ivrTaskcall1.getTaskid()); if (ivrTask.getSendState() != null && ivrTask.getSendState() == 3 || ivrTask.getSendState() != null && ivrTask.getSendState() == 4) { //濡備綍浠诲姟琚�滄殏鍋溾�濇垨鈥滅粓姝⑩�� break; } + + //浠诲姟鍙戦�佽褰曪紙杩欎釜浠g爜搴旇鍐欏湪phoneTask涓紝鍏堝啓鍦ㄨ繖锛屽悗闈㈠啀鏀癸級 + ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); + serviceSubtaskRecord.setTaskid(ivrTaskcall1.getTaskid().toString()); + serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); + serviceSubtaskRecord.setTasktype(ivrTaskcall1.getType()); + serviceSubtaskRecord.setPreachform("3"); + serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); + serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); + //閫氳繃澶氱嚎绋嬬殑鏂瑰紡鍘绘墦鐢佃瘽 executorService.submit(new PhoneTask(ivrTaskcall1, ivrTaskTemplateVO1, redisCache, sendService, phonePath, robotPhoneUtils)); } @@ -200,18 +212,28 @@ String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); - for (IvrTaskSingle ivrTaskSingle : ivrTaskcalls) { + for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); SendMagParam sendMagParam = new SendMagParam(); sendMagParam.setType("4"); sendMagParam.setUrl(req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid); - sendService.sendMsg(sendMagParam); + Boolean aBoolean = sendService.sendMsg(sendMagParam); + + //浠诲姟鍙戦�佽褰� + ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); + serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); + serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); + serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); + serviceSubtaskRecord.setPreachform("4"); + serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); + serviceSubtaskRecord.setResult(aBoolean == true ? "鎴愬姛" : "澶辫触"); + serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); } } else if (descByCode.equals("鍏紬鍙�")) { //鍏紬鍙� RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); - for (IvrTaskSingle ivrTaskSingle : ivrTaskcalls) { + for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); SendMagParam sendMagParam = new SendMagParam(); sendMagParam.setType("5"); @@ -222,7 +244,129 @@ Map map = new HashMap(); map.put("first", ivrTask1.getTaskName()); sendMagParam.setContent(JSON.toJSONString(map)); - sendService.sendMsg(sendMagParam); + Boolean aBoolean = sendService.sendMsg(sendMagParam); + + //浠诲姟鍙戦�佽褰� + ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); + serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); + serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); + serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); + serviceSubtaskRecord.setPreachform("4"); + serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); + serviceSubtaskRecord.setResult(aBoolean == true ? "鎴愬姛" : "澶辫触"); + serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); + } + } + //閫氱煡 MQ 娑堟伅宸茶鎺ユ敹,鍙互ACK(浠庨槦鍒椾腑鍒犻櫎)浜� 锛堣繖涓渶瑕佹牴鎹笟鍔″啀鍘诲鐞咥CK锛� + } + } + } + + /** + * 瀹f暀浠诲姟澶勭悊 + * + * @param commonTaskcallMQ + */ + private void xjHandle(CommonTaskcallMQ commonTaskcallMQ) { + //鍒ゆ柇涓�涓媍ommonTaskcallMQ涓殑stopstate鏄惁涓巌vr_task涓殑涓�鑷达紝涓嶄竴鑷达紝鍒欒鏄庢槸鏆傚仠浜� + ServiceTask ivrTask1 = ivrTaskMapper.selectServiceTaskByTaskid(commonTaskcallMQ.getTaskid()); + if (ivrTask1.getStopState() != commonTaskcallMQ.getStopState()) { + //灏嗘秷鎭粠闃熷垪涓墧闄� + return; + } + + if (StringUtils.isNotEmpty(commonTaskcallMQ.getPreachform())) { + //濡備綍浠诲姟鍙戦�佹柟寮忎笉涓虹┖ + String[] split = commonTaskcallMQ.getPreachform().split(","); + System.out.println("split鐨勫�间负锛�" + split); + for (String serviceFrom : split) { + String descByCode = ServiceFromEnum.getDescByCode(Integer.valueOf(serviceFrom)); + //杩欓噷鍙互鑰冭檻鐢ㄧ瓥鐣ユā寮忎紭鍖栦竴涓嬶紝涓嶇劧澶毦鐪嬩簡 + + //閫氳繃妯℃澘ID鑾峰彇妯℃澘闂 + IvrTaskTemplateVO ivrTaskTemplateVO = new IvrTaskTemplateVO(); + ivrTaskTemplateVO.setID(Long.valueOf(commonTaskcallMQ.getTemplateid())); + IvrTaskTemplateVO ivrTaskTemplateVO1 = ivrTaskTemplateService.selectInfoByCondition(ivrTaskTemplateVO); + + //閫氳繃浠诲姟ID鎷垮埌鎮h�呬俊鎭� + ServiceSubtask ivrTaskcall = new ServiceSubtask(); + ivrTaskcall.setTaskid(commonTaskcallMQ.getTaskid()); + List<ServiceSubtask> ivrTaskcalls = ivrTaskcallMapper.selectServiceSubtaskList(ivrTaskcall); + if (descByCode.equals("鐢佃瘽")) { + for (ServiceSubtask ivrTaskcall1 : ivrTaskcalls) { + ServiceTask ivrTask = ivrTaskMapper.selectServiceTaskByTaskid(ivrTaskcall1.getTaskid()); + if (ivrTask.getSendState() != null && ivrTask.getSendState() == 3 || ivrTask.getSendState() != null && ivrTask.getSendState() == 4) { + //濡備綍浠诲姟琚�滄殏鍋溾�濇垨鈥滅粓姝⑩�� + break; + } + + //浠诲姟鍙戦�佽褰曪紙杩欎釜浠g爜搴旇鍐欏湪phoneTask涓紝鍏堝啓鍦ㄨ繖锛屽悗闈㈠啀鏀癸級 + ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); + serviceSubtaskRecord.setTaskid(ivrTaskcall1.getTaskid().toString()); + serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); + serviceSubtaskRecord.setTasktype(ivrTaskcall1.getType()); + serviceSubtaskRecord.setPreachform("3"); + serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); + serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); + + //閫氳繃澶氱嚎绋嬬殑鏂瑰紡鍘绘墦鐢佃瘽 + executorService.submit(new PhoneTask(ivrTaskcall1, ivrTaskTemplateVO1, redisCache, sendService, phonePath, robotPhoneUtils)); + } + } else if (descByCode.equals("澶氬獟浣�")) { + //澶氬獟浣� + } else if (descByCode.equals("绾歌川")) { + //绾歌川 + } else if (descByCode.equals("鐭俊")) { + //鐭俊 +// http://localhost:8099/followvisit/particty?param1=3¶m2=348 + //瀵箄rl涓袱涓弬鏁板姞瀵� + RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); + String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); + + + for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { + String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); + SendMagParam sendMagParam = new SendMagParam(); + sendMagParam.setType("4"); + sendMagParam.setUrl(req_path + "/followvisit/particty?param1=" + taskId + "¶m2=" + patid); + Boolean aBoolean = sendService.sendMsg(sendMagParam); + + //浠诲姟鍙戦�佽褰� + ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); + serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); + serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); + serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); + serviceSubtaskRecord.setPreachform("4"); + serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); + serviceSubtaskRecord.setResult(aBoolean == true ? "鎴愬姛" : "澶辫触"); + serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); + } + } else if (descByCode.equals("鍏紬鍙�")) { + //鍏紬鍙� + RSAPublicKeyExample rsaPublicKeyExample = new RSAPublicKeyExample(); + String taskId = rsaPublicKeyExample.encryptedData(ivrTask1.getTaskid().toString(), pub_key); + for (ServiceSubtask ivrTaskSingle : ivrTaskcalls) { + String patid = rsaPublicKeyExample.encryptedData(ivrTaskSingle.getPatid().toString(), pub_key); + SendMagParam sendMagParam = new SendMagParam(); + sendMagParam.setType("5"); + sendMagParam.setUrl(req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); + log.info("閾炬帴瀹屾暣璺緞锛歿}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + ivrTask1.getTaskName()); + //杩欎釜妯℃澘ID鍏堝啓姝伙紝鍚庨潰鍋氭垚鍙�� + sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); + Map map = new HashMap(); + map.put("first", ivrTask1.getTaskName()); + sendMagParam.setContent(JSON.toJSONString(map)); + Boolean aBoolean = sendService.sendMsg(sendMagParam); + + //浠诲姟鍙戦�佽褰� + ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); + serviceSubtaskRecord.setTaskid(ivrTaskSingle.getTaskid().toString()); + serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); + serviceSubtaskRecord.setTasktype(ivrTaskSingle.getType()); + serviceSubtaskRecord.setPreachform("4"); + serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); + serviceSubtaskRecord.setResult(aBoolean == true ? "鎴愬姛" : "澶辫触"); + serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); } } //閫氱煡 MQ 娑堟伅宸茶鎺ユ敹,鍙互ACK(浠庨槦鍒椾腑鍒犻櫎)浜� 锛堣繖涓渶瑕佹牴鎹笟鍔″啀鍘诲鐞咥CK锛� @@ -267,6 +411,15 @@ //濡備綍浠诲姟琚�滄殏鍋溾�濇垨鈥滅粓姝⑩�� break; } + + //浠诲姟鍙戦�佽褰曪紙杩欎釜浠g爜搴旇鍐欏湪phoneTask涓紝鍏堝啓鍦ㄨ繖锛屽悗闈㈠啀鏀癸級 + ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); + serviceSubtaskRecord.setTaskid(svyTaskSingle1.getTaskid().toString()); + serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); + serviceSubtaskRecord.setTasktype(svyTaskSingle1.getType()); + serviceSubtaskRecord.setPreachform("3"); + serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); + serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); //閫氳繃澶氱嚎绋嬬殑鏂瑰紡鍘绘墦鐢佃瘽 // executorService.submit(new PhoneTask(ivrTaskcall1, ivrTaskTemplateVO1, redisCache, sendService, phonePath, robotPhoneUtils)); } @@ -284,14 +437,24 @@ String patid = rsaPublicKeyExample.encryptedData(svyTaskSingle1.getPatid().toString(), pub_key); SendMagParam sendMagParam = new SendMagParam(); sendMagParam.setType("5"); - sendMagParam.setUrl(req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskname()); - log.info("閾炬帴瀹屾暣璺緞锛歿}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskname()); + sendMagParam.setUrl(req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName()); + log.info("閾炬帴瀹屾暣璺緞锛歿}", req_path + "/outsideChain?param1=" + taskId + "¶m2=" + patid + "¶m3=" + svyTask.getTaskName()); //杩欎釜妯℃澘ID鍏堝啓姝伙紝鍚庨潰鍋氭垚鍙�� sendMagParam.setTmpCode("oG3pJHPVWpE81DmZsua_2tKwgJ97r0qz37z56ns7NB4"); Map map = new HashMap(); - map.put("first", svyTask.getTaskname()); + map.put("first", svyTask.getTaskName()); sendMagParam.setContent(JSON.toJSONString(map)); - sendService.sendMsg(sendMagParam); + Boolean aBoolean = sendService.sendMsg(sendMagParam); + + //浠诲姟鍙戦�佽褰� + ServiceSubtaskRecord serviceSubtaskRecord = new ServiceSubtaskRecord(); + serviceSubtaskRecord.setTaskid(svyTaskSingle1.getTaskid().toString()); + serviceSubtaskRecord.setUuid(UUID.randomUUID().toString()); + serviceSubtaskRecord.setTasktype(svyTaskSingle1.getType()); + serviceSubtaskRecord.setPreachform("4"); + serviceSubtaskRecord.setStartTime(System.currentTimeMillis()); + serviceSubtaskRecord.setResult(aBoolean == true ? "鎴愬姛" : "澶辫触"); + serviceSubtaskRecordService.insertServiceSubtaskRecord(serviceSubtaskRecord); } } //閫氱煡 MQ 娑堟伅宸茶鎺ユ敹,鍙互ACK(浠庨槦鍒椾腑鍒犻櫎)浜� 锛堣繖涓渶瑕佹牴鎹笟鍔″啀鍘诲鐞咥CK锛� -- Gitblit v1.9.3