pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigatePlanMapper.xml
@@ -5,6 +5,7 @@
    <!--@mbg.generated-->
    <!--@Table ir_irrigate_plan-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="project_id" jdbcType="BIGINT" property="projectId" />
    <result column="plan_name" jdbcType="VARCHAR" property="planName" />
    <result column="startup_mode" jdbcType="TINYINT" property="startupMode" />
    <result column="plan_start_time" jdbcType="TIMESTAMP" property="planStartTime" />
@@ -16,7 +17,7 @@
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, plan_name, startup_mode, plan_start_time, plan_stop_time, duration,
    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">
@@ -33,11 +34,11 @@
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan">
    <!--@mbg.generated-->
    insert into ir_irrigate_plan (id, plan_name,
    insert into ir_irrigate_plan (id, project_id, plan_name,
      startup_mode, plan_start_time, plan_stop_time, 
      duration, plan_state, executing_state, 
      deleted)
    values (#{id,jdbcType=BIGINT}, #{planName,jdbcType=VARCHAR},
    values (#{id,jdbcType=BIGINT}, #{projectId,jdbcType=BIGINT}, #{planName,jdbcType=VARCHAR},
      #{startupMode,jdbcType=TINYINT}, #{planStartTime,jdbcType=TIMESTAMP}, #{planStopTime,jdbcType=TIMESTAMP}, 
      #{duration,jdbcType=INTEGER}, #{planState,jdbcType=TINYINT}, #{executingState,jdbcType=TINYINT}, 
      #{deleted,jdbcType=BIGINT})
@@ -48,6 +49,9 @@
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="projectId != null">
        project_id,
      </if>
      <if test="planName != null">
        plan_name,
@@ -77,6 +81,9 @@
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="projectId != null">
        #{projectId,jdbcType=BIGINT},
      </if>
      <if test="planName != null">
        #{planName,jdbcType=VARCHAR},
@@ -108,6 +115,9 @@
    <!--@mbg.generated-->
    update ir_irrigate_plan
    <set>
      <if test="projectId != null">
        project_id = #{projectId,jdbcType=BIGINT},
      </if>
      <if test="planName != null">
        plan_name = #{planName,jdbcType=VARCHAR},
      </if>
@@ -138,7 +148,8 @@
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigatePlan">
    <!--@mbg.generated-->
    update ir_irrigate_plan
    set plan_name = #{planName,jdbcType=VARCHAR},
    set project_id = #{projectId,jdbcType=BIGINT},
      plan_name = #{planName,jdbcType=VARCHAR},
      startup_mode = #{startupMode,jdbcType=TINYINT},
      plan_start_time = #{planStartTime,jdbcType=TIMESTAMP},
      plan_stop_time = #{planStopTime,jdbcType=TIMESTAMP},
@@ -270,39 +281,43 @@
  <!--获取未完成的计划列表,小程序计划列表页使用-->
  <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, '执行中', '已完成')
      pro.project_name AS projectName,
      plan.id AS planId,
      plan.plan_name AS planName,
      plan.startup_mode AS startupMode,
      plan.plan_start_time AS planStartTime,
      plan.plan_stop_time AS planStopTime,
      plan.duration,
      IF(plan.plan_state = 1, 1,
         IF(NOW() &lt; plan.plan_start_time, 2,
            IF(NOW() &gt;= plan.plan_start_time AND NOW() &lt; plan.plan_stop_time, 3, 4)
        )
      ) 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
        INNER JOIN ir_project pro ON pro.id = plan.project_id
    WHERE plan.deleted = 0 AND (plan.plan_state = 1 OR NOW() &lt; plan.plan_stop_time)
    ORDER BY plan.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, '执行中', '已完成')
      pro.project_name AS projectName,
      plan.id AS planId,
      plan.plan_name AS planName,
      plan.startup_mode AS startupMode,
      plan.plan_start_time AS planStartTime,
      plan.plan_stop_time AS planStopTime,
      plan.duration,
      IF(plan.plan_state = 1, 1,
         IF(NOW() &lt; plan.plan_start_time, 2,
            IF(NOW() &gt;= plan.plan_start_time AND NOW() &lt; plan.plan_stop_time, 3, 4)
        )
      ) 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
        INNER JOIN ir_project pro ON pro.id = plan.project_id
    WHERE plan.deleted = 0 AND (plan.plan_state = 2 AND NOW() &gt;= plan.plan_stop_time)
    ORDER BY plan.plan_state DESC
  </select>
</mapper>