Explorar o código

模块统计质控缺陷数sql调整

chengyao %!s(int64=3) %!d(string=hai) anos
pai
achega
84696d23a8

+ 117 - 1
dblayer-mbg/src/main/resources/mapper/report/QcresultInfoMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="com.lantone.dblayermbg.mapper.report.QcresultInfoMapper">
 
     <!-- 按模块统计质控缺陷数 -->
-    <select id="entryCountGroupByCase" parameterType="com.lantone.common.vo.report.FilterVO"
+   <!-- <select id="entryCountGroupByCase" parameterType="com.lantone.common.vo.report.FilterVO"
             resultType="com.lantone.common.dto.report.NumDTO">
         SELECT
         t1.id AS id,
@@ -128,6 +128,122 @@
             LIMIT 0,
             #{limitCount}
         </if>
+    </select>-->
+
+    <!-- 按模块统计质控缺陷数 -->
+    <select id="entryCountGroupByCase" parameterType="com.lantone.common.vo.report.FilterVO"
+            resultType="com.lantone.common.dto.report.NumDTO">
+        SELECT
+        t1.id AS id,
+        t1.NAME AS NAME,
+        t1.num AS num,
+        t2.mrNum AS mrNum,
+        t3.standardNum AS standardNum,
+        t2.mrNum * t3.standardNum AS totleNum,
+        ROUND( t1.num /( t2.mrNum * t3.standardNum ), 4 ) AS percent,
+        CONCAT( ROUND( t1.num /( t2.mrNum * t3.standardNum )* 100, 2 ), '%' ) AS percentStr
+        FROM
+        (
+        SELECT
+        e.id,
+        f.NAME AS NAME,
+        e.num
+        from(
+        SELECT
+        a.cases_id AS id,
+        count(*) AS num
+        FROM
+        med_qcresult_report a
+        WHERE
+        AND a.is_deleted ='N'
+        AND a.cases_id is not null
+        <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>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        GROUP BY
+        a.cases_id
+        ) e,
+        qc_cases f
+        WHERE
+         f.is_deleted = 'N'
+        AND e.id = f.id
+        ) t1,
+        (
+        SELECT
+        count(DISTINCT a.behospital_code) AS mrNum
+        FROM
+        med_qcresult_report a
+        WHERE
+        a.is_deleted = 'N'
+        <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>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        ) t2,
+        (
+        SELECT
+        a.id,
+        a.NAME,
+        count(*) AS standardNum
+        FROM
+        qc_cases a,
+        qc_cases_entry b
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND a.id = b.cases_id
+        GROUP BY
+        a.id,
+        a.`name`
+        ) t3
+        WHERE
+        t1.id = t3.id
+        AND t1.NAME = t3.NAME
+        ORDER BY
+        percent DESC
+        <if test="limitCount != null">
+            LIMIT 0,
+            #{limitCount}
+        </if>
     </select>
 
     <!-- 条目缺陷占比(首页) -->