Przeglądaj źródła

各模块缺陷占比

zhaops 5 lat temu
rodzic
commit
261065b8aa

+ 0 - 53
src/main/java/com/diagbot/aggregate/ResultStatisticsAggregate.java

@@ -71,60 +71,7 @@ public class ResultStatisticsAggregate {
      */
     @DataProvider("entryCountGroupByCase")
     public List<NumDTO> entryCountGroupByCase(@InvokeParameter("filterVO") FilterVO filterVO) {
-        DecimalFormat df = new DecimalFormat("#0.00");
-        Integer limitCount = filterVO.getLimitCount();
-        QcresultFilterVO qcresultFilterVO = new QcresultFilterVO();
-        BeanUtil.copyProperties(filterVO, qcresultFilterVO);
-        int mrNum = qcresultInfoFacade.resultCount(qcresultFilterVO);
         List<NumDTO> qcEntryNumList = qcresultInfoFacade.entryCountGroupByCase(filterVO);
-        List<NumDTO> standardEntryNumList = qcCasesFacade.entryGroupByCase();
-        if (ListUtil.isEmpty(qcEntryNumList)) {
-            return qcEntryNumList;
-        }
-        if (ListUtil.isEmpty(standardEntryNumList)
-                && ListUtil.isNotEmpty(qcEntryNumList)) {
-            qcEntryNumList.forEach(entryNum -> {
-                entryNum.setNum(0);
-                entryNum.setPercent(0d);
-                entryNum.setPercentStr("0%");
-                entryNum.setTotleNum(0);
-            });
-        }
-        if (ListUtil.isNotEmpty(qcEntryNumList)) {
-            Map<String, Integer> standardMap
-                    = EntityUtil.makeMapWithKeyValue(standardEntryNumList, "name", "num");
-            qcEntryNumList.forEach(item -> {
-                if (!standardMap.containsKey(item.getName())) {
-                    item.setTotleNum(0);
-                    item.setPercent(0d);
-                    item.setPercentStr("0%");
-                } else {
-                    Integer totleNum = standardMap.get(item.getName()) * mrNum;
-                    Double percent = BigDecimal.valueOf(item.getNum())
-                            .divide(BigDecimal.valueOf(totleNum), 4, RoundingMode.HALF_UP)
-                            .doubleValue();
-                    String percentStr
-                            = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
-                    item.setTotleNum(totleNum);
-                    item.setPercent(percent);
-                    item.setPercentStr(percentStr);
-                }
-            });
-            //降序排序
-            Collections.sort(qcEntryNumList, new Comparator<NumDTO>() {
-                @Override
-                public int compare(NumDTO o1, NumDTO o2) {
-                    return o2.getPercent().compareTo(o1.getPercent());
-                }
-            });
-        }
-
-        //取top10
-        qcEntryNumList = qcEntryNumList
-                .stream()
-                .limit(limitCount)
-                .collect(Collectors.toList());
-
         return qcEntryNumList;
     }
 

+ 152 - 77
src/main/resources/mapper/QcresultInfoMapper.xml

@@ -155,31 +155,40 @@
 
     <!-- 按模块统计质控缺陷数 -->
     <select id="entryCountGroupByCase" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.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
         d.cases_id AS id,
-        e.NAME AS name,
         count(*) AS num
         FROM
         med_behospital_info a,
         med_qcresult_info c,
-        med_qcresult_detail d,
-        qc_cases e,
-        qc_cases_entry 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.behospital_code = c.behospital_code
         AND a.behospital_code = d.behospital_code
-        AND d.cases_id = e.id
-        AND d.cases_entry_id = f.id
-        AND e.id = f.cases_id
         AND a.is_placefile = '1'
-        <![CDATA[AND a.qc_type_id <>0 ]]>
+        AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
@@ -190,8 +199,61 @@
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         GROUP BY
-        d.cases_id,
-        e.`name`
+        d.cases_id
+        ) e,
+        qc_cases f
+        WHERE
+        f.is_deleted = 'N'
+        AND e.id = f.id
+        ) t1,
+        (
+        SELECT
+        COUNT(*) AS mrNum
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c
+        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.is_placefile = '1'
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="startDate != null and startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </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>
 
     <!-- 条目缺陷占比(首页) -->
@@ -576,53 +638,60 @@
     <!-- 按模块统计质控缺陷数 -->
     <select id="entryCountGroupByCaseAndDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.DeptNumDTO">
         SELECT
-        d.cases_id AS id,
-        e.NAME AS NAME,
+        f.id,
+        g.NAME AS NAME,
+        f.deptId,
+        f.deptName,
+        f.num
+        FROM
+        (
+        SELECT
         a.beh_dept_id AS deptId,
         a.beh_dept_name AS deptName,
+        c.cases_id AS id,
         count(*) AS num
         FROM
         med_behospital_info a,
-        med_qcresult_info c,
-        med_qcresult_detail d,
-        qc_cases e,
-        qc_cases_entry f,
-        sys_user_dept g
+        med_qcresult_info b,
+        med_qcresult_detail c,
+        qc_cases_entry d,
+        sys_user_dept e
         WHERE
         a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
         AND c.is_deleted = 'N'
         AND d.is_deleted = 'N'
         AND e.is_deleted = 'N'
-        AND f.is_deleted = 'N'
-        AND g.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
         AND a.hospital_id = c.hospital_id
-        AND a.hospital_id = d.hospital_id
-        AND a.hospital_id = g.hospital_id
+        AND a.hospital_id = e.hospital_id
+        AND a.behospital_code = b.behospital_code
         AND a.behospital_code = c.behospital_code
-        AND a.behospital_code = d.behospital_code
-        AND d.cases_id = e.id
-        AND d.cases_entry_id = f.id
-        AND e.id = f.cases_id
-        AND a.beh_dept_id = g.dept_id
+        AND c.cases_entry_id = d.id
+        AND a.beh_dept_id = e.dept_id
         AND a.is_placefile = '1'
-        <![CDATA[AND a.qc_type_id <>0 ]]>
+        AND a.qc_type_id != 0
         <if test="userId!=null">
-            AND g.user_id = #{userId}
+            AND e.user_id = #{userId}
         </if>
         <if test="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
         <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+            <![CDATA[ AND a.leave_hospital_date >= DATE(#{startDate})]]>
         </if>
         <if test="endDate != null and endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         GROUP BY
         d.cases_id,
-        e.`name`,
         a.beh_dept_id,
         a.beh_dept_name
+        ) f,
+        qc_cases g
+        WHERE
+        g.is_deleted = 'N'
+        AND f.id = g.id
     </select>
 
     <!-- 条目缺陷占比-科室(首页) -->
@@ -874,8 +943,8 @@
         FROM
         (
         SELECT
-        t1.caseId AS id,
-        t1.caseName AS NAME,
+        t1.casesId AS id,
+        t1.casesName AS NAME,
         t1.num AS num,
         t2.mrNum,
         t3.originalNum,
@@ -885,30 +954,28 @@
         FROM
         (
         SELECT
-        d.cases_id AS caseId,
-        e.NAME AS caseName,
+        d.casesId,
+        e.NAME AS casesName,
+        d.num
+        FROM
+        (
+        SELECT
+        c.cases_id AS casesId,
         count(*) AS num
         FROM
         med_behospital_info a,
-        med_qcresult_info c,
-        med_qcresult_detail d,
-        qc_cases e,
-        qc_cases_entry f
+        med_qcresult_info b,
+        med_qcresult_detail c
         WHERE
         a.is_deleted = 'N'
+        AND b.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 = b.hospital_id
         AND a.hospital_id = c.hospital_id
-        AND a.hospital_id = d.hospital_id
+        AND a.behospital_code = b.behospital_code
         AND a.behospital_code = c.behospital_code
-        AND a.behospital_code = d.behospital_code
-        AND d.cases_id = e.id
-        AND d.cases_entry_id = f.id
-        AND e.id = f.cases_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>
@@ -918,15 +985,19 @@
         <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.deptName != null and filterPageVO.deptName != ''">
             AND a.beh_dept_name like CONCAT('%', #{filterPageVO.deptName},'%')
         </if>
         GROUP BY
-        d.cases_id,
-        e.`name`
+        c.cases_id
+        ) d,
+        qc_cases e
+        WHERE
+        e.is_deleted = 'N'
+        AND d.casesId = e.id
+        <if test="filterPageVO.name != null and filterPageVO.name != ''">
+            AND e.name like CONCAT('%', #{filterPageVO.name},'%')
+        </if>
         ) t1,
         (
         SELECT
@@ -940,7 +1011,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>
@@ -956,8 +1027,8 @@
         ) t2,
         (
         SELECT
-        a.id AS caseId,
-        a.NAME AS caseName,
+        a.id AS casesId,
+        a.NAME AS casesName,
         count(*) AS originalNum
         FROM
         qc_cases a,
@@ -974,10 +1045,8 @@
         a.`name`
         ) t3
         WHERE
-        t1.caseId = t3.caseId
-        AND t1.caseName = t3.caseName
-        ORDER BY
-        ROUND( t1.num /( t2.mrNum * t3.originalNum ), 4 ) DESC
+        t1.casesId = t3.casesId
+        AND t1.casesName = t3.casesName
         ) t
     </select>
 
@@ -1207,6 +1276,8 @@
         SELECT
         t.id,
         t.`NAME`,
+        t.deptId,
+        t.deptName,
         t.num,
         t.totleNum,
         t.percent,
@@ -1216,6 +1287,8 @@
         SELECT
         t1.caseId AS id,
         t1.caseName AS NAME,
+        t1.deptId,
+        t1.deptName,
         t1.num AS num,
         t2.mrNum,
         t3.originalNum,
@@ -1225,36 +1298,36 @@
         FROM
         (
         SELECT
-        d.cases_id AS caseId,
+        f.caseId,
         e.NAME AS caseName,
+        f.deptId,
+        f.deptName,
+        f.num
+        FROM
+        (
+        SELECT
         a.beh_dept_id AS deptId,
         a.beh_dept_name AS deptName,
+        d.cases_id AS caseId,
         count(*) AS num
         FROM
         med_behospital_info a,
         med_qcresult_info c,
         med_qcresult_detail d,
-        qc_cases e,
-        qc_cases_entry f,
         sys_user_dept g
         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 g.is_deleted = 'N'
         AND a.hospital_id = c.hospital_id
         AND a.hospital_id = d.hospital_id
         AND a.hospital_id = g.hospital_id
         AND a.behospital_code = c.behospital_code
         AND a.behospital_code = d.behospital_code
-        AND d.cases_id = e.id
-        AND d.cases_entry_id = f.id
-        AND e.id = f.cases_id
         AND a.beh_dept_id = g.dept_id
         AND a.is_placefile = '1'
-        <![CDATA[AND a.qc_type_id <>0 ]]>
+        AND a.qc_type_id != 0
         <if test="filterPageByDeptVO.userId!=null">
             AND g.user_id = #{filterPageByDeptVO.userId}
         </if>
@@ -1267,17 +1340,21 @@
         <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
             <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
         </if>
-        <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
-            AND e.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
-        </if>
         <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
             AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
         </if>
         GROUP BY
         d.cases_id,
-        e.`name`,
         a.beh_dept_id,
         a.beh_dept_name
+        ) f,
+        qc_cases e
+        WHERE
+        e.is_deleted = 'N'
+        AND f.caseId = e.id
+        <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
+            AND e.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
+        </if>
         ) t1,
         (
         SELECT
@@ -1297,7 +1374,7 @@
         AND a.behospital_code = c.behospital_code
         AND a.beh_dept_id = d.dept_id
         AND a.is_placefile = '1'
-        <![CDATA[AND a.qc_type_id <>0 ]]>
+        AND a.qc_type_id != 0
         <if test="filterPageByDeptVO.userId!=null">
             AND d.user_id = #{filterPageByDeptVO.userId}
         </if>
@@ -1338,8 +1415,6 @@
         AND t1.caseName = t3.caseName
         AND t1.deptId = t2.deptId
         AND t1.deptName = t2.deptName
-        ORDER BY
-        ROUND( t1.num /( t2.mrNum * t3.originalNum ), 4 ) DESC
         ) t
     </select>