1.需求
2.语句
<!--====================工作台相关接口=====================-->
<select id="selectEquCount" resultType="int">
select count(*) from t_record
<where>
1 = 1
<if test="doctorId != null "> and doctor_id = #{doctorId}</if>
<if test="hospitalId != null "> and hospital_id = #{hospitalId}</if>
<if test="status != null and status != ''"> and status = #{status}</if>
<if test="month != null ">
and DATE_FORMAT(create_time,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')
</if>
<if test="week != null ">
and YEARWEEK(date_format(create_time,'%Y-%m-%d'),1) = YEARWEEK(now(),1)
</if>
<if test="day != null ">
and TO_DAYS(create_time) = TO_DAYS(NOW())
</if>
</where>
</select>
<select id="dayPlan" resultType="com.ruoyi.system.domain.resp.PlatformDayPlanResp">
select
a.create_time as createTime,
if(a.status = '0','预约','就诊') as status,
b.name
from t_record a LEFT JOIN t_patient b on a.patient_id = b.id
where TO_DAYS(a.create_time) = TO_DAYS(NOW())
and b.del_flag = 0
<if test="doctorId != null "> and a.doctor_id = #{doctorId}</if>
<if test="hospitalId != null "> and a.hospital_id = #{hospitalId}</if>
ORDER BY a.create_time desc
limit 5
</select>
<select id="weekMonthPersonCount" resultType="com.ruoyi.system.domain.resp.WeekMonthPersonCountResp">
select date_format(create_time, '%Y-%m-%d') createTime, count(*) count
from
<if test="weekMonth == 1 || weekMonth == null">
(select * from t_record where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(create_time)) X
</if>
<if test="weekMonth == 2">
(select * from t_record where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(create_time)) X
</if>
where X.status = '1'
<if test="doctorId != null "> and X.doctor_id = #{doctorId}</if>
<if test="hospitalId != null "> and X.hospital_id = #{hospitalId}</if>
group by date_format(X.create_time, '%Y-%m-%d');
</select>
<select id="ageCount" resultType="com.ruoyi.system.domain.TPatient">
SELECT
DISTINCT(a.phone),a.id,a.age
from t_patient a
inner JOIN t_record b on a.id = b.patient_id
where 1 = 1
and a.del_flag = 0
<if test="doctorId != null "> and b.doctor_id = #{doctorId}</if>
<if test="hospitalId != null "> and b.hospital_id = #{hospitalId}</if>
</select>
<select id="weekMonthTimeCount" resultType="com.ruoyi.system.domain.resp.WeekMonthTimeResp">
select date_format(create_time, '%H') createTime, count(*) count
from
<if test="weekMonth == 1 || weekMonth == null">
(select * from t_record where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(create_time)) X
</if>
<if test="weekMonth == 2">
(select * from t_record where DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(create_time)) X
</if>
where X.status = '1'
<if test="doctorId != null "> and X.doctor_id = #{doctorId}</if>
<if test="hospitalId != null "> and X.hospital_id = #{hospitalId}</if>
group by date_format(X.create_time, '%H');
</select>
<!--====================工作台相关接口=====================-->