Browse Source

条目缺陷占比-内页优化

zhaops 5 years ago
parent
commit
5229ae3586
1 changed files with 41 additions and 33 deletions
  1. 41 33
      src/main/resources/mapper/QcresultInfoMapper.xml

+ 41 - 33
src/main/resources/mapper/QcresultInfoMapper.xml

@@ -330,9 +330,11 @@
 
     <!-- 条目缺陷占比(内页) -->
     <select id="entryGroupByEntryInnerPage" resultType="com.diagbot.dto.EntryNumDTO">
-        SELECT t.*
+        SELECT
+        t.*
         FROM
-        (SELECT
+        (
+        SELECT
         t1.id AS id,
         t1.NAME AS NAME,
         t1.casesId AS casesId,
@@ -346,61 +348,67 @@
         FROM
         (
         SELECT
-        e.id,
-        e.NAME,
-        e.cases_id AS casesId,
-        e.cases_name AS casesName,
+        tt2.id,
+        tt2.NAME,
+        tt2.cases_id AS casesId,
+        tt2.cases_name AS casesName,
+        tt3.score,
+        tt1.num,
+        tt1.is_reject AS isReject
+        FROM
+        (
+        SELECT
+        a.hospital_id,
+        d.cases_entry_id,
+        d.cases_id,
         count(*) AS num,
-        f.score,
-        d.is_reject AS isReject
+        d.is_reject
         FROM
         med_behospital_info a,
         med_qcresult_info c,
-        med_qcresult_detail d,
-        qc_cases_entry e,
-        qc_cases_entry_hospital f
+        med_qcresult_detail d
         WHERE
         a.is_deleted = 'N'
         AND c.is_deleted = 'N'
         AND d.is_deleted = 'N'
-        AND e.is_deleted = 'N'
-        AND f.is_deleted = 'N'
         AND a.hospital_id = c.hospital_id
         AND a.hospital_id = d.hospital_id
-        AND a.hospital_id = f.hospital_id
         AND a.behospital_code = c.behospital_code
         AND a.behospital_code = d.behospital_code
-        AND d.cases_id = e.cases_id
-        AND d.cases_entry_id = e.id
-        AND e.id = f.cases_entry_id
         AND a.is_placefile = '1'
-        <![CDATA[AND a.qc_type_id <>0 ]]>
+        AND a.qc_type_id != 0
         <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
             AND a.hospital_id = #{filterPageVO.hospitalId}
         </if>
         <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
-            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
+            <![CDATA[ AND a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
         </if>
         <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
         </if>
-        <if test="filterPageVO.name != null and filterPageVO.name != ''">
-            AND e.name like CONCAT('%', #{filterPageVO.name},'%')
-        </if>
-        <if test="filterPageVO.casesName != null and filterPageVO.casesName != ''">
-            AND e.cases_name = #{filterPageVO.casesName}
-        </if>
         <if test="filterPageVO.isReject != null">
             AND d.is_reject = #{filterPageVO.isReject}
         </if>
         GROUP BY
-        e.id,
-        e.NAME,
-        <if test="filterPageVO.isReject == null">
-            d.is_reject,
+        d.cases_entry_id,
+        d.is_reject,
+        d.cases_id
+        ) tt1,
+        qc_cases_entry tt2,
+        qc_cases_entry_hospital tt3
+        WHERE
+        tt2.is_deleted = 'N'
+        AND tt3.is_deleted = 'N'
+        AND tt1.hospital_id = tt3.hospital_id
+        AND tt1.cases_id = tt2.cases_id
+        AND tt1.cases_entry_id = tt2.id
+        AND tt1.cases_entry_id = tt3.cases_entry_id
+        <if test="filterPageVO.name != null and filterPageVO.name != ''">
+            AND tt2.name like CONCAT('%', #{filterPageVO.name},'%')
+        </if>
+        <if test="filterPageVO.casesName != null and filterPageVO.casesName != ''">
+            AND tt2.cases_name = #{filterPageVO.casesName}
         </if>
-        e.cases_id,
-        e.cases_name
         ) t1,
         (
         SELECT
@@ -414,7 +422,7 @@
         AND a.hospital_id = c.hospital_id
         AND a.behospital_code = c.behospital_code
         AND a.is_placefile = '1'
-        <![CDATA[AND a.qc_type_id <>0 ]]>
+        AND a.qc_type_id != 0
         <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
             AND a.hospital_id = #{filterPageVO.hospitalId}
         </if>
@@ -425,7 +433,7 @@
             <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
         </if>
         ) t2
-        )t
+        ) t
     </select>
 
     <!-- 单项否决缺陷占比(首页) -->