use of com.dtstack.taier.dao.domain.ScheduleTaskShadeInfo in project Taier by DTStack.
the class TaskService method saveTask.
/**
* 提交单个任务 (不包括工作流)
* @param savaTaskDTO 任务
* @return 是否提交成功
*/
public Boolean saveTask(SavaTaskDTO savaTaskDTO) {
ScheduleTaskShadeDTO scheduleTaskShadeDTO = savaTaskDTO.getScheduleTaskShadeDTO();
ScheduleTaskShade scheduleTaskShade = ScheduleTaskMapstructTransfer.INSTANCE.dtoToBean(scheduleTaskShadeDTO);
ScheduleTaskShade dbTaskShade = this.lambdaQuery().eq(ScheduleTaskShade::getTaskId, scheduleTaskShade.getTaskId()).eq(ScheduleTaskShade::getIsDeleted, Deleted.NORMAL.getStatus()).one();
ScheduleTaskShadeInfo scheduleTaskShadeInfo = new ScheduleTaskShadeInfo();
scheduleTaskShadeInfo.setInfo(scheduleTaskShade.getExtraInfo());
scheduleTaskShadeInfo.setTaskId(scheduleTaskShade.getTaskId());
// 保存任务或者更新任务
if (dbTaskShade != null) {
scheduleTaskShade.setId(dbTaskShade.getId());
this.updateById(scheduleTaskShade);
scheduleTaskShadeInfoService.update(scheduleTaskShadeInfo, scheduleTaskShade.getTaskId());
} else {
this.save(scheduleTaskShade);
scheduleTaskShadeInfoService.insert(scheduleTaskShadeInfo);
}
// 保存关系
List<Long> parentTaskIdList = savaTaskDTO.getParentTaskIdList();
List<ScheduleTaskTaskShade> scheduleTaskTaskShadeList = Lists.newArrayList();
for (Long parentTaskId : parentTaskIdList) {
ScheduleTaskTaskShade scheduleTaskTaskShade = new ScheduleTaskTaskShade();
scheduleTaskTaskShade.setTenantId(scheduleTaskShade.getTenantId());
scheduleTaskTaskShade.setTaskId(scheduleTaskShade.getTaskId());
scheduleTaskTaskShade.setParentTaskId(parentTaskId);
scheduleTaskTaskShadeList.add(scheduleTaskTaskShade);
}
// TODO 这块后面还需要考虑成环判断
// 删除任务依赖
tasktaskService.lambdaUpdate().eq(ScheduleTaskTaskShade::getTaskId, scheduleTaskShade.getTaskId()).remove();
return tasktaskService.saveBatch(scheduleTaskTaskShadeList);
}
Aggregations