huliguo
2025-05-09 bf2f1ffb99634b8350539b28bd9d1f20b30a5aa1
src/main/resources/mapper/DataMapper.xml
@@ -9,7 +9,10 @@
                *,
                ROW_NUMBER() OVER (PARTITION BY county ORDER BY create_time DESC) AS rn
            FROM t_data
            WHERE county=#{county} or #{county}=0 AND del_flag = 0
            WHERE del_flag = 0
                      <if test="county!=null and county !=0">
                          and  county=#{county}
                      </if>
        )
        SELECT
            create_time,
@@ -116,6 +119,7 @@
        <if test="name!=null and ''!=name">
            and creator.name like concat('%',#{name},'%')
        </if>
        order by d.create_time desc
    </select>
    <select id="beforeOne" resultType="com.cl.pojo.entity.DataEntity">
@@ -137,7 +141,12 @@
                *,
                ROW_NUMBER() OVER (PARTITION BY county ORDER BY create_time DESC) AS rn
            FROM t_data
            WHERE county=#{county} or #{county}=0 AND del_flag = 0
            WHERE
        del_flag = 0
                <if test="county!=null and county!=0">
                 and   county=#{county}
                </if>
        )
        SELECT
            create_time,
@@ -218,4 +227,35 @@
        FROM latest_records
        WHERE rn = 1;
    </select>
    <select id="getYearList" resultType="java.lang.Integer">
        SELECT
            DISTINCT YEAR(create_time) AS year
        FROM
            t_data
        where
            del_flag=0
        <if test="county!=null and county!=0">
            and   county=#{county}
        </if>
        ORDER BY
            year ASC;
    </select>
    <select id="getAssistiveDeviceTotal" resultType="java.lang.Integer">
        WITH latest_records AS (
        SELECT
        assistive_device_total,
        ROW_NUMBER() OVER (PARTITION BY county ORDER BY create_time DESC) AS rn
        FROM t_data
        WHERE
        del_flag = 0
        AND create_time  &lt; #{createTime}
        <if test="county != null and county != 0">
            AND county = #{county}
        </if>
        )
        SELECT
        COALESCE(SUM(assistive_device_total), 0) AS total_sum
        FROM latest_records
        WHERE rn = 1
    </select>
</mapper>