<?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.tievd.jyz.mapper.OiloutRecordMapper">
|
|
<select id="pageList" resultType="com.tievd.jyz.entity.vo.OiloutRecordVo">
|
SELECT r.*, IF(oe.count=oe.total,1,2) eventType, CONCAT(oe.count,'/', oe.total) complete
|
FROM `t_oilout_record` r
|
LEFT JOIN (
|
select record_id, count(IF(event_type=1, 1,null)) count, count(id) total
|
from t_oilout_event GROUP BY record_id
|
) oe
|
on r.id=oe.record_id
|
<where>
|
<if test="recordVo.id != null">and r.id=#{recordVo.id}</if>
|
<if test="recordVo.orgCode != null and recordVo.orgCode != ''">and r.org_code like concat(#{recordVo.orgCode}, '%')</if>
|
<if test="recordVo.licenseNum != null and recordVo.licenseNum != ''">and r.license_num=#{recordVo.licenseNum}</if>
|
<if test="recordVo.eventType != null and recordVo.eventType==1">and oe.count = oe.total </if>
|
<if test="recordVo.eventType != null and recordVo.eventType==2">and oe.count != oe.total </if>
|
<if test="recordVo.startTime != null and recordVo.startTime != ''">and r.start_time >= #{recordVo.startTime}</if>
|
<if test="recordVo.endTime != null and recordVo.endTime != ''">and r.end_time <= #{recordVo.endTime}</if>
|
</where>
|
GROUP BY r.id
|
order by r.start_time desc
|
</select>
|
</mapper>
|