| | |
| | | ORDER BY groupCode |
| | | </select> |
| | | |
| | | <!-- 宣教统计:按病区或科室分组,统计发送总量、发送成功量(sendstate=6)、已读量(finishtime不为空) --> |
| | | <select id="getHeLibraryCount" parameterType="com.smartor.domain.VO.HeLibraryCountVO" resultType="map"> |
| | | SELECT |
| | | <choose> |
| | | <when test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0"> |
| | | leavehospitaldistrictcode AS groupCode, |
| | | leavehospitaldistrictname AS groupName, |
| | | </when> |
| | | <otherwise> |
| | | deptcode AS groupCode, |
| | | deptname AS groupName, |
| | | </otherwise> |
| | | </choose> |
| | | COUNT(*) AS totalCount, |
| | | SUM(CASE WHEN sendstate = 6 THEN 1 ELSE 0 END) AS sendSuccessCount, |
| | | SUM(CASE WHEN finishtime IS NOT NULL THEN 1 ELSE 0 END) AS readCount |
| | | FROM service_subtask |
| | | WHERE del_flag = 0 |
| | | AND service_type = 4 |
| | | <if test="starttime != null">AND starttime >= #{starttime}</if> |
| | | <if test="endtime != null">AND endtime <= #{endtime}</if> |
| | | <if test="visittime != null">AND DATE(visit_time) = DATE(#{visittime})</if> |
| | | <if test="finishtime != null">AND DATE(finishtime) = DATE(#{finishtime})</if> |
| | | <if test="hospType != null and hospType != ''">AND hosp_type = #{hospType}</if> |
| | | <choose> |
| | | <when test="hospitaldistrictcodes != null and hospitaldistrictcodes.size() > 0"> |
| | | AND leavehospitaldistrictcode IN |
| | | <foreach collection="hospitaldistrictcodes" item="code" open="(" separator="," close=")"> |
| | | #{code} |
| | | </foreach> |
| | | GROUP BY leavehospitaldistrictcode, leavehospitaldistrictname |
| | | ORDER BY groupCode |
| | | </when> |
| | | <otherwise> |
| | | <if test="deptcodes != null and deptcodes.size() > 0"> |
| | | AND deptcode IN |
| | | <foreach collection="deptcodes" item="code" open="(" separator="," close=")"> |
| | | #{code} |
| | | </foreach> |
| | | </if> |
| | | GROUP BY deptcode, deptname |
| | | ORDER BY groupCode |
| | | </otherwise> |
| | | </choose> |
| | | </select> |
| | | |
| | | </mapper> |