TaskController.java
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package vion.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.dto.TaskDTO;
import vion.model.FaultLog;
import vion.service.IFaultLogService;
import vion.service.ITaskService;
import vion.vo.TaskVO;
import java.util.Date;
import java.util.List;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class TaskController {
private final ITaskService taskService;
private final IFaultLogService faultLogService;
@GetMapping("/tasks")
@SaCheckPermission(value = "task:list", orRole = "admin")
public Page<TaskVO> getTaskList(TaskDTO data) {
return taskService.getTaskList(data);
}
@GetMapping("/task")
@SaCheckPermission(value = "task:query", orRole = "admin")
public TaskVO getTaskById(Long taskId) {
return taskService.getTaskById(taskId);
}
@PostMapping("/tasks")
@SaCheckPermission(value = "task:editAndSave", orRole = "admin")
public Long saveOrUpdate(TaskDTO data, @RequestHeader String token) {
return taskService.circTask(data, token);
}
@GetMapping("/faultLogs")
@SaCheckPermission(value = "task:log:list", orRole = "admin")
public List<FaultLog> getFaultLogById(Long storeId, Long taskId) {
List<FaultLog> faultLogList = faultLogService.lambdaQuery()
.eq(FaultLog::getStoreId, storeId)
.eq(FaultLog::getTaskId, taskId)
.orderByAsc(FaultLog::getCreateTime)
.list();
TaskVO taskVO = taskService.getTaskById(taskId);
// 进行中的任务,在最后追加一条当前处理人正在处理的记录,仅做显示用
if (taskVO.getStatus() == 2) {
FaultLog faultLog = new FaultLog();
faultLog.setOperator(taskVO.getActiveUser());
faultLog.setContent("工单正在处理中");
faultLog.setCreateTime(new Date());
faultLogList.add(faultLog);
}
return faultLogList;
}
}