123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483 |
- <?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.zhyc.xps.hos.mapper.SatisfyStatisMapper">
- <resultMap id="GroupResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupVo">
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
- <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
- <result column="score" property="score" jdbcType="FLOAT" />
- </resultMap>
- <select id="groupByList" resultMap="GroupResultMap">
- SELECT
- A.target_group_id AS group_id,
- D.group_name,
- COUNT(A.record_id) AS record_qty,
- COUNT(distinct(A.target_id)) AS target_qty,
- ROUND(AVG(A.score)*20, 1) AS score
- FROM checklist_record AS A
- LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- LEFT JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
- LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
- <where>
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId}
- </if>
- <if test="targetType != null">
- AND B.target_type = #{targetType}
- </if>
- <if test="checklistCatId != null">
- AND B.checklist_cat_id = #{checklistCatId}
- </if>
- <if test="year != null">
- AND YEAR(A.record_time) = #{year}
- </if>
- <if test="month != null">
- AND MONTH(A.record_time) = #{month}
- </if>
- <if test="recordTime != null">
- AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND C.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND C.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- </where>
- GROUP BY A.target_group_id
- </select>
- <resultMap id="GroupYearResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupYearVo">
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="year" property="year" jdbcType="INTEGER" />
- <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
- <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
- <result column="score" property="score" jdbcType="FLOAT" />
- </resultMap>
- <select id="groupYearByList" resultMap="GroupYearResultMap">
- SELECT
- A.target_group_id AS group_id,
- D.group_name,
- YEAR(A.record_time) AS year,
- COUNT(A.record_id) AS record_qty,
- COUNT(distinct(A.target_id)) AS target_qty,
- ROUND(AVG(A.score)*20, 1) AS score
- FROM checklist_record AS A
- LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- LEFT JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
- LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
- <where>
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId}
- </if>
- <if test="targetType != null">
- AND B.target_type = #{targetType}
- </if>
- <if test="checklistCatId != null">
- AND B.checklist_cat_id = #{checklistCatId}
- </if>
- <if test="year != null">
- AND YEAR(A.record_time) = #{year}
- </if>
- <if test="month != null">
- AND MONTH(A.record_time) = #{month}
- </if>
- <if test="recordTime != null">
- AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND D.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND D.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- </where>
- GROUP BY YEAR(A.record_time), A.target_group_id
- ORDER BY group_id, year
- </select>
- <select id="groupMonthScoreCounterById" resultType="com.zhyc.xps.hos.vo.SatisfyGroupMonthScoreCounterVo">
- SELECT
- A.target_group_id AS group_id,
- D.group_name,
- YEAR(A.record_time) AS year,
- CASE MONTH(A.record_time) when 1 then ROUND(AVG(A.score)*20, 1) else 0 end AS m1,
- CASE MONTH(A.record_time) when 2 then ROUND(AVG(A.score)*20, 1) else 0 end AS m2,
- CASE MONTH(A.record_time) when 3 then ROUND(AVG(A.score)*20, 1) else 0 end AS m3,
- CASE MONTH(A.record_time) when 4 then ROUND(AVG(A.score)*20, 1) else 0 end AS m4,
- CASE MONTH(A.record_time) when 5 then ROUND(AVG(A.score)*20, 1) else 0 end AS m5,
- CASE MONTH(A.record_time) when 6 then ROUND(AVG(A.score)*20, 1) else 0 end AS m6,
- CASE MONTH(A.record_time) when 7 then ROUND(AVG(A.score)*20, 1) else 0 end AS m7,
- CASE MONTH(A.record_time) when 8 then ROUND(AVG(A.score)*20, 1) else 0 end AS m8,
- CASE MONTH(A.record_time) when 9 then ROUND(AVG(A.score)*20, 1) else 0 end AS m9,
- CASE MONTH(A.record_time) when 10 then ROUND(AVG(A.score)*20, 1) else 0 end AS m10,
- CASE MONTH(A.record_time) when 11 then ROUND(AVG(A.score)*20, 1) else 0 end AS m11,
- CASE MONTH(A.record_time) when 12 then ROUND(AVG(A.score)*20, 1) else 0 end AS m12
- FROM checklist_record AS A
- LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- LEFT JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
- LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
- <where>
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId}
- </if>
- <if test="targetType != null">
- AND B.target_type = #{targetType}
- </if>
- <if test="checklistCatId != null">
- AND B.checklist_cat_id = #{checklistCatId}
- </if>
- <if test="year != null">
- AND YEAR(A.record_time) = #{year}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND C.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND C.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- </where>
- </select>
- <resultMap id="GroupMonthResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupMonthVo">
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="year" property="year" jdbcType="BIGINT" />
- <result column="month" property="month" jdbcType="BIGINT" />
- <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
- <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
- <result column="score" property="score" jdbcType="FLOAT" />
- </resultMap>
- <select id="groupMonthByList" parameterType="java.util.Map" resultMap="GroupMonthResultMap" >
- SELECT
- D.group_id,
- D.group_name,
- YEAR(A.record_time) AS year,
- Month(A.record_time) AS month,
- COUNT(A.record_id) AS record_qty,
- COUNT(distinct(A.target_id)) AS target_qty,
- ROUND(AVG(A.score)*20, 1) AS score
- FROM checklist_record AS A
- JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
- JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
- <where>
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="checklistCatId != null">
- AND B.checklist_cat_id=#{checklistCatId}
- </if>
- <if test="recordTime != null">
- AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
- </if>
- <if test="year != null">
- AND YEAR(A.record_time) = #{year}
- </if>
- <if test="month != null">
- AND MONTH(A.record_time) = #{month}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND D.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND D.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- </where>
- GROUP BY D.group_id, YEAR(A.record_time), Month(A.record_time)
- </select>
- <resultMap id="GroupChecklistMonthResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupChecklistMonthVo">
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="year" property="year" jdbcType="BIGINT" />
- <result column="month" property="month" jdbcType="BIGINT" />
- <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
- <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
- <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
- <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
- <result column="score" property="score" jdbcType="FLOAT" />
- </resultMap>
- <select id="groupChecklistMonthByList" parameterType="java.util.Map" resultMap="GroupChecklistMonthResultMap" >
- SELECT
- D.group_id,
- D.group_name,
- YEAR(A.record_time) AS year,
- Month(A.record_time) AS month,
- C.target_type,
- A.checklist_id,
- B.checklist_title,
- COUNT(A.record_id) AS record_qty,
- COUNT(distinct(A.target_id)) AS target_qty,
- ROUND(AVG(A.score)*20, 1) AS score
- FROM checklist_record AS A
- JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
- JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
- <where>
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="checklistCatId != null">
- AND B.checklist_cat_id=#{checklistCatId}
- </if>
- <if test="recordTime != null">
- AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
- </if>
- <if test="year != null">
- AND YEAR(A.record_time) = #{year}
- </if>
- <if test="month != null">
- AND MONTH(A.record_time) = #{month}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND D.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND D.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- </where>
- GROUP BY A.checklist_id
- </select>
- <resultMap id="GroupChecklistMonthScoreCounterResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupChecklistMonthScoreCounterVo">
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="group_title" property="groupName" jdbcType="VARCHAR" />
- <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
- <result column="checklist_title" property="checklistTitle" jdbcType="VARCHAR" />
- <result column="year" property="year" jdbcType="BIGINT" />
- <result column="m1" property="m1" jdbcType="FLOAT" />
- <result column="m2" property="m2" jdbcType="FLOAT" />
- <result column="m3" property="m3" jdbcType="FLOAT" />
- <result column="m4" property="m4" jdbcType="FLOAT" />
- <result column="m5" property="m5" jdbcType="FLOAT" />
- <result column="m6" property="m6" jdbcType="FLOAT" />
- <result column="m7" property="m7" jdbcType="FLOAT" />
- <result column="m8" property="m8" jdbcType="FLOAT" />
- <result column="m9" property="m9" jdbcType="FLOAT" />
- <result column="m10" property="m10" jdbcType="FLOAT" />
- <result column="m11" property="m11" jdbcType="FLOAT" />
- <result column="m12" property="m12" jdbcType="FLOAT" />
- </resultMap>
- <select id="groupChecklistMonthScoreCounterByList" resultMap="GroupChecklistMonthScoreCounterResultMap">
- SELECT
- D.group_id,
- D.group_name,
- C.target_type,
- A.checklist_id,
- B.checklist_title,
- YEAR(A.record_time) AS year,
- CASE MONTH(A.record_time) when 1 then ROUND(AVG(A.score)*20, 1) else 0 end AS m1,
- CASE MONTH(A.record_time) when 2 then ROUND(AVG(A.score)*20, 1) else 0 end AS m2,
- CASE MONTH(A.record_time) when 3 then ROUND(AVG(A.score)*20, 1) else 0 end AS m3,
- CASE MONTH(A.record_time) when 4 then ROUND(AVG(A.score)*20, 1) else 0 end AS m4,
- CASE MONTH(A.record_time) when 5 then ROUND(AVG(A.score)*20, 1) else 0 end AS m5,
- CASE MONTH(A.record_time) when 6 then ROUND(AVG(A.score)*20, 1) else 0 end AS m6,
- CASE MONTH(A.record_time) when 7 then ROUND(AVG(A.score)*20, 1) else 0 end AS m7,
- CASE MONTH(A.record_time) when 8 then ROUND(AVG(A.score)*20, 1) else 0 end AS m8,
- CASE MONTH(A.record_time) when 9 then ROUND(AVG(A.score)*20, 1) else 0 end AS m9,
- CASE MONTH(A.record_time) when 10 then ROUND(AVG(A.score)*20, 1) else 0 end AS m10,
- CASE MONTH(A.record_time) when 11 then ROUND(AVG(A.score)*20, 1) else 0 end AS m11,
- CASE MONTH(A.record_time) when 12 then ROUND(AVG(A.score)*20, 1) else 0 end AS m12
- FROM checklist_record AS A
- LEFT JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- LEFT JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
- LEFT JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
- <where>
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId}
- </if>
- <if test="targetType != null">
- AND B.target_type = #{targetType}
- </if>
- <if test="checklistCatId != null">
- AND B.checklist_cat_id = #{checklistCatId}
- </if>
- <if test="year != null">
- AND YEAR(A.record_time) = #{year}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND C.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND C.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- </where>
- </select>
- <resultMap id="DoctorSatisfyResultMap" type="com.zhyc.xps.hos.vo.SatisfyDoctorVo">
- <result column="doctor_id" property="doctorId" jdbcType="BIGINT" />
- <result column="doctor_name" property="doctorName" jdbcType="VARCHAR" />
- <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
- <result column="score" property="score" jdbcType="FLOAT" />
- </resultMap>
- <select id="doctorByList" resultMap="DoctorSatisfyResultMap">
- SELECT
- D.doctor_id,
- D.doctor_name,
- COUNT(A.record_id) AS record_qty,
- ROUND(AVG(A.score)*20, 1) AS score
- FROM checklist_record AS A
- JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
- JOIN hos_doctor AS D ON (A.oc_id = D.oc_id AND A.target_id = D.doctor_id)
- JOIN s_group AS E ON (D.oc_id = E.oc_id AND D.group_id = E.group_id)
- <where>
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="targetType != null">
- AND C.target_type = #{targetType}
- </if>
- <if test="year != null">
- AND YEAR(A.record_time) = #{year}
- </if>
- <if test="month != null">
- AND MONTH(A.record_time) = #{month}
- </if>
- <if test="recordTime != null">
- AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND E.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND E.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- </where>
- GROUP BY D.doctor_id
- </select>
- <resultMap id="GridResultMap" type="com.zhyc.xps.hos.vo.SatisfyGridVo">
- <result column="grid_id" property="gridId" jdbcType="BIGINT" />
- <result column="grid_title" property="gridTitle" jdbcType="VARCHAR" />
- <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
- <result column="score" property="score" jdbcType="FLOAT" />
- </resultMap>
- <select id="gridByList" resultMap="GridResultMap">
- SELECT
- D.grid_id,
- D.grid_title,
- COUNT(A.record_id) AS record_qty,
- ROUND(AVG(A.score)*20, 1) AS score
- FROM checklist_record AS A
- JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
- JOIN ent_grid AS D ON (A.oc_id = D.oc_id AND A.target_id = D.grid_id)
- JOIN s_group AS E ON (D.oc_id = E.oc_id AND D.group_id = E.group_id)
- <where>
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId}
- </if>
- <if test="targetType != null">
- AND C.target_type = #{targetType}
- </if>
- <if test="checklistCatId != null">
- AND B.checklist_cat_id = #{checklistCatId}
- </if>
- <if test="year != null">
- AND YEAR(A.record_time) = #{year}
- </if>
- <if test="month != null">
- AND MONTH(A.record_time) = #{month}
- </if>
- <if test="recordTime != null">
- AND DATE_FORMAT(A.record_time,'%Y-%m-%d') = #{recordTime}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND E.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND E.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- </where>
- GROUP BY D.grid_id
- </select>
- <resultMap id="GroupChecklistDayResultMap" type="com.zhyc.xps.hos.vo.SatisfyGroupChecklistDayVo">
- <result column="group_id" property="groupId" jdbcType="BIGINT" />
- <result column="group_name" property="groupName" jdbcType="VARCHAR" />
- <result column="year" property="year" jdbcType="BIGINT" />
- <result column="month" property="month" jdbcType="BIGINT" />
- <result column="day" property="day" jdbcType="BIGINT" />
- <result column="checklist_id" property="checklistId" jdbcType="BIGINT" />
- <result column="checklist_title" property="checklistTitle" jdbcType="BIGINT" />
- <result column="record_qty" property="recordQty" jdbcType="BIGINT" />
- <result column="target_qty" property="targetQty" jdbcType="BIGINT" />
- <result column="score" property="score" jdbcType="FLOAT" />
- </resultMap>
- <select id="groupChecklistDayByList" resultMap="GroupChecklistDayResultMap">
- SELECT
- D.group_id,
- D.group_name,
- A.checklist_id,
- B.checklist_title,
- YEAR(A.record_time) AS year,
- MONTH(A.record_time) AS month,
- DAY(A.record_time) AS day,
- COUNT(A.record_id) AS record_qty,
- COUNT(distinct(A.target_id)) AS target_qty,
- ROUND(AVG(A.score)*20, 1) AS score
- FROM checklist_record AS A
- JOIN checklist AS B ON (A.oc_id = B.oc_id AND A.checklist_id = B.checklist_id)
- JOIN checklist_target AS C ON (A.oc_id = C.oc_id AND A.checklist_id = C.checklist_id AND A.target_id = C.target_id)
- JOIN s_group AS D ON (A.oc_id = D.oc_id AND A.target_group_id = D.group_id)
- <where>
- <if test="ocId != null">
- AND A.oc_id = #{ocId}
- </if>
- <if test="checklistId != null">
- AND A.checklist_id = #{checklistId}
- </if>
- <if test="targetType != null">
- AND B.target_type = #{targetType}
- </if>
- <if test="checklistCatId != null">
- AND B.checklist_cat_id = #{checklistCatId}
- </if>
- <if test="year != null">
- AND YEAR(A.record_time) = #{year}
- </if>
- <if test="month != null">
- AND MONTH(A.record_time) = #{month}
- </if>
- <if test="nodeLeft != null and nodeRight != null">
- <![CDATA[
- AND D.node_left >= #{nodeLeft, jdbcType=BIGINT}
- AND D.node_right <= #{nodeRight, jdbcType=BIGINT}
- ]]>
- </if>
- </where>
- GROUP BY D.group_id, A.checklist_id, DAY(A.record_time)
- ORDER BY day
- </select>
- </mapper>
|