郑永安
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
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.entity.SafeCheckTaskAndQuota;
import com.gkhy.safePlatform.safeCheck.model.dto.req.*;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.ExcepOrderHandledDataByIdRespDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.ListUserExcepOrderByPageRespDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckTaskDataByConditionMobileRespDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckTaskMobilePageRespDTO;
import com.gkhy.safePlatform.safeCheck.service.SafeCheckTaskMobileManagerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
 
 
/**
 * @description 手机端的接口
 */
@RestController
@RequestMapping("/SafeCheckMobileTerminal")
public class SafeCheckMobileTerminalController {
 
    @Autowired
    private SafeCheckTaskMobileManagerService safeCheckTaskMobileManagerService;
 
    /**
     * @description 查询用户所属的班组,用户上班时间的任务信息
     */
    @PostMapping("/select/listUserTaskByPage")
    public ResultVO<IPage<SafeCheckTaskMobilePageRespDTO>> listUserTaskByPage(Authentication authentication,@RequestBody SafeCheckMobilePageReqDTO safeCheckMobilePageReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
 
        Integer pageIndex = safeCheckMobilePageReqDTO.getPageIndex();
        Integer pageSize = safeCheckMobilePageReqDTO.getPageSize();
        if (pageIndex == 0 || pageSize == 0){
            throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0");
        }
        Page pageInfo = new Page(pageIndex, pageSize);
        //连表查询后再统计总数
//        pageInfo.setOptimizeCountSql(false);
        IPage iPage = safeCheckTaskMobileManagerService.listUserTaskByPage(currentUser,pageInfo, safeCheckMobilePageReqDTO);
        return new ResultVO<>(ResultCodes.OK,iPage);
    }
 
 
 
    /**
     * @description 根据部门,班组和状态作为条件查询任务以及任务相关的巡检点
     */
    @PostMapping("/select/listTaskDataByCondition")
    public ResultVO<IPage<SafeCheckTaskDataByConditionMobileRespDTO>> listTaskDataByCondition(Authentication authentication, @RequestBody ListTaskDataByConditionReqDTO reqDTO) {
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
 
        Integer pageIndex = reqDTO.getPageIndex();
        Integer pageSize = reqDTO.getPageSize();
        if (pageIndex == 0 || pageSize == 0){
            throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0");
        }
        Page pageInfo = new Page(pageIndex, pageSize);
        //连表查询后再统计总数
//        pageInfo.setOptimizeCountSql(false);
        IPage iPage = safeCheckTaskMobileManagerService.listTaskDataByCondition(currentUser,pageInfo, reqDTO);
        return new ResultVO<>(ResultCodes.OK,iPage);
    }
 
 
    /**
     * @description 用户认领任务
     */
    @PostMapping("/update/updateTaskClaimById")
    public ResultVO<String> updateTaskClaimById(Authentication authentication, @RequestBody SafeCheckTask safeCheckTask){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        Long taskId = safeCheckTask.getId();
        safeCheckTaskMobileManagerService.updateTaskClaimById(currentUser, taskId);
        ResultVO resultVO = new ResultVO<>("200","任务认领成功");
        return resultVO;
    }
 
    /**
     * @description 用户单个提交巡检点巡检结果
     */
    @PostMapping("/update/updateTaskAndQuotaResultById")
    public ResultVO<String> updateTaskAndQuotaResultById(Authentication authentication, @RequestBody SafeCheckTaskAndQuotaSubmitReqDTO safeCheckTaskAndQuotaSubmitReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        safeCheckTaskMobileManagerService.updateTaskAndQuotaResultById(currentUser,safeCheckTaskAndQuotaSubmitReqDTO);
        ResultVO resultVO = new ResultVO<>("200","巡检点巡检结果提交成功");
        return resultVO;
    }
 
    /**
     * @description 最终提交
     */
 
    @PostMapping("/update/updateTaskResultById")
    public ResultVO<String> updateTaskResultById(Authentication authentication, @RequestBody SafeCheckTaskAndQuota safeCheckTaskAndQuota){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        Long taskId = safeCheckTaskAndQuota.getTaskId();
        safeCheckTaskMobileManagerService.updateTaskResultById(currentUser,taskId);
        ResultVO resultVO = new ResultVO<>("200","所有巡检点已完成巡检并提交");
        return resultVO;
    }
 
    /**
     * @description 查询用户工单列表
     */
    @PostMapping("/select/listUserExcepOrderByPage")
    public ResultVO<IPage<ListUserExcepOrderByPageRespDTO>> listUserExcepOrderByPage(Authentication authentication, @RequestBody SafeCheckExcepOrderPageReqDTO excepOrderPageReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
 
        Integer pageIndex = excepOrderPageReqDTO.getPageIndex();
        Integer pageSize = excepOrderPageReqDTO.getPageSize();
        if (pageIndex == 0 || pageSize == 0){
            throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0");
        }
        Page pageInfo = new Page(pageIndex, pageSize);
        IPage iPage = safeCheckTaskMobileManagerService.listUserExcepOrderByPage(currentUser,pageInfo);
        return new ResultVO<>(ResultCodes.OK,iPage);
    }
 
    /**
     * 根据id响应回执
     */
    @PostMapping("/update/ExcepOrderhandleStatusById")
    public ResultVO<String> updateExcepOrderhandleStatusById(Authentication authentication, @RequestBody ExcepOrderhandleStatusByIdReqDTO reqDTO){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        safeCheckTaskMobileManagerService.updateExcepOrderhandleStatusById(currentUser,reqDTO);
        ResultVO resultVO = new ResultVO<>("200","响应回执提交成功");
        return resultVO;
    }
 
    /**
     * @description 根据id处理后填报(可以多次更新)
     */
    @PostMapping("/update/ExcepOrderHandledAfterStatusById")
    public ResultVO<String> updateExcepOrderHandledAfterStatusById(Authentication authentication, @RequestBody ExcepOrderHandledAfterStatusByIdReqDTO reqDTO){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        safeCheckTaskMobileManagerService.updateExcepOrderHandledAfterStatusById(currentUser,reqDTO);
        ResultVO resultVO = new ResultVO<>("200","反馈填写成功");
        return resultVO;
    }
 
    /**
     * @description 根据id获取反馈填报信息内容
     */
    @PostMapping("/select/getExcepOrderHandledDataById")
    public ResultVO<ExcepOrderHandledDataByIdRespDTO> getExcepOrderHandledDataById(@RequestBody ExcepOrderHandledDataByIdReqDTO reqDTO){
        ExcepOrderHandledDataByIdRespDTO dataByIdRespDTO = safeCheckTaskMobileManagerService.getExcepOrderHandledDataById(reqDTO);
        return new ResultVO<>(ResultCodes.OK,dataByIdRespDTO);
    }
 
}