From 4c78c3a6fc3fe5fbbcabc85465612a799d98587d Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期三, 26 三月 2025 16:45:31 +0800
Subject: [PATCH] 获取未完成计划列表、获取已完成计划列表

---
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoPlans.java                                 |   61 ++++++++++++++++++++
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java                   |   14 ++++
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml                                  |   38 ++++++++++++
 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java |   41 ++++++++++++-
 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java   |   17 +++++
 5 files changed, 166 insertions(+), 5 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java
index 4d0e363..1cbb726 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java
@@ -3,10 +3,12 @@
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan;
 import com.dy.pipIrrGlobal.voIr.VoPlanSimple;
+import com.dy.pipIrrGlobal.voIr.VoPlans;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.Date;
+import java.util.List;
 
 /**
  * @author ZhuBaoMin
@@ -62,4 +64,16 @@
      * @return
      */
     Integer updatePlanTimes(@Param("planStartTime") Date planStartTime, @Param("planStopTime") Date planEndTime, @Param("planId")  Long planId);
+
+    /**
+     * 鑾峰彇鏈畬鎴愮殑璁″垝鍒楄〃锛屽皬绋嬪簭璁″垝鍒楄〃椤典娇鐢�
+     * @return
+     */
+    List<VoPlans> getNotCompletePlans();
+
+    /**
+     * 鑾峰彇宸插畬鎴愮殑璁″垝鍒楄〃锛屽皬绋嬪簭璁″垝鍒楄〃椤典娇鐢�
+     * @return
+     */
+    List<VoPlans> getCompletedPlans();
 }
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoPlans.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoPlans.java
new file mode 100644
index 0000000..2318ee7
--- /dev/null
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoPlans.java
@@ -0,0 +1,61 @@
+package com.dy.pipIrrGlobal.voIr;
+
+import com.alibaba.fastjson2.annotation.JSONField;
+import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2025-03-26 15:54
+ * @LastEditTime 2025-03-26 15:54
+ * @Description 鐏屾簤璁″垝淇℃伅瀵硅薄瑙嗗浘锛屽皬绋嬪簭璁″垝鍒楄〃椤典娇鐢�
+ */
+
+@Data
+@JsonPropertyOrder({"planId", "planName", "startupMode", "planStartTime", "planStopTime", "duration", "planState"})
+public class VoPlans {
+    public static final long serialVersionUID = 202503261555001L;
+
+    /**
+     * 璁″垝ID
+     */
+    @JSONField(serializeUsing= ObjectWriterImplToString.class)
+    private Long planId;
+
+    /**
+     * 璁″垝鍚嶇О
+     */
+    private String planName;
+
+    /**
+     * 璁″垝鍚姩鏂瑰紡
+     */
+    private Integer startupMode;
+
+    /**
+     * 璁″垝鍚姩鏃堕棿
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    private Date planStartTime;
+
+    /**
+     * 璁″垝鍋滄鏃堕棿
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
+    private Date planStopTime;
+
+    /**
+     * 鐏屾簤鎸佺画鏃堕棿
+     */
+    private Integer duration;
+
+    /**
+     * 璁″垝鐘舵�侊細鑽夌銆佹湭鎵ц銆佹墽琛屼腑銆佸凡瀹屾垚
+     */
+    private String planState;
+
+}
diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml
index 7f5b8fc..699d758 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml
@@ -267,4 +267,42 @@
     WHERE id = #{planId}
   </update>
 
