| | |
| | | |
| | | <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, |
| | | t.id, |
| | | t.user_id, |
| | | <!-- user_name 存的是登录账号,这里改取用户昵称;取不到时回退为原值 --> |
| | | IFNULL(su.nick_name, t.user_name) AS user_name, |
| | | t.code, |
| | | t.name, |
| | | t.model, |
| | | t.most_date, |
| | | t.valid, |
| | | t.next_date, |
| | | t.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 |
| | | WHEN t.most_date IS NOT NULL |
| | | AND t.valid IS NOT NULL |
| | | AND DATE_ADD(t.most_date, INTERVAL t.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 |
| | | t.create_user, |
| | | t.create_time, |
| | | t.update_user, |
| | | t.update_time, |
| | | t.tenant_id, |
| | | t.unit, |
| | | t.dept_id, |
| | | t.instation_location, |
| | | t.cycle |
| | | FROM |
| | | measuring_instrument_ledger |
| | | measuring_instrument_ledger t |
| | | LEFT JOIN sys_user su ON t.user_id = su.user_id |
| | | <where> |
| | | <!-- 查询条件同上 --> |
| | | <if test="req.code != null and req.code != ''"> |
| | | AND code LIKE CONCAT('%', #{req.code}, '%') |
| | | AND t.code LIKE CONCAT('%', #{req.code}, '%') |
| | | </if> |
| | | <if test="req.name != null and req.name != ''"> |
| | | AND name LIKE CONCAT('%', #{req.name}, '%') |
| | | AND t.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() |
| | | AND t.most_date IS NOT NULL |
| | | AND t.valid IS NOT NULL |
| | | AND DATE_ADD(t.most_date, INTERVAL t.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() |
| | | t.most_date IS NULL |
| | | OR t.valid IS NULL |
| | | OR DATE_ADD(t.most_date, INTERVAL t.valid DAY) < CURDATE() |
| | | ) |
| | | </when> |
| | | </choose> |
| | | </if> |
| | | <if test="req.tenantId != null"> |
| | | AND tenant_id = #{req.tenantId} |
| | | AND t.tenant_id = #{req.tenantId} |
| | | </if> |
| | | <if test="req.recordDate != null"> |
| | | AND record_date = DATE_FORMAT(#{req.recordDate},'%Y-%m-%d') |
| | | AND t.record_date = DATE_FORMAT(#{req.recordDate},'%Y-%m-%d') |
| | | </if> |
| | | </where> |
| | | ORDER BY create_time DESC |
| | | ORDER BY t.create_time DESC |
| | | </select> |
| | | </mapper> |