package cn.gistack.job.executor.jobhandler;
|
|
import cn.gistack.job.executor.entity.XxlJobInfo;
|
import cn.gistack.job.executor.service.IXxlJobInfoService;
|
import cn.gistack.job.executor.vo.XxlJobInfoVO;
|
import cn.gistack.sm.intelligentCall.feign.OutCallClient;
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.xxl.job.core.biz.model.ReturnT;
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
import com.xxl.job.core.log.XxlJobLogger;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
/**
|
* 智能外呼定时任务执行器
|
* @author zhongrj
|
* @date 2023-06-03
|
*/
|
@Component
|
public class OutCallXxlJob {
|
|
@Autowired
|
private OutCallClient outCallClient;
|
|
@Autowired
|
private IXxlJobInfoService xxlJobInfoService;
|
|
/**
|
* 智能外呼定时创建任务执行器
|
* @param param
|
* @return
|
* @throws Exception
|
*/
|
@XxlJob("createOutCallTaskJobHandler")
|
public ReturnT<String> createOutCallTaskJobHandler(String param){
|
XxlJobLogger.log("开始执行任务...");
|
JSONObject jsonParam = JSON.parseObject(param);
|
String isOver = jsonParam.getString("isOver");
|
String taskScheduleTime = jsonParam.getString("taskScheduleTime");
|
String personNumber = jsonParam.getString("personNumber");
|
String day = jsonParam.getString("day");
|
// 创建外呼任务
|
List<String> result = outCallClient.createOutCallTaskJobHandler(isOver,taskScheduleTime,personNumber, day);
|
XxlJobLogger.log("任务响应结果..." + result);
|
// if (result.get(2).equals("true")) {
|
// // 获取任务id
|
// String taskId = result.get(1);
|
// // 修改定时任务
|
// XxlJobInfo jobInfo = xxlJobInfoService.getById(11);
|
// // 解析参数
|
// Map mapParams = (Map) jobInfo.getExecutorParam();
|
// String time = mapParams.get("time").toString();
|
// XxlJobInfoVO xxlJobInfo = new XxlJobInfoVO();
|
// xxlJobInfo.setId(11);
|
// Map<String, Object> map = new HashMap<>(2);
|
// map.put("taskId", taskId);
|
// map.put("time", time);
|
// xxlJobInfo.setExecutorParam(map);
|
// Object o = xxlJobInfoService.updateXxlJobById(xxlJobInfo);
|
// if (Boolean.parseBoolean(o.toString())) {
|
// XxlJobLogger.log("外呼未接通短信通知定时任务修改成功!任务ID:" + taskId);
|
// }else {
|
// XxlJobLogger.log("外呼未接通短信通知定时任务修改失败!任务ID:" + taskId);
|
// }
|
// }
|
XxlJobLogger.log("结束自动创建任务...");
|
return ReturnT.SUCCESS;
|
}
|
|
/**
|
* 测试
|
* @param param
|
* @return
|
* @throws Exception
|
*/
|
@XxlJob("testOutCall")
|
public ReturnT<String> testOutCall(String param){
|
XxlJobLogger.log("开始执行任务...");
|
// JSONObject jsonParam = JSON.parseObject(param);
|
// String isOver = jsonParam.getString("isOver");
|
// String taskScheduleTime = jsonParam.getString("taskScheduleTime");
|
// String personNumber = jsonParam.getString("personNumber");
|
// String day = jsonParam.getString("day");
|
// 创建外呼任务
|
// Object result = outCallClient.testOutCall(isOver,taskScheduleTime,personNumber, day);
|
// XxlJobLogger.log("任务响应结果:" + result);
|
XxlJobLogger.log("结束自动创建任务...");
|
return ReturnT.SUCCESS;
|
}
|
}
|