From bf2f1ffb99634b8350539b28bd9d1f20b30a5aa1 Mon Sep 17 00:00:00 2001 From: huliguo <2023611923@qq.com> Date: 星期五, 09 五月 2025 17:29:13 +0800 Subject: [PATCH] 小bug修改 --- src/main/resources/mapper/DataMapper.xml | 44 ++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/main/resources/mapper/DataMapper.xml b/src/main/resources/mapper/DataMapper.xml index 1d78b2c..41011ac 100644 --- a/src/main/resources/mapper/DataMapper.xml +++ b/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 < #{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> \ No newline at end of file -- Gitblit v1.7.1