| | |
| | | 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.log.XxlJobLogger; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 智能外呼定时任务执行器 |
| | |
| | | |
| | | @Autowired |
| | | private OutCallClient outCallClient; |
| | | |
| | | @Autowired |
| | | private IXxlJobInfoService xxlJobInfoService; |
| | | |
| | | /** |
| | | * 智能外呼定时创建任务执行器 |
| | |
| | | String day = jsonParam.getString("day"); |
| | | // 创建外呼任务 |
| | | Object result = outCallClient.createOutCallTaskJobHandler(isOver,taskScheduleTime,personNumber, day); |
| | | XxlJobLogger.log("任务响应结果:" + result); |
| | | String[] split = result.toString().split(","); |
| | | if (split[0].equals("true")) { |
| | | // 获取任务id |
| | | String taskId = split[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; |
| | | } |
| | |
| | | @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"); |
| | | // 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); |
| | | // Object result = outCallClient.testOutCall(isOver,taskScheduleTime,personNumber, day); |
| | | // XxlJobLogger.log("任务响应结果:" + result); |
| | | XxlJobLogger.log("结束自动创建任务..."); |
| | | return ReturnT.SUCCESS; |
| | | } |