From 6a4f68b8f99dca3a00c297cbcff82c065575212c Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期六, 16 八月 2025 11:25:20 +0800
Subject: [PATCH] 1、完善代码;2、作物去除lat属性,采用关联气象站的lat;3、project模块增加查询全部气象站的方法。
---
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/manure/ManureCtrl.java | 191 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 190 insertions(+), 1 deletions(-)
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/manure/ManureCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/manure/ManureCtrl.java
index ccb4ca3..9963af5 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/manure/ManureCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/mqtt/manure/ManureCtrl.java
@@ -1,9 +1,198 @@
package com.dy.pipIrrProject.mqtt.manure;
+import com.dy.common.aop.SsoAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.common.webUtil.ResultCodeMsg;
+import com.dy.pipIrrGlobal.pojoPr.PrStManure;
+import com.dy.pipIrrGlobal.voPr.VoManure;
+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 jakarta.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Objects;
+
/**
* @Author: liurunyu
- * @Date: 2025/6/18 14:51
+ * @Date: 2025/6/19 10:41
* @Description
*/
+@Slf4j
+@Tag(name = "姘磋偉鏈虹鐞�", description = "姘磋偉鏈虹鐞�")
+@RestController
+@RequestMapping(path = "manureStation")
+@RequiredArgsConstructor
public class ManureCtrl {
+ private ManureSv sv;
+
+ @Autowired
+ private void setSv(ManureSv sv){
+ this.sv = sv ;
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ姘磋偉鏈鸿褰�
+ * @param vo
+ * @return
+ */
+ @Operation(summary = "鑾峰緱涓�椤垫按鑲ユ満璁板綍", description = "杩斿洖涓�椤垫按鑲ユ満鏁版嵁")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "杩斿洖涓�椤垫按鑲ユ満鏁版嵁锛圔aseResponse.content:QueryResultVo[{}]锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = VoManure.class))}
+ )
+ })
+ @GetMapping(path = "/some")
+ @SsoAop()
+ public BaseResponse<QueryResultVo<List<VoManure>>> some(QueryVo vo){
+ try {
+ return BaseResponseUtils.buildSuccess(this.sv.selectSome(vo));
+ } catch (Exception e) {
+ log.error("鑾峰彇姘磋偉鏈鸿褰曞紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage()) ;
+ }
+ }
+
+ /**
+ * 寰楀埌涓�濂楁按鑲ユ満鏁版嵁
+ * @return 涓�濂楁按鑲ユ満鏁版嵁
+ */
+ @Operation(summary = "涓�濂楁按鑲ユ満", description = "寰楀埌涓�濂楁按鑲ユ満鏁版嵁")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "杩斿洖涓�濂楁按鑲ユ満鏁版嵁锛圔aseResponse.content:{}锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = VoManure.class))}
+ )
+ })
+ @GetMapping(path = "one")
+ @SsoAop()
+ public BaseResponse<VoManure> one(Long id){
+ return BaseResponseUtils.buildSuccess(this.sv.selectOne(id));
+ }
+
+ /**
+ * 淇濆瓨姘磋偉鏈�
+ * @param dto 淇濆瓨姘磋偉鏈篺orm琛ㄥ崟瀵硅薄
+ * @return 鏄惁鎴愬姛
+ */
+ @Operation(summary = "淇濆瓨姘磋偉鏈�", description = "鎻愪氦姘磋偉鏈烘暟鎹紙form琛ㄥ崟锛夛紝杩涜淇濆瓨")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @SsoAop()
+ public BaseResponse<Boolean> save(@RequestBody @Valid ManureDto dto, BindingResult bindingResult){
+ if(bindingResult != null && bindingResult.hasErrors()){
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ PrStManure po = dto.toNewPo() ;
+ po.deleted = 0 ;
+ int count;
+ try {
+ count = this.sv.save(po);
+ } catch (Exception e) {
+ log.error("淇濆瓨姘磋偉鏈哄紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage()) ;
+ }
+ if(count <= 0){
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+ }else{
+ return BaseResponseUtils.buildSuccess(true) ;
+ }
+ }
+
+ /**
+ * 缂栬緫淇敼姘磋偉鏈�
+ * @param dto 淇濆瓨姘磋偉鏈篺orm琛ㄥ崟瀵硅薄
+ * @return 鏄惁鎴愬姛
+ */
+ @Operation(summary = "缂栬緫淇敼姘磋偉鏈�", description = "鎻愪氦姘磋偉鏈烘暟鎹紙form琛ㄥ崟锛夛紝杩涜淇敼")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
+ @SsoAop()
+ public BaseResponse<Boolean> update(@RequestBody @Valid ManureDto dto, BindingResult bindingResult){
+ if(bindingResult != null && bindingResult.hasErrors()){
+ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+ }
+ PrStManure po = dto.toPo() ;
+ if(po.id == null){
+ return BaseResponseUtils.buildFail("鏃犳暟鎹疄浣揑D") ;
+ }
+ int count;
+ try {
+ count = this.sv.update(po);
+ } catch (Exception e) {
+ log.error("淇濆瓨姘磋偉鏈哄紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage()) ;
+ }
+ if(count <= 0){
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+ }else{
+ return BaseResponseUtils.buildSuccess(true) ;
+ }
+ }
+
+
+ /**
+ * 鍒犻櫎姘磋偉鏈�
+ * @param id 姘磋偉鏈篒D
+ * @return 鏄惁鎴愬姛
+ */
+ @Operation(summary = "鍒犻櫎姘磋偉鏈�", description = "鎻愪氦姘磋偉鏈篒D锛岃繘琛岄�昏緫鍒犻櫎")
+ @ApiResponses(value = {
+ @ApiResponse(
+ responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
+ description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�",
+ content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
+ schema = @Schema(implementation = Boolean.class))}
+ )
+ })
+ @GetMapping(path = "delete")
+ @SsoAop()
+ public BaseResponse<Boolean> delete(Long id){
+ if(id == null){
+ return BaseResponseUtils.buildFail("id涓嶈兘涓虹┖") ;
+ }
+ int count;
+ try {
+ count = this.sv.delete(id);
+ } catch (Exception e) {
+ log.error("淇濆瓨姘磋偉鏈哄紓甯�", e);
+ return BaseResponseUtils.buildException(e.getMessage()) ;
+ }
+ if(count <= 0){
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�") ;
+ }else{
+ return BaseResponseUtils.buildSuccess(true) ;
+ }
+ }
+
}
--
Gitblit v1.8.0