Browse Source

sql逻辑调整

chengyao 3 years ago
parent
commit
c50e6e1927
1 changed files with 22 additions and 53 deletions
  1. 22 53
      src/main/resources/mapper/BehospitalInfoMapper.xml

+ 22 - 53
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -13399,15 +13399,15 @@
         left join qc_cases_entry d
         on  d.is_deleted = 'N'
         AND be.cases_id = d.cases_id
-                <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
-                    AND d.NAME = #{qcResultShortPageVO.casesEntryName}
-                </if>
-                <if test="qcResultShortPageVO.casesEntryId != null ">
-                    AND d.id = #{qcResultShortPageVO.casesEntryId}
-                </if>
-                <if test="qcResultShortPageVO.ruleType != null">
-                    AND d.rule_type = #{qcResultShortPageVO.ruleType}
-                </if>
+        <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
+            AND d.NAME = #{qcResultShortPageVO.casesEntryName}
+        </if>
+        <if test="qcResultShortPageVO.casesEntryId != null ">
+            AND d.id = #{qcResultShortPageVO.casesEntryId}
+        </if>
+        <if test="qcResultShortPageVO.ruleType != null">
+            AND d.rule_type = #{qcResultShortPageVO.ruleType}
+        </if>
         ) t1
         LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
         AND t1.behospital_code = t2.behospital_code
@@ -13533,21 +13533,13 @@
         a.ward_name
         FROM
         med_behospital_info a,
-        med_qcresult_detail k,
-        med_qcresult_cases c,
-        qc_cases_entry d
+        med_qcresult_cases c
         WHERE
         a.is_deleted = 'N'
         AND c.is_deleted = 'N'
-        AND d.is_deleted = 'N'
         AND a.hospital_id = c.hospital_id
         AND a.behospital_code = c.behospital_code
-        AND c.cases_id = d.cases_id
-        AND a.hospital_id = k.hospital_id
-        AND a.behospital_code = k.behospital_code
-        AND c.cases_id = k.cases_id
-        AND k.cases_id = d.cases_id
-        AND k.cases_entry_id = d.id
+        AND c.cases_id = 243
         <if test="qcResultShortPageVO.titleName != null ">
             <if test="qcResultShortPageVO.titleName == '不合格数'">
                 AND c.`level`='不合格'
@@ -13591,9 +13583,6 @@
         <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
             AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
         </if>
-        <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
-            AND d.NAME = #{qcResultShortPageVO.casesEntryName}
-        </if>
         <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
             AND (a.doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
             OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' )
@@ -13604,12 +13593,6 @@
             OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
             OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
         </if>
-        <if test="qcResultShortPageVO.casesEntryId != null ">
-            AND d.id = #{qcResultShortPageVO.casesEntryId}
-        </if>
-        <if test="qcResultShortPageVO.ruleType != null">
-            AND d.rule_type = #{qcResultShortPageVO.ruleType}
-        </if>
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'
@@ -13990,13 +13973,11 @@
         FROM
         med_behospital_info a,
         med_home_page b,
-        med_qcresult_cases c,
-        qc_cases_entry d
+        med_qcresult_cases c
         WHERE
         a.is_deleted = 'N'
         AND b.is_deleted = 'N'
         AND c.is_deleted = 'N'
-        AND d.is_deleted = 'N'
         AND a.hospital_id = b.hospital_id
         AND a.hospital_id = c.hospital_id
         AND a.behospital_code = b.behospital_code
@@ -14051,9 +14032,6 @@
         <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
             AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
         </if>
-        <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
-            AND d.NAME = #{qcResultShortPageVO.casesEntryName}
-        </if>
         <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
             AND (case
             when b.attending_doctor != '' and b.attending_doctor is not null then b.attending_doctor
@@ -14487,26 +14465,26 @@
         a.ward_name
         FROM
         med_behospital_info a,
-        med_qcresult_detail k,
         sys_user_dept b,
-        med_qcresult_cases c,
-        qc_cases_entry d
+        med_qcresult_cases c
         WHERE
         a.is_deleted = 'N'
         AND b.is_deleted = 'N'
         AND c.is_deleted = 'N'
-        AND d.is_deleted = 'N'
         AND a.hospital_id = b.hospital_id
         AND a.hospital_id = c.hospital_id
         AND a.behospital_code = c.behospital_code
         AND a.beh_dept_id = b.dept_id
-        AND c.cases_id = d.cases_id
-        AND a.hospital_id = k.hospital_id
-        AND a.behospital_code = k.behospital_code
-        AND c.cases_id = k.cases_id
-        AND k.cases_id = d.cases_id
-        AND k.cases_entry_id = d.id
         AND a.qc_type_id != 0
+        AND c.cases_id = 243
+        <if test="qcResultShortPageVO.titleName != null ">
+            <if test="qcResultShortPageVO.titleName == '不合格数'">
+                AND c.`level`='不合格'
+            </if>
+            <if test="qcResultShortPageVO.titleName == '合格数'">
+                AND c.`level`='合格'
+            </if>
+        </if>
         <if test="qcResultShortPageVO.userId!=null">
             AND b.user_id = #{qcResultShortPageVO.userId}
         </if>
@@ -14547,9 +14525,6 @@
         <if test="qcResultShortPageVO.patName != null and qcResultShortPageVO.patName != ''">
             AND a.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.patName}, '%' )
         </if>
-        <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
-            AND d.NAME = #{qcResultShortPageVO.casesEntryName}
-        </if>
         <if test="qcResultShortPageVO.doctorId != null and qcResultShortPageVO.doctorId != ''">
             AND a.doctor_id = #{qcResultShortPageVO.doctorId}
         </if>
@@ -14558,12 +14533,6 @@
             OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
             OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
         </if>
-        <if test="qcResultShortPageVO.casesEntryId != null ">
-            AND d.id = #{qcResultShortPageVO.casesEntryId}
-        </if>
-        <if test="qcResultShortPageVO.ruleType != null">
-            AND d.rule_type = #{qcResultShortPageVO.ruleType}
-        </if>
         )be
         left join med_check_info mci
         on mci.is_deleted = 'N'