liusheng
2024-08-05 89e166f18d6e33efde0dda97f1fb27f29e675660
ruoyi-admin/src/main/java/com/ruoyi/web/task/PhoneTask.java
@@ -7,39 +7,31 @@
import com.ruoyi.common.utils.uuid.IdUtils;
import com.smartor.common.SendService;
import com.smartor.config.PhoneUtils;
import com.smartor.config.RabbitMqCallPhoneConfig;
import com.smartor.config.RobotPhoneUtils;
import com.smartor.domain.*;
import com.smartor.domain.robot.RobotData;
import com.smartor.domain.robot.RobotDataConfig;
import com.smartor.domain.robot.RobotIdlenumVO;
import com.smartor.domain.robot.RobotScritpTemplateVO;
import org.springframework.amqp.core.Message;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.concurrent.TimeUnit;
public class PhoneTask implements Runnable {
    private IvrTaskSingle ivrTaskSingle;
    private ServiceSubtask ivrTaskSingle;
    private List<IvrTaskTemplateScriptVO> ivrTaskTemplateScriptVO;
    private RedisCache redisCache;
    private IvrTaskTemplateVO ivrTaskTemplateVO;
    private RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig;
    private Message message;
    private SendService sendService;
    private String phonePath;
    private RobotPhoneUtils robotPhoneUtils;
    public PhoneTask(IvrTaskSingle ivrTaskSingle, IvrTaskTemplateVO ivrTaskTemplateVO, RedisCache redisCache, RabbitMqCallPhoneConfig rabbitMqCallPhoneConfig, Message message, SendService sendService, String phonePath, RobotPhoneUtils robotPhoneUtils) {
        this.ivrTaskSingle = DtoConversionUtils.sourceToTarget(ivrTaskSingle, IvrTaskSingle.class);
    public PhoneTask(ServiceSubtask ivrTaskSingle, IvrTaskTemplateVO ivrTaskTemplateVO, RedisCache redisCache, SendService sendService, String phonePath, RobotPhoneUtils robotPhoneUtils) {
        this.ivrTaskSingle = DtoConversionUtils.sourceToTarget(ivrTaskSingle, ServiceSubtask.class);
        this.ivrTaskTemplateScriptVO = DtoConversionUtils.sourceToTarget(ivrTaskTemplateVO.getIvrTaskTemplateScriptVOList(), IvrTaskTemplateScriptVO.class);
        this.ivrTaskTemplateVO = DtoConversionUtils.sourceToTarget(ivrTaskTemplateVO, IvrTaskTemplateVO.class);
        this.redisCache = redisCache;
        this.rabbitMqCallPhoneConfig = rabbitMqCallPhoneConfig;
        this.message = message;
        this.sendService = sendService;
        this.phonePath = phonePath;
        this.robotPhoneUtils = robotPhoneUtils;
@@ -65,7 +57,7 @@
                    for (IvrTaskTemplateScriptVO ivrTaskTemplateScriptVO : ivrTaskTemplateScriptVO) {
                        for (Map<String, String> map : mapList) {
                            for (String key : map.keySet()) {
                                ivrTaskTemplateScriptVO.setQuestionText(ivrTaskTemplateScriptVO.getQuestionText().replace(key, map.get(key)));
                                ivrTaskTemplateScriptVO.setScriptContent(ivrTaskTemplateScriptVO.getScriptContent().replace(key, map.get(key)));
                            }
                        }
                    }
@@ -89,11 +81,11 @@
                redisCache.setCacheObject(uuid + "returnQues", returnQues, 120, TimeUnit.MINUTES);
                redisCache.setCacheObject(uuid + "ivrTaskTemplateVO", ivrTaskTemplateVO, 120, TimeUnit.MINUTES);
                System.out.println("----------------uuID为 :" + uuid + "       " + ivrTaskSingle.getSendname() + "       " + returnQues.getNowQuestion().getQuestionText() + "     " + ivrTaskSingle.getPhone());
                System.out.println("----------------uuID为 :" + uuid + "       " + ivrTaskSingle.getSendname() + "       " + returnQues.getNowQuestion().getScriptContent() + "     " + ivrTaskSingle.getPhone());
                //先将话术放到ob_queue队列中
                IvrTaskcallPhoneMQ ivrTaskcallPhoneMQ = new IvrTaskcallPhoneMQ();
                ivrTaskcallPhoneMQ.setScript(ivrTaskTemplateVO.getRevisitBefore() + returnQues.getNowQuestion().getQuestionText());
                ivrTaskcallPhoneMQ.setScript(ivrTaskTemplateVO.getRevisitBefore() + returnQues.getNowQuestion().getScriptContent());
                ivrTaskcallPhoneMQ.setType("1");
                ivrTaskcallPhoneMQ.setUuid(uuid);
                String data = JSON.toJSONString(ivrTaskcallPhoneMQ);
@@ -101,11 +93,11 @@
                //调用机器人电话,开始电话
                String ob = phoneUtils.ob("", "", "", "", "", "", "", ivrTaskSingle.getPhone(), uuid, true);
                System.out.println("----------------uuID为 :" + uuid + "       " + ivrTaskSingle.getSendname() + "       " + returnQues.getNowQuestion().getQuestionText() + "     " + ivrTaskSingle.getPhone() + "----------已经拨打");
                System.out.println("----------------uuID为 :" + uuid + "       " + ivrTaskSingle.getSendname() + "       " + returnQues.getNowQuestion().getScriptContent() + "     " + ivrTaskSingle.getPhone() + "----------已经拨打");
                Map<String, String> obMap = objectMapper.readValue(ob, Map.class);
                Thread.sleep(1000);
                redisCache.setCacheObject(uuid + "state_id", "0", 10, TimeUnit.MINUTES);
                rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.ob1", data, 0L);
//                rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.ob1", data, 0L);
//这里先注释,state_id,电话那边,只能返回6,不能返回0,还需要电话那边进行修改,那边修改之后,上面两行可删除,将下面的解开注释
//            if (obMap.get("state_id").equals("0")) {
//                // 说明打通了