<?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.casking.ccss.modules.cs.dao.CustomerAllVisitedDao">
<!-- 查询全部回访客户信息 -->
<select id="findList" parameterType="com.casking.ccss.modules.cs.entity.CustomerInfo"
resultType="com.casking.ccss.modules.cs.entity.CustomerInfo">
select
n.c_p_i_id as "num",
n.c_p_i_name as "name",
n.c_p_i_sex as "sex",
n.c_p_i_age as "age",
n.c_p_i_tel as "phone",
n.c_p_i_diagnose_type as "diagnoseType",
n.c_p_i_office as "office",
n.c_p_i_doctor as "doctor",
n.c_p_i_diagnose_date as "diagnoseDate",
n.c_p_i_code as "code",
t.visit_state as "visitState",
t.c_n_status as "status",
t.note_state as "noteStatus",
t.question_state as "questStatus",
m.c_n_s_id as "noteSetId",
m.c_n_s_taskType as "taskType",
m.c_n_s_name as "taskName",
m.c_n_s_state as "questionState"
from c_note_info t,c_note_set m,c_patient_info n
where t.c_n_s_id = m.c_n_s_id
and t.is_sample = '1'
and m.c_n_s_state = '1'
and t.c_i_p_id = n.c_p_i_id
and to_char(n.c_p_i_diagnose_date,'yyyy-MM-dd') = to_char(#{beginDate},'yyyy-MM-dd')
and (t.visit_state is null
or t.visit_state = '1'
or t.visit_state = '2'
or t.visit_state = '0')
<if test="office != null and office !='all' and office != ''">
and n.c_p_i_office=#{office}
</if>
<if test="doctor != null and doctor !='all' and doctor != ''">
and n.c_p_i_doctor=#{doctor}
</if>
<if test="status != null and status !='all' and status != ''">
and t.c_n_status=#{status}
</if>
<if test="noteStatus != null and noteStatus !='all' and noteStatus != ''">
and t.note_state=#{noteStatus}
</if>
<if test="taskType != null and taskType !='all' and taskType != ''">
and m.c_n_s_taskType=#{taskType}
</if>
<if test="taskName != null and taskName !='all' and taskName != ''">
and m.c_n_s_name=#{taskName}
</if>
group by
n.c_p_i_id,
n.c_p_i_name,
n.c_p_i_sex,
n.c_p_i_age,
n.c_p_i_tel,
n.c_p_i_diagnose_type,
n.c_p_i_office,
n.c_p_i_doctor,
n.c_p_i_diagnose_date,
n.c_p_i_code,
t.visit_state,
t.c_n_status,
t.note_state,
t.question_state,
m.c_n_s_id,
m.c_n_s_taskType,
m.c_n_s_name,
m.c_n_s_state
order by n.c_p_i_diagnose_date desc
</select>
<!-- 二级联动查询任务类型 -->
<select id="findTask" parameterType="com.casking.ccss.modules.cs.entity.CustomerInfo"
resultType="com.casking.ccss.modules.cs.entity.CustomerInfo">
select s.c_n_s_taskType as "taskType",
s.c_n_s_name as "taskName"
from c_note_set s
where s.c_n_s_taskType = #{taskType}
</select>
</mapper>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.casking.ccss.modules.cs.dao.CustomerAllVisitedDao">
<!-- 查询全部回访客户信息 -->
<select id="findList" parameterType="com.casking.ccss.modules.cs.entity.CustomerInfo"
resultType="com.casking.ccss.modules.cs.entity.CustomerInfo">
select
n.c_p_i_id as "num",
n.c_p_i_name as "name",
n.c_p_i_sex as "sex",
n.c_p_i_age as "age",
n.c_p_i_tel as "phone",
n.c_p_i_diagnose_type as "diagnoseType",
n.c_p_i_office as "office",
n.c_p_i_doctor as "doctor",
n.c_p_i_diagnose_date as "diagnoseDate",
n.c_p_i_code as "code",
t.visit_state as "visitState",
t.c_n_status as "status",
t.note_state as "noteStatus",
t.question_state as "questStatus",
m.c_n_s_id as "noteSetId",
m.c_n_s_taskType as "taskType",
m.c_n_s_name as "taskName",
m.c_n_s_state as "questionState"
from c_note_info t,c_note_set m,c_patient_info n
where t.c_n_s_id = m.c_n_s_id
and t.is_sample = '1'
and m.c_n_s_state = '1'
and t.c_i_p_id = n.c_p_i_id
and to_char(n.c_p_i_diagnose_date,'yyyy-MM-dd') = to_char(#{beginDate},'yyyy-MM-dd')
and (t.visit_state is null
or t.visit_state = '1'
or t.visit_state = '2'
or t.visit_state = '0')
<if test="office != null and office !='all' and office != ''">
and n.c_p_i_office=#{office}
</if>
<if test="doctor != null and doctor !='all' and doctor != ''">
and n.c_p_i_doctor=#{doctor}
</if>
<if test="status != null and status !='all' and status != ''">
and t.c_n_status=#{status}
</if>
<if test="noteStatus != null and noteStatus !='all' and noteStatus != ''">
and t.note_state=#{noteStatus}
</if>
<if test="taskType != null and taskType !='all' and taskType != ''">
and m.c_n_s_taskType=#{taskType}
</if>
<if test="taskName != null and taskName !='all' and taskName != ''">
and m.c_n_s_name=#{taskName}
</if>
group by
n.c_p_i_id,
n.c_p_i_name,
n.c_p_i_sex,
n.c_p_i_age,
n.c_p_i_tel,
n.c_p_i_diagnose_type,
n.c_p_i_office,
n.c_p_i_doctor,
n.c_p_i_diagnose_date,
n.c_p_i_code,
t.visit_state,
t.c_n_status,
t.note_state,
t.question_state,
m.c_n_s_id,
m.c_n_s_taskType,
m.c_n_s_name,
m.c_n_s_state
order by n.c_p_i_diagnose_date desc
</select>
<!-- 二级联动查询任务类型 -->
<select id="findTask" parameterType="com.casking.ccss.modules.cs.entity.CustomerInfo"
resultType="com.casking.ccss.modules.cs.entity.CustomerInfo">
select s.c_n_s_taskType as "taskType",
s.c_n_s_name as "taskName"
from c_note_set s
where s.c_n_s_taskType = #{taskType}
</select>
</mapper>