+  <!--鑾峰彇鏈畬鎴愮殑璁″垝鍒楄〃锛屽皬绋嬪簭璁″垝鍒楄〃椤典娇鐢�-->
+  <select id="getNotCompletePlans" resultType="com.dy.pipIrrGlobal.voIr.VoPlans">
+    SELECT
+      id AS planId,
+      plan_name AS planName,
+      startup_mode AS startupMode,
+      plan_start_time AS planStartTime,
+      plan_stop_time AS planStopTime,
+      duration,
+      IF(plan_state = 1,'鑽夌',
+         IF(NOW() &lt; plan_start_time, '鏈墽琛�',
+            IF(NOW() &gt;= plan_start_time AND NOW() &lt; plan_stop_time, '鎵ц涓�', '宸插畬鎴�')
+        )
+      ) AS planState
+    FROM ir_irrigate_plan plan
+    WHERE deleted = 0 AND (plan_state = 1 OR NOW() &lt; plan_stop_time)
+    ORDER BY plan_state DESC
+  </select>
+
+  <!--鑾峰彇宸插畬鎴愮殑璁″垝鍒楄〃锛屽皬绋嬪簭璁″垝鍒楄〃椤典娇鐢�-->
+  <select id="getCompletedPlans" resultType="com.dy.pipIrrGlobal.voIr.VoPlans">
+    SELECT
+      id AS planId,
+      plan_name AS planName,
+      startup_mode AS startupMode,
+      plan_start_time AS planStartTime,
+      plan_stop_time AS planStopTime,
+      duration,
+      IF(plan_state = 1,'鑽夌',
+         IF(NOW() &lt; plan_start_time, '鏈墽琛�',
+            IF(NOW() &gt;= plan_start_time AND NOW() &lt; plan_stop_time, '鎵ц涓�', '宸插畬鎴�')
+        )
+      ) AS planState
+    FROM ir_irrigate_plan plan
+    WHERE deleted = 0 AND (plan_state = 2 AND NOW() &gt;= plan_stop_time)
+    ORDER BY plan_state DESC
+  </select>
+
 </mapper>
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java
index 4ef7508..2e03d8f 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java
@@ -2,9 +2,13 @@
 
 import com.dy.common.webUtil.BaseResponse;
 import com.dy.common.webUtil.BaseResponseUtils;
-import com.dy.pipIrrGlobal.pojoIr.*;
+import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan;
+import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule;
+import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate;
+import com.dy.pipIrrGlobal.pojoIr.IrPlanSchedule;
 import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule;
 import com.dy.pipIrrGlobal.voIr.VoPlanSimple;
+import com.dy.pipIrrGlobal.voIr.VoPlans;
 import com.dy.pipIrrWechat.command.CommandSv;
 import com.dy.pipIrrWechat.command.dto.AutomaticClose;
 import com.dy.pipIrrWechat.irrigatePlan.dto.IrrigatePlan;
@@ -17,10 +21,7 @@
 import org.springframework.http.MediaType;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.BindingResult;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.time.LocalDateTime;
 import java.time.ZoneId;
@@ -141,6 +142,36 @@
     }
 
     /**
+     * 鑾峰彇鏈畬鎴愮殑璁″垝鍒楄〃锛屽皬绋嬪簭璁″垝鍒楄〃椤典娇鐢�
+     * @return
+     */
+    @GetMapping(path = "/getNotCompletePlans")
+    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")
+    public BaseResponse<List<VoPlans>> getCompletedPlans() {
+        try {
+            List<VoPlans> res = irrigatePlanSv.getCompletedPlans();
+            return BaseResponseUtils.buildSuccess(res);
+        } catch (Exception e) {
+            log.error("鑾峰彇椤圭洰璁板綍寮傚父", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
+
+    /**
      * 鍙戝竷鐏屾簤璁″垝
      * 1. 淇敼鐏屾簤璁″垝鐘舵�佷负鍙戝竷鐘舵��
      * 2. 娣诲姞鐏屾簤璁″垝鎿嶄綔璁板綍
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java
index 6367ea5..06c4060 100644
--- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java
@@ -7,6 +7,7 @@
 import com.dy.pipIrrGlobal.pojoIr.IrPlanSchedule;
 import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule;
 import com.dy.pipIrrGlobal.voIr.VoPlanSimple;
+import com.dy.pipIrrGlobal.voIr.VoPlans;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -59,6 +60,22 @@
     }
 
     /**
+     * 鑾峰彇鏈畬鎴愮殑璁″垝鍒楄〃锛屽皬绋嬪簭璁″垝鍒楄〃椤典娇鐢�
+      * @return
+     */
+    public List<VoPlans> getNotCompletePlans() {
+        return irrigatePlanMapper.getNotCompletePlans();
+    }
+
+    /**
+     * 鑾峰彇宸插畬鎴愮殑璁″垝鍒楄〃锛屽皬绋嬪簭璁″垝鍒楄〃椤典娇鐢�
+     * @return
+     */
+    public List<VoPlans> getCompletedPlans() {
+        return irrigatePlanMapper.getCompletedPlans();
+    }
+
+    /**
      * 鏍规嵁鎸囧畾鐨勮鍒扞D鑾峰彇鍚姩妯″紡
      * @param planId
      * @return

--
Gitblit v1.8.0