郑永安
2023-06-19 7a6abd05683528032687c75e80e0bd2030a3e46c
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package com.gkhy.safePlatform.safeCheck.controller;
 
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
import com.gkhy.safePlatform.commons.enums.E;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.exception.AusinessException;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.safeCheck.entity.SafeCheckTask;
import com.gkhy.safePlatform.safeCheck.model.dto.req.SafeCheckPageGeneralReqDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.req.SafeCheckTaskAndQuotaPageReqDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.req.SafeCheckTaskPageReqDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.*;
import com.gkhy.safePlatform.safeCheck.service.SafeCheckTaskResultManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
 
@RestController
@RequestMapping("/SafeCheckTask")
public class SafeCheckTaskController {
 
    @Autowired
    private SafeCheckTaskResultManagerService safeCheckTaskResultManagerService;
 
    /**
     * @description 查询所有巡检任务数据并进行分页(包含条件查询)
     */
    @PostMapping("/select/listTaskByPage")
    public ResultVO<Page<SafeCheckTaskPageRespDTO>> listTaskUnitByPage(Authentication authentication,@RequestBody SafeCheckTaskPageReqDTO safeCheckTaskPageReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        Integer pageIndex = safeCheckTaskPageReqDTO.getPageIndex();
        Integer pageSize = safeCheckTaskPageReqDTO.getPageSize();
        if (pageIndex == 0 || pageSize == 0){
            throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0");
        }
        Page pageInfo = new Page(pageIndex, pageSize);
        pageInfo = safeCheckTaskResultManagerService.listTaskByPage(pageInfo, safeCheckTaskPageReqDTO,currentUser);
        return new ResultVO<>(ResultCodes.OK,pageInfo);
    }
 
    /**
     * @description 根据任务id查询该任务下所有的巡检点检查结果  现在不用了
     */
//    @PostMapping("/select/listTaskAndQuotaByPage")
    public ResultVO<Page<SafeCheckTaskAndQuotaPageRespDTO>> listTaskAndQuotaByPage(Authentication authentication,@RequestBody SafeCheckTaskAndQuotaPageReqDTO taskPageReqDTO){
        Integer pageIndex = taskPageReqDTO.getPageIndex();
        Integer pageSize = taskPageReqDTO.getPageSize();
        if (pageIndex == 0 || pageSize == 0){
            throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0");
        }
        Page pageInfo = new Page(pageIndex, pageSize);
        pageInfo = safeCheckTaskResultManagerService.listTaskAndQuotaByPage(pageInfo,taskPageReqDTO);
        return new ResultVO<>(ResultCodes.OK,pageInfo);
    }
 
    /**
     * @description 根据任务id查询该任务下主内容及所有巡检链信息
     */
    @PostMapping("/select/listTaskMainAndQuota")
    public ResultVO<SafeCheckTaskMainAndQuotaRespDTO> listTaskMainAndQuota(Authentication authentication, @RequestBody SafeCheckTaskAndQuotaPageReqDTO taskPageReqDTO){
        Long taskId = taskPageReqDTO.getId();
        SafeCheckTaskMainAndQuotaRespDTO taskMainAndQuota = safeCheckTaskResultManagerService.listTaskMainAndQuota(taskId);
        return new ResultVO<>(ResultCodes.OK,taskMainAndQuota);
    }
 
    /**
     * @description 查询所有巡检任务数据并进行分页(只查询已完成,巡检中) 对任务状态进行分组 对结束时间由近到远
     */
    @PostMapping("/select/listTaskByPageAndStatusAndTime")
    public ResultVO<IPage<SafeCheckPageGrByStatusOrByTimeRespDTO>> listTaskByPageGrByStatusOrByTime(Authentication authentication, @RequestBody SafeCheckPageGeneralReqDTO pageGeneralReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        Integer pageIndex = pageGeneralReqDTO.getPageIndex();
        Integer pageSize = pageGeneralReqDTO.getPageSize();
        if (pageIndex == 0 || pageSize == 0){
            throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0");
        }
        Page pageInfo = new Page(pageIndex, pageSize);
        IPage iPage =  safeCheckTaskResultManagerService.listTaskByPageGrByStatusOrByTime(pageInfo,currentUser);
        return new ResultVO<>(ResultCodes.OK,iPage);
    }
 
    /**
     * @description 根据任务id查询所关联的巡检链巡检结果 结果先按region分组 然后按照指标分组 然后按照巡检点分组
     */
    @PostMapping("/select/listTaskQuotaGbRegionGbQuotaGbPoint")
    public ResultVO<SafeCheckTaskQuotaResultClassifyAndSummarizeRespDTO> listTaskQuotaGbRegionGbQuotaGbPoint(Authentication authentication
            , @RequestBody SafeCheckTask safeCheckTask){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        Long taskId = safeCheckTask.getId();
        if (taskId == null){
            return new ResultVO<>("200","任务id不能为空");
        }
        SafeCheckTaskQuotaResultClassifyAndSummarizeRespDTO taskQuotaResults =
                safeCheckTaskResultManagerService.listTaskQuotaGbRegionGbQuotaGbPoint(currentUser,taskId);
        ResultVO resultVO = new ResultVO<>(ResultCodes.OK,taskQuotaResults);
        return resultVO;
 
    }
 
    /**
     * @description 获取当前0点-当前时间异常的任务和没有检查的任务
     */
    @GetMapping("/select/listTaskByNoCheckTaskAndAbnormalTask")
    public ResultVO<SafeCheckTaskByNoCheckTaskAndAbnormalTaskRepsDTO> listTaskByNoCheckTaskAndAbnormalTask(Authentication authentication){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        SafeCheckTaskByNoCheckTaskAndAbnormalTaskRepsDTO taskByCondition =
                safeCheckTaskResultManagerService.listTaskByNoCheckTaskAndAbnormalTask(currentUser);
        ResultVO resultVO = new ResultVO<>(ResultCodes.OK,taskByCondition);
        return resultVO;
    }
}