<?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="org.dromara.qa.md.mapper.WeighingBoxMapper">
|
|
<resultMap type="org.dromara.qa.md.domain.WeighingBox" id="WeighingBoxResult">
|
<id property="id" column="id"/>
|
<result property="name" column="name"/>
|
<result property="code" column="code"/>
|
<result property="weight" column="weight"/>
|
<result property="unit" column="unit"/>
|
<result property="location" column="location"/>
|
<result property="calibCycleDays" column="calib_cycle_days"/>
|
<result property="remindDays" column="remind_days"/>
|
<result property="lastCalibDate" column="last_calib_date"/>
|
<result property="nextCalibDate" column="next_calib_date"/>
|
<result property="activeStatus" column="active_status"/>
|
<result property="description" column="description"/>
|
<result property="delFlag" column="del_flag"/>
|
<result property="createBy" column="create_by"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateBy" column="update_by"/>
|
<result property="updateTime" column="update_time"/>
|
</resultMap>
|
|
<sql id="selectWeighingBoxVo">
|
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
|
</sql>
|
|
<select id="selectPageList" resultType="org.dromara.qa.md.domain.WeighingBox">
|
<include refid="selectWeighingBoxVo"/>
|
<where>
|
del_flag = '0'
|
<if test="weighingBox.name != null and weighingBox.name != ''">
|
and name like concat('%', #{weighingBox.name}, '%')
|
</if>
|
<if test="weighingBox.code != null and weighingBox.code != ''">
|
and code like concat('%', #{weighingBox.code}, '%')
|
</if>
|
<if test="weighingBox.activeStatus != null">
|
and active_status = #{weighingBox.activeStatus}
|
</if>
|
</where>
|
order by create_time desc
|
</select>
|
|
<select id="selectWeighingBoxList" parameterType="org.dromara.qa.md.domain.WeighingBox" resultMap="WeighingBoxResult">
|
<include refid="selectWeighingBoxVo"/>
|
<where>
|
<if test="delFlag != null">
|
and del_flag = #{delFlag}
|
</if>
|
<if test="name != null and name != ''">
|
and name like concat('%', #{name}, '%')
|
</if>
|
<if test="code != null and code != ''">
|
and code like concat('%', #{code}, '%')
|
</if>
|
<if test="location != null and location != ''">
|
and location like concat('%', #{location}, '%')
|
</if>
|
<if test="activeStatus != null">
|
and active_status = #{activeStatus}
|
</if>
|
</where>
|
order by create_time desc
|
</select>
|
|
<select id="selectActiveWeighingBoxes" resultMap="WeighingBoxResult">
|
<include refid="selectWeighingBoxVo"/>
|
where del_flag = 0 and active_status = 1
|
</select>
|
|
<update id="batchUpdateStatus">
|
update qm_weighing_box set active_status = #{activeStatus} where id in
|
<foreach collection="boxIds" item="id" open="(" separator="," close=")">
|
${id}
|
</foreach>
|
</update>
|
|
<update id="batchUpdateCalibConfig">
|
update qm_weighing_box set calib_cycle_days = #{calibCycleDays}, remind_days = #{remindDays} where id in
|
<foreach collection="boxIds" item="id" open="(" separator="," close=")">
|
${id}
|
</foreach>
|
</update>
|
|
<!-- 带校准状态过滤的查询 -->
|
<select id="selectWeighingBoxListWithCalibStatus" parameterType="org.dromara.qa.md.domain.WeighingBox" resultMap="WeighingBoxResult">
|
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
|
<if test="name != null and name != ''">
|
and box.name like concat('%', #{name}, '%')
|
</if>
|
<if test="code != null and code != ''">
|
and box.code like concat('%', #{code}, '%')
|
</if>
|
<if test="location != null and location != ''">
|
and box.location like concat('%', #{location}, '%')
|
</if>
|
<if test="activeStatus != null">
|
and box.active_status = #{activeStatus}
|
</if>
|
<if test="calibStatus != null and calibStatus != ''">
|
and box.calib_status = #{calibStatus}
|
</if>
|
order by box.create_time desc
|
</select>
|
|
<!-- 带校准状态过滤的计数 -->
|
<select id="selectWeighingBoxCountWithCalibStatus" parameterType="org.dromara.qa.md.domain.WeighingBox" resultType="java.lang.Long">
|
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
|
<if test="name != null and name != ''">
|
and box.name like concat('%', #{name}, '%')
|
</if>
|
<if test="code != null and code != ''">
|
and box.code like concat('%', #{code}, '%')
|
</if>
|
<if test="location != null and location != ''">
|
and box.location like concat('%', #{location}, '%')
|
</if>
|
<if test="activeStatus != null">
|
and box.active_status = #{activeStatus}
|
</if>
|
<if test="calibStatus != null and calibStatus != ''">
|
and box.calib_status = #{calibStatus}
|
</if>
|
</select>
|
|
</mapper>
|