liusheng
2024-06-24 3153009257c97b0f0099f787e951dd15472d077e
代码提交
已添加3个文件
已删除1个文件
已修改14个文件
已重命名1个文件
563 ■■■■■ 文件已修改
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/CommonTaskController.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/IvrTaskController.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/TestLsController.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/CommonTaskcallMQ.java 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/SendTaskVO.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/SvyLibTemplateScript.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/SvyTask.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/SvyTaskTemplateScript.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/domain/SvyTaskTemplateScriptVO.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/CommonTaskService.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/IIvrTaskService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/CommonTaskServiceImpl.java 229 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/IvrTaskServiceImpl.java 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/java/com/smartor/service/impl/SvyLibTemplateServiceImpl.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/SvyLibTemplateScriptMapper.xml 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/SvyLibTemplateTargetoptionMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/SvyTaskMapper.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
smartor/src/main/resources/mapper/smartor/SvyTaskTemplateScriptMapper.xml 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/component/RedisMqReceiver.java
@@ -102,14 +102,14 @@
            log.info("不是任务信息");
            return;
        }
        IvrTaskcallMQ ivrTaskcallMQ = null;
        CommonTaskcallMQ ivrTaskcallMQ = null;
        try {
            ObjectMapper mapper = new ObjectMapper();
            try {
                if (!content.startsWith("{")) {
                    ivrTaskcallMQ = mapper.readValue("{" + content + "}", IvrTaskcallMQ.class);
                    ivrTaskcallMQ = mapper.readValue("{" + content + "}", CommonTaskcallMQ.class);
                } else {
                    ivrTaskcallMQ = mapper.readValue(content, IvrTaskcallMQ.class);
                    ivrTaskcallMQ = mapper.readValue(content, CommonTaskcallMQ.class);
                }
            } catch (JsonProcessingException e) {
                e.printStackTrace();
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/CommonTaskController.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,54 @@
package com.ruoyi.web.controller.smartor;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.smartor.domain.SendTaskVO;
import com.smartor.domain.ServiceThirdData;
import com.smartor.service.CommonTaskService;
import com.smartor.service.IServiceThirdDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * é€šç”¨ä»»åŠ¡Controller
 *
 * @author ruoyi
 * @date 2023-06-26
 */
@Api(description = "CommonTaskController")
@RestController
@RequestMapping("/commonTask")
public class CommonTaskController extends BaseController {
    @Autowired
    private IServiceThirdDataService iServiceThirdDataService;
    @Autowired
    private CommonTaskService commonTaskService;
    /**
     * æŸ¥è¯¢é¢˜ç›®åˆ—表(义乌的his数据获取情况)
     */
    @PostMapping("/list")
    public TableDataInfo list(@RequestBody ServiceThirdData serviceThirdData) {
        List<ServiceThirdData> list = iServiceThirdDataService.queryList(serviceThirdData);
        return getDataTable(list);
    }
    /**
     * ä»»åŠ¡çš„å‘é€æ‰§è¡Œã€æš‚åœã€ç»ˆæ­¢
     */
    @ApiOperation("任务的发送执行、暂停、终止")
    @PostMapping("/taskSend")
    public AjaxResult taskSend(@RequestBody SendTaskVO sendTaskVO) {
        return toAjax(commonTaskService.taskSend(sendTaskVO));
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/IvrTaskController.java
@@ -173,13 +173,4 @@
        return getDataTable(ivrTaskService.getScriptInfoByCondition(tid, pid));
    }
    /**
     * ä»»åŠ¡çš„å‘é€æ‰§è¡Œã€æš‚åœã€ç»ˆæ­¢
     */
    @ApiOperation("任务的发送执行、暂停、终止")
    @PostMapping("/taskSend")
    public AjaxResult taskSend(@RequestBody SendTaskVO sendTaskVO) {
        return toAjax(ivrTaskService.taskSend(sendTaskVO));
    }
}
ruoyi-admin/src/main/java/com/ruoyi/web/controller/smartor/TestLsController.java
ÎļþÒÑɾ³ý
smartor/src/main/java/com/smartor/domain/CommonTaskcallMQ.java
ÎļþÃû´Ó smartor/src/main/java/com/smartor/domain/IvrTaskcallMQ.java ÐÞ¸Ä
@@ -1,17 +1,11 @@
package com.smartor.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
 * MQ任务
@@ -19,9 +13,9 @@
 * @author ruoyi
 * @date 2024-02-02
 */
@ApiModel(value = "IvrTaskcallMQ", description = "MQ任务")
@ApiModel(value = "CommonTaskcallMQ", description = "MQ任务")
@Data
public class IvrTaskcallMQ {
public class CommonTaskcallMQ {
    private static final long serialVersionUID = 1L;
    /**
@@ -58,6 +52,12 @@
    @ApiModelProperty(value = "暂停状态 ï¼š çŠ¶æ€å¦‚æžœå‘ç”Ÿä¿®æ”¹ï¼Œå€¼å°±åŠ 1")
    private Long stopState;
    /**
     * æš‚停状态 ï¼š çŠ¶æ€å¦‚æžœå‘ç”Ÿä¿®æ”¹ï¼Œå€¼å°±åŠ 1
     */
    @ApiModelProperty(value = "暂停状态 ï¼š çŠ¶æ€å¦‚æžœå‘ç”Ÿä¿®æ”¹ï¼Œå€¼å°±åŠ 1")
    private Integer taskType;
    /**
     * å‘送时间段
smartor/src/main/java/com/smartor/domain/SendTaskVO.java
@@ -26,5 +26,12 @@
    @ApiModelProperty(value = "发送状态: 1创建   2执行中   3 æš‚停   4终止  5完成 ")
    private Integer sendState;
    /**
     * ä»»åŠ¡ç±»åž‹ï¼š  1  éšè®¿   2 é—®å·    3 å®£æ•™
     */
    @Excel(name = " ä»»åŠ¡ç±»åž‹ï¼š  1  éšè®¿   2 é—®å·    3 å®£æ•™ ")
    @ApiModelProperty(value = "任务类型:  1  éšè®¿   2 é—®å·    3 å®£æ•™ ")
    private Integer taskType;
}
smartor/src/main/java/com/smartor/domain/SvyLibTemplateScript.java
@@ -230,4 +230,11 @@
    @ApiModelProperty("题目分值:数字1,2等;字母A、B,C,D等;")
    private String score;
    /**
     * é¢˜ç›®ä¸»é¢˜
     */
    @Excel(name = "题目主题")
    @ApiModelProperty("题目主题")
    private String topic;
}
smartor/src/main/java/com/smartor/domain/SvyTask.java
@@ -236,7 +236,7 @@
     */
    @Excel(name = "是否发送 ï¼š 0 æš‚停发送  1 å®šæ—¶å‘送  2 ç«‹å³å‘送  ")
    @ApiModelProperty(value = "是否发送 ï¼š 0 æš‚停发送  1 å®šæ—¶å‘送  2 ç«‹å³å‘送")
    private Long isSend;
    private Long sendType;
    /**
     * å‘送状态:  0  å¤±è´¥   1成功
smartor/src/main/java/com/smartor/domain/SvyTaskTemplateScript.java
@@ -152,6 +152,12 @@
    private Long playWavOnly;
    /**
     * æŽ’序
     */
    @ApiModelProperty(value = "排序")
    private Long sort;
    /**
     * åˆ é™¤æ ‡è®°
     */
    private String delFlag;
@@ -241,4 +247,12 @@
    @ApiModelProperty(value = "问题图片路径")
    private String picturePath;
    /**
     * é¢˜ç›®ä¸»é¢˜
     */
    @Excel(name = "题目主题")
    @ApiModelProperty("题目主题")
    private String topic;
}
smartor/src/main/java/com/smartor/domain/SvyTaskTemplateScriptVO.java
@@ -28,6 +28,13 @@
    private Long ID;
    /**
     * é¢˜ç›®ä¸»é¢˜
     */
    @Excel(name = "题目主题")
    @ApiModelProperty("题目主题")
    private String topic;
    /**
     * ä»»åŠ¡id
     */
    @ApiModelProperty(value = "任务id")
smartor/src/main/java/com/smartor/service/CommonTaskService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,23 @@
package com.smartor.service;
import com.smartor.domain.SendTaskVO;
import com.smartor.domain.ServiceThirdData;
import java.util.List;
/**
 * ç¬¬ä¸‰æ–¹åŽ‚å•†æ•°æ®Service接口
 *
 * @author ruoyi
 * @date 2023-10-10
 */
public interface CommonTaskService {
    /**
     * ä»»åŠ¡å‘é€æ‰§è¡Œ
     *
     * @param sendTaskVO
     * @return ç»“æžœ
     */
    public Integer taskSend(SendTaskVO sendTaskVO);
}
smartor/src/main/java/com/smartor/service/IIvrTaskService.java
@@ -65,11 +65,4 @@
    public  List<IvrLibaTemplateScriptVO> getScriptInfoByCondition(Long taskid, Long patid);
    /**
     * ä»»åŠ¡å‘é€æ‰§è¡Œ
     *
     * @param sendTaskVO
     * @return ç»“æžœ
     */
    public int taskSend(SendTaskVO sendTaskVO);
}
smartor/src/main/java/com/smartor/service/impl/CommonTaskServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,229 @@
package com.smartor.service.impl;
import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.DtoConversionUtils;
import com.smartor.domain.*;
import com.smartor.service.CommonTaskService;
import com.smartor.service.IIvrTaskService;
import com.smartor.service.ISvyTaskService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
 * ç¬¬ä¸‰æ–¹åŽ‚å•†æ•°æ®Service业务层处理
 *
 * @author ruoyi
 * @date 2023-10-10
 */
