| | |
| | | service_task t |
| | | INNER JOIN service_subtask s ON s.taskid = t.taskid |
| | | INNER JOIN service_subtask_detail d ON d.sub_id = s.id |
| | | <!-- 去重:同一子任务同一题目只保留最新一条,避免重答/重复回调把同一道题重复计入项数(与 mzMydScoreRank 口径一致) --> |
| | | AND d.id = ( |
| | | SELECT MAX(d2.id) |
| | | FROM service_subtask_detail d2 |
| | | WHERE d2.sub_id = d.sub_id |
| | | AND d2.questiontext <=> d.questiontext |
| | | AND d2.del_flag = '0' |
| | | ) |
| | | INNER JOIN ( |
| | | SELECT |
| | | d.questiontext, |
| | |
| | | service_task t |
| | | INNER JOIN service_subtask s ON s.taskid = t.taskid |
| | | INNER JOIN service_subtask_detail d ON d.sub_id = s.id |
| | | <!-- 去重:分母(该题有效答卷总数)与明细口径保持一致,保证各选项比例合计 100% --> |
| | | AND d.id = ( |
| | | SELECT MAX(d4.id) |
| | | FROM service_subtask_detail d4 |
| | | WHERE d4.sub_id = d.sub_id |
| | | AND d4.questiontext <=> d.questiontext |
| | | AND d4.del_flag = '0' |
| | | ) |
| | | WHERE 1=1 |
| | | <if test="subtaskIds != null and subtaskIds.size() > 0"> |
| | | AND s.id IN |
| | |
| | | </foreach> |
| | | </if> |
| | | <if test="valueType != null">AND d.value_type >= #{valueType}</if> |
| | | <if test="scoreStart != null">AND d.score = #{scoreStart}</if> |
| | | <if test="scoreStart != null">AND d.score >= #{scoreStart}</if> |
| | | <if test="scoreEnd != null">AND d.score <= #{scoreEnd}</if> |
| | | <if test="questiontext != null and questiontext != ''">and d.questiontext like concat('%', #{questiontext}, |
| | | '%') |
| | | </if> |
| | | AND s.sendstate = 6 |
| | | AND d.del_flag=0 |
| | | <!-- 分母与明细用同一套时间条件,否则选了日期区间后各选项比例合计不到 100% --> |
| | | <if test="startOutHospTime != null"> |
| | | AND date_format(s.endtime,'%y%m%d') >= date_format(#{startOutHospTime},'%y%m%d') |
| | | </if> |
| | | <if test="endOutHospTime != null"> |
| | | AND date_format(s.endtime,'%y%m%d') <= date_format(#{endOutHospTime},'%y%m%d') |
| | | </if> |
| | | <if test="startFinishTime != null"> |
| | | AND date_format(s.finishtime,'%y%m%d') >= date_format(#{startFinishTime},'%y%m%d') |
| | | </if> |
| | | <if test="endFinishTime != null"> |
| | | AND date_format(s.finishtime,'%y%m%d') <= date_format(#{endFinishTime},'%y%m%d') |
| | | </if> |
| | | GROUP BY d.questiontext |
| | | ) t2 ON t2.questiontext = d.questiontext |
| | | WHERE 1=1 |
| | | <!-- 去重:明细行同一子任务同一题目只保留最新一条,重答不重复计入项数 --> |
| | | AND d.id = ( |
| | | SELECT MAX(d3.id) |
| | | FROM service_subtask_detail d3 |
| | | WHERE d3.sub_id = d.sub_id |
| | | AND d3.questiontext <=> d.questiontext |
| | | AND d3.del_flag = '0' |
| | | ) |
| | | <if test="subtaskIds != null and subtaskIds.size() > 0"> |
| | | AND s.id IN |
| | | <foreach collection="subtaskIds" item="subtaskId" open="(" separator="," close=")"> |