<?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.sinata.appointment.mapper.ApprovalInstanceMapper">
|
|
<select id="countDashboardByCreateTime" resultType="java.lang.Long">
|
SELECT COUNT(*)
|
FROM approval_instance ai
|
INNER JOIN appointment_order o ON o.id = ai.order_id AND o.del_flag = 0
|
WHERE ai.del_flag = 0
|
AND ai.status = #{status}
|
AND ai.create_time <![CDATA[>=]]> CONCAT(#{startDate}, ' 00:00:00')
|
AND ai.create_time <![CDATA[<]]> DATE_ADD(CONCAT(#{endDate}, ' 00:00:00'), INTERVAL 1 DAY)
|
<if test="deptIds != null and deptIds.size() > 0">
|
AND o.visited_dept_id IN
|
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
#{deptId}
|
</foreach>
|
</if>
|
</select>
|
|
<select id="listDashboardFinishedTrend" resultType="com.sinata.appointment.dto.DashboardDailyTotalVo">
|
SELECT DATE(ai.finished_at) AS statDate,
|
COUNT(*) AS totalCount
|
FROM approval_instance ai
|
INNER JOIN appointment_order o ON o.id = ai.order_id AND o.del_flag = 0
|
WHERE ai.del_flag = 0
|
AND ai.status = #{status}
|
AND ai.finished_at IS NOT NULL
|
AND ai.finished_at <![CDATA[>=]]> CONCAT(#{startDate}, ' 00:00:00')
|
AND ai.finished_at <![CDATA[<]]> DATE_ADD(CONCAT(#{endDate}, ' 00:00:00'), INTERVAL 1 DAY)
|
<if test="deptIds != null and deptIds.size() > 0">
|
AND o.visited_dept_id IN
|
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
#{deptId}
|
</foreach>
|
</if>
|
GROUP BY DATE(ai.finished_at)
|
ORDER BY DATE(ai.finished_at)
|
</select>
|
|
<select id="listDashboardInProgressInstances" resultType="com.sinata.appointment.entity.ApprovalInstance">
|
SELECT ai.*
|
FROM approval_instance ai
|
INNER JOIN appointment_order o ON o.id = ai.order_id AND o.del_flag = 0
|
WHERE ai.del_flag = 0
|
AND ai.status = 'IN_PROGRESS'
|
AND ai.create_time <![CDATA[<]]> DATE_ADD(CONCAT(#{endDate}, ' 00:00:00'), INTERVAL 1 DAY)
|
AND (ai.finished_at IS NULL OR ai.finished_at <![CDATA[>=]]> CONCAT(#{startDate}, ' 00:00:00'))
|
<if test="deptIds != null and deptIds.size() > 0">
|
AND o.visited_dept_id IN
|
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
|
#{deptId}
|
</foreach>
|
</if>
|
</select>
|
|
</mapper>
|