@Slf4j
@Service
public class CommonTaskServiceImpl implements CommonTaskService {
    @Autowired
    private IIvrTaskService ivrTaskService;
    @Autowired
    private ISvyTaskService iSvyTaskService;
    @Autowired
    private RedisCache redisCache;
    @Override
    public Integer taskSend(SendTaskVO sendTaskVO) {
        if (sendTaskVO.getTaskId() == null || sendTaskVO.getTaskType() == null)
            throw new BaseException("任务ID或者任务类型不能为空,请检查后,再进行执行");
        if (sendTaskVO.getTaskType() == 1) {
            //随访
            return sfSend(sendTaskVO);
        } else if (sendTaskVO.getTaskType() == 2) {
            //问卷
            return wjSend(sendTaskVO);
        } else if (sendTaskVO.getTaskType() == 3) {
            //宣教
        }
        return null;
    }
    public int sfSend(SendTaskVO sendTaskVO) {
        IvrTask ivrTask = ivrTaskService.selectIvrTaskByTaskid(sendTaskVO.getTaskId());
        if (sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 3 || sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 4) {
            //任务暂停或终止
            IvrTask ivrTask3 = new IvrTask();
            ivrTask3.setTaskid(sendTaskVO.getTaskId());
            ivrTask3.setStopState(ivrTask.getStopState() + 1);
            ivrTask3.setSendState(sendTaskVO.getSendState());
            ivrTaskService.updateIvrTask(ivrTask3);
            return 0;
        }
        //判断发送状态是否为空
        if (StringUtils.isEmpty(sendTaskVO.getSendType())) {
            sendTaskVO.setSendType(ivrTask.getSendType().toString());
        }
        //判断任务是否是立即发送
        if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) {
            String content = sendMQContent(sendTaskVO, ivrTask.getTemplateid().toString(), ivrTask.getPreachform(), ivrTask.getStopState(), null);
            //立即发送
            redisCache.setCacheObject(content, content, 1, TimeUnit.SECONDS);
            //将任务状态修改成执行中
            IvrTask ivrTask2 = new IvrTask();
            ivrTask2.setTaskid(ivrTask.getTaskid());
            ivrTask2.setSendState(2);
            ivrTaskService.updateIvrTask(ivrTask2);
        } else if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("1") || StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("3")) {
            //时间段发送
            ObjectMapper objectMapper = new ObjectMapper();
            if (org.apache.commons.lang3.StringUtils.isNotEmpty(ivrTask.getSendTimeSlot())) {
                List<TaskSendTimeVO> taskSendTimeVOList = null;
                try {
                    taskSendTimeVOList = objectMapper.readValue(ivrTask.getSendTimeSlot(), new TypeReference<List<TaskSendTimeVO>>() {
                    });
                } catch (JsonProcessingException e) {
                    log.error("JsonProcessingException报错了:{}", e.getMessage());
                }
                for (TaskSendTimeVO taskSendTimeVO : taskSendTimeVOList) {
                    //去SendTimeslot中,获取所有的时间段
                    List<TaskSendTimeVO> list = new ArrayList<>();
                    list.add(taskSendTimeVO);
                    //获取开始发送时间
                    String begantime = taskSendTimeVO.getBegantime();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    //记录目前到发送时间的毫秒值 ï¼ˆå‘送时间的毫秒值 - å½“前时间的毫秒值)
                    Long milliseconds = 1000L;
                    try {
                        Date date = sdf.parse(begantime);
                        milliseconds = date.getTime() - System.currentTimeMillis();
                        System.out.println("日期毫秒数:" + milliseconds);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    SendTaskVO sendTaskVO1 = DtoConversionUtils.sourceToTarget(sendTaskVO, SendTaskVO.class);
                    sendTaskVO1.setSendType("1");
                    String content = sendMQContent(sendTaskVO1, ivrTask.getTemplateid().toString(), ivrTask.getPreachform(), ivrTask.getStopState(), list);
                    redisCache.setCacheObject(content, content, milliseconds / 1000, TimeUnit.SECONDS);
                }
                //将任务状态修改成执行中
                IvrTask ivrTask2 = new IvrTask();
                ivrTask2.setTaskid(ivrTask.getTaskid());
                ivrTask2.setSendState(2);
                ivrTaskService.updateIvrTask(ivrTask2);
            }
        }
        return 1;
    }
    public int wjSend(SendTaskVO sendTaskVO) {
        SvyTask svyTask = iSvyTaskService.selectSvyTaskByTaskid(sendTaskVO.getTaskId());
        if (sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 3 || sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 4) {
            //任务暂停或终止
            SvyTask svyTask1 = new SvyTask();
            svyTask1.setTaskid(sendTaskVO.getTaskId());
            svyTask1.setStopState(svyTask.getStopState() + 1);
            svyTask1.setSendState(sendTaskVO.getSendState().toString());
            iSvyTaskService.updateSvyTask(svyTask1);
            return 0;
        }
        //判断发送状态是否为空
        if (StringUtils.isEmpty(sendTaskVO.getSendType())) {
            sendTaskVO.setSendType(svyTask.getSendType().toString());
        }
        //判断任务是否是立即发送
        if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) {
            String content = sendMQContent(sendTaskVO, svyTask.getTemplateid(), svyTask.getPreachform(), svyTask.getStopState(), null);
            //立即发送
            redisCache.setCacheObject(content, content, 1, TimeUnit.SECONDS);
            //将任务状态修改成执行中
            SvyTask svyTask2 = new SvyTask();
            svyTask2.setTaskid(svyTask.getTaskid());
            svyTask2.setSendState("2");
            iSvyTaskService.updateSvyTask(svyTask2);
        } else if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("1") || StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("3")) {
            //时间段发送
            ObjectMapper objectMapper = new ObjectMapper();
            if (StringUtils.isNotEmpty(svyTask.getSendTimeSlot())) {
                List<TaskSendTimeVO> taskSendTimeVOList = null;
                try {
                    taskSendTimeVOList = objectMapper.readValue(svyTask.getSendTimeSlot(), new TypeReference<List<TaskSendTimeVO>>() {
                    });
                } catch (JsonProcessingException e) {
                    log.error("JsonProcessingException报错了:{}", e.getMessage());
                }
                for (TaskSendTimeVO taskSendTimeVO : taskSendTimeVOList) {
                    //去SendTimeslot中,获取所有的时间段
                    List<TaskSendTimeVO> list = new ArrayList<>();
                    list.add(taskSendTimeVO);
                    //获取开始发送时间
                    String begantime = taskSendTimeVO.getBegantime();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    //记录目前到发送时间的毫秒值 ï¼ˆå‘送时间的毫秒值 - å½“前时间的毫秒值)
                    Long milliseconds = 1000L;
                    try {
                        Date date = sdf.parse(begantime);
                        milliseconds = date.getTime() - System.currentTimeMillis();
                        System.out.println("日期毫秒数:" + milliseconds);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    SendTaskVO sendTaskVO1 = DtoConversionUtils.sourceToTarget(sendTaskVO, SendTaskVO.class);
                    sendTaskVO1.setSendType("1");
                    String content = sendMQContent(sendTaskVO1, svyTask.getTemplateid(), svyTask.getPreachform(), svyTask.getStopState(), list);
                    redisCache.setCacheObject(content, content, milliseconds / 1000, TimeUnit.SECONDS);
                }
                //将任务状态修改成执行中
                SvyTask svyTask3 = new SvyTask();
                svyTask3.setTaskid(svyTask.getTaskid());
                svyTask3.setSendState("2");
                iSvyTaskService.updateSvyTask(svyTask3);
            }
        }
        return 1;
    }
    /**
     * MQ任务创建内容
     *
     * @param sendTaskVO
     * @param templateid
     * @param preachform
     * @param stopState
     * @param sendTimeslot
     * @return
     */
    private String sendMQContent(SendTaskVO sendTaskVO, String templateid, String preachform, Long stopState, List<TaskSendTimeVO> sendTimeslot) {
        CommonTaskcallMQ commonTaskcallMQ = new CommonTaskcallMQ();
        commonTaskcallMQ.setTaskid(sendTaskVO.getTaskId());
        commonTaskcallMQ.setSendType(sendTaskVO.getSendType());
        commonTaskcallMQ.setTemplateid(templateid);
        commonTaskcallMQ.setPreachform(preachform);
        commonTaskcallMQ.setStopState(stopState);
        commonTaskcallMQ.setTaskType(sendTaskVO.getTaskType());
        commonTaskcallMQ.setSendTimeslot(sendTimeslot);
        String commonTaskcallMQJson = JSON.toJSONString(commonTaskcallMQ);
        commonTaskcallMQJson = commonTaskcallMQJson.substring(1, commonTaskcallMQJson.length() - 1);
        return commonTaskcallMQJson;
    }
}
smartor/src/main/java/com/smartor/service/impl/IvrTaskServiceImpl.java
@@ -186,99 +186,5 @@
        return ivrLibaTemplateScriptVOS;
    }
    /**
     * ä»»åŠ¡å‘é€
     *
     * @return
     */
    @Override
    public int taskSend(SendTaskVO sendTaskVO) {
        if (sendTaskVO.getTaskId() == null) throw new BaseException("任务ID不能为空,请检查后,再进行执行");
        IvrTask ivrTask = selectIvrTaskByTaskid(sendTaskVO.getTaskId());
        if (sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 3 || sendTaskVO.getSendState() != null && sendTaskVO.getSendState() == 4) {
            //任务暂停或终止
            IvrTask ivrTask3 = new IvrTask();
            ivrTask3.setTaskid(sendTaskVO.getTaskId());
            ivrTask3.setStopState(ivrTask.getStopState() + 1);
            ivrTask3.setSendState(sendTaskVO.getSendState());
            updateIvrTask(ivrTask3);
            return 0;
        }
        //判断发送状态是否为空
        if (org.apache.commons.lang3.StringUtils.isEmpty(sendTaskVO.getSendType())) {
            sendTaskVO.setSendType(ivrTask.getSendType().toString());
        }
        //判断任务是否是立即发送
        if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("2")) {
            IvrTaskcallMQ ivrTaskcallMQ = new IvrTaskcallMQ();
            ivrTaskcallMQ.setTaskid(sendTaskVO.getTaskId());
            ivrTaskcallMQ.setSendType(sendTaskVO.getSendType());
            ivrTaskcallMQ.setTemplateid(ivrTask.getTemplateid().toString());
            ivrTaskcallMQ.setPreachform(ivrTask.getPreachform());
            ivrTaskcallMQ.setStopState(ivrTask.getStopState());
            String ivrTaskcallMQJson = JSON.toJSONString(ivrTaskcallMQ);
            ivrTaskcallMQJson = ivrTaskcallMQJson.substring(1, ivrTaskcallMQJson.length() - 1);
            //立即发送
//            rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", ivrTaskcallMQJson, 0L);
            redisCache.setCacheObject(ivrTaskcallMQJson, ivrTaskcallMQJson, 1, TimeUnit.SECONDS);
            //将任务状态修改成执行中
            IvrTask ivrTask2 = new IvrTask();
            ivrTask2.setTaskid(ivrTask.getTaskid());
            ivrTask2.setSendState(2);
            updateIvrTask(ivrTask2);
        } else if (StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("1") || StringUtils.isNotEmpty(sendTaskVO.getSendType()) && sendTaskVO.getSendType().equals("3")) {
            //时间段发送
            ObjectMapper objectMapper = new ObjectMapper();
            if (org.apache.commons.lang3.StringUtils.isNotEmpty(ivrTask.getSendTimeSlot())) {
                List<TaskSendTimeVO> taskSendTimeVOList = null;
                try {
                    taskSendTimeVOList = objectMapper.readValue(ivrTask.getSendTimeSlot(), new TypeReference<List<TaskSendTimeVO>>() {
                    });
                } catch (JsonProcessingException e) {
                    log.error("JsonProcessingException报错了:{}", e.getMessage());
                }
                for (TaskSendTimeVO taskSendTimeVO : taskSendTimeVOList) {
                    //去SendTimeslot中,获取所有的时间段
                    List<TaskSendTimeVO> list = new ArrayList<>();
                    list.add(taskSendTimeVO);
                    //获取开始发送时间
                    String begantime = taskSendTimeVO.getBegantime();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                    //记录目前到发送时间的毫秒值 ï¼ˆå‘送时间的毫秒值 - å½“前时间的毫秒值)
                    Long milliseconds = 1000L;
                    try {
                        Date date = sdf.parse(begantime);
                        milliseconds = date.getTime() - System.currentTimeMillis();
                        System.out.println("日期毫秒数:" + milliseconds);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    IvrTaskcallMQ ivrTaskcallMQ = new IvrTaskcallMQ();
                    ivrTaskcallMQ.setTaskid(sendTaskVO.getTaskId());
                    ivrTaskcallMQ.setSendType("1");
                    ivrTaskcallMQ.setTemplateid(ivrTask.getTemplateid().toString());
                    ivrTaskcallMQ.setSendTimeslot(list);
                    ivrTaskcallMQ.setStopState(ivrTask.getStopState());
                    ivrTaskcallMQ.setPreachform(ivrTask.getPreachform());
                    Long finalMilliseconds = milliseconds;
                    String ivrTaskcallMQJson = JSON.toJSONString(ivrTaskcallMQ);
                    ivrTaskcallMQJson = ivrTaskcallMQJson.substring(1, ivrTaskcallMQJson.length() - 1);
//                    rabbitMqCallPhoneConfig.sendMessage("phone_exchange", "phone.123", ivrTaskcallMQJson, milliseconds);
                    redisCache.setCacheObject(ivrTaskcallMQJson, ivrTaskcallMQJson, milliseconds / 1000, TimeUnit.SECONDS);
                }
                //将任务状态修改成执行中
                IvrTask ivrTask2 = new IvrTask();
                ivrTask2.setTaskid(ivrTask.getTaskid());
                ivrTask2.setSendState(2);
                updateIvrTask(ivrTask2);
            }
        }
        return 1;
    }
}
smartor/src/main/java/com/smartor/service/impl/SvyLibTemplateServiceImpl.java
@@ -14,6 +14,7 @@
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@@ -162,20 +163,22 @@
        //处理题目
        if (CollectionUtils.isNotEmpty(svyLibTemplate.getSvyLibScripts())) {
            for (SvyLibTemplateScript svyLibScript : svyLibTemplate.getSvyLibScripts()) {
                SvyLibTemplateScript svyLibTemplateScript = DtoConversionUtils.sourceToTarget(svyLibScript, SvyLibTemplateScript.class);
//                SvyLibTemplateScript svyLibTemplateScript = DtoConversionUtils.sourceToTarget(svyLibScript, SvyLibTemplateScript.class);
                //对题目进行处理
                if (svyLibScript.getIsoperation() != null && svyLibScript.getIsoperation() == 1) {
                    //新增
                    svyLibTemplateScript.setSvyid(svyLibTemplate.getSvyid());
                    svyLibTemplateScript.setId(null);
                    svyLibTemplateScriptMapper.insertSvyLibTemplateScript(svyLibTemplateScript);
                    svyLibScript.setSvyid(svyLibTemplate.getSvyid());
                    svyLibScript.setId(null);
                    svyLibScript.setCreateTime(new Date());
                    svyLibTemplateScriptMapper.insertSvyLibTemplateScript(svyLibScript);
                } else if (svyLibScript.getIsoperation() != null && svyLibScript.getIsoperation() == 2) {
                    //修改
                    svyLibTemplateScript.setSvyid(svyLibTemplate.getSvyid());
                    svyLibTemplateScriptMapper.updateSvyLibTemplateScript(svyLibTemplateScript);
                    svyLibScript.setSvyid(svyLibTemplate.getSvyid());
                    svyLibScript.setUpdateTime(new Date());
                    svyLibTemplateScriptMapper.updateSvyLibTemplateScript(svyLibScript);
                } else if (svyLibScript.getIsoperation() != null && svyLibScript.getIsoperation() == 3) {
                    svyLibTemplateScriptMapper.deleteSvyLibTemplateScriptByTopicid(svyLibTemplateScript.getId());
                    svyLibTemplateScriptMapper.deleteSvyLibTemplateScriptByTopicid(svyLibScript.getId());
                }
                //对题目选项进行处理
@@ -184,10 +187,12 @@
                        if (svyLibTemplateTargetoption.getIsoperation() != null && svyLibTemplateTargetoption.getIsoperation() == 1) {
                            //新增
                            svyLibTemplateTargetoption.setScriptid(svyLibScript.getId());
                            svyLibTemplateTargetoption.setCreateTime(new Date());
                            svyLibTemplateTargetoptionMapper.insertSvyLibTemplateTargetoption(svyLibTemplateTargetoption);
                        } else if (svyLibTemplateTargetoption.getIsoperation() != null && svyLibTemplateTargetoption.getIsoperation() == 2) {
                            //修改
                            svyLibTemplateTargetoption.setScriptid(svyLibScript.getId());
                            svyLibTemplateTargetoption.setUpdateTime(new Date());
                            svyLibTemplateTargetoptionMapper.updateSvyLibTemplateTargetoption(svyLibTemplateTargetoption);
                        } else if (svyLibTemplateTargetoption.getIsoperation() != null && svyLibTemplateTargetoption.getIsoperation() == 3) {
                            //删除
smartor/src/main/resources/mapper/smartor/SvyLibTemplateScriptMapper.xml
@@ -37,6 +37,7 @@
        <result property="scoretype" column="scoretype"/>
        <result property="score" column="score"/>
        <result property="scriptPicture" column="script_picture"/>
        <result property="topic" column="topic"/>
    </resultMap>
    <sql id="selectSvyLibTemplateScriptVo">
@@ -65,6 +66,7 @@
               script_content,
               suitway,
               script_picture,
               topic,
               isavailable, language, otherdata, value_type, reply, scoretype, score
        from svy_lib_template_script
    </sql>
@@ -73,6 +75,7 @@
            resultMap="SvyLibTemplateScriptResult">
        <include refid="selectSvyLibTemplateScriptVo"/>
        <where>
            del_flag=0
            <if test="oldid != null ">and oldid = #{oldid}</if>
            <if test="svyid != null ">and svyid = #{svyid}</if>
            <if test="scriptType != null  and scriptType != ''">and script_type = #{scriptType}</if>
@@ -98,6 +101,7 @@
            <if test="reply != null  and reply != ''">and reply = #{reply}</if>
            <if test="scoretype != null  and scoretype != ''">and scoretype = #{scoretype}</if>
            <if test="score != null  and score != ''">and score = #{score}</if>
            <if test="topic != null  and topic != ''">and topic = #{topic}</if>
        </where>
    </select>
@@ -141,6 +145,7 @@
            <if test="scoretype != null">scoretype,</if>
            <if test="score != null">score,</if>
            <if test="scriptPicture != null">script_picture,</if>
            <if test="topic != null">topic,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="oldid != null">#{oldid},</if>
@@ -174,6 +179,7 @@
            <if test="scoretype != null">#{scoretype},</if>
            <if test="score != null">#{score},</if>
            <if test="scriptPicture != null">#{scriptPicture},</if>
            <if test="topic != null">#{topic},</if>
        </trim>
    </insert>
@@ -211,6 +217,7 @@
            <if test="scoretype != null">scoretype = #{scoretype},</if>
            <if test="score != null">score = #{score},</if>
            <if test="scriptPicture != null">script_picture = #{scriptPicture},</if>
            <if test="topic != null">topic = #{topic},</if>
        </trim>
        where id = #{id}
    </update>
smartor/src/main/resources/mapper/smartor/SvyLibTemplateTargetoptionMapper.xml
@@ -64,6 +64,7 @@
            resultMap="SvyLibTemplateTargetoptionResult">
        <include refid="selectSvyLibTemplateTargetoptionVo"/>
        <where>
            del_flag=0
            <if test="groupid != null  and groupid != ''">and groupid = #{groupid}</if>
            <if test="categoryName != null  and categoryName != ''">and categoryName like concat('%', #{categoryName},
                '%')
smartor/src/main/resources/mapper/smartor/SvyTaskMapper.xml
@@ -39,7 +39,7 @@
        <result property="pid" column="pid"/>
        <result property="guid" column="guid"/>
        <result property="preachform" column="preachform"/>
        <result property="isSend" column="is_send"/>
        <result property="sendType" column="send_type"/>
        <result property="sendState" column="send_state"/>
        <result property="param" column="param"/>
        <result property="textParam" column="text_param"/>
@@ -97,7 +97,7 @@
               pid,
               guid,
               preachform,
               is_send,
               send_type,
               send_state,
               param
        from svy_task
@@ -140,7 +140,7 @@
            <if test="pid != null ">and pid = #{pid}</if>
            <if test="guid != null  and guid != ''">and guid = #{guid}</if>
            <if test="preachform != null  and preachform != ''">and preachform = #{preachform}</if>
            <if test="isSend != null ">and is_send = #{isSend}</if>
            <if test="sendType != null ">and send_type = #{sendType}</if>
            <if test="sendState != null  and sendState != ''">and send_state = #{sendState}</if>
            <if test="param != null  and param != ''">and param = #{param}</if>
            <if test="sendTimeSlot != null  and sendTimeSlot != ''">and send_time_slot like concat('%', #{sendTimeSlot},
@@ -192,7 +192,7 @@
            <if test="pid != null">pid,</if>
            <if test="guid != null">guid,</if>
            <if test="preachform != null">preachform,</if>
            <if test="isSend != null">is_send,</if>
            <if test="sendType != null">send_type,</if>
            <if test="sendState != null">send_state,</if>
            <if test="param != null">param,</if>
            <if test="textParam != null">text_param,</if>
@@ -239,7 +239,7 @@
            <if test="pid != null">#{pid},</if>
            <if test="guid != null">#{guid},</if>
            <if test="preachform != null">#{preachform},</if>
            <if test="isSend != null">#{isSend},</if>
            <if test="sendType != null">#{sendType},</if>
            <if test="sendState != null">#{sendState},</if>
            <if test="param != null">#{param},</if>
            <if test="textParam != null">#{textParam},</if>
@@ -290,7 +290,7 @@
            <if test="pid != null">pid = #{pid},</if>
            <if test="guid != null">guid = #{guid},</if>
            <if test="preachform != null">preachform = #{preachform},</if>
            <if test="isSend != null">is_send = #{isSend},</if>
            <if test="sendType != null">send_type = #{sendType},</if>
            <if test="sendState != null">send_state = #{sendState},</if>
            <if test="param != null">param = #{param},</if>
            <if test="textParam != null">text_param = #{textParam},</if>
smartor/src/main/resources/mapper/smartor/SvyTaskTemplateScriptMapper.xml
@@ -45,10 +45,12 @@
        <result property="questionResult"    column="question_result"    />
        <result property="otherdata"    column="otherdata"    />
        <result property="picturePath"    column="picture_path"    />
        <result property="sort"    column="sort"    />
        <result property="topic"    column="topic"    />
    </resultMap>
    <sql id="selectSvyTaskTemplateScriptVo">
        select ID, taskid, templateQuestionNum, templateID, scriptID, questiontitle, language, categoryName, questionPoint, questionText, questionVoice, noMatchText, noMatchVoice, slienceText, slienceVoice, submoduleText, submoduleVoice, noClearlyText, noClearlyVoice, is_must, playWavOnly, del_flag, update_by, update_time, create_by, create_time, isupload, upload_time, orgid, pid, guid, value_type, targetOptions, targettype, targetid, targetvalue, next_question, question_result, otherdata, picture_path from svy_task_template_script
        select ID,sort,topic, taskid, templateQuestionNum, templateID, scriptID, questiontitle, language, categoryName, questionPoint, questionText, questionVoice, noMatchText, noMatchVoice, slienceText, slienceVoice, submoduleText, submoduleVoice, noClearlyText, noClearlyVoice, is_must, playWavOnly, del_flag, update_by, update_time, create_by, create_time, isupload, upload_time, orgid, pid, guid, value_type, targetOptions, targettype, targetid, targetvalue, next_question, question_result, otherdata, picture_path from svy_task_template_script
    </sql>
    <select id="selectSvyTaskTemplateScriptList" parameterType="com.smartor.domain.SvyTaskTemplateScript" resultMap="SvyTaskTemplateScriptResult">
@@ -88,6 +90,7 @@
            <if test="questionResult != null  and questionResult != ''"> and question_result = #{questionResult}</if>
            <if test="otherdata != null  and otherdata != ''"> and otherdata = #{otherdata}</if>
            <if test="picturePath != null  and picturePath != ''"> and picture_path = #{picturePath}</if>
            <if test="topic != null  and topic != ''"> and topic = #{topic}</if>
        </where>
    </select>
@@ -138,6 +141,8 @@
            <if test="questionResult != null">question_result,</if>
            <if test="otherdata != null">otherdata,</if>
            <if test="picturePath != null">picture_path,</if>
            <if test="sort != null">sort,</if>
            <if test="topic != null">topic,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="taskid != null">#{taskid},</if>
@@ -179,6 +184,8 @@
            <if test="questionResult != null">#{questionResult},</if>
            <if test="otherdata != null">#{otherdata},</if>
            <if test="picturePath != null">#{picturePath},</if>
            <if test="sort != null">#{sort},</if>
            <if test="topic != null">#{topic},</if>
         </trim>
    </insert>
@@ -224,6 +231,8 @@
            <if test="questionResult != null">question_result = #{questionResult},</if>
            <if test="otherdata != null">otherdata = #{otherdata},</if>
            <if test="picturePath != null">picture_path = #{picturePath},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="topic != null">topic = #{topic},</if>
        </trim>
        where ID = #{ID}
    </update>