فهرست منبع

1、新增条目缺陷占比内页接口
2、修改条目缺陷占比首页统计接口

zhaops 5 سال پیش
والد
کامیت
cb69d897aa

+ 2 - 52
src/main/java/com/diagbot/aggregate/ResultStatisticsAggregate.java

@@ -136,64 +136,14 @@ public class ResultStatisticsAggregate {
      */
     @DataProvider("entryCountGroupByEntry")
     public List<NumDTO> entryCountGroupByEntry(@InvokeParameter("filterVO") FilterVO filterVO) {
-        DecimalFormat df = new DecimalFormat("#0.00");
         Integer limitCount = filterVO.getLimitCount();
         List<NumDTO> numDTOList = qcresultInfoFacade.entryCountGroupByEntry(filterVO);
         if (ListUtil.isNotEmpty(numDTOList)) {
-            int totle = numDTOList
-                    .stream()
-                    .map(NumDTO::getNum)
-                    .reduce(0, Integer::sum);
             List<NumDTO> retList = Lists.newLinkedList();
-            numDTOList.forEach(numDTO -> {
-                numDTO.setTotleNum(totle);
-                Double percent = BigDecimal.valueOf(numDTO.getNum())
-                        .divide(BigDecimal.valueOf(totle), 4, RoundingMode.HALF_UP)
-                        .doubleValue();
-                numDTO.setPercent(percent);
-                String percentStr
-                        = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
-                numDTO.setPercentStr(percentStr);
-            });
-
-            //降序排序
-            Collections.sort(numDTOList, new Comparator<NumDTO>() {
-                @Override
-                public int compare(NumDTO o1, NumDTO o2) {
-                    return o2.getPercent().compareTo(o1.getPercent());
-                }
-            });
-
-            //top9+其他
             if (numDTOList.size() <= limitCount) {
-                retList.addAll(numDTOList);
+                retList = numDTOList;
             } else {
-                int count = 0;
-                double sumPercent = 0d;
-                for (NumDTO numDTO : numDTOList) {
-                    if (retList.size() < limitCount - 1) {
-                        retList.add(numDTO);
-                        count += numDTO.getNum();
-                        sumPercent = BigDecimal.valueOf(sumPercent)
-                                .add(BigDecimal.valueOf(numDTO.getPercent()))
-                                .doubleValue();
-                    } else {
-                        NumDTO otherNumDTO = new NumDTO();
-                        int num = totle - count;
-                        otherNumDTO.setName("其他");
-                        otherNumDTO.setNum(num);
-                        otherNumDTO.setTotleNum(totle);
-                        Double percent = BigDecimal.valueOf(num)
-                                .divide(BigDecimal.valueOf(totle), 4, RoundingMode.HALF_UP)
-                                .doubleValue();
-                        otherNumDTO.setPercent(percent);
-                        String percentStr
-                                = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
-                        otherNumDTO.setPercentStr(percentStr);
-                        retList.add(otherNumDTO);
-                        break;
-                    }
-                }
+                retList = numDTOList.subList(0, limitCount);
             }
             return retList;
         }

+ 23 - 49
src/main/java/com/diagbot/facade/ConsoleByDeptFacade.java

@@ -366,63 +366,19 @@ public class ConsoleByDeptFacade {
             }
             List<DeptNumDTO> listByDept = numListMap.get(deptName);
             if (ListUtil.isNotEmpty(listByDept)) {
-                List<NumDTO> entryByDeptList = BeanUtil.listCopyTo(listByDept, NumDTO.class);
-                int totle = entryByDeptList
-                        .stream()
-                        .map(NumDTO::getNum)
-                        .reduce(0, Integer::sum);
-                List<NumDTO> retList = Lists.newLinkedList();
-                entryByDeptList.forEach(numDTO -> {
-                    numDTO.setTotleNum(totle);
-                    Double percent = BigDecimal.valueOf(numDTO.getNum())
-                            .divide(BigDecimal.valueOf(totle), 4, RoundingMode.HALF_UP)
-                            .doubleValue();
-                    numDTO.setPercent(percent);
-                    String percentStr
-                            = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
-                    numDTO.setPercentStr(percentStr);
-                });
-
                 //降序排序
-                Collections.sort(entryByDeptList, new Comparator<NumDTO>() {
+                Collections.sort(listByDept, new Comparator<DeptNumDTO>() {
                     @Override
-                    public int compare(NumDTO o1, NumDTO o2) {
+                    public int compare(DeptNumDTO o1, DeptNumDTO o2) {
                         return o2.getPercent().compareTo(o1.getPercent());
                     }
                 });
 
-                //top9+其他
-                if (entryByDeptList.size() <= limitCount) {
-                    retList.addAll(entryByDeptList);
+                if (listByDept.size() <= limitCount) {
+                    retMap.put(deptName, listByDept);
                 } else {
-                    int count = 0;
-                    double sumPercent = 0d;
-                    for (NumDTO numDTO : entryByDeptList) {
-                        if (retList.size() < limitCount - 1) {
-                            retList.add(numDTO);
-                            count += numDTO.getNum();
-                            sumPercent = BigDecimal.valueOf(sumPercent)
-                                    .add(BigDecimal.valueOf(numDTO.getPercent()))
-                                    .doubleValue();
-                        } else {
-                            NumDTO otherNumDTO = new NumDTO();
-                            int num = totle - count;
-                            otherNumDTO.setName("其他");
-                            otherNumDTO.setNum(num);
-                            otherNumDTO.setTotleNum(totle);
-                            Double percent = BigDecimal.valueOf(num)
-                                    .divide(BigDecimal.valueOf(totle), 4, RoundingMode.HALF_UP)
-                                    .doubleValue();
-                            otherNumDTO.setPercent(percent);
-                            String percentStr
-                                    = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
-                            otherNumDTO.setPercentStr(percentStr);
-                            retList.add(otherNumDTO);
-                            break;
-                        }
-                    }
+                    retMap.put(deptName, listByDept.subList(0, limitCount));
                 }
-                retMap.put(deptName, retList);
             }
         }
         return retMap;
@@ -579,6 +535,24 @@ public class ConsoleByDeptFacade {
         return page;
     }
 
+    /**
+     * 条目缺陷占比-科室(内页)
+     *
+     * @param filterPageByDeptVO
+     * @return
+     */
+    public IPage<DeptNumDTO> entryGroupByEntryAndDeptInnerPage(FilterPageByDeptVO filterPageByDeptVO) {
+        if (StringUtil.isBlank(filterPageByDeptVO.getDeptName())) {
+            List<DeptBaseDTO> deptList = this.getDept();
+            //默认取第一个科室
+            if (ListUtil.isNotEmpty(deptList)) {
+                filterPageByDeptVO.setDeptName(deptList.get(0).getDeptName());
+            }
+        }
+        filterPageByDeptVOSet(filterPageByDeptVO);
+        IPage<DeptNumDTO> page = qcresultInfoFacade.entryGroupByEntryAndDeptInnerPage(filterPageByDeptVO);
+        return page;
+    }
 
     /**
      * 各科室缺陷占比(组合)

+ 12 - 0
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -476,6 +476,18 @@ public class ConsoleFacade {
         IPage<QcResultPercentDTO> page = qcresultInfoFacade.levelPercentGroupByDeptPage(filterPageVO);
         return page;
     }
+
+    /**
+     * 条目缺陷占比(内页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    public IPage<NumDTO> entryGroupByEntryInnerPage(FilterPageVO filterPageVO) {
+        filterPageVOSet(filterPageVO);
+        IPage<NumDTO> page = qcresultInfoFacade.entryGroupByEntryInnerPage(filterPageVO);
+        return page;
+    }
     //endregion-----------------------分页接口结束-------------------------------
 
     /**

+ 19 - 2
src/main/java/com/diagbot/mapper/QcresultInfoMapper.java

@@ -134,15 +134,32 @@ public interface QcresultInfoMapper extends BaseMapper<QcresultInfo> {
 
     /**
      * 各模块缺陷占比-科室(分页)
+     *
      * @param filterPageByDeptVO
      * @return
      */
-    public IPage<DeptNumDTO> entryCountGroupByCaseAndDeptPage(@Param("filterPageByDeptVO")FilterPageByDeptVO filterPageByDeptVO);
+    public IPage<DeptNumDTO> entryCountGroupByCaseAndDeptPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO);
 
     /**
      * 缺陷详情-科室(分页)
+     *
+     * @param filterPageByDeptVO
+     * @return
+     */
+    public IPage<CaseAndDeptNumDTO> entryCountGroupByEntryAndDeptPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO);
+
+    /**
+     * 条目缺陷占比(内页)
+     *
+     * @return
+     */
+    public IPage<NumDTO> entryGroupByEntryInnerPage(@Param("filterPageVO") FilterPageVO filterPageVO);
+
+    /**
+     * 条目缺陷占比-科室(内页)
+     *
      * @param filterPageByDeptVO
      * @return
      */
-    public IPage<CaseAndDeptNumDTO> entryCountGroupByEntryAndDeptPage(@Param("filterPageByDeptVO")FilterPageByDeptVO filterPageByDeptVO);
+    public IPage<DeptNumDTO> entryGroupByEntryAndDeptInnerPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO);
 }

+ 15 - 0
src/main/java/com/diagbot/service/QcresultInfoService.java

@@ -146,4 +146,19 @@ public interface QcresultInfoService extends IService<QcresultInfo> {
      * @return
      */
     public IPage<CaseAndDeptNumDTO> entryCountGroupByEntryAndDeptPage(@Param("filterPageByDeptVO")FilterPageByDeptVO filterPageByDeptVO);
+
+    /**
+     * 条目缺陷占比(内页)
+     *
+     * @return
+     */
+    public IPage<NumDTO> entryGroupByEntryInnerPage(@Param("filterPageVO") FilterPageVO filterPageVO);
+
+    /**
+     * 条目缺陷占比-科室(内页)
+     *
+     * @param filterPageByDeptVO
+     * @return
+     */
+    public IPage<DeptNumDTO> entryGroupByEntryAndDeptInnerPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO);
 }

