From b029979db841167a3b2b403fdb24dfbf5ffce615 Mon Sep 17 00:00:00 2001
From: zhubaomin <zhubaomin>
Date: 星期一, 17 二月 2025 14:10:41 +0800
Subject: [PATCH] 代码优化

---
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/StClientAmountDayMapper.xml |   91 ++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 88 insertions(+), 3 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StClientAmountDayMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StClientAmountDayMapper.xml
index cd1e7c5..456ce0b 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StClientAmountDayMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/StClientAmountDayMapper.xml
@@ -116,6 +116,21 @@
     times27, amount28, money28, times28, amount29, money29, times29, amount30, money30, 
     times30, amount31, money31, times31
   </sql>
+  <sql id="Base_Column_List_with_alias">
+    ${alias}.id, ${alias}.client_id, ${alias}.`year`, ${alias}.`month`, ${alias}.amount1, ${alias}.money1, ${alias}.times1, ${alias}.amount2, ${alias}.money2, ${alias}.times2,
+    ${alias}.amount3, ${alias}.money3, ${alias}.times3, ${alias}.amount4, ${alias}.money4, ${alias}.times4, ${alias}.amount5, ${alias}.money5, ${alias}.times5, ${alias}.amount6,
+    ${alias}.money6, ${alias}.times6, ${alias}.amount7, ${alias}.money7, ${alias}.times7, ${alias}.amount8, ${alias}.money8, ${alias}.times8, ${alias}.amount9, ${alias}.money9,
+    ${alias}.times9, ${alias}.amount10, ${alias}.money10, ${alias}.times10, ${alias}.amount11, ${alias}.money11, ${alias}.times11, ${alias}.amount12, ${alias}.money12,
+    ${alias}.times12, ${alias}.amount13, ${alias}.money13, ${alias}.times13, ${alias}.amount14, ${alias}.money14, ${alias}.times14, ${alias}.amount15, ${alias}.money15,
+    ${alias}.times15, ${alias}.amount16, ${alias}.money16, ${alias}.times16, ${alias}.amount17, ${alias}.money17, ${alias}.times17, ${alias}.amount18, ${alias}.money18,
+    ${alias}.times18, ${alias}.amount19, ${alias}.money19, ${alias}.times19, ${alias}.amount20, ${alias}.money20, ${alias}.times20, ${alias}.amount21, ${alias}.money21,
+    ${alias}.times21, ${alias}.amount22, ${alias}.money22, ${alias}.times22, ${alias}.amount23, ${alias}.money23, ${alias}.times23, ${alias}.amount24, ${alias}.money24,
+    ${alias}.times24, ${alias}.amount25, ${alias}.money25, ${alias}.times25, ${alias}.amount26, ${alias}.money26, ${alias}.times26, ${alias}.amount27, ${alias}.money27,
+    ${alias}.times27, ${alias}.amount28, ${alias}.money28, ${alias}.times28, ${alias}.amount29, ${alias}.money29, ${alias}.times29, ${alias}.amount30, ${alias}.money30,
+    ${alias}.times30, ${alias}.amount31, ${alias}.money31, ${alias}.times31
+  </sql>
+
+
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--@mbg.generated-->
     select 
@@ -1185,14 +1200,84 @@
   </update>
 
   <!-- ////////////////////////////////// -->
+  <!-- 鏌ヨ缁熻缁撴灉                         -->
+  <!-- ////////////////////////////////// -->
+  <select id="selectCountDayStatistics" 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="selectDayStatistics" resultType="com.dy.pipIrrGlobal.voSt.VoStClientAmountDay">
+    select
+    mtb.id as clientId,
+    mtb.clientNum as clientNum,
+    mtb.name as clientName,
+    mtb.address as clientAddress,
+    <include refid="Base_Column_List_with_alias" >
+      <property name="alias" value="stTb"/>
+    </include>
+    from se_client mtb
+    LEFT JOIN st_client_amount_day stTb on stTb.client_id = mtb.id
+    where mtb.deleted != 1
+    <trim prefix="and" suffixOverrides="and">
+      <if test = "year != null">
+        stTb.year = #{year, jdbcType=INTEGER}
+      </if>
+      <if test = "month != null">
+        AND stTb.month = #{month, jdbcType=INTEGER}
+      </if>
+      <if test="name != null and name != ''">
+        AND 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="selectByClientIdAndYearAndMonthAndDay" resultType="com.dy.pipIrrGlobal.pojoSt.StClientAmountDay">
+  <select id="statisticsByClient" resultType="com.dy.pipIrrGlobal.voSt.VoClientAmountStatistics">
+    select client_id as clientId,
+    sum(
+    IFNULL(amount1,0) + IFNULL(amount2,0) + IFNULL(amount3,0) + IFNULL(amount4,0) + IFNULL(amount5,0) + IFNULL(amount6,0) + IFNULL(amount7,0) + IFNULL(amount8,0) + IFNULL(amount9,0) +
+    IFNULL(amount10,0) + IFNULL(amount11,0) + IFNULL(amount12,0) + IFNULL(amount13,0) + IFNULL(amount14,0) + IFNULL(amount15,0) + IFNULL(amount16,0) + IFNULL(amount17,0) + IFNULL(amount18,0) + IFNULL(amount19,0) +
+    IFNULL(amount20,0) + IFNULL(amount21,0) + IFNULL(amount22,0) + IFNULL(amount23,0) + IFNULL(amount24,0) + IFNULL(amount25,0) + IFNULL(amount26,0) + IFNULL(amount27,0) + IFNULL(amount28,0) + IFNULL(amount29,0) +
+    IFNULL(amount30,0) + IFNULL(amount31,0)
+    ) as amount,
+    sum(
+    IFNULL(money1,0) + IFNULL(money2,0) + IFNULL(money3,0) + IFNULL(money4,0) + IFNULL(money5,0) + IFNULL(money6,0) + IFNULL(money7,0) + IFNULL(money8,0) + IFNULL(money9,0) +
+    IFNULL(money10,0) + IFNULL(money11,0) + IFNULL(money12,0) + IFNULL(money13,0) + IFNULL(money14,0) + IFNULL(money15,0) + IFNULL(money16,0) + IFNULL(money17,0) + IFNULL(money18,0) + IFNULL(money19,0) +
+    IFNULL(money20,0) + IFNULL(money21,0) + IFNULL(money22,0) + IFNULL(money23,0) + IFNULL(money24,0) + IFNULL(money25,0) + IFNULL(money26,0) + IFNULL(money27,0) + IFNULL(money28,0) + IFNULL(money29,0) +
+    IFNULL(money30,0) + IFNULL(money31,0)
+    ) as money,
+    sum(
+    IFNULL(times1,0) + IFNULL(times2,0) + IFNULL(times3,0) + IFNULL(times4,0) + IFNULL(times5,0) + IFNULL(times6,0) + IFNULL(times7,0) + IFNULL(times8,0) + IFNULL(times9,0) +
+    IFNULL(times10,0) + IFNULL(times11,0) + IFNULL(times12,0) + IFNULL(times13,0) + IFNULL(times14,0) + IFNULL(times15,0) + IFNULL(times16,0) + IFNULL(times17,0) + IFNULL(times18,0) + IFNULL(times19,0) +
+    IFNULL(times20,0) + IFNULL(times21,0) + IFNULL(times22,0) + IFNULL(times23,0) + IFNULL(times24,0) + IFNULL(times25,0) + IFNULL(times26,0) + IFNULL(times27,0) + IFNULL(times28,0) + IFNULL(times29,0) +
+    IFNULL(times30,0) + IFNULL(times31,0)
+    ) as times
+    from st_client_amount_day
+    where year = #{year, jdbcType=INTEGER}
+    and month = #{month, jdbcType=INTEGER}
+    group by client_id
+  </select>
+  <select id="selectByYearAndMonthAndDay" resultType="com.dy.pipIrrGlobal.pojoSt.StClientAmountDay">
     select
     <include refid="Base_Column_List" />
     from st_client_amount_day
-    where client_id = #{clientId,jdbcType=BIGINT}
-    and year = #{year,jdbcType=INTEGER}
+    where year = #{year,jdbcType=INTEGER}
     and month = #{month,jdbcType=INTEGER}
   </select>
 

--
Gitblit v1.8.0