package com.dy.pipIrrProject.mqtt; import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.ResultCodeMsg; import com.dy.pipIrrProject.mqtt.manure.ManureSv; import com.dy.pipIrrProject.mqtt.soil.SoilSv; import com.dy.pipIrrProject.mqtt.weather.WeatherSv; 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; /** * @Author: liurunyu * @Date: 2025/6/18 14:55 * @Description */ @Slf4j @Tag(name = "农业灌溉综合站", description = "农业灌溉综合站管理") @RestController @RequestMapping(path = "mqtt") @RequiredArgsConstructor public class MqttCtrl { private ManureSv manureSv ; private SoilSv soilSv ; private WeatherSv weatherSv ; @Autowired public void setSv(ManureSv manureSv, SoilSv soilSv, WeatherSv weatherSv) { this.manureSv = manureSv; this.soilSv = soilSv; this.weatherSv = weatherSv; } /** * 客户端请求得到所有水肥机、气象站、墒情站简单信息 * @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 = MqttSimpleVo.class))} ) }) @GetMapping(path = "allSimple") @SsoAop() public BaseResponse allSimple() { try { MqttSimpleVo reVo = new MqttSimpleVo() ; reVo.manures = this.manureSv.allSimple() ; reVo.soils = this.soilSv.allSimple() ; reVo.weathers = this.weatherSv.allSimple() ; return BaseResponseUtils.buildSuccess(reVo); } catch (Exception e) { log.error("查询全部水肥机、气象站、墒情站简单信息异常", e); return BaseResponseUtils.buildException(e.getMessage()); } } }