From cd7fd2ea35de966cfd1c6f3038e593097d7a6dec Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期四, 03 七月 2025 11:26:46 +0800
Subject: [PATCH] 轮灌组PC端接口

---
 pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigatePlan/IrrigatePlanCtrl.java |  212 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 212 insertions(+), 0 deletions(-)

diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigatePlan/IrrigatePlanCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigatePlan/IrrigatePlanCtrl.java
new file mode 100644
index 0000000..f6425a2
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigatePlan/IrrigatePlanCtrl.java
@@ -0,0 +1,212 @@
+package com.dy.pipIrrIrrigate.irrigatePlan;
+
+import com.dy.common.aop.SsoAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryConditionVo;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pipIrrGlobal.voIr.VoPlanDetails;
+import com.dy.pipIrrGlobal.voIr.VoPlans;
+import com.dy.pipIrrIrrigate.irrigatePlan.dto.IrrigatePlan;
+import com.dy.pipIrrIrrigate.irrigatePlan.dto.PlanSimple;
+import jakarta.validation.Valid;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.http.MediaType;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2025-06-30 14:58
+ * @LastEditTime 2025-06-30 14:58
+ * @Description
+ */
+
+@Slf4j
+@RestController
+@RequestMapping(path = "plan")
+@RequiredArgsConstructor
+public class IrrigatePlanCtrl {
+    private final IrrigatePlanSv irrigatePlanSv;
+
+    /**
+     * 鍒涘缓鐏屾簤璁″垝
+     * @param planAndSchedule
+     * @param bindingResult
+     * @return
+     */
+    @PostMapping(path = "createPlan", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @SsoAop()
+    public BaseResponse<Boolean> createPlan(@RequestBody @Valid IrrigatePlan planAndSchedule, BindingResult bindingResult){
+        if(bindingResult != null && bindingResult.hasErrors()){
+            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+        }
+
+        Map map_result = irrigatePlanSv.createPlan(planAndSchedule);
+        if(map_result.get("success").equals(false)) {
+            return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
+        }
+        return BaseResponseUtils.buildSuccess() ;
+    }
+
+    /**
+     * 鍒犻櫎鐏屾簤璁″垝
+     * @param planSimple
+     * @param bindingResult
+     * @return
+     */
+    @PostMapping(path = "deletePlan")
+    @SsoAop()
+    public BaseResponse<Boolean> deletePlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult) {
+        if(bindingResult != null && bindingResult.hasErrors()){
+            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+        }
+
+        Map map_result = irrigatePlanSv.deletePlan(planSimple);
+        if(map_result.get("success").equals(false)) {
+            return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
+        }
+        return BaseResponseUtils.buildSuccess() ;
+    }
+
+    /**
+     * 鍙戝竷鐏屾簤璁″垝
+     * 1. 淇敼鐏屾簤璁″垝鐘舵�佷负鍙戝竷鐘舵��
+     * 2. 娣诲姞鐏屾簤璁″垝鎿嶄綔璁板綍
+     * 3. 鐢熸垚寮�闃�璁″垝
+     * @param planSimple
+     * @param bindingResult
+     * @return
+     */
+    @PostMapping(path = "publishPlan", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @SsoAop()
+    public BaseResponse<Boolean> publishPlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult){
+        if(bindingResult != null && bindingResult.hasErrors()){
+            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+        }
+
+        Map map_result = irrigatePlanSv.publishPlan(planSimple);
+        if(map_result.get("success").equals(false)) {
+            return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
+        }
+        return BaseResponseUtils.buildSuccess() ;
+    }
+
+    /**
+     * 缁堟鐏屾簤璁″垝
+     * @param planSimple
+     * @param bindingResult
+     * @return
+     */
+    @PostMapping(path = "terminatePlan", consumes = MediaType.APPLICATION_JSON_VALUE)
+    @SsoAop()
+    public BaseResponse<Boolean> terminatePlan(@RequestBody @Valid PlanSimple planSimple, BindingResult bindingResult){
+        if(bindingResult != null && bindingResult.hasErrors()){
+            return BaseResponseUtils.buildErrorMsg(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
+        }
+
+        Map map_result = irrigatePlanSv.terminatePlan(planSimple);
+        if(map_result.get("success").equals(false)) {
+            return BaseResponseUtils.buildErrorMsg(map_result.get("msg").toString());
+        }
+        return BaseResponseUtils.buildSuccess() ;
+    }
+
+    /**
+     * 鑾峰彇鏈畬鎴愮殑璁″垝鍒楄〃锛岀亴婧夋ā鍧楄鍒掑垪琛ㄩ〉浣跨敤
+     * @return
+     */
+    @GetMapping(path = "/getNotCompletePlans")
+    @SsoAop()
+    public BaseResponse<List<VoPlans>> getNotCompletePlans() {
+        try {
+            List<VoPlans> res = irrigatePlanSv.getNotCompletePlans();
+            return BaseResponseUtils.buildSuccess(res);
+        } catch (Exception e) {
+            log.error("鑾峰彇鏈畬鐨勮鍒掑紓甯�", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+    /**
+     * 鑾峰彇宸插畬鎴愮殑璁″垝鍒楄〃锛岀亴婧夋ā鍧楄鍒掑垪琛ㄩ〉浣跨敤
+     * @return
+     */
+    @GetMapping(path = "/getCompletedPlans")
+    @SsoAop()
+    public BaseResponse<QueryResultVo<List<VoPlans>>> getCompletedPlans(QueryConditionVo qo) {
+        try {
+            return BaseResponseUtils.buildSuccess(irrigatePlanSv.getCompletedPlans(qo));
+        } catch (Exception e) {
+            log.error("鑾峰彇椤圭洰璁板綍寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+    /**
+     * 鏍规嵁璁″垝ID鑾峰彇璁″垝鍙戝竷缁撴灉
+     * @param planId
+     * @return
+     */
+    @GetMapping(path = "/getPublishResults")
+    @SsoAop()
+    public BaseResponse<VoPlanDetails> getPublishResults(@RequestParam Long planId) {
+        if(planId == null) {
+            return BaseResponseUtils.buildErrorMsg("璁″垝ID涓嶈兘涓虹┖");
+        }
+
+        try {
+            VoPlanDetails res = irrigatePlanSv.getPublishResults(planId);
+            return BaseResponseUtils.buildSuccess(res);
+        } catch (Exception e) {
+            log.error("鑾峰彇璁″垝鍙戝竷缁撴灉寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+    /**
+     * 鏍规嵁璁″垝ID鑾峰彇璁″垝缁堟鎿嶄綔缁撴灉
+     * @param planId
+     * @return
+     */
+    @GetMapping(path = "/getTerminateResults")
+    @SsoAop()
+    public BaseResponse<VoPlanDetails> getTerminateResults(@RequestParam Long planId) {
+        if(planId == null) {
+            return BaseResponseUtils.buildErrorMsg("璁″垝ID涓嶈兘涓虹┖");
+        }
+
+        try {
+            VoPlanDetails res = irrigatePlanSv.getTerminateResults(planId);
+            return BaseResponseUtils.buildSuccess(res);
+        } catch (Exception e) {
+            log.error("鑾峰彇璁″垝鍙戝竷缁撴灉寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+    /**
+     * 鏍规嵁璁″垝ID鑾峰彇璁″垝鏈�鏂扮姸鎬�
+     * @param planId
+     * @return
+     */
+    @GetMapping(path = "/getPlanLatestState")
+    @SsoAop()
+    public BaseResponse<Integer> getPlanLatestState(@RequestParam Long planId) {
+        if(planId == null) {
+            return BaseResponseUtils.buildErrorMsg("璁″垝ID涓嶈兘涓虹┖");
+        }
+
+        try {
+            return BaseResponseUtils.buildSuccess(irrigatePlanSv.getPlanLatestState(planId));
+        } catch (Exception e) {
+            log.error("鑾峰彇鏈畬鐨勮鍒掑紓甯�", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+}

--
Gitblit v1.8.0