添加任务接口
This commit is contained in:
parent
2f4b81fac0
commit
da84164744
|
|
@ -156,6 +156,16 @@ public class TaskController extends BaseController
|
|||
return R.ok(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询待自动执行的任务
|
||||
* @return 待执行任务列表
|
||||
*/
|
||||
@GetMapping("/pending-auto")
|
||||
public R<List<TaskVO>> getPendingTasksForAutoExecute()
|
||||
{
|
||||
return R.ok(TaskControllerConvert.fromList(taskService.getPendingTasksForAutoExecute()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 按年统计任务
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -67,4 +67,11 @@ public interface ITaskDomain {
|
|||
* @return 任务领域模型
|
||||
*/
|
||||
Task getCurrentTaskByUavId(String uavId);
|
||||
|
||||
/**
|
||||
* 查询待自动执行的任务(最近5分钟内)
|
||||
*
|
||||
* @return 任务列表
|
||||
*/
|
||||
List<Task> getPendingTasksForAutoExecute();
|
||||
}
|
||||
|
|
@ -92,4 +92,12 @@ public class TaskDomainImpl implements ITaskDomain {
|
|||
TaskInfoEntity entity = taskInfoMapper.selectCurrentTaskByUavId(uavId);
|
||||
return TaskConvert.toModel(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Task> getPendingTasksForAutoExecute() {
|
||||
List<TaskInfoEntity> entityList = taskInfoMapper.selectPendingTasksForAutoExecute();
|
||||
return entityList.stream()
|
||||
.map(TaskConvert::toModel)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
|
@ -65,4 +65,11 @@ public interface TaskInfoMapper {
|
|||
* @return 任务信息
|
||||
*/
|
||||
TaskInfoEntity selectCurrentTaskByUavId(String uavId);
|
||||
|
||||
/**
|
||||
* 查询待自动执行的任务(最近5分钟内)
|
||||
*
|
||||
* @return 待执行任务信息集合
|
||||
*/
|
||||
List<TaskInfoEntity> selectPendingTasksForAutoExecute();
|
||||
}
|
||||
|
|
@ -90,6 +90,12 @@ public interface ITaskService {
|
|||
*/
|
||||
boolean updateTaskRecovery(Long taskId);
|
||||
|
||||
/**
|
||||
* 查询待自动执行的任务
|
||||
* @return 待执行任务列表
|
||||
*/
|
||||
List<TaskDTO> getPendingTasksForAutoExecute();
|
||||
|
||||
/**
|
||||
* 按年统计任务
|
||||
* @param queryDTO 查询条件
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.ruoyi.common.core.domain.R;
|
|||
import com.ruoyi.device.api.RemoteAircraftService;
|
||||
import com.ruoyi.task.api.domain.TaskResultVO;
|
||||
import com.ruoyi.task.api.enums.StatusEnum;
|
||||
import com.ruoyi.task.api.enums.TaskTypeEnum;
|
||||
import com.ruoyi.task.domain.api.ITaskDomain;
|
||||
import com.ruoyi.task.domain.api.ITaskPlanDomain;
|
||||
import com.ruoyi.task.domain.model.Task;
|
||||
|
|
@ -368,4 +369,10 @@ public class TaskServiceImpl implements ITaskService {
|
|||
result.setDays(days);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TaskDTO> getPendingTasksForAutoExecute() {
|
||||
List<Task> tasks = taskDomain.getPendingTasksForAutoExecute();
|
||||
return TaskDTOConvert.toDTOList(tasks);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
-- 添加飞行任务自动执行定时任务
|
||||
INSERT INTO sys_job (
|
||||
job_id,
|
||||
job_name,
|
||||
job_group,
|
||||
invoke_target,
|
||||
cron_expression,
|
||||
misfire_policy,
|
||||
concurrent,
|
||||
status,
|
||||
create_by,
|
||||
create_time,
|
||||
remark
|
||||
) VALUES (
|
||||
(SELECT COALESCE(MAX(job_id), 0) + 1 FROM sys_job),
|
||||
'飞行任务自动执行',
|
||||
'DEFAULT',
|
||||
'taskAutoExecuteJob.execute()',
|
||||
'0 */1 * * * ?',
|
||||
'1',
|
||||
'1',
|
||||
'admin',
|
||||
NOW(),
|
||||
'自动扫描并执行待执行的飞行任务(定时任务和周期任务)'
|
||||
);
|
||||
|
|
@ -156,4 +156,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectPendingTasksForAutoExecute" resultMap="TaskInfoResult">
|
||||
<include refid="selectTaskInfoVo"/>
|
||||
where status = 'PENDING'
|
||||
and task_type in ('TIMED', 'CYCLE')
|
||||
and start_time <= now()
|
||||
and start_time > date_sub(now(), interval 5 minute)
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue