LymsXljcRecordTraceMapper.xml 4 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
<?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.lyms.talkonlineweb.mapper.LymsXljcRecordTraceMapper">

<resultMap id="BaseResultMap" type="com.lyms.talkonlineweb.domain.LymsXljcRecordTrace">
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="rid" column="rid" jdbcType="INTEGER"/>
<result property="nextExamineDate" column="next_examine_date" jdbcType="TIMESTAMP"/>
<result property="nextExamineStatus" column="next_examine_status" jdbcType="INTEGER"/>
<result property="traceTime" column="trace_time" jdbcType="TIMESTAMP"/>
<result property="tracePerson" column="trace_person" jdbcType="VARCHAR"/>
<result property="traceWay" column="trace_way" jdbcType="INTEGER"/>
<result property="result" column="result" jdbcType="VARCHAR"/>
<result property="createdby" column="createdby" jdbcType="INTEGER"/>
<result property="createdtime" column="createdtime" jdbcType="TIMESTAMP"/>
<result property="updatedby" column="updatedby" jdbcType="INTEGER"/>
<result property="updatedtime" column="updatedtime" jdbcType="TIMESTAMP"/>
</resultMap>


<select id="queryXljcTraceRecords" parameterType="com.lyms.talkonlineweb.request.XljcTraceRequest"
resultType="com.lyms.talkonlineweb.result.XljcTraceRecord">
select * from (
select
r.id as rid,
r.arch_id as archId,
trace.id as traceId,
a.pname,
a.idno,
a.tel,
a.age,
a.sex,
a.birth,
trace.next_examine_date as nextExamineDate,
trace.next_examine_status as nextExamineStatus,
trace.trace_way as traceWay,
trace.trace_person as tracePerson,
trace.trace_time as traceDate,
DATEDIFF((case when next_examine_status = 0 then now() else trace_time end),
next_examine_date) as overDays,
trace.result
from
lyms_xljc_archive a,
lyms_xljc_record r,
lyms_xljc_record_trace trace
where
a.id = r.arch_id
and r.id = trace.rid
and trace.yn = 1
and trace.next_examine_date &lt;= DATE_SUB(CURDATE() ,INTERVAL 7 DAY)
<if test="trace.examineHid != null">
and r.examine_hid = #{trace.examineHid}
</if>
<if test="trace.overDays != null">
and trace.next_examine_date = DATE_SUB(CURDATE() ,INTERVAL #{trace.overDays} DAY)
</if>
<if test="trace.traceTimeStart != null and trace.traceTimeStart != '' ">
and trace.trace_time > STR_TO_DATE(#{trace.traceTimeStart},'%Y-%m-%d')
</if>
<if test="trace.traceTimeEnd != null and trace.traceTimeEnd !='' ">
and trace.trace_time &lt; STR_TO_DATE(#{trace.traceTimeEnd},'%Y-%m-%d %H:%i:%s')
</if>

<if test="trace.nextExamineStatus != null">
and trace.next_examine_status = #{trace.nextExamineStatus}
</if>
<if test="trace.key != null and trace.key != '' ">
and (a.pname = #{trace.key } or a.idno = #{trace.key } or a.tel = #{trace.key })
</if>
) a
where 1=1
<if test="trace.overDaysMin != null">
and a.overDays >= #{trace.overDaysMin}
</if>
<if test="trace.overDaysMax != null">
and a.overDays &lt;= #{trace.overDaysMax}
</if>

order by a.nextExamineDate

</select>


</mapper>