郑永安
2023-09-19 69185134fcfaf913ea45f1255677225a2cc311a4
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
package com.gk.hotwork.specialWork.controller;
 
import com.alibaba.fastjson.JSONObject;
import com.gk.hotwork.Controller.Base.BaseController;
import com.gk.hotwork.Domain.co.ContextCacheUser;
import com.gk.hotwork.Domain.Enum.ResultCodes;
import com.gk.hotwork.Domain.Vo.PageQuery;
import com.gk.hotwork.Domain.Utils.PageUtils;
import com.gk.hotwork.Domain.Vo.ResultVO;
import com.gk.hotwork.doublePrevention.utils.CacheUserTransfer;
import com.gk.hotwork.specialWork.model.dto.req.*;
import com.gk.hotwork.specialWork.model.dto.resp.*;
import com.gk.hotwork.specialWork.model.query.AllWorkApplyPageQuery;
import com.gk.hotwork.specialWork.model.query.WorkApplyApplyingPageQuery;
import com.gk.hotwork.specialWork.model.query.WorkApplyPendingPageQuery;
import com.gk.hotwork.specialWork.service.WorkApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
@RestController
@RequestMapping("/work")
public class WorkApplyController extends BaseController {
 
    @Autowired
    private WorkApplyService workApplyService;
 
    /**
    * @Description: 动火作业申请
    */
    @RequestMapping(value = "/apply/hot",method = RequestMethod.POST)
    public ResultVO<String> workApplyHot(Authentication authentication, @RequestBody WorkApplyReqDTO<WorkApplyHotReqDTO> applyReqDTO){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.workApply(currentUser, applyReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
 
    /**
     * @Description: 受限空间作业申请
     */
    @RequestMapping(value = "/apply/confinedspace",method = RequestMethod.POST)
    public ResultVO<String> workApplyConfinedSpace(Authentication authentication, @RequestBody WorkApplyReqDTO<WorkApplyConfinedSpaceReqDTO> applyReqDTO){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.workApply(currentUser, applyReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
    /**
     * @Description: 盲板抽堵作业申请
     */
    @RequestMapping(value = "/apply/blindPlatePlugging",method = RequestMethod.POST)
    public ResultVO<String> workApplyBlindPlatePlugging(Authentication authentication, @RequestBody WorkApplyReqDTO<WorkApplyBlindPlatePluggingReqDTO> applyReqDTO){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.workApply(currentUser, applyReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
    /**
     * @Description: 高处安全作业申请
     */
    @RequestMapping(value = "/apply/height",method = RequestMethod.POST)
    public ResultVO<String> workApplyHeight(Authentication authentication, @RequestBody WorkApplyReqDTO<WorkApplyAtHighReqDTO> applyReqDTO){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.workApply(currentUser, applyReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
    /**
     * @Description: 断路作业申请
     */
        @RequestMapping(value = "/apply/brokenCircuit",method = RequestMethod.POST)
    public ResultVO<String> workApplyBrokenCircuit(Authentication authentication, @RequestBody WorkApplyReqDTO<WorkApplyBrokenCircuitReqDTO> applyReqDTO){
            ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.workApply(currentUser, applyReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
    /**
     * @Description: 吊装作业申请
     */
    @RequestMapping(value = "/apply/hoisting",method = RequestMethod.POST)
    public ResultVO<String> workApplyHoisting(Authentication authentication, @RequestBody WorkApplyReqDTO<WorkApplyHoistingReqDTO> applyReqDTO){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.workApply(currentUser, applyReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
    /**
     * @Description: 临时用电作业申请
     */
    @RequestMapping(value = "/apply/temporaryPower",method = RequestMethod.POST)
    public ResultVO<String> workApplyTemporaryPower(Authentication authentication, @RequestBody WorkApplyReqDTO<WorkApplyTemporaryPowerReqDTO> applyReqDTO){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.workApply(currentUser, applyReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
    /**
     * @Description: 动土作业申请
     */
    @RequestMapping(value = "/apply/groundBreaking",method = RequestMethod.POST)
    public ResultVO<String> workApplyGroundBreaking(Authentication authentication, @RequestBody WorkApplyReqDTO<WorkApplyGroundBreakingReqDTO> applyReqDTO){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.workApply(currentUser, applyReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
 
    /**
    * @Description: 取消申请
    */
    @RequestMapping(value = "/apply/cancel",method = RequestMethod.POST)
    public ResultVO<String> workApplyCancel(Authentication authentication, @RequestBody JSONObject json){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        Long workApplyId = json.getLong("workApplyId");
        workApplyService.cancelWorkApply(currentUser, workApplyId);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
 
 
    /**
    * @Description: 申请中的作业
    */
    @RequestMapping(value = "/apply/applying/page/list",method = RequestMethod.POST)
    public ResultVO<List<WorkApplyPageRespDTO>> workApplyApplyingPageList(Authentication authentication, @RequestBody PageQuery<WorkApplyApplyingPageQuery> pageQuery){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        PageUtils.checkCheck(pageQuery);
        return workApplyService.listApplyingWorkApplyByPage(currentUser, pageQuery);
    }
 
    /**
    * @Description: 已经审批的进度(申请人)
    */
    @RequestMapping(value = "/apply/applicant/approved/view",method = RequestMethod.POST)
    public ResultVO<ApplicantWorkApprovedApplyDetailRespDTO> workApplyApplyingViewForApplicant(Authentication authentication, @RequestBody JSONObject json){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        Long workApplyId = json.getLong("workApplyId");
        ApplicantWorkApprovedApplyDetailRespDTO data = workApplyService.getApprovedApplyDetailForApplicant(currentUser, workApplyId);
        return new ResultVO<>(ResultCodes.OK,data);
    }
 
 
    /**
     * @Description: 已经审批的进度(审批人)
     */
    @RequestMapping(value = "/apply/approver/approved/view",method = RequestMethod.POST)
    public ResultVO<ApproverWorkApprovedApplyDetailRespDTO> workApplyApplyingViewForApprover(Authentication authentication, @RequestBody JSONObject json){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        Long workApplyId = json.getLong("workApplyId");
        ApproverWorkApprovedApplyDetailRespDTO data = workApplyService.getApprovedApplyDetailForApprover(currentUser, workApplyId);
        return new ResultVO<>(ResultCodes.OK,data);
    }
 
    /**
    * @Description: 获取当前层级审批数据(审批人)
    */
    @RequestMapping(value = "/approval/pending/data",method = RequestMethod.POST)
    public ResultVO<ApproverWorkPendingApprovalDataRespDTO> getPendingApprovalData(Authentication authentication, @RequestBody JSONObject json){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        Long workApplyId = json.getLong("workApplyId");
        ApproverWorkPendingApprovalDataRespDTO data = workApplyService.getPendingApprovalData(currentUser, workApplyId);
        return new ResultVO<>(ResultCodes.OK,data);
    }
 
 
    /**
    * @Description: 待审批的作业(给work所出层级的每个单元)
    */
    @RequestMapping(value = "/apply/pending/page/list",method = RequestMethod.POST)
    public ResultVO<List<WorkApplyPendingPageRespDTO>> workApplyPendingPageList(Authentication authentication, @RequestBody PageQuery<WorkApplyPendingPageQuery> pageQuery){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        PageUtils.checkCheck(pageQuery);
        return workApplyService.listPendingWorkApplyByPage(currentUser, pageQuery);
    }
 
    /**
    * @Description: 审批
    */
 
    @RequestMapping(value = "/apply/approve",method = RequestMethod.POST)
    public ResultVO<String> workApplyApprove(Authentication authentication, @RequestBody ApprovalItemDataReqDTO approvalItemData){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.approveItem(currentUser, approvalItemData);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
    @RequestMapping(value = "/apply/abord",method = RequestMethod.POST)
    public ResultVO<String> workApplyAbord(Authentication authentication, @RequestBody ApprovalItemAbordDataReqDTO abordDataReqDTO){
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.abordItem(currentUser, abordDataReqDTO);
        return new ResultVO<>(ResultCodes.OK);
    }
 
 
    /**
     *
     * 作业票导出
     * @param authentication
     * @param json
     * @param response
     */
    @RequestMapping(value = "/apply/printing",method = RequestMethod.POST)
    public void workApplyPrinting(Authentication authentication, @RequestBody JSONObject json, HttpServletResponse response){
        Long applyWorkId = json.getLong("applyWorkId");
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        workApplyService.printing(currentUser,applyWorkId,response);
    }
 
 
    /**
     * @Description: 所有申请记录 非仅对申请人查看
     */
    @RequestMapping(value = "/apply/all/page/list",method = RequestMethod.POST)
    public ResultVO<List<AllWorkApplyPageRespDTO>> workApplyAllPageList(Authentication authentication, @RequestBody PageQuery<AllWorkApplyPageQuery> pageQuery) {
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        PageUtils.checkCheck(pageQuery);
        return workApplyService.listAllWorkApply(currentUser, pageQuery);
    }
 
    /**
     * @Description: 所有申请记录的 单条记录详情查询
     */
    @RequestMapping(value = "/apply/others/view",method = RequestMethod.POST)
    public ResultVO<OthersWorkApprovedApplyDetailRespDTO> workApplyApplyingViewForOthers(Authentication authentication, @RequestBody JSONObject json) {
        ContextCacheUser currentUser = CacheUserTransfer.transfer(getUser());
        Long workApplyId = json.getLong("workApplyId");
        OthersWorkApprovedApplyDetailRespDTO detail = workApplyService.getWorkApplyDetailForOthers(currentUser, workApplyId);
        return new ResultVO<>(ResultCodes.OK, detail);
    }
 
}