From ef77ac7224c9ff7468e0ad7daf50686eebbbd9fa Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期二, 25 二月 2025 16:21:51 +0800
Subject: [PATCH] 获取灌溉计划列表接口

---
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoIr/IrIrrigatePlanMapper.java                    |    4 
 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/qo/QoIrrigatePlan.java |   42 ++++++++++
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml                                   |   73 ++++++++++-------
 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanCtrl.java  |   24 +++++-
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoIrrigatePlan.java                           |    9 +
 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/IrrigatePlanSv.java    |   26 +++++
 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrIrrigatePlan.java                         |   41 +++++----
 7 files changed, 159 insertions(+), 60 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 8ef4634..697f90e 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
@@ -10,8 +10,8 @@
 
 /**
  * @author ZhuBaoMin
- * @date 2025-02-20 15:33
- * @LastEditTime 2025-02-20 15:33
+ * @date 2025-02-25 14:59
+ * @LastEditTime 2025-02-25 14:59
  * @Description
  */
 
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrIrrigatePlan.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrIrrigatePlan.java
index f0c2679..90c7951 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrIrrigatePlan.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoIr/IrIrrigatePlan.java
@@ -30,54 +30,59 @@
     public static final long serialVersionUID = 202502201543001L;
 
     /**
-    * 涓婚敭
-    */
+     * 涓婚敭
+     */
     @JSONField(serializeUsing= ObjectWriterImplToString.class)
     @TableId(type = IdType.INPUT)
     private Long id;
 
     /**
-    * 椤圭洰ID
-    */
+     * 椤圭洰ID
+     */
     private Long projectId;
 
     /**
-    * 璁″垝鍚嶇О
-    */
+     * 璁″垝鍚嶇О
+     */
     @NotBlank(message = "璁″垝鍚嶇О涓嶈兘涓虹┖")
     private String planName;
 
     /**
-    * 璁″垝鍚姩妯″紡;1-鎵嬪姩鍚姩锛�2-鑷姩鍚姩
-    */
+     * 璁″垝鍚姩妯″紡;1-鎵嬪姩鍚姩锛�2-鑷姩鍚姩
+     */
     @NotNull(message = "璁″垝鍚姩妯″紡涓嶈兘涓虹┖")
     private Byte startupMode;
 
     /**
-    * 鐏屾簤寮�濮嬫椂闂�;绮剧‘鍒板垎
-    */
+     * 鐏屾簤寮�濮嬫椂闂�;绮剧‘鍒板垎
+     */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date planStartTime;
 
     /**
-    * 鐏屾簤缁撴潫鏃堕棿;绮剧‘鍒板垎
-    */
+     * 鐏屾簤缁撴潫鏃堕棿;绮剧‘鍒板垎
+     */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date planStopTime;
 
     /**
-    * 璁″垝鐘舵��;1-鑽夌锛�2-宸插彂甯�
-    */
+     * 鐏屾簤鏃堕暱;鍒嗛挓
+     */
+    private Integer duration;
+
+    /**
+     * 璁″垝鐘舵��;1-鑽夌锛�2-宸插彂甯�
+     */
     private Byte planState;
 
     /**
-    * 鎵ц鐘舵��;1-鏈墽琛岋紝2-鎵ц涓紝3-宸叉殏鍋滐紝4-宸茬粓姝紝5-宸插畬鎴�
-    */
+     * 鎵ц鐘舵��;1-鏈墽琛岋紝2-鎵ц涓紝3-宸叉殏鍋滐紝4-宸茬粓姝紝5-宸插畬鎴�
+     */
     private Byte executingState;
 
     /**
-    * 閫昏緫鍒犻櫎鏍囪瘑;鏈垹闄や负0锛屽凡鍒犻櫎涓哄垹闄ゆ椂闂�
-    */
+     * 閫昏緫鍒犻櫎鏍囪瘑;鏈垹闄や负0锛屽凡鍒犻櫎涓哄垹闄ゆ椂闂�
+     */
     private Long deleted;
 
 }
\ No newline at end of file
diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoIrrigatePlan.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoIrrigatePlan.java
index cbaa7bf..3eb8770 100644
--- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoIrrigatePlan.java
+++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voIr/VoIrrigatePlan.java
@@ -17,7 +17,7 @@
  */
 
 @Data
-@JsonPropertyOrder({"planId", "projectName", "planName", "startupMode", "startTime", "stopTime", "planState", "executingState"})
+@JsonPropertyOrder({"planId", "projectName", "planName", "startupMode", "startTime", "stopTime", "duration", "planState", "executingState"})
 public class VoIrrigatePlan implements BaseEntity {
     public static final long serialVersionUID = 202502241652001L;
 
@@ -55,12 +55,17 @@
     private Date stopTime;
 
     /**
+     * 鐏屾簤鏃堕暱
+     */
+    private Integer duration;
+
+    /**
      * 璁″垝鐘舵�侊紱1-鑽夌锛�2-宸插彂甯�
      */
     private String planState;
 
     /**
-     * 璁″垝鎵ц鐘舵��
+     * 璁″垝鎵ц鐘舵�侊紱1-鏈墽琛岋紝2-鎵ц涓紝3-宸叉殏鍋滐紝4-宸茬粓姝紝5-宸插畬鎴�
      */
     private String executingState;
 }
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 abd6ed3..bbf7b56 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml
@@ -10,14 +10,15 @@
     <result column="startup_mode" jdbcType="TINYINT" property="startupMode" />
     <result column="plan_start_time" jdbcType="TIMESTAMP" property="planStartTime" />
     <result column="plan_stop_time" jdbcType="TIMESTAMP" property="planStopTime" />
+    <result column="duration" jdbcType="INTEGER" property="duration" />
     <result column="plan_state" jdbcType="TINYINT" property="planState" />
     <result column="executing_state" jdbcType="TINYINT" property="executingState" />
     <result column="deleted" jdbcType="BIGINT" property="deleted" />
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id, project_id, plan_name, startup_mode, plan_start_time, plan_stop_time, plan_state, 
-    executing_state, deleted
+    id, project_id, plan_name, startup_mode, plan_start_time, plan_stop_time, duration, 
+    plan_state, executing_state, deleted
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--@mbg.generated-->
@@ -35,12 +36,12 @@
     <!--@mbg.generated-->
     insert into ir_irrigate_plan (id, project_id, plan_name, 
       startup_mode, plan_start_time, plan_stop_time, 
-      plan_state, executing_state, deleted
-      )
+      duration, plan_state, executing_state, 
+      deleted)
     values (#{id,jdbcType=BIGINT}, #{projectId,jdbcType=BIGINT}, #{planName,jdbcType=VARCHAR}, 
       #{startupMode,jdbcType=TINYINT}, #{planStartTime,jdbcType=TIMESTAMP}, #{planStopTime,jdbcType=TIMESTAMP}, 
-      #{planState,jdbcType=TINYINT}, #{executingState,jdbcType=TINYINT}, #{deleted,jdbcType=BIGINT}
-      )
+      #{duration,jdbcType=INTEGER}, #{planState,jdbcType=TINYINT}, #{executingState,jdbcType=TINYINT}, 
+      #{deleted,jdbcType=BIGINT})
   </insert>
   <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan">
     <!--@mbg.generated-->
@@ -63,6 +64,9 @@
       </if>
       <if test="planStopTime != null">
         plan_stop_time,
+      </if>
+      <if test="duration != null">
+        duration,
       </if>
       <if test="planState != null">
         plan_state,
@@ -92,6 +96,9 @@
       </if>
       <if test="planStopTime != null">
         #{planStopTime,jdbcType=TIMESTAMP},
+      </if>
+      <if test="duration != null">
+        #{duration,jdbcType=INTEGER},
       </if>
       <if test="planState != null">
         #{planState,jdbcType=TINYINT},
@@ -123,6 +130,9 @@
       <if test="planStopTime != null">
         plan_stop_time = #{planStopTime,jdbcType=TIMESTAMP},
       </if>
+      <if test="duration != null">
+        duration = #{duration,jdbcType=INTEGER},
+      </if>
       <if test="planState != null">
         plan_state = #{planState,jdbcType=TINYINT},
       </if>
@@ -143,6 +153,7 @@
       startup_mode = #{startupMode,jdbcType=TINYINT},
       plan_start_time = #{planStartTime,jdbcType=TIMESTAMP},
       plan_stop_time = #{planStopTime,jdbcType=TIMESTAMP},
+      duration = #{duration,jdbcType=INTEGER},
       plan_state = #{planState,jdbcType=TINYINT},
       executing_state = #{executingState,jdbcType=TINYINT},
       deleted = #{deleted,jdbcType=BIGINT}
@@ -158,7 +169,7 @@
   <select id="getIrrigatePlanCount" resultType="java.lang.Long">
     SELECT COUNT(*)
     FROM ir_irrigate_plan plan
-        INNER JOIN ir_project pro ON pro.id = plan.project_id
+    INNER JOIN ir_project pro ON pro.id = plan.project_id
     <where>
       AND plan.deleted = 0
       AND pro.deleted = 0
@@ -187,32 +198,32 @@
   <!--鏍规嵁鎸囧畾鐨勬潯浠惰幏鍙栬鍒掑垪琛�-->
   <select id="getIrrigatePlans" resultType="com.dy.pipIrrGlobal.voIr.VoIrrigatePlan">
     SELECT
-      plan.id AS planId,
-      pro.project_name AS projectName,
-      plan.plan_name AS planName,
-      CASE plan.startup_mode
-        WHEN 1 THEN '鎵嬪姩鍚姩'
-        WHEN 2 THEN '鑷姩鍚姩'
-        END AS startupMode,
-      plan.plan_start_time AS startTime,
-      plan.plan_stop_time AS stopTime,
-      CASE plan.plan_state
-        WHEN 1 THEN '鑽夌'
-        WHEN 2 THEN '宸插彂甯�'
-        END AS planState,
+    plan.id AS planId,
+    pro.project_name AS projectName,
+    plan.plan_name AS planName,
+    CASE plan.startup_mode
+    WHEN 1 THEN '鎵嬪姩鍚姩'
+    WHEN 2 THEN '鑷姩鍚姩'
+    END AS startupMode,
+    plan.plan_start_time AS startTime,
+    plan.plan_stop_time AS stopTime,
+    CASE plan.plan_state
+    WHEN 1 THEN '鑽夌'
+    WHEN 2 THEN '宸插彂甯�'
+    END AS planState,
 
-      CASE plan.executing_state
-        WHEN 1 THEN
-          '鏈墽琛�'
-        WHEN 2 THEN
-          '鎵ц涓�'
-        WHEN 3 THEN
-          '宸叉殏鍋�'
-        WHEN 4 THEN
-          '宸茬粓姝�'
-        END AS executingState
+    CASE plan.executing_state
+    WHEN 1 THEN
+    '鏈墽琛�'
+    WHEN 2 THEN
+    '鎵ц涓�'
+    WHEN 3 THEN
+    '宸叉殏鍋�'
+    WHEN 4 THEN
+    '宸茬粓姝�'
+    END AS executingState
     FROM ir_irrigate_plan plan
-        INNER JOIN ir_project pro ON pro.id = plan.project_id
+    INNER JOIN ir_project pro ON pro.id = plan.project_id
     <where>
       AND plan.deleted = 0
       AND pro.deleted = 0
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 246fb29..1e9be73 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,25 +2,25 @@
 
 import com.dy.common.webUtil.BaseResponse;
 import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
 import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan;
 import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule;
 import com.dy.pipIrrGlobal.pojoIr.IrOpeningSchedule;
 import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate;
+import com.dy.pipIrrGlobal.voIr.VoIrrigatePlan;
 import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule;
 import com.dy.pipIrrWechat.irrigatePlan.dto.IrrigatePlan;
 import com.dy.pipIrrWechat.irrigatePlan.dto.IrrigateSchedule;
 import com.dy.pipIrrWechat.irrigatePlan.dto.PlanSimple;
 import com.dy.pipIrrWechat.irrigatePlan.enums.OperateTypeENUM;
+import com.dy.pipIrrWechat.irrigatePlan.qo.QoIrrigatePlan;
 import jakarta.validation.Valid;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 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.util.Date;
 import java.util.List;
@@ -171,4 +171,20 @@
         }
         return BaseResponseUtils.buildSuccess();
     }
+
+    /**
+     * 鑾峰彇鐏屾簤璁″垝鍒楄〃
+     * @param vo
+     * @return
+     */
+    @GetMapping(path = "/getIrrigatePlans")
+    public BaseResponse<QueryResultVo<List<VoIrrigatePlan>>> getIrrigatePlans(QoIrrigatePlan vo) {
+        try {
+            QueryResultVo<List<VoIrrigatePlan>> res = irrigatePlanSv.getIrrigatePlans(vo);
+            return BaseResponseUtils.buildSuccess(res);
+        } catch (Exception e) {
+            log.error("鑾峰彇杞亴缁勮褰曞紓甯�", e);
+            return BaseResponseUtils.buildException(e.getMessage());
+        }
+    }
 }
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 e205fb6..c75639d 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
@@ -1,16 +1,21 @@
 package com.dy.pipIrrWechat.irrigatePlan;
 
+import com.dy.common.webUtil.QueryResultVo;
 import com.dy.pipIrrGlobal.daoIr.*;
 import com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan;
 import com.dy.pipIrrGlobal.pojoIr.IrIrrigateSchedule;
 import com.dy.pipIrrGlobal.pojoIr.IrOpeningSchedule;
 import com.dy.pipIrrGlobal.pojoIr.IrPlanOperate;
+import com.dy.pipIrrGlobal.voIr.VoIrrigatePlan;
 import com.dy.pipIrrGlobal.voIr.VoIrrigateSchedule;
+import com.dy.pipIrrWechat.irrigatePlan.qo.QoIrrigatePlan;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.dubbo.common.utils.PojoUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author ZhuBaoMin
@@ -50,9 +55,24 @@
         return po.getId();
     }
 
-    //public List<VoIrrigatePlan> getIrrigatePlans(Map<?, ?> params {
-    //    return irrigatePlanMapper.getIrrigatePlans(params);
-    //}
+    /**
+     * 鏍规嵁鎸囧畾鐨勬潯浠惰幏鍙栬鍒掑垪琛�
+     * @param queryVo
+     * @return
+     */
+    public QueryResultVo<List<VoIrrigatePlan>> getIrrigatePlans(QoIrrigatePlan queryVo) {
+        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+
+        Long itemTotal = irrigatePlanMapper.getIrrigatePlanCount(params);
+
+        QueryResultVo<List<VoIrrigatePlan>> rsVo = new QueryResultVo<>();
+        rsVo.pageSize = queryVo.pageSize;
+        rsVo.pageCurr = queryVo.pageCurr;
+
+        rsVo.calculateAndSet(itemTotal, params);
+        rsVo.obj = irrigatePlanMapper.getIrrigatePlans(params);
+        return rsVo;
+    }
 
     /**
      * 鍙戝竷鎸囧畾鐨勭亴婧夎鍒�
diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/qo/QoIrrigatePlan.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/qo/QoIrrigatePlan.java
new file mode 100644
index 0000000..2c10a36
--- /dev/null
+++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/irrigatePlan/qo/QoIrrigatePlan.java
@@ -0,0 +1,42 @@
+package com.dy.pipIrrWechat.irrigatePlan.qo;
+
+import com.dy.common.webUtil.QueryConditionVo;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author ZhuBaoMin
+ * @date 2025-02-25 15:42
+ * @LastEditTime 2025-02-25 15:42
+ * @Description 鐏屾簤璁″垝鏌ヨ瀵硅薄
+ */
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class QoIrrigatePlan extends QueryConditionVo {
+
+    /**
+     * 椤圭洰鍚嶇О
+     */
+    private String projectName;
+
+    /**
+     * 璁″垝鍚嶇О
+     */
+    private String planName;
+
+    /**
+     * 璁″垝鍚姩妯″紡锛�1-鎵嬪姩鍚姩锛�2-鑷姩鍚姩
+     */
+    private Byte startupMode;
+
+    /**
+     * 璁″垝鐘舵�侊紱1-鑽夌锛�2-宸插彂甯�
+     */
+    private Byte planState;
+
+    /**
+     * 鎵ц鐘舵�侊紱1-鏈墽琛岋紝2-鎵ц涓紝3-宸叉殏鍋滐紝4-宸茬粓姝紝5-宸插畬鎴�
+     */
+    private Byte executingState;
+}

--
Gitblit v1.8.0