Sfoglia il codice sorgente

二级报表sql调整

chengyao 3 anni fa
parent
commit
cd935807da

+ 15 - 123
dblayer-mbg/src/main/resources/mapper/report/BehospitalInfoMapper.xml

@@ -4284,23 +4284,10 @@
         a.beh_dept_id AS deptId,
         a.beh_dept_name AS deptName
         FROM
-        med_behospital_info a,
-        med_qcresult_cases c,
-        med_qcresult_detail d,
-        qc_cases_entry e
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND d.is_deleted = 'N'
-        AND e.is_deleted = 'N'
-        AND a.hospital_id = c.hospital_id
-        AND a.hospital_id = d.hospital_id
-        AND a.behospital_code = c.behospital_code
-        AND a.behospital_code = d.behospital_code
-        AND c.cases_id = d.cases_id
-        AND d.cases_id = e.cases_id
-        AND d.cases_entry_id = e.id
-        AND d.cases_id = 243
+        AND a.cases_id = 243
         AND a.qc_type_id != 0
         <if test="qcResultPageVO.isPlacefile != null and qcResultPageVO.isPlacefile != ''">
             and a.is_placefile = #{qcResultPageVO.isPlacefile}
@@ -4324,28 +4311,12 @@
                 <![CDATA[ AND a.leave_hospital_date <= #{qcResultPageVO.endDate}]]>
             </if>
         </if>
-        <if test="qcResultPageVO.diagnose != null and qcResultPageVO.diagnose != ''">
-            AND a.diagnose LIKE CONCAT( '%', #{qcResultPageVO.diagnose}, '%' )
-        </if>
         <if test="qcResultPageVO.deptName != null and qcResultPageVO.deptName != ''">
             AND a.beh_dept_name LIKE CONCAT( '%', #{qcResultPageVO.deptName}, '%' )
         </if>
         <if test="qcResultPageVO.behospitalCode != null and qcResultPageVO.behospitalCode != ''">
             AND a.behospital_code LIKE CONCAT( '%', #{qcResultPageVO.behospitalCode}, '%' )
         </if>
-        <if test="qcResultPageVO.patName != null and qcResultPageVO.patName != ''">
-            AND a.NAME LIKE CONCAT( '%', #{qcResultPageVO.patName}, '%' )
-        </if>
-        <if test="qcResultPageVO.doctorId != null and qcResultPageVO.doctorId != ''">
-            AND (a.doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
-            OR a.beh_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' )
-            OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultPageVO.doctorId}, '%' ))
-        </if>
-        <if test="qcResultPageVO.doctorName != null and qcResultPageVO.doctorName != ''">
-            AND (a.doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
-            OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' )
-            OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultPageVO.doctorName}, '%' ))
-        </if>
         GROUP BY
         a.beh_dept_id,
         a.beh_dept_name
@@ -5169,36 +5140,18 @@
         </if>
         )f1,
         (SELECT
-        ROUND( AVG( qi.score_res ), 2 ) AS avgScore,
+        ROUND( AVG( t.scoreRes ), 2 ) AS avgScore,
         t.behDeptId,
         t.behDeptName
         FROM
         (SELECT DISTINCT
         t1.hospital_id AS hospitalId,
         t1.behospital_code AS behospitalCode,
-        t1.bed_code AS bedCode,
         t1.LEVEL AS LEVEL,
-        t1.grade_type AS gradeType,
         t1.score_res AS scoreRes,
-        t1.NAME AS NAME,
-        t1.sex AS sex,
         t1.beh_dept_id AS behDeptId,
         t1.beh_dept_name AS behDeptName,
-        t1.doctor_id AS doctorId,
-        t1.doctor_name AS doctorName,
-        t1.beh_doctor_id AS behDoctorId,
-        t1.beh_doctor_name AS behDoctorName,
-        t1.director_doctor_id AS directorDoctorId,
-        t1.director_doctor_name AS directorDoctorName,
-        t1.birthday AS birthday,
-        t1.behospital_date AS behospitalDate,
-        t1.leave_hospital_date AS leaveHospitalDate,
-        t1.placefile_date AS placefileDate,
-        t1.gmt_create AS gradeTime,
-        t1.diagnose,
-        t1.ward_name AS wardName,
         t2.age,
-        t1.file_code AS fileCode,
         t1.checkStatus,
         t1.mrStatus,
         t1.chName,
@@ -5208,10 +5161,6 @@
         FROM
         (SELECT
         be.*,
-        b.grade_type,
-        b.score_res,
-        b.gmt_create,
-        b.LEVEL,
         ifnull(mci.status,0) AS checkStatus,
         ifnull(hm_mci.status,0) AS mrStatus,
         mci.check_name as chName,
@@ -5221,51 +5170,17 @@
         FROM
         (
         SELECT DISTINCT
-        a.hospital_id,
-        a.behospital_code,
-        a.bed_code,
-        a.file_code,
-        a.NAME,
-        a.sex,
         a.beh_dept_id,
         a.beh_dept_name,
-        a.birthday,
-        a.behospital_date,
-        a.leave_hospital_date,
-        a.doctor_id,
-        a.doctor_name,
-        a.beh_doctor_id,
-        a.beh_doctor_name,
-        a.director_doctor_id,
-        a.director_doctor_name,
-        a.diagnose,
-        a.placefile_date,
-        a.ward_name
+        a.hospital_id,
+        a.behospital_code,
+        a.LEVEL,
+        a.score_res
         FROM
-        med_behospital_info a,
-        med_qcresult_detail k,
-        med_qcresult_cases c,
-        qc_cases_entry d
+        med_qcresult_report a
         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
-        <!--        <if test="qcResultShortPageVO.titleName != null ">-->
-        <!--            <if test="qcResultShortPageVO.titleName == '不合格数'">-->
-        <!--                AND c.`level`='不合格'-->
-        <!--            </if>-->
-        <!--            <if test="qcResultShortPageVO.titleName == '合格数'">-->
-        <!--                AND c.`level`='合格'-->
-        <!--            </if>-->
-        <!--        </if>-->
+        AND a.cases_id = 243
         AND a.qc_type_id != 0
         <if test="qcResultShortPageVO.isPlacefile != null and qcResultShortPageVO.isPlacefile != ''">
             and a.is_placefile = #{qcResultShortPageVO.isPlacefile}
@@ -5289,36 +5204,23 @@
                 <![CDATA[ AND a.leave_hospital_date <= #{qcResultShortPageVO.endDate}]]>
             </if>
         </if>
-        <if test="qcResultShortPageVO.diagnose != null and qcResultShortPageVO.diagnose != ''">
-            AND a.diagnose LIKE CONCAT( '%', #{qcResultShortPageVO.diagnose}, '%' )
-        </if>
         <if test="qcResultShortPageVO.deptName != null and qcResultShortPageVO.deptName != ''">
             AND a.beh_dept_name = #{qcResultShortPageVO.deptName}
         </if>
         <if test="qcResultShortPageVO.behospitalCode != null and qcResultShortPageVO.behospitalCode != ''">
             AND a.behospital_code LIKE CONCAT( '%', #{qcResultShortPageVO.behospitalCode}, '%' )
         </if>
-        <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}, '%' )
-            OR a.director_doctor_id LIKE CONCAT( '%', #{qcResultShortPageVO.doctorId}, '%' ))
-        </if>
-        <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
-            AND (a.doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
-            OR a.beh_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' )
-            OR a.director_doctor_name LIKE CONCAT( '%', #{qcResultShortPageVO.doctorName}, '%' ))
+            AND a.msg = #{qcResultShortPageVO.casesEntryName}
         </if>
         <if test="qcResultShortPageVO.casesEntryId != null ">
-            AND d.id = #{qcResultShortPageVO.casesEntryId}
+            AND a.cases_entry_id = #{qcResultShortPageVO.casesEntryId}
         </if>
         <if test="qcResultShortPageVO.ruleType != null">
-            AND d.rule_type = #{qcResultShortPageVO.ruleType}
+            AND a.rule_type = #{qcResultShortPageVO.ruleType}
+        </if>
+        <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
+            AND a.`level` = #{qcResultPageVO.level}
         </if>
         )be
         left join med_check_info mci
@@ -5331,21 +5233,11 @@
         and hm_mci.check_type = 1
         and be.hospital_id = hm_mci.hospital_id
         and be.behospital_code = hm_mci.behospital_code
-        left join med_qcresult_info b
-        on  b.is_deleted = 'N'
-        AND be.hospital_id = b.hospital_id
-        AND be.behospital_code = b.behospital_code
-        <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
-            AND b.`level` = #{qcResultPageVO.level}
-        </if>
         ) t1
         LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
         AND t1.behospital_code = t2.behospital_code
         AND t2.is_deleted = 'N'
         ) t
-        LEFT JOIN med_qcresult_info qi ON qi.is_deleted = 'N'
-        AND t.hospitalId = qi.hospital_id
-        AND t.behospitalCode = qi.behospital_code
         where 1=1
         <if test="qcResultShortPageVO.checkStatus != null">
             AND t.checkStatus = #{qcResultShortPageVO.checkStatus}

+ 21 - 47
dblayer-mbg/src/main/resources/mapper/report/QcresultInfoMapper.xml

@@ -782,10 +782,7 @@
 
     <!-- 缺陷详情(分页) -->
     <select id="entryCountGroupByEntryPage"  resultType="com.lantone.common.dto.report.EntryNumGroupDTO">
-        SELECT
-        t.*
-        FROM
-        (
+        SELECT * from(
         SELECT
         t1.id,
         t1.NAME,
@@ -800,28 +797,18 @@
         FROM
         (
         SELECT
-        tt2.id AS id,
-        tt2.NAME AS NAME,
-        tt2.cases_id AS casesId,
-        tt2.cases_name AS casesName,
-        tt1.num,
-        tt2.rule_type AS ruleType,
-        tt1.is_reject AS isReject
-        FROM
-        (
-        SELECT
-        d.cases_id,
-        d.cases_entry_id,
-        d.is_reject,
+        a.cases_entry_id as id,
+        a.msg as name,
+        a.cases_id AS casesId,
+        a.cases_name AS casesName,
+        a.rule_type AS ruleType,
+        a.is_reject AS isReject,
         count(*) AS num
         FROM
-        med_behospital_info a,
-        med_qcresult_detail d
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND d.is_deleted = 'N'
-        AND a.hospital_id = d.hospital_id
-        AND a.behospital_code = d.behospital_code
+        and a.cases_id is not null
         <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
             and a.is_placefile = #{filterPageVO.isPlacefile}
         </if>
@@ -849,47 +836,34 @@
             AND a.beh_dept_name = #{filterPageVO.deptName}
         </if>
         <if test="filterPageVO.casesId != null and filterPageVO.casesId != 0">
-            AND d.cases_id = #{filterPageVO.casesId}
+            AND a.cases_id = #{filterPageVO.casesId}
         </if>
         <if test="filterPageVO.isReject != null">
-            AND d.is_reject = #{filterPageVO.isReject}
+            AND a.is_reject = #{filterPageVO.isReject}
         </if>
-        GROUP BY
-        d.cases_entry_id,
-        d.cases_id
-        ) tt1,
-        qc_cases_entry tt2
-        WHERE
-        tt2.is_deleted = 'N'
-        AND tt1.cases_id = tt2.cases_id
-        AND tt1.cases_entry_id = tt2.id
         <if test="filterPageVO.casesName != null and filterPageVO.casesName != ''">
-            AND tt2.cases_name like CONCAT('%', #{filterPageVO.casesName},'%')
+            AND a.cases_name like CONCAT('%', #{filterPageVO.casesName},'%')
         </if>
         <if test="filterPageVO.name != null and filterPageVO.name != ''">
-            AND tt2.name like CONCAT('%', #{filterPageVO.name},'%')
+            AND a.msg like CONCAT('%', #{filterPageVO.name},'%')
         </if>
         <if test="filterPageVO.ruleType != null">
-            AND tt2.rule_type = #{filterPageVO.ruleType}
+            AND a.rule_type = #{filterPageVO.ruleType}
         </if>
+        GROUP BY
+        a.cases_entry_id,
+        a.cases_id
         ) t1,(
         SELECT
         count(*) AS totleNum
         FROM
-        med_behospital_info a,
-        med_qcresult_detail d,
-        qc_cases_entry e
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND d.is_deleted = 'N'
-        AND e.is_deleted = 'N'
-        AND a.hospital_id = d.hospital_id
-        AND a.behospital_code = d.behospital_code
+        AND a.cases_id is not null
         <if test="filterPageVO.isPlacefile != null and filterPageVO.isPlacefile != ''">
             and a.is_placefile = #{filterPageVO.isPlacefile}
         </if>
-        AND e.cases_id = d.cases_id
-        AND e.id = d.cases_entry_id
         AND a.qc_type_id != 0
         <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
             AND a.hospital_id = #{filterPageVO.hospitalId}
@@ -914,10 +888,10 @@
             AND a.beh_dept_name  =  #{filterPageVO.deptName}
         </if>
         <if test="filterPageVO.isReject != null">
-            AND d.is_reject = #{filterPageVO.isReject}
+            AND a.is_reject = #{filterPageVO.isReject}
         </if>
         <if test="filterPageVO.ruleType != null">
-            AND e.rule_type = #{filterPageVO.ruleType}
+            AND a.rule_type = #{filterPageVO.ruleType}
         </if>
         ) t2
         )t