From 3a6ac2949244e6a3f70e165cd3802f1d90b78819 Mon Sep 17 00:00:00 2001
From: liurunyu <lry9898@163.com>
Date: 星期四, 24 十月 2024 11:20:41 +0800
Subject: [PATCH] 格式化SQL语句

---
 pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayLastMapper.xml |  737 +++++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 535 insertions(+), 202 deletions(-)

diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayLastMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayLastMapper.xml
index c0b3971..f70b447 100644
--- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayLastMapper.xml
+++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmLossDayLastMapper.xml
@@ -1,215 +1,548 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.dy.pipIrrGlobal.daoRm.RmLossDayLastMapper">
-  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
-    <!--@mbg.generated-->
-    <!--@Table rm_loss_day_last-->
-    <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="last_history_id" jdbcType="BIGINT" property="lastHistoryId" />
-    <result column="controller_id" jdbcType="BIGINT" property="controllerId" />
-    <result column="intake_id" jdbcType="BIGINT" property="intakeId" />
-    <result column="rtu_addr" jdbcType="VARCHAR" property="rtuAddr" />
-    <result column="dt" jdbcType="DATE" property="dt" />
-    <result column="dt_last" jdbcType="TIMESTAMP" property="dtLast" />
-    <result column="dt_rtu" jdbcType="TIMESTAMP" property="dtRtu" />
-    <result column="loss_amount" jdbcType="DOUBLE" property="lossAmount" />
-  </resultMap>
-  <sql id="Base_Column_List">
-    <!--@mbg.generated-->
-    id, last_history_id, controller_id, intake_id, rtu_addr, dt, dt_last, dt_rtu, loss_amount
-  </sql>
-  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
-    <!--@mbg.generated-->
-    select
-    <include refid="Base_Column_List" />
-    from rm_loss_day_last
-    where id = #{id,jdbcType=BIGINT}
-  </select>
-  <select id="selectByIntakeId" parameterType="java.lang.Long" resultMap="BaseResultMap">
-    <!--@mbg.generated-->
-    select
-    <include refid="Base_Column_List" />
-    from rm_loss_day_last
-    where intake_id = #{intakeId,jdbcType=BIGINT}
-  </select>
-  <select id="selectByDate" parameterType="java.util.Date" resultMap="BaseResultMap">
-    <!--@mbg.generated-->
-    select
-    <include refid="Base_Column_List" />
-    from rm_loss_day_last
-    where dt = #{dt,jdbcType=DATE}
-  </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
-    <!--@mbg.generated-->
-    delete from rm_loss_day_last
-    where id = #{id,jdbcType=BIGINT}
-  </delete>
-  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
-    <!--@mbg.generated-->
-    insert into rm_loss_day_last (id, last_history_id, controller_id,
-    intake_id, rtu_addr, dt, dt_last, dt_rtu,
-    loss_amount)
-    values (#{id,jdbcType=BIGINT}, #{lastHistoryId,jdbcType=BIGINT}, #{controllerId,jdbcType=BIGINT},
-    #{intakeId,jdbcType=BIGINT}, #{rtuAddr,jdbcType=VARCHAR}, #{dt,jdbcType=DATE}, #{dtLast,jdbcType=TIMESTAMP}, #{dtRtu,jdbcType=TIMESTAMP},
-    #{lossAmount,jdbcType=DOUBLE})
-  </insert>
-  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
-    <!--@mbg.generated-->
-    insert into rm_loss_day_last
-    <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="id != null">
+    <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
+        <!--@mbg.generated-->
+        <!--@Table rm_loss_day_last-->
+        <id column="id" jdbcType="BIGINT" property="id"/>
+        <result column="last_history_id" jdbcType="BIGINT" property="lastHistoryId"/>
+        <result column="controller_id" jdbcType="BIGINT" property="controllerId"/>
+        <result column="intake_id" jdbcType="BIGINT" property="intakeId"/>
+        <result column="rtu_addr" jdbcType="VARCHAR" property="rtuAddr"/>
+        <result column="dt" jdbcType="DATE" property="dt"/>
+        <result column="dt_last" jdbcType="TIMESTAMP" property="dtLast"/>
+        <result column="dt_rtu" jdbcType="TIMESTAMP" property="dtRtu"/>
+        <result column="loss_amount" jdbcType="DOUBLE" property="lossAmount"/>
+    </resultMap>
+    <sql id="Base_Column_List">
+        <!--@mbg.generated-->
         id,
-      </if>
-      <if test="lastHistoryId != null">
         last_history_id,
-      </if>
-      <if test="controllerId != null">
         controller_id,
-      </if>
-      <if test="intakeId != null">
         intake_id,
-      </if>
-      <if test="rtuAddr != null">
         rtu_addr,
-      </if>
-      <if test="dt != null">
         dt,
-      </if>
-      <if test="dtLast != null">
         dt_last,
-      </if>
-      <if test="dtRtu != null">
         dt_rtu,
-      </if>
-      <if test="lossAmount != null">
-        loss_amount,
-      </if>
-    </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        #{id,jdbcType=BIGINT},
-      </if>
-      <if test="lastHistoryId != null">
-        #{lastHistoryId,jdbcType=BIGINT},
-      </if>
-      <if test="controllerId != null">
-        #{controllerId,jdbcType=BIGINT},
-      </if>
-      <if test="intakeId != null">
-        #{intakeId,jdbcType=BIGINT},
-      </if>
-      <if test="rtuAddr != null">
-        #{rtuAddr,jdbcType=VARCHAR},
-      </if>
-      <if test="dt != null">
-        #{dt,jdbcType=DATE},
-      </if>
-      <if test="dtLast != null">
-        #{dtLast,jdbcType=TIMESTAMP},
-      </if>
-      <if test="dtRtu != null">
-        #{dtRtu,jdbcType=TIMESTAMP},
-      </if>
-      <if test="lossAmount != null">
-        #{lossAmount,jdbcType=DOUBLE},
-      </if>
-    </trim>
-  </insert>
-  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
-    <!--@mbg.generated-->
-    update rm_loss_day_last
-    <set>
-      <if test="lastHistoryId != null">
-        last_history_id = #{lastHistoryId,jdbcType=BIGINT},
-      </if>
-      <if test="controllerId != null">
-        controller_id = #{controllerId,jdbcType=BIGINT},
-      </if>
-      <if test="intakeId != null">
-        intake_id = #{intakeId,jdbcType=BIGINT},
-      </if>
-      <if test="rtuAddr != null">
-        rtu_addr = #{rtuAddr,jdbcType=VARCHAR},
-      </if>
-      <if test="dt != null">
-        dt = #{dt,jdbcType=DATE},
-      </if>
-      <if test="dtLast != null">
-        dt_last = #{dtLast,jdbcType=TIMESTAMP},
-      </if>
-      <if test="dtRtu != null">
-        dt_rtu = #{dtRtu,jdbcType=TIMESTAMP},
-      </if>
-      <if test="lossAmount != null">
-        loss_amount = #{lossAmount,jdbcType=DOUBLE},
-      </if>
-    </set>
-    where id = #{id,jdbcType=BIGINT}
-  </update>
-  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
-    <!--@mbg.generated-->
-    update rm_loss_day_last
-    set last_history_id = #{lastHistoryId,jdbcType=BIGINT},
-    controller_id = #{controllerId,jdbcType=BIGINT},
-    intake_id = #{intakeId,jdbcType=BIGINT},
-    rtu_addr = #{rtuAddr,jdbcType=VARCHAR},
-    dt = #{dt,jdbcType=DATE},
-    dt_last = #{dtLast,jdbcType=TIMESTAMP},
-    dt_rtu = #{dtRtu,jdbcType=TIMESTAMP},
-    loss_amount = #{lossAmount,jdbcType=DOUBLE}
-    where id = #{id,jdbcType=BIGINT}
-  </update>
-  <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇璁板綍鎬绘暟-->
-  <select id="getRecordCount" resultType="java.lang.Long">
-    select count(*)
-    from rm_loss_day_last rldl
-    Left join pr_intake pint on pint.id = rldl.intake_id
-    <where>
-      <if test="intakeName != null">
-        and pint.name like CONCAT('%',#{intakeName,jdbcType=VARCHAR},'%')
-      </if>
-      <if test="intakeId != null">
-        and rldl.intake_id = #{intakeId}
-      </if>
-      <if test="startDt != null">
-        and rldl.dt &gt;= #{startDt,jdbcType=DATE}
-      </if>
-      <if test="endDt != null">
-        and rldl.dt &lt;= #{endDt,jdbcType=DATE}
-      </if>
-    </where>
-  </select>
-  <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇璁板綍-->
-  <select id="getLossDayLast" resultType="com.dy.pipIrrGlobal.voRm.VoLossDay">
-    select
-    CAST(rldl.intake_id AS char)AS intakeId,
-    CAST(rldl.controller_id AS char)AS controllerId,
-    pint.name as intakeName,
-    rldl.rtu_addr as rtuAddr,
-    rldl.dt as dt,
-    rldl.dt_last as dtLast,
-    rldl.dt_rtu as dtRtu,
-    rldl.loss_amount as lossAmount
-    from rm_loss_day_last rldl
-    Left join pr_intake pint on pint.id = rldl.intake_id
-    <where>
-      <if test="intakeName != null">
-        and pint.name like CONCAT('%',#{intakeName,jdbcType=VARCHAR},'%')
-      </if>
-      <if test="intakeId != null">
-        and rldl.intake_id = #{intakeId}
-      </if>
-      <if test="startDt != null">
-        and rldl.dt &gt;= #{startDt,jdbcType=DATE}
-      </if>
-      <if test="endDt != null">
-        and rldl.dt &lt;= #{endDt,jdbcType=DATE}
-      </if>
-    </where>
-    ORDER BY rldl.id DESC
-    <if test="pageCurr != null and pageSize != null">
-      LIMIT ${(pageCurr-1)*pageSize}, ${pageSize}
-    </if>
-  </select>
+        loss_amount
+    </sql>
+    <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        <!--@mbg.generated-->
+        select
+        <include refid="Base_Column_List"/>
+        from rm_loss_day_last
+        where id = #{id,jdbcType=BIGINT}
+    </select>
+    <select id="selectByIntakeId" parameterType="java.lang.Long" resultMap="BaseResultMap">
+        <!--@mbg.generated-->
+        select
+        <include refid="Base_Column_List"/>
+        from rm_loss_day_last
+        where intake_id = #{intakeId,jdbcType=BIGINT}
+    </select>
+    <select id="selectByDate" parameterType="java.util.Date" resultMap="BaseResultMap">
+        <!--@mbg.generated-->
+        select
+        <include refid="Base_Column_List"/>
+        from rm_loss_day_last
+        where dt = #{dt,jdbcType=DATE}
+    </select>
+    <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
+        <!--@mbg.generated-->
+        delete
+        from rm_loss_day_last
+        where id = #{id,jdbcType=BIGINT}
+    </delete>
+    <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
+        <!--@mbg.generated-->
+        insert into rm_loss_day_last (id, last_history_id, controller_id,
+                                      intake_id, rtu_addr, dt, dt_last, dt_rtu,
+                                      loss_amount)
+        values (#{id,jdbcType=BIGINT}, #{lastHistoryId,jdbcType=BIGINT}, #{controllerId,jdbcType=BIGINT},
+                #{intakeId,jdbcType=BIGINT}, #{rtuAddr,jdbcType=VARCHAR}, #{dt,jdbcType=DATE},
+                #{dtLast,jdbcType=TIMESTAMP}, #{dtRtu,jdbcType=TIMESTAMP},
+                #{lossAmount,jdbcType=DOUBLE})
+    </insert>
+    <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
+        <!--@mbg.generated-->
+        insert into rm_loss_day_last
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="lastHistoryId != null">
+                last_history_id,
+            </if>
+            <if test="controllerId != null">
+                controller_id,
+            </if>
+            <if test="intakeId != null">
+                intake_id,
+            </if>
+            <if test="rtuAddr != null">
+                rtu_addr,
+            </if>
+            <if test="dt != null">
+                dt,
+            </if>
+            <if test="dtLast != null">
+                dt_last,
+            </if>
+            <if test="dtRtu != null">
+                dt_rtu,
+            </if>
+            <if test="lossAmount != null">
+                loss_amount,
+            </if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id,jdbcType=BIGINT},
+            </if>
+            <if test="lastHistoryId != null">
+                #{lastHistoryId,jdbcType=BIGINT},
+            </if>
+            <if test="controllerId != null">
+                #{controllerId,jdbcType=BIGINT},
+            </if>
+            <if test="intakeId != null">
+                #{intakeId,jdbcType=BIGINT},
+            </if>
+            <if test="rtuAddr != null">
+                #{rtuAddr,jdbcType=VARCHAR},
+            </if>
+            <if test="dt != null">
+                #{dt,jdbcType=DATE},
+            </if>
+            <if test="dtLast != null">
+                #{dtLast,jdbcType=TIMESTAMP},
+            </if>
+            <if test="dtRtu != null">
+                #{dtRtu,jdbcType=TIMESTAMP},
+            </if>
+            <if test="lossAmount != null">
+                #{lossAmount,jdbcType=DOUBLE},
+            </if>
+        </trim>
+    </insert>
+    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
+        <!--@mbg.generated-->
+        update rm_loss_day_last
+        <set>
+            <if test="lastHistoryId != null">
+                last_history_id = #{lastHistoryId,jdbcType=BIGINT},
+            </if>
+            <if test="controllerId != null">
+                controller_id = #{controllerId,jdbcType=BIGINT},
+            </if>
+            <if test="intakeId != null">
+                intake_id = #{intakeId,jdbcType=BIGINT},
+            </if>
+            <if test="rtuAddr != null">
+                rtu_addr = #{rtuAddr,jdbcType=VARCHAR},
+            </if>
+            <if test="dt != null">
+                dt = #{dt,jdbcType=DATE},
+            </if>
+            <if test="dtLast != null">
+                dt_last = #{dtLast,jdbcType=TIMESTAMP},
+            </if>
+            <if test="dtRtu != null">
+                dt_rtu = #{dtRtu,jdbcType=TIMESTAMP},
+            </if>
+            <if test="lossAmount != null">
+                loss_amount = #{lossAmount,jdbcType=DOUBLE},
+            </if>
+        </set>
+        where id = #{id,jdbcType=BIGINT}
+    </update>
+    <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoRm.RmLossDayLast">
+        <!--@mbg.generated-->
+        update rm_loss_day_last
+        set last_history_id = #{lastHistoryId,jdbcType=BIGINT},
+            controller_id   = #{controllerId,jdbcType=BIGINT},
+            intake_id       = #{intakeId,jdbcType=BIGINT},
+            rtu_addr        = #{rtuAddr,jdbcType=VARCHAR},
+            dt              = #{dt,jdbcType=DATE},
+            dt_last         = #{dtLast,jdbcType=TIMESTAMP},
+            dt_rtu          = #{dtRtu,jdbcType=TIMESTAMP},
+            loss_amount     = #{lossAmount,jdbcType=DOUBLE}
+        where id = #{id,jdbcType=BIGINT}
+    </update>
+    <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇璁板綍鎬绘暟-->
+    <select id="getRecordCount" resultType="java.lang.Long">
+        select count(*)
+        from rm_loss_day_last rldl
+                 Left join pr_intake pint on pint.id = rldl.intake_id
+        <where>
+            <if test="intakeId != null and intakeId != ''">
+                and rldl.intake_id = #{intakeId}
+            </if>
+            <if test="intakeName != null and intakeName != ''">
+                and pint.name like CONCAT('%', #{intakeName,jdbcType=VARCHAR}, '%')
+            </if>
+            <if test="startDt != null">
+                and rldl.dt &gt;= #{startDt,jdbcType=DATE}
+            </if>
+            <if test="endDt != null">
+                and rldl.dt &lt;= #{endDt,jdbcType=DATE}
+            </if>
+        </where>
+    </select>
+    <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇璁板綍-->
+    <select id="getLossDayLast" resultType="com.dy.pipIrrGlobal.voRm.VoLossDay">
+        select CAST(rldl.intake_id AS char)     AS intakeId,
+               CAST(rldl.controller_id AS char) AS controllerId,
+               pint.name                        as intakeName,
+               rldl.rtu_addr                    as rtuAddr,
+               rldl.dt                          as dt,
+               rldl.dt_last                     as dtLast,
+               rldl.dt_rtu                      as dtRtu,
+               rldl.loss_amount                 as lossAmount
+        from rm_loss_day_last rldl
+                 Left join pr_intake pint on pint.id = rldl.intake_id
+        <where>
+            <if test="intakeId != null and intakeId != ''">
+                and rldl.intake_id = #{intakeId}
+            </if>
+            <if test="intakeName != null and intakeName != ''">
+                and pint.name like CONCAT('%', #{intakeName,jdbcType=VARCHAR}, '%')
+            </if>
+            <if test="startDt != null">
+                and rldl.dt &gt;= #{startDt,jdbcType=DATE}
+            </if>
+            <if test="endDt != null">
+                and rldl.dt &lt;= #{endDt,jdbcType=DATE}
+            </if>
+        </where>
+        ORDER BY rldl.dt DESC, rldl.loss_amount DESC
+        <!--    <if test="pageCurr != null and pageSize != null">-->
+        <!--      LIMIT ${(pageCurr-1)*pageSize}, ${pageSize}-->
+        <!--    </if>-->
+        <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="getDayLossAmountCount" resultType="java.lang.Long">
+        SELECT COUNT(*) AS recordCount
+        FROM pr_intake inta
+        <where>
+            AND inta.deleted = 0
+            <if test="intakeNum != null and intakeNum != ''">
+                AND inta.name = #{intakeNum}
+            </if>
+        </where>
+    </select>
+
+    <!--缁熻鎸囧畾鏈堜唤鍚勫ぉ婕忔崯閲�-->
+    <select id="getDayLossAmount" resultType="com.dy.pipIrrGlobal.voSt.VoDayLoss">
+        SELECT inta.id                                 AS intakeId,
+               inta.name                               AS intakeNum,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 1), 0)  AS lossAmount1,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 2), 0)  AS lossAmount2,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 3), 0)  AS lossAmount3,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 4), 0)  AS lossAmount4,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 5), 0)  AS lossAmount5,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 6), 0)  AS lossAmount6,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 7), 0)  AS lossAmount7,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 8), 0)  AS lossAmount8,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 9), 0)  AS lossAmount9,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 10), 0) AS lossAmount10,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 11), 0) AS lossAmount11,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 12), 0) AS lossAmount12,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 13), 0) AS lossAmount13,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 14), 0) AS lossAmount14,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 15), 0) AS lossAmount15,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 16), 0) AS lossAmount16,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 17), 0) AS lossAmount17,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 18), 0) AS lossAmount18,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 19), 0) AS lossAmount19,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 20), 0) AS lossAmount20,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 21), 0) AS lossAmount21,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 22), 0) AS lossAmount22,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 23), 0) AS lossAmount23,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 24), 0) AS lossAmount24,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 25), 0) AS lossAmount25,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 26), 0) AS lossAmount26,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 27), 0) AS lossAmount27,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 28), 0) AS lossAmount28,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 29), 0) AS lossAmount29,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 30), 0) AS lossAmount30,
+               IFNULL((SELECT IFNULL(loss_amount, 0)
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = #{month}
+                         AND DAY(intaDay.dt) = 31), 0) AS lossAmount31
+        FROM pr_intake inta
+        <where>
+            AND inta.deleted = 0
+            <if test="intakeNum != null and intakeNum != ''">
+                AND inta.name = #{intakeNum}
+            </if>
+        </where>
+        ORDER BY inta.id
+        <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="getMonthLossAmountCount" resultType="java.lang.Long">
+        SELECT COUNT(*) AS recordCount
+        FROM pr_intake inta
+        <where>
+            AND inta.deleted = 0
+            <if test="intakeNum != null and intakeNum != ''">
+                AND inta.name = #{intakeNum}
+            </if>
+        </where>
+    </select>
+
+    <!--缁熻鎸囧畾骞翠唤鍚勬湀婕忔崯閲�-->
+    <select id="getMonthLossAmount" resultType="com.dy.pipIrrGlobal.voSt.VoMonthAmount">
+        SELECT inta.id                                  AS intakeId,
+               inta.name                                AS intakeNum,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 1
+                       GROUP BY(intaDay.intake_id)), 0) AS month1,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 2
+                       GROUP BY(intaDay.intake_id)), 0) AS month2,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 3
+                       GROUP BY(intaDay.intake_id)), 0) AS month3,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 4
+                       GROUP BY(intaDay.intake_id)), 0) AS month4,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 5
+                       GROUP BY(intaDay.intake_id)), 0) AS month5,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 6
+                       GROUP BY(intaDay.intake_id)), 0) AS month6,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 7
+                       GROUP BY(intaDay.intake_id)), 0) AS month7,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 8
+                       GROUP BY(intaDay.intake_id)), 0) AS month8,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 9
+                       GROUP BY(intaDay.intake_id)), 0) AS month9,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 10
+                       GROUP BY(intaDay.intake_id)), 0) AS month10,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 11
+                       GROUP BY(intaDay.intake_id)), 0) AS month11,
+               IFNULL((SELECT SUM(loss_amount) AS amount
+                       FROM rm_loss_day_last intaDay
+                       WHERE intaDay.intake_id = inta.id
+                         AND YEAR(intaDay.dt) = #{year}
+                         AND MONTH(intaDay.dt) = 12
+                       GROUP BY(intaDay.intake_id)), 0) AS month12
+        FROM pr_intake inta
+        <where>
+            AND inta.deleted = 0
+            <if test="intakeNum != null and intakeNum != ''">
+                AND inta.name = #{intakeNum}
+            </if>
+        </where>
+        ORDER BY inta.id
+        <trim prefix="limit ">
+            <if test="start != null and count != null">
+                #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
+            </if>
+        </trim>
+    </select>
 </mapper>
\ No newline at end of file

--
Gitblit v1.8.0