select id, name, code, weight, unit, location, calib_cycle_days, remind_days, last_calib_date, next_calib_date, active_status, description, del_flag, create_by, create_time, update_by, update_time from qm_weighing_box
del_flag = '0'
and name like concat('%', #{weighingBox.name}, '%')
and code like concat('%', #{weighingBox.code}, '%')
and active_status = #{weighingBox.activeStatus}
order by create_time desc
and del_flag = #{delFlag}
and name like concat('%', #{name}, '%')
and code like concat('%', #{code}, '%')
and location like concat('%', #{location}, '%')
and active_status = #{activeStatus}
order by create_time desc
where del_flag = 0 and active_status = 1
update qm_weighing_box set active_status = #{activeStatus} where id in
${id}
update qm_weighing_box set calib_cycle_days = #{calibCycleDays}, remind_days = #{remindDays} where id in
${id}
select * from (
select
id, name, code, weight, unit, location, calib_cycle_days, remind_days,
last_calib_date, next_calib_date, active_status, description,
del_flag, create_by, create_time, update_by, update_time,
case
when next_calib_date is null then 'unset'
when current_date > next_calib_date then 'overdue'
when current_date + interval '1 day' * remind_days >= next_calib_date then 'warning'
else 'normal'
end as calib_status
from qm_weighing_box
where del_flag = 0
) as box
where 1=1
and box.name like concat('%', #{name}, '%')
and box.code like concat('%', #{code}, '%')
and box.location like concat('%', #{location}, '%')
and box.active_status = #{activeStatus}
and box.calib_status = #{calibStatus}
order by box.create_time desc
select count(*) from (
select
id, name, code, weight, unit, location, calib_cycle_days, remind_days,
last_calib_date, next_calib_date, active_status, description,
del_flag, create_by, create_time, update_by, update_time,
case
when next_calib_date is null then 'unset'
when current_date > next_calib_date then 'overdue'
when current_date + interval '1 day' * remind_days >= next_calib_date then 'warning'
else 'normal'
end as calib_status
from qm_weighing_box
where del_flag = 0
) as box
where 1=1
and box.name like concat('%', #{name}, '%')
and box.code like concat('%', #{code}, '%')
and box.location like concat('%', #{location}, '%')
and box.active_status = #{activeStatus}
and box.calib_status = #{calibStatus}