<?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.ruoyi.measuringinstrumentledger.mapper.MeasuringInstrumentLedgerMapper">
|
|
<select id="listPage" resultType="com.ruoyi.measuringinstrumentledger.pojo.MeasuringInstrumentLedger">
|
SELECT
|
id,
|
user_id,
|
user_name,
|
code,
|
name,
|
model,
|
most_date,
|
valid,
|
next_date,
|
record_date,
|
CASE
|
WHEN most_date IS NOT NULL
|
AND valid IS NOT NULL
|
AND DATE_ADD(most_date, INTERVAL valid DAY) >= CURDATE() THEN 1
|
ELSE 2
|
END AS status,
|
create_user,
|
create_time,
|
update_user,
|
update_time,
|
tenant_id,
|
unit,
|
dept_id,
|
instation_location,
|
cycle
|
FROM
|
measuring_instrument_ledger
|
<where>
|
<!-- 查询条件同上 -->
|
<if test="req.code != null and req.code != ''">
|
AND code LIKE CONCAT('%', #{req.code}, '%')
|
</if>
|
<if test="req.name != null and req.name != ''">
|
AND name LIKE CONCAT('%', #{req.name}, '%')
|
</if>
|
<if test="req.status != null">
|
<choose>
|
<when test="req.status == 1">
|
AND most_date IS NOT NULL
|
AND valid IS NOT NULL
|
AND DATE_ADD(most_date, INTERVAL valid DAY) >= CURDATE()
|
</when>
|
<when test="req.status == 2">
|
AND (
|
most_date IS NULL
|
OR valid IS NULL
|
OR DATE_ADD(most_date, INTERVAL valid DAY) < CURDATE()
|
)
|
</when>
|
</choose>
|
</if>
|
<if test="req.tenantId != null">
|
AND tenant_id = #{req.tenantId}
|
</if>
|
<if test="req.recordDate != null">
|
AND record_date = DATE_FORMAT(#{req.recordDate},'%Y-%m-%d')
|
</if>
|
</where>
|
ORDER BY create_time DESC
|
</select>
|
|
<select id="selectExistingCodes" resultType="java.lang.String">
|
SELECT code
|
FROM measuring_instrument_ledger
|
WHERE tenant_id = #{tenantId}
|
AND code IN
|
<foreach collection="codes" item="code" open="(" separator="," close=")">
|
#{code}
|
</foreach>
|
</select>
|
</mapper>
|