+ 21 - 0
src/main/java/com/diagbot/service/impl/QcresultInfoServiceImpl.java

@@ -197,4 +197,25 @@ public class QcresultInfoServiceImpl extends ServiceImpl<QcresultInfoMapper, Qcr
     public IPage<CaseAndDeptNumDTO> entryCountGroupByEntryAndDeptPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO) {
         return baseMapper.entryCountGroupByEntryAndDeptPage(filterPageByDeptVO);
     }
+
+    /**
+     * 条目缺陷占比(内页)
+     *
+     * @return
+     */
+    @Override
+    public IPage<NumDTO> entryGroupByEntryInnerPage(@Param("filterPageVO") FilterPageVO filterPageVO) {
+        return baseMapper.entryGroupByEntryInnerPage(filterPageVO);
+    }
+
+    /**
+     * 条目缺陷占比-科室(内页)
+     *
+     * @param filterPageByDeptVO
+     * @return
+     */
+    @Override
+    public IPage<DeptNumDTO> entryGroupByEntryAndDeptInnerPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO) {
+        return baseMapper.entryGroupByEntryAndDeptInnerPage(filterPageByDeptVO);
+    }
 }

+ 18 - 1
src/main/java/com/diagbot/web/ConsoleByDeptController.java

@@ -119,7 +119,7 @@ public class ConsoleByDeptController {
             notes = "type: 统计维度 1-本月,2-本年(必填)<br>" +
                     "name: 缺陷名称<br>" +
                     "deptName: 科室名称(必填)<br>" +
-                    "casesId: 模块id:243=病案首页 <br>"+
+                    "casesId: 模块id:243=病案首页 <br>" +
                     "casesName: 模块名称<br>")
     @PostMapping("/entryCountGroupByEntryAndDeptPage")
     @SysLogger("entryCountGroupByEntryAndDeptPage")
@@ -141,6 +141,23 @@ public class ConsoleByDeptController {
         return RespDTO.onSuc(data);
     }
 
+    /**
+     * 条目缺陷占比-内页
+     *
+     * @param filterPageByDeptVO
+     * @return
+     */
+    @ApiOperation(value = "条目缺陷占比-内页(分页)-内页[by:zhaops]",
+            notes = "type: 统计维度 1-本月,2-本年(必填)<br>" +
+                    "name: 缺陷名称<br>" +
+                    "deptName: 科室名称(必填)<br>")
+    @PostMapping("/entryGroupByEntryAndDeptInnerPage")
+    @SysLogger("entryGroupByEntryAndDeptInnerPage")
+    public RespDTO<IPage<DeptNumDTO>> entryGroupByEntryAndDeptInnerPage(@RequestBody @Valid FilterPageByDeptVO filterPageByDeptVO) {
+        IPage<DeptNumDTO> data = consoleByDeptFacade.entryGroupByEntryAndDeptInnerPage(filterPageByDeptVO);
+        return RespDTO.onSuc(data);
+    }
+
     /**
      * 各科室缺陷占比(组合)
      *

+ 16 - 3
src/main/java/com/diagbot/web/ConsoleController.java

@@ -163,7 +163,7 @@ public class ConsoleController {
      * @param filterVO
      * @return
      */
-    @ApiOperation(value = "各模块缺陷占比排行[by:zhaops]",
+    @ApiOperation(value = "各模块缺陷占比排行(首页)[by:zhaops]",
             notes = "type: 统计维度 1-本月,2-本年(必填)<br>")
     @PostMapping("/entryCountGroupByCase")
     @SysLogger("entryCountGroupByCase")
@@ -177,7 +177,7 @@ public class ConsoleController {
      * @param filterVO
      * @return
      */
-    @ApiOperation(value = "条目缺陷占比[by:zhaops]",
+    @ApiOperation(value = "条目缺陷占比(首页)[by:zhaops]",
             notes = "type: 统计维度 1-本月,2-本年(必填)<br>")
     @PostMapping("/entryCountGroupByEntry")
     @SysLogger("entryCountGroupByEntry")
@@ -225,7 +225,7 @@ public class ConsoleController {
     @ApiOperation(value = "缺陷详情(分页)[by:zhaops]",
             notes = "type: 统计维度 1-本月,2-本年(必填)<br>" +
                     "deptName: 科室名称 <br>" +
-                    "casesId: 模块id:243=病案首页 <br>"+
+                    "casesId: 模块id:243=病案首页 <br>" +
                     "casesName: 模块名称 <br>")
     @PostMapping("/entryCountGroupByEntryPage")
     @SysLogger("entryCountGroupByEntryPage")
@@ -305,6 +305,19 @@ public class ConsoleController {
         return RespDTO.onSuc(consoleFacade.levelPercentGroupByDeptPage(filterPageVO));
     }
 
+    /**
+     * 条目缺陷占比(内页)
+     *
+     * @param filterPageVO
+     * @return
+     */
+    @ApiOperation(value = "条目缺陷占比(分页)[by:zhaops]",
+            notes = "type: 统计维度 1-本月,2-本年(必填)<br>")
+    @PostMapping("/entryGroupByEntryInnerPage")
+    @SysLogger("entryGroupByEntryInnerPage")
+    public RespDTO<IPage<NumDTO>> entryGroupByEntryInnerPage(@RequestBody @Valid FilterPageVO filterPageVO) {
+        return RespDTO.onSuc(consoleFacade.entryGroupByEntryInnerPage(filterPageVO));
+    }
     //endregion-----------------------分页接口结束-------------------------------
 
     /**

+ 287 - 2
src/main/resources/mapper/QcresultInfoMapper.xml

@@ -169,8 +169,16 @@
         e.`name`
     </select>
 
-    <!-- 条目缺陷分组统计 -->
+    <!-- 条目缺陷占比(首页) -->
     <select id="entryCountGroupByEntry" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
+        SELECT
+        t1.NAME AS NAME,
+        t1.num AS num,
+        t2.mrNum AS totleNum,
+        Round( t1.num / t2.mrNum, 4 ) AS percent,
+        CONCAT( Round( t1.num / t2.mrNum * 100, 2 ), '%' ) AS percentStr
+        FROM
+        (
         SELECT
         e.id,
         e.NAME,
@@ -208,6 +216,114 @@
         GROUP BY
         e.id,
         e.NAME
+        ) t1,
+        (
+        SELECT
+        count(*) AS mrNum
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        <![CDATA[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
+        ORDER BY
+        percent DESC
+    </select>
+
+    <!-- 条目缺陷占比(内页) -->
+    <select id="entryGroupByEntryInnerPage" resultType="com.diagbot.dto.NumDTO">
+        SELECT t.*
+        FROM
+        (SELECT
+        t1.NAME AS NAME,
+        t1.num AS num,
+        t2.mrNum AS totleNum,
+        Round( t1.num / t2.mrNum, 4 ) AS percent,
+        CONCAT( Round( t1.num / t2.mrNum * 100, 2 ), '%' ) AS percentStr
+        FROM
+        (
+        SELECT
+        e.id,
+        e.NAME,
+        count(*) AS num
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c,
+        med_qcresult_detail d,
+        qc_cases_entry 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 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.cases_id
+        AND d.cases_entry_id = e.id
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageVO.hospitalId}
+        </if>
+        <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
+        </if>
+        <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
+        </if>
+        GROUP BY
+        e.id,
+        e.NAME
+        ) t1,
+        (
+        SELECT
+        count(*) AS mrNum
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageVO.hospitalId}
+        </if>
+        <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
+        </if>
+        <if test="filterPageVO.endDate != null and filterPageVO.endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
+        </if>
+        ) t2
+        )t
     </select>
 
     <!-- 质控平均分按科室统计 -->
@@ -346,8 +462,18 @@
         a.beh_dept_name
     </select>
 
-    <!-- 条目缺陷分组统计 -->
+    <!-- 条目缺陷占比-科室(首页) -->
     <select id="entryCountGroupByEntryAndDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.DeptNumDTO">
+        SELECT
+        t1.deptId AS deptId,
+        t1.deptName AS deptName,
+        t1.NAME AS NAME,
+        t1.num AS num,
+        t2.mrNum AS totleNum,
+        Round( t1.num / t2.mrNum, 4 ) AS percent,
+        CONCAT( Round( t1.num / t2.mrNum * 100, 2 ), '%' ) AS percentStr
+        FROM
+        (
         SELECT
         e.id,
         e.NAME,
@@ -396,6 +522,165 @@
         e.NAME,
         a.beh_dept_id,
         a.beh_dept_name
+        ) t1,
+        (
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        count(*) AS mrNum
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c,
+        sys_user_dept f
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.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 = f.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND a.beh_dept_id = f.dept_id
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="userId!=null">
+            AND f.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})]]>
+        </if>
+        <if test="endDate != null and endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) t2
+        WHERE
+        t1.deptId = t2.deptId
+        AND t1.deptName = t2.deptName
+        ORDER BY
+        percent DESC,
+        num DESC
+    </select>
+
+    <!-- 条目缺陷占比-科室(内页) -->
+    <select id="entryGroupByEntryAndDeptInnerPage" resultType="com.diagbot.dto.DeptNumDTO">
+        SELECT t.*
+        FROM
+        (SELECT
+        t1.deptId AS deptId,
+        t1.deptName AS deptName,
+        t1.NAME AS NAME,
+        t1.num AS num,
+        t2.mrNum AS totleNum,
+        Round( t1.num / t2.mrNum, 4 ) AS percent,
+        CONCAT( Round( t1.num / t2.mrNum * 100, 2 ), '%' ) AS percentStr
+        FROM
+        (
+        SELECT
+        e.id,
+        e.NAME,
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        count(*) AS num
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c,
+        med_qcresult_detail d,
+        qc_cases_entry e,
+        sys_user_dept f
+        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.hospital_id = f.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.cases_id
+        AND d.cases_entry_id = e.id
+        AND a.beh_dept_id = f.dept_id
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageByDeptVO.userId!=null">
+            AND f.user_id = #{filterPageByDeptVO.userId}
+        </if>
+        <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
+        </if>
+        <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
+        </if>
+        <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
+        </if>
+        <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
+            AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
+        </if>
+        GROUP BY
+        e.id,
+        e.NAME,
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) t1,
+        (
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        count(*) AS mrNum
+        FROM
+        med_behospital_info a,
+        med_home_page b,
+        med_qcresult_info c,
+        sys_user_dept f
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.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 = f.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND a.beh_dept_id = f.dept_id
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageByDeptVO.userId!=null">
+            AND f.user_id = #{filterPageByDeptVO.userId}
+        </if>
+        <if test="filterPageByDeptVO.hospitalId != null and filterPageByDeptVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageByDeptVO.hospitalId}
+        </if>
+        <if test="filterPageByDeptVO.startDate != null and filterPageByDeptVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageByDeptVO.startDate})]]>
+        </if>
+        <if test="filterPageByDeptVO.endDate != null and filterPageByDeptVO.endDate != ''">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageByDeptVO.endDate})]]>
+        </if>
+        <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
+            AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) t2
+        WHERE
+        t1.deptId = t2.deptId
+        AND t1.deptName = t2.deptName
+        )t
     </select>
 
     <!-- 按模块统计质控缺陷数(分页) -->