zhubaomin
2025-03-25 802fc74478ae3f2c4e8ab7cd417f97469c84f157
pipIrr-platform/pipIrr-global/src/main/resources/mapper/IrIrrigateGroupMapper.xml
@@ -5,19 +5,38 @@
        <!--@mbg.generated-->
        <!--@Table ir_irrigate_group-->
        <id column="id" jdbcType="BIGINT" property="id" />
        <result column="project_id" jdbcType="BIGINT" property="projectId" />
        <result column="group_code" jdbcType="VARCHAR" property="groupCode" />
    <result column="default_duration" jdbcType="INTEGER" property="defaultDuration" />
        <result column="remarks" jdbcType="VARCHAR" property="remarks" />
        <result column="operator" jdbcType="BIGINT" property="operator" />
        <result column="operate_time" jdbcType="TIMESTAMP" property="operateDt" />
    <result column="operate_time" jdbcType="TIMESTAMP" property="operateTime" />
        <result column="deleted" jdbcType="TINYINT" property="deleted" />
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, project_id, group_code, remarks, `operator`,
        operate_time, deleted
    id, group_code, default_duration, remarks, `operator`, operate_time, deleted
    </sql>
    <!--添加-->
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from ir_irrigate_group
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ir_irrigate_group
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup">
    <!--@mbg.generated-->
    insert into ir_irrigate_group (id, group_code, default_duration,
      remarks, `operator`, operate_time,
      deleted)
    values (#{id,jdbcType=BIGINT}, #{groupCode,jdbcType=VARCHAR}, #{defaultDuration,jdbcType=INTEGER},
      #{remarks,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT}, #{operateTime,jdbcType=TIMESTAMP},
      #{deleted,jdbcType=TINYINT})
  </insert>
    <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup">
        <!--@mbg.generated-->
        insert into ir_irrigate_group
@@ -25,11 +44,11 @@
            <if test="id != null">
                id,
            </if>
            <if test="projectId != null">
                project_id,
            </if>
            <if test="groupCode != null">
                group_code,
      </if>
      <if test="defaultDuration != null">
        default_duration,
            </if>
            <if test="remarks != null">
                remarks,
@@ -37,7 +56,7 @@
            <if test="operator != null">
                `operator`,
            </if>
            <if test="operateDt != null">
      <if test="operateTime != null">
                operate_time,
            </if>
            <if test="deleted != null">
@@ -48,11 +67,11 @@
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="projectId != null">
                #{projectId,jdbcType=BIGINT},
            </if>
            <if test="groupCode != null">
                #{groupCode,jdbcType=VARCHAR},
      </if>
      <if test="defaultDuration != null">
        #{defaultDuration,jdbcType=INTEGER},
            </if>
            <if test="remarks != null">
                #{remarks,jdbcType=VARCHAR},
@@ -60,14 +79,50 @@
            <if test="operator != null">
                #{operator,jdbcType=BIGINT},
            </if>
            <if test="operateDt != null">
                #{operateDt,jdbcType=TIMESTAMP},
      <if test="operateTime != null">
        #{operateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="deleted != null">
                #{deleted,jdbcType=TINYINT},
            </if>
        </trim>
    </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup">
    <!--@mbg.generated-->
    update ir_irrigate_group
    <set>
      <if test="groupCode != null">
        group_code = #{groupCode,jdbcType=VARCHAR},
      </if>
      <if test="defaultDuration != null">
        default_duration = #{defaultDuration,jdbcType=INTEGER},
      </if>
      <if test="remarks != null">
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="operator != null">
        `operator` = #{operator,jdbcType=BIGINT},
      </if>
      <if test="operateTime != null">
        operate_time = #{operateTime,jdbcType=TIMESTAMP},
      </if>
      <if test="deleted != null">
        deleted = #{deleted,jdbcType=TINYINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup">
    <!--@mbg.generated-->
    update ir_irrigate_group
    set group_code = #{groupCode,jdbcType=VARCHAR},
      default_duration = #{defaultDuration,jdbcType=INTEGER},
      remarks = #{remarks,jdbcType=VARCHAR},
      `operator` = #{operator,jdbcType=BIGINT},
      operate_time = #{operateTime,jdbcType=TIMESTAMP},
      deleted = #{deleted,jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
    <!--逻辑删除-->
    <delete id="deleteLogicById" parameterType="java.lang.Long">
@@ -81,9 +136,6 @@
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup">
        update ir_irrigate_group
        <set>
            <if test="projectId != null">
                project_id = #{projectId,jdbcType=BIGINT},
            </if>
            <if test="groupCode != null">
                group_code = #{groupCode,jdbcType=VARCHAR},
            </if>
@@ -93,8 +145,8 @@
            <if test="operator != null">
                operator = #{operator,jdbcType=BIGINT},
            </if>
            <if test="operateDt != null">
                operate_time = #{operateDt,jdbcType=TIMESTAMP},
      <if test="operateTime != null">
        operate_time = #{operateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="deleted != null">
                deleted = #{deleted,jdbcType=TINYINT},
@@ -174,14 +226,53 @@
        ) a
    </select>
    <!--根据轮灌组编号获取取水口列表-->
    <select id="getIntakesByGroupId" resultType="java.lang.Long">
        SELECT
            uni.intake_id AS intakeId
        FROM ir_irrigate_group grp
            INNER JOIN ir_group_unit gu ON gu.group_id = grp.id
            INNER JOIN ir_irrigate_unit uni ON uni.id = gu.unit_id
        WHERE grp.deleted = 0 AND grp.id = #{groupId}
  <!--根据指定条件获取轮灌组记录数-->
  <select id="getSimpleGroupCount" resultType="java.lang.Long">
    SELECT COUNT(*) AS recordCount
    FROM ir_irrigate_group grp
        INNER JOIN ir_project_group pg ON pg.group_id = grp.id
        INNER JOIN ir_project pro ON pg.project_id = pro.id
    <where>
      AND grp.deleted = 0
      <if test="projectId != null and projectId != ''">
        AND pro.id = #{projectId}
      </if>
      <if test="groupCode != null and groupCode != ''">
        AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%')
      </if>
    </where>
  </select>
  <!--根据指定条件获取轮灌组列表-->
  <select id="getSimpleGroups" resultType="com.dy.pipIrrGlobal.voIr.VoGroupSimple">
    SELECT
      grp.id AS groupId,
      grp.group_code AS groupCode,
      (SELECT COUNT(*) FROM ir_group_intake WHERE group_id = grp.id) AS intakeCount,
      grp.default_duration AS defaultDuration,
      pg.sort
    FROM ir_irrigate_group grp
           INNER JOIN ir_project_group pg ON pg.group_id = grp.id
           INNER JOIN ir_project pro ON pg.project_id = pro.id
    <where>
      AND grp.deleted = 0
      <if test="projectId != null and projectId != ''">
        AND pro.id = #{projectId}
      </if>
      <if test="groupCode != null and groupCode != ''">
        AND grp.group_code LIKE CONCAT('%', #{groupCode}, '%')
      </if>
    </where>
    ORDER BY pg.sort
    <trim prefix="limit ">
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
      </if>
    </trim>
    </select>
</mapper>