| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.api.entity.enums.TaskStsType; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.common.annotation.OperationLog; |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | | import com.vincent.rsf.server.common.domain.KeyValVo; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.manager.entity.Task; |
| | | import com.vincent.rsf.server.manager.entity.TaskItem; |
| | | import com.vincent.rsf.server.manager.service.TaskItemService; |
| | | import com.vincent.rsf.server.manager.service.TaskService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | |
| | | @Autowired |
| | | private TaskService taskService; |
| | | |
| | | @Autowired |
| | | private TaskItemService taskItemService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:task:list')") |
| | | @PostMapping("/task/page") |
| | |
| | | @PreAuthorize("hasAuthority('manager:task:remove')") |
| | | @OperationLog("Delete 任务工作档") |
| | | @PostMapping("/task/remove/{ids}") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (Objects.isNull(ids) || ids.length < 1) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | List<Long> longs = Arrays.asList(TaskStsType.GENERATE_IN.id, TaskStsType.GENERATE_OUT.id); |
| | | List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().in(Task::getId, ids).in(Task::getTaskStatus, longs)); |
| | | if (tasks.isEmpty()) { |
| | | throw new CoolException("任务已处执行状态不可取消!!"); |
| | | } |
| | | if (!taskService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | } |
| | | if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().in(TaskItem::getTaskId, ids))) { |
| | | return R.error("Details delete Failed"); |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | } |
| | |
| | | ExcelUtil.build(ExcelUtil.create(taskService.list(), Task.class), response); |
| | | } |
| | | |
| | | |
| | | @PreAuthorize("hasAuthority('manager:task:update')") |
| | | @ApiOperation("完成任务") |
| | | @GetMapping("/task/complete/{id}") |
| | | public R completeTask(@PathVariable String id) { |
| | | if (Objects.isNull(id)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | // return taskService.completeTask(id); |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |