liurunyu
2025-08-21 5715d16c6fc4842191c802adb2e3b94d19f44f17
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
package com.dy.pipIrrWechat.mqtt;
 
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrGlobal.voPr.VoMqttSimple;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import java.util.List;
 
/**
 * @Author: liurunyu
 * @Date: 2025/8/13 16:41
 * @Description
 */
@Slf4j
@Tag(name = "农业灌溉综合站", description = "农业灌溉综合站管理")
@RestController
@RequestMapping(path = "mqtt")
@RequiredArgsConstructor
public class MqttCtrl {
 
    private MqttSv sv ;
 
    @Autowired
    public void setSv(MqttSv sv) {
        this.sv = sv;
    }
 
 
    /**
     * 客户端请求得到所有水肥机、气象站、墒情站简单信息
     * @return 所有水肥机、气象站、墒情站简单信息
     */
    @Operation(summary = "获得全部水肥机、气象站、墒情站简单信息", description = "返回全部水肥机、气象站、墒情站简单信息")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回全部水肥机、气象站、墒情站简单信息数据(BaseResponse.content:TypesVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = MqttVo.class))}
            )
    })
    @GetMapping(path = "allSimple")
    public BaseResponse<MqttVo> allSimple() {
        try {
            MqttVo reVo = new MqttVo() ;
            reVo.manures = this.sv.allManureSimple() ;
            reVo.soils = this.sv.allSoilSimple() ;
            reVo.weathers = this.sv.allWeatherSimple() ;
            return BaseResponseUtils.buildSuccess(reVo);
        } catch (Exception e) {
            log.error("查询全部水肥机、气象站、墒情站简单信息异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
 
 
 
    /**
     * 客户端请求得到所有水肥机简单信息
     * @return 所有水肥机简单信息
     */
    @Operation(summary = "获得全部水肥机简单信息", description = "返回全部水肥机简单信息")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回全部水肥机、气象站、墒情站简单信息数据(BaseResponse.content:TypesVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = VoMqttSimple.class))}
            )
    })
    @GetMapping(path = "allManureSimple")
    public BaseResponse<List<VoMqttSimple>> allManureSimple() {
        try {
            List<VoMqttSimple> list = this.sv.allManureSimple() ;
            return BaseResponseUtils.buildSuccess(list);
        } catch (Exception e) {
            log.error("查询全部水肥机简单信息异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
 
 
    /**
     * 客户端请求得到所有墒情站简单信息
     * @return 所有墒情站简单信息
     */
    @Operation(summary = "获得全部墒情站简单信息", description = "返回全部墒情站简单信息")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回全部墒情站简单信息数据(BaseResponse.content:TypesVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = VoMqttSimple.class))}
            )
    })
    @GetMapping(path = "allSoilSimple")
    public BaseResponse<List<VoMqttSimple>> allSoilSimple() {
        try {
            List<VoMqttSimple> list = this.sv.allSoilSimple() ;
            return BaseResponseUtils.buildSuccess(list);
        } catch (Exception e) {
            log.error("查询全部墒情站简单信息异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
 
 
    /**
     * 客户端请求得到所有气象站简单信息
     * @return 所有气象站简单信息
     */
    @Operation(summary = "获得全部气象站简单信息", description = "返回全部气象站简单信息")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回全部气象站简单信息数据(BaseResponse.content:TypesVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = MqttVo.class))}
            )
    })
    @GetMapping(path = "allWeatherSimple")
    public BaseResponse<List<VoMqttSimple>> allWeatherSimple() {
        try {
            List<VoMqttSimple> list = this.sv.allWeatherSimple() ;
            return BaseResponseUtils.buildSuccess(list);
        } catch (Exception e) {
            log.error("查询全部气象站简单信息异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
    }
 
}