郑永安
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
package com.gkhy.safePlatform.doublePrevention.controller;
 
import com.gkhy.safePlatform.account.rpc.apimodel.AccountAuthService;
import com.gkhy.safePlatform.account.rpc.apimodel.model.resp.UserRPCRespDTO;
import com.gkhy.safePlatform.commons.co.ContextCacheUser;
import com.gkhy.safePlatform.commons.enums.ResultCodes;
import com.gkhy.safePlatform.commons.vo.ResultVO;
import com.gkhy.safePlatform.doublePrevention.entity.PreventDangerManage;
import com.gkhy.safePlatform.doublePrevention.entity.PreventRiskAnaUnit;
import com.gkhy.safePlatform.doublePrevention.entity.dto.req.*;
import com.gkhy.safePlatform.doublePrevention.entity.dto.resp.PreventDangerManageQueryRespDTO;
import com.gkhy.safePlatform.doublePrevention.service.RectifyService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
 
import java.security.Principal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Date;
 
@RestController
@RequestMapping("prevent/dangerManage")
public class PreventDangerManageController {
 
    @DubboReference(check = false)
    private AccountAuthService accountAuthService;
 
    @Autowired
    private RectifyService rectifyService;
 
    /**
     * 隐患治理清单-分页查询
     */
    @PostMapping("/select/getDangerManagePage")
    public ResultVO<PreventDangerManage> getDangerManagePage(Authentication authentication, @RequestBody PreventDangerManageQueryReqDTO manageQueryReqDTO) {
        //获取用户信息
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        return rectifyService.getDangerManagePage(currentUser.getUid(), manageQueryReqDTO);
    }
 
    /**
     * 隐患治理清单-列表
     */
    @PostMapping("/select/listDangerManage")
    public ResultVO<PreventDangerManage> listDangerManage(Authentication authentication) {
        //获取用户信息
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        return rectifyService.listDangerManage(currentUser.getUid());
    }
 
    /**
     * 隐患治理清单-新增
     */
    @PostMapping("/insert/saveDangerManage")
    public ResultVO<PreventDangerManage> saveDangerManage(Authentication authentication, @RequestBody PreventDangerManageSaveReqDTO manageSaveReqDTO) {
        //获取用户信息
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        return rectifyService.saveDangerManage(currentUser.getUid(), manageSaveReqDTO);
    }
 
    /**
     * 隐患治理清单-修改
     */
    @PostMapping("/update/updateDangerManage")
    public ResultVO<PreventDangerManage> updateDangerManage(Authentication authentication, @RequestBody PreventDangerManageUpdateReqDTO manageUpdateReqDTO) {
        //获取用户信息
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        return rectifyService.updateDangerManage(currentUser.getUid(), manageUpdateReqDTO);
    }
 
    /**
     * 隐患治理清单-删除
     */
    @PostMapping("/delete/deleteDangerManage")
    public ResultVO<PreventDangerManage> deleteDangerManage(Authentication authentication, @RequestBody PreventDangerManageDeleteReqDTO manageDeleteReqDTO) {
        //获取用户信息
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        return rectifyService.deleteDangerManage(currentUser.getUid(), manageDeleteReqDTO);
    }
 
    /**
     * 隐患管理-手工上报-配置
     */
    @PostMapping("/update/updateReport")
    public ResultVO<PreventRiskAnaUnit> updateDangerManagerReport(Authentication authentication, @RequestBody PreventHandReportConfigReqDTO preventHandReportConfigReqDTO) {
        //获取用户信息
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        return rectifyService.updateDangerManagerReport(currentUser.getUid(), preventHandReportConfigReqDTO);
    }
 
    /**
     * 隐患管理-关闭隐患单
     */
    @PostMapping("/update/closeDanger")
    public ResultVO<PreventRiskAnaUnit> closeDanger(Authentication authentication, @RequestBody PreventCloseDangerReqDTO closeDangerReqDTO) {
        //获取用户信息
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        return rectifyService.closeDanger(currentUser.getUid(), closeDangerReqDTO);
    }
 
    @GetMapping("/count/byCreateDate")
    public ResultVO getDangerCountByCreateDate(String date){
        ResultVO resultVO = new ResultVO<>();
        LocalDate localDate = null;
        if(date == null || date.isEmpty()){
            resultVO.setCode(ResultCodes.CLIENT_PARAM_ERROR.getCode());
            resultVO.setMsg(ResultCodes.CLIENT_PARAM_ERROR.getDesc());
            return resultVO;
        }
        try {
            localDate = LocalDate.parse(date);
        } catch (Exception e) {
            resultVO.setCode(ResultCodes.CLIENT_PARAM_ERROR.getCode());
            resultVO.setMsg(ResultCodes.CLIENT_PARAM_ERROR.getDesc());
            return resultVO;
        }
        return rectifyService.countDangerByDate(localDate);
    }
 
    @GetMapping("/find/serialCode")
    public ResultVO findDangerManageBySerialCode(String serialCode){
        ResultVO<PreventDangerManageQueryRespDTO> resultVO = new ResultVO<>();
        resultVO.setCode(ResultCodes.OK.getCode());
        if(serialCode == null || serialCode.length() < 13){
            return resultVO;
        }
        resultVO = rectifyService.findByDangerSerialCode(serialCode);
        return resultVO;
    }
 
}