liurunyu
2 天以前 90c02e0ad08c054e1f44476a3e9e16b947c1fd8c
pipIrr-platform/pipIrr-global/src/main/resources/mapper/StClientAmountYearMapper.xml
@@ -111,6 +111,121 @@
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!-- ////////////////////////////////// -->
  <!-- 查询统计结果                         -->
  <!-- ////////////////////////////////// -->
  <select id="selectCountYearStatistics" resultType="java.lang.Long">
    select
    count(*)
    from se_client mtb
    where mtb.deleted != 1
    <trim prefix="and" suffixOverrides="and">
      <if test="name != null and name != ''">
        mtb.name like concat('%', #{name}, '%')
      </if>
    </trim>
  </select>
  <select id="selectCountYearStatistics4OneYear" resultType="java.lang.Long">
    select
    count(*)
    from se_client ctb
    INNER JOIN st_client_amount_year cayTb on cayTb.client_id = ctb.id
    where ctb.deleted != 1
    <trim prefix="and" suffixOverrides="and">
      <if test="year != null">
        cayTb.`year` = #{year,jdbcType=INTEGER}
      </if>
      <if test="name != null and name != ''">
        and ctb.name like concat('%', #{name}, '%')
      </if>
    </trim>
  </select>
  <select id="selectClientIds4YearStatistics" resultType="com.dy.pipIrrGlobal.voSt.VoStClientIdAmountYearRecord">
    select
    mtb.id as clientId
    from se_client mtb
    where mtb.deleted != 1
    <trim prefix="and" suffixOverrides="and">
      <if test="name != null and name != ''">
        mtb.name like concat('%', #{name}, '%')
      </if>
    </trim>
    order by mtb.id DESC
    <trim prefix="limit " >
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
      </if>
    </trim>
  </select>
  <select id="selectYearStatistics4OneYear" resultType="com.dy.pipIrrGlobal.voSt.VoStClientAmountYearRecord">
    select
    ctb.id as clientId,
    ctb.clientNum as clientNum,
    ctb.name as clientName,
    ctb.address as clientAddress,
    cayTb.amount as amount,
    cayTb.money as money,
    cayTb.times as times
    from se_client ctb
    INNER JOIN st_client_amount_year cayTb on cayTb.client_id = ctb.id
    where ctb.deleted != 1
    <trim prefix="and" suffixOverrides="and">
      <if test="year != null">
        cayTb.`year` = #{year,jdbcType=INTEGER}
      </if>
      <if test="name != null and name != ''">
        and ctb.name like concat('%', #{clientName}, '%')
      </if>
    </trim>
    order by ctb.id DESC
    <trim prefix="limit " >
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
      </if>
    </trim>
  </select>
  <select id="selectYearStatistics" resultType="com.dy.pipIrrGlobal.voSt.VoStClientAmountYearRecord">
    select
    ctb.id as clientId,
    ctb.clientNum as clientNum,
    ctb.name as clientName,
    ctb.address as clientAddress,
    cayTb.amount as amount,
    cayTb.money as money,
    cayTb.times as times
    from se_client ctb
    <if test="clientIdsJson != null and clientIdsJson !=''">
      INNER JOIN JSON_TABLE(
      <!--'[{"clientId":"37142501020100215"},{"clientId":"37142501020100215"}]'-->
      #{clientIdsJson},
      '$[*]' COLUMNS (
        clientId BIGINT PATH '$.clientId'
        )
      ) clientIdTb ON clientIdTb.clientId = ctb.id
    </if>
    LEFT JOIN st_client_amount_year cayTb on cayTb.client_id = clientIdTb.clientId
    where ctb.deleted != 1
    <trim prefix="and" suffixOverrides="and">
      <if test="year != null">
        (cayTb.`year` = #{year,jdbcType=INTEGER} or cayTb.`year` is null)
      </if>
      <if test="name != null and name != ''">
        and ctb.name like concat('%', #{clientName}, '%')
      </if>
    </trim>
    order by ctb.id DESC
    <!-- 2025-07-14 因为有clientIdsJson限制的数量,所以不再用limit了
    <trim prefix="limit " >
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
      </if>
    </trim>
    -->
  </select>
  <!-- ////////////////////////////////// -->
  <!-- 统计相关                         -->