| | |
| | | import com.xxl.job.core.handler.annotation.XxlJob; |
| | | import com.xxl.job.core.log.XxlJobLogger; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | import java.util.List; |
| | | import java.util.concurrent.ExecutorService; |
| | | import java.util.concurrent.Executors; |
| | | |
| | | /** |
| | | * 巡查任务定时任务执行器 |
| | |
| | | * @date 2023-06-03 |
| | | */ |
| | | @Component |
| | | @Slf4j |
| | | public class PatrolXxlJob { |
| | | |
| | | @Autowired |
| | |
| | | String title = jsonParam.getString("title"); |
| | | String content = jsonParam.getString("content"); |
| | | String typeStr = jsonParam.getString("type"); |
| | | int type = 0; |
| | | if (!StringUtil.isBlank(typeStr)) |
| | | type = Integer.parseInt(typeStr); |
| | | |
| | | // 远程调用 |
| | | // List<Integer> taskJobHandler = patrolTasClient.createTaskJobHandler(processDefinitionId, taskType, title, content, type); |
| | | |
| | | List<Integer> taskJobHandler = patrolTasClient.createNewTaskJobHandler(taskType,title,content,type); |
| | | ExecutorService executorService = Executors.newSingleThreadExecutor(); |
| | | executorService.submit(() -> { |
| | | int type = 0; |
| | | if (!StringUtil.isBlank(typeStr)) |
| | | type = Integer.parseInt(typeStr); |
| | | // 这里是你的异步任务逻辑 |
| | | List<Integer> taskJobHandler = patrolTasClient.createNewTaskJobHandler(taskType,title,content,type); |
| | | |
| | | log.info("总数量:<span style='color:red'>" + taskJobHandler.get(0) + "</span> ... 失败数量:<span style='color:red'>" + taskJobHandler.get(1) + "</span> "); |
| | | }); |
| | | |
| | | // 打印响应数据 |
| | | XxlJobLogger.log("结束自动创建任务..."); |
| | | XxlJobLogger.log("总数量:<span style='color:red'>" + taskJobHandler.get(0) + "</span> ... 失败数量:<span style='color:red'>" + taskJobHandler.get(1) + "</span> "); |
| | | |
| | | return ReturnT.SUCCESS; |
| | | } |
| | | |