郑永安
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
package com.gkhy.safePlatform.safeCheck.controller;
 
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gkhy.safePlatform.account.rpc.apimodel.AccountUserService;
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.model.dto.req.*;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckPointPageRespDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckPointRespDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckRegionPageRespDTO;
import com.gkhy.safePlatform.safeCheck.model.dto.resp.SafeCheckRegionRespDTO;
import com.gkhy.safePlatform.safeCheck.service.SafeCheckBaseManagerService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.HashMap;
import java.util.List;
 
/**
 * @description 巡检点
 */
@RestController
@RequestMapping("/safeCheckPoint")
public class SafeCheckPointController {
 
    @Autowired
    private SafeCheckBaseManagerService safeCheckBaseManagerService;
 
    /**
     * @description 新增巡检点
     */
    @PostMapping("/insert/savePoint")
    public ResultVO<String> savePoint(Authentication authentication, @RequestBody SafeCheckPointReqDTO safeCheckPointReqDTO){
 
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        safeCheckBaseManagerService.savePoint(currentUser, safeCheckPointReqDTO);
        return new ResultVO<>("200","新增巡检点成功");
    }
 
    /***
     * @description 根据巡检点id删除巡检点
     */
    @PostMapping("/delete/deletePointById")
    public ResultVO<String> deletePointById(Authentication authentication,@RequestBody SafeCheckPointReqDTO safeCheckPointReqDTO){
        Long id = safeCheckPointReqDTO.getId();
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        safeCheckBaseManagerService.deletePointById(currentUser, id);
        ResultVO resultVO = new ResultVO<>("200","删除巡检点成功");
        return resultVO;
    }
 
 
    /**
     * @description 根据id更新巡检点
     */
    @PostMapping("/update/updatePointById")
    public ResultVO<String> updatePointById(Authentication authentication, @RequestBody SafeCheckPointReqDTO safeCheckPointReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        safeCheckBaseManagerService.updatePointById(currentUser, safeCheckPointReqDTO);
        ResultVO resultVO = new ResultVO<>("200","更新巡检点成功");
        return resultVO;
    }
 
    /**
     * @description 查询所有数据并进行分页展示
     */
    @PostMapping("/select/listPointByPage")
    public ResultVO<Page<SafeCheckPointPageRespDTO>> listPointByPage(Authentication authentication,@RequestBody SafeCheckPointPageReqDTO safeCheckPointPageReqDTO){
        ContextCacheUser currentUser = (ContextCacheUser)authentication.getPrincipal();
        Integer pageIndex = safeCheckPointPageReqDTO.getPageIndex();
        Integer pageSize = safeCheckPointPageReqDTO.getPageSize();
        if (pageIndex == 0 || pageSize == 0){
            throw new AusinessException(E.DATA_PARAM_NULL,"当前页码或当前页显示数不能为0");
        }
        Page pageInfo = new Page(pageIndex, pageSize);
        pageInfo = safeCheckBaseManagerService.listPointByPage(pageInfo,safeCheckPointPageReqDTO,currentUser);
        return new ResultVO<>(ResultCodes.OK,pageInfo);
    }
 
    /**
     * @description 根据巡检点id查询数据
     */
    @PostMapping("/select/getPointById")
    public ResultVO<SafeCheckPointRespDTO> getPointById(@RequestBody SafeCheckPointReqDTO safeCheckPointReqDTO){
        Long id = safeCheckPointReqDTO.getId();
        SafeCheckPointRespDTO pointRespDTO = safeCheckBaseManagerService.getPointById(id);
        ResultVO resultVO = new ResultVO<>(ResultCodes.OK,pointRespDTO);
        return resultVO;
    }
 
    /**
     * @description 获取所有巡检点、巡检区域、巡检rfid的id值
     */
    @PostMapping("/select/getPointRegionRfidId")
    public ResultVO<List<SafeCheckPointRespDTO>> getPointRegionRfidId(){
        List<SafeCheckPointRespDTO> pointRespDTOS = safeCheckBaseManagerService.getPointRegionRfidId();
        ResultVO resultVO = new ResultVO<>(ResultCodes.OK,pointRespDTOS);
        return resultVO;
    }
 
}