From a2aaa19a13112d29c7b32ce2ca54cdc847d3a5ba Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期一, 18 八月 2025 10:54:05 +0800
Subject: [PATCH] 完善代码
---
pipIrr-platform/pipIrr-web/pipIrr-web-irrigate/src/main/java/com/dy/pipIrrIrrigate/irrigatePlan/IrrigatePlanCtrl.java | 196 +++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 182 insertions(+), 14 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
index 0f22e38..f6425a2 100644
--- 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
@@ -3,41 +3,209 @@
import com.dy.common.aop.SsoAop;
import com.dy.common.webUtil.BaseResponse;
import com.dy.common.webUtil.BaseResponseUtils;
-import com.dy.pipIrrGlobal.voIr.VoGroupSimple;
+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.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+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 2024-11-28 17:20
- * @LastEditTime 2024-11-28 17:20
- * @Description 鐏屾簤璁″垝鎺у埗绫�
+ * @date 2025-06-30 14:58
+ * @LastEditTime 2025-06-30 14:58
+ * @Description
*/
@Slf4j
@RestController
-@RequestMapping(path = "irrigatePlan")
+@RequestMapping(path = "plan")
@RequiredArgsConstructor
public class IrrigatePlanCtrl {
private final IrrigatePlanSv irrigatePlanSv;
/**
- * 鏍规嵁鍐滄埛缂栧彿鑾峰彇杞亴缁勫垪琛�
+ * 鍒涘缓鐏屾簤璁″垝
+ * @param planAndSchedule
+ * @param bindingResult
* @return
*/
- @GetMapping(path = "/getGroups")
+ @PostMapping(path = "createPlan", consumes = MediaType.APPLICATION_JSON_VALUE)
@SsoAop()
- public BaseResponse<List<VoGroupSimple>> getGroups(@RequestParam("clientId") Long clientId) {
+ 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 {
- return BaseResponseUtils.buildSuccess(irrigatePlanSv.getGroups(clientId));
+ List<VoPlans> res = irrigatePlanSv.getNotCompletePlans();
+ return BaseResponseUtils.buildSuccess(res);
} catch (Exception e) {
- log.error("鑾峰彇浠诲姟绫诲瀷寮傚父", 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