瀏覽代碼

控制台sql调整完成

chengyao 3 年之前
父節點
當前提交
a325509070

+ 3 - 7
dblayer-mbg/src/main/resources/mapper/report/BehospitalInfoMapper.xml

@@ -2329,7 +2329,6 @@
         AND a.hospital_id = e.hospital_id
         AND a.behospital_code = b.behospital_code
         AND a.behospital_code = e.behospital_code
-        AND m1.home_page_level != ""
         AND a.score_res > e.score_res
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
@@ -2710,15 +2709,12 @@
         a.beh_dept_name AS NAME,
         count(*) AS num
         FROM
-        med_behospital_info a,
-        med_qcresult_detail b
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND b.is_deleted = 'N'
-        AND a.hospital_id = b.hospital_id
-        AND a.behospital_code = b.behospital_code
         AND a.qc_type_id != 0
-        and b.cases_entry_id=2658
+        and a.cases_entry_id=2658
+        and a.cases_id is not null
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>

+ 56 - 119
dblayer-mbg/src/main/resources/mapper/report/QcresultInfoMapper.xml

@@ -570,27 +570,22 @@
         select
         m1.id,
         m1.name,
-        m1.totleValue,
-        m2.sameTotleValue,
-        m1.averageValue,
-        m2.lastYearAverageValue,
-        m1.num,
-        m2.sameNum
+        count(m1.behospital_code)AS num,
+        count(m2.behospital_code) AS sameNum,
+        ROUND( sum( CAST( m1.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS totleValue,
+        ROUND( sum( CAST( m1.score_res AS DECIMAL ( 18, 2 ) ))/  count(m1.behospital_code), 2 ) AS averageValue,
+        ROUND( sum( CAST( m2.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS sameTotleValue,
+        ROUND( sum( CAST( m2.score_res AS DECIMAL ( 18, 2 ) ))/ count(m2.behospital_code), 2 ) AS lastYearAverageValue
         from(
-        SELECT
+        SELECT distinct
         a.beh_dept_id AS id,
         a.beh_dept_name AS name,
-        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS totleValue,
-        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS averageValue,
-        count(*) AS num
+        a.behospital_code,
+        a.score_res
         FROM
-        med_behospital_info a,
-        med_qcresult_info c
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND a.hospital_id = c.hospital_id
-        AND a.behospital_code = c.behospital_code
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>
@@ -614,23 +609,17 @@
                 <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
             </if>
         </if>
-        GROUP BY
-        a.beh_dept_id,
-        a.beh_dept_name)m1 left join
-        ( SELECT
+        )m1
+         left join
+        ( SELECT distinct
         a.beh_dept_id AS id,
         a.beh_dept_name AS name,
-        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS sameTotleValue,
-        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastYearAverageValue,
-        count(*) AS sameNum
+        a.behospital_code,
+        a.score_res
         FROM
-        med_behospital_info a,
-        med_qcresult_info c
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND a.hospital_id = c.hospital_id
-        AND a.behospital_code = c.behospital_code
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>
@@ -654,12 +643,12 @@
                 <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
             </if>
         </if>
-        GROUP BY
-        a.beh_dept_id,
-        a.beh_dept_name)m2
+        )m2
         on
         m1.id = m2.id
         and m1.name = m2.name
+        GROUP BY
+        m1.id,m1.name
     </select>
 
     <!-- 各科室质控平均分(首页)-根据内外科系统统计 -->
@@ -667,35 +656,28 @@
         select
         m1.id,
         m1.name,
-        m1.totleValue,
-        m2.sameTotleValue,
-        m1.averageValue,
-        m2.lastYearAverageValue,
-        m1.num,
-        m2.sameNum,
-        m1.deptClass
+        count(m1.behospital_code)AS num,
+        count(m2.behospital_code) AS sameNum,
+        ROUND( sum( CAST( m1.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS totleValue,
+        ROUND( sum( CAST( m1.score_res AS DECIMAL ( 18, 2 ) ))/  count(m1.behospital_code), 2 ) AS averageValue,
+        ROUND( sum( CAST( m2.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS sameTotleValue,
+        ROUND( sum( CAST( m2.score_res AS DECIMAL ( 18, 2 ) ))/ count(m2.behospital_code), 2 ) AS lastYearAverageValue
         from(
-        SELECT
+        SELECT distinct
         a.beh_dept_id AS id,
         a.beh_dept_name AS NAME,
-        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS totleValue,
-        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS averageValue,
-        count(*) AS num ,
-        e.dept_name as deptClass
+        a.behospital_code,
+        a.score_res
         FROM
-        med_behospital_info a,
-        med_qcresult_info c,
+        med_qcresult_report a,
         bas_dept_info d,
         bas_dept_info e
         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.hospital_id = e.hospital_id
-        AND a.behospital_code = c.behospital_code
         AND a.beh_dept_id = d.dept_id
         AND d.parent_dept_id = e.dept_id
         <if test="isPlacefile != null and isPlacefile != ''">
@@ -724,30 +706,22 @@
         <if test="deptClass != null and deptClass != ''">
             AND e.dept_name = #{deptClass}
         </if>
-        GROUP BY
-        a.beh_dept_id,
-        a.beh_dept_name) m1 left join
-        (SELECT
+       ) m1 left join
+        (SELECT distinct
         a.beh_dept_id AS id,
         a.beh_dept_name AS NAME,
-        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS sameTotleValue,
-        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastYearAverageValue,
-        count(*) AS sameNum ,
-        e.dept_name as deptClass
+        a.behospital_code,
+        a.score_res
         FROM
-        med_behospital_info a,
-        med_qcresult_info c,
+        med_qcresult_report a,
         bas_dept_info d,
         bas_dept_info e
         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.hospital_id = e.hospital_id
-        AND a.behospital_code = c.behospital_code
         AND a.beh_dept_id = d.dept_id
         AND d.parent_dept_id = e.dept_id
         <if test="isPlacefile != null and isPlacefile != ''">
@@ -776,67 +750,45 @@
         <if test="deptClass != null and deptClass != ''">
             AND e.dept_name = #{deptClass}
         </if>
-        GROUP BY
-        a.beh_dept_id,
-        a.beh_dept_name)m2
+       )m2
         on
         m1.id = m2.id
         and m1.name = m2.name
+        GROUP BY
+        m1.id,m1.name
     </select>
 
     <!-- 单项否决缺陷占比(首页) -->
     <select id="entryRejectPercent" resultType="com.lantone.common.dto.report.EntryNumDTO">
         SELECT
-        t1.id AS id,
-        t1.NAME AS NAME,
-        t1.casesId AS casesId,
-        t1.casesName AS casesName,
-        t1.num AS num,
+        t1.id,
+        t1.name ,
+        t1.casesId,
+        t1.casesName,
+        t1.num,
         t2.mrNum AS totleNum,
-        t1.score AS score,
-        t1.isReject AS isReject,
+        t1.isReject,
         Round( t1.num / t2.mrNum, 4 ) AS percent,
         CONCAT( Round( t1.num / t2.mrNum * 100, 2 ), '%' ) AS percentStr
         FROM
         (
         SELECT
-        tt2.id,
-        tt2.NAME,
-        tt2.cases_id AS casesId,
-        tt2.cases_name AS casesName,
-        tt1.num,
-        <if test="isPlacefile != null and isPlacefile == 0">
-            tt3.score_run as score,
-        </if>
-        <if test="isPlacefile != null and isPlacefile == 1">
-            tt3.score,
-        </if>
-        tt1.is_reject AS isReject
-        FROM
-        (
-        SELECT
-        d.cases_entry_id,
-        d.cases_id,
-        a.hospital_id,
+        a.cases_entry_id as id,
+        a.msg as name,
+        a.cases_id as casesId,
+        a.cases_name as casesName,
         count(*) AS num,
-        d.is_reject
+        a.is_reject AS isReject
         FROM
-        med_behospital_info a,
-        med_qcresult_info c,
-        med_qcresult_detail 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.hospital_id = d.hospital_id
-        AND a.behospital_code = c.behospital_code
-        AND a.behospital_code = d.behospital_code
+        AND a.is_reject = 1
+        AND a.qc_type_id != 0
+        AND a.cases_id is not null
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>
-        AND d.is_reject = 1
-        AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
@@ -857,34 +809,19 @@
             </if>
         </if>
         GROUP BY
-        d.cases_entry_id,
-        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 tt2.id = tt3.cases_entry_id
+        a.cases_entry_id
         ) t1,
         (
         SELECT
-        count(*) AS mrNum
+        count(DISTINCT a.behospital_code) AS mrNum
         FROM
-        med_behospital_info a,
-        med_qcresult_info c
+        med_qcresult_report a
         WHERE
         a.is_deleted = 'N'
-        AND c.is_deleted = 'N'
-        AND a.hospital_id = c.hospital_id
-        AND a.behospital_code = c.behospital_code
+        AND a.qc_type_id != 0
         <if test="isPlacefile != null and isPlacefile != ''">
             and a.is_placefile = #{isPlacefile}
         </if>
-        AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>

+ 0 - 1
report-service/src/main/java/com/lantone/report/aggregate/HomePageStatisticsAggregate.java

@@ -32,7 +32,6 @@ public class HomePageStatisticsAggregate {
             @DataConsumer("getImproveDTO") HomePageImproveDTO improveDTO) {
         Map<String, Object> retMap = new LinkedHashMap<>();
         retMap.put("合格率", null);
-        retMap.put("不合格率", null);
         retMap.put("完整率", null);
         retMap.put("改善率", null);
 

+ 0 - 1
report-service/src/main/java/com/lantone/report/facade/HomePageInfoFacade.java

@@ -41,7 +41,6 @@ public class HomePageInfoFacade {
     public Map<String, Object> homePageMRCount(FilterVO filterVO) {
         Map<String, Object> retMap = new HashMap<>();
         retMap.put("合格率", null);
-        retMap.put("不合格率", null);
         retMap.put("完整率", null);
         retMap.put("改善率", null);
         filterFacade.filterVOSet(filterVO);