Browse Source

控制台(科室)-统计详情

zhaops 5 years ago
parent
commit
1cf94e8c65

+ 147 - 1
src/main/java/com/diagbot/facade/ConsoleByDeptFacade.java

@@ -1,13 +1,19 @@
 package com.diagbot.facade;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.DeptBaseDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.NumDTO;
+import com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
 import com.diagbot.util.BeanUtil;
+import com.diagbot.util.DateUtil;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.ListUtil;
+import com.diagbot.util.StringUtil;
 import com.diagbot.util.SysUserUtils;
 import com.diagbot.vo.FilterByDeptVO;
+import com.diagbot.vo.FilterPageByDeptVO;
 import com.diagbot.vo.HPFilterByDeptVO;
 import com.diagbot.vo.QcresultFilterByDeptVO;
 import com.google.common.collect.Lists;
@@ -19,6 +25,7 @@ import java.math.RoundingMode;
 import java.text.DecimalFormat;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
@@ -452,4 +459,143 @@ public class ConsoleByDeptFacade {
         List<DeptBaseDTO> deptList = basDeptInfoFacade.getDeptByUser(filterByDeptVO);
         return deptList;
     }
-}
+
+
+    /**
+     * 过滤条件设置
+     *
+     * @param filterPageByDeptVO
+     */
+    private void filterPageByDeptVOSet(FilterPageByDeptVO filterPageByDeptVO) {
+        String hospitalId = SysUserUtils.getCurrentHospitalID();
+        String userId = SysUserUtils.getCurrentPrincipleID();
+        String startDate = "";
+        String endDate = "";
+        Date date = new Date();
+
+        //1-本月,2-本年,3-上月,4-去年本月,5-去年
+        if (filterPageByDeptVO.getType().equals(1) || filterPageByDeptVO.getType().equals(2)) {
+            startDate = filterFacade.getStartDateStr(filterPageByDeptVO.getType(), null);
+            endDate = filterFacade.getEndDateStr(filterPageByDeptVO.getType(), null);
+        } else if (filterPageByDeptVO.getType().equals(3) || filterPageByDeptVO.getType().equals(5)) {
+            startDate = filterFacade.getLastStartDateStr(filterPageByDeptVO.getType());
+            endDate = filterFacade.getLastEndDateStr(filterPageByDeptVO.getType());
+        } else if (filterPageByDeptVO.getType().equals(4)) {
+            String year = DateUtil.getYear(date);
+            startDate = filterFacade.getStartDateStr(filterPageByDeptVO.getType(), Integer.valueOf(year) - 1);
+            endDate = filterFacade.getEndDateStr(filterPageByDeptVO.getType(), Integer.valueOf(year) - 1);
+        }
+
+        filterPageByDeptVO.setStartDate(startDate);
+        filterPageByDeptVO.setEndDate(endDate);
+        filterPageByDeptVO.setHospitalId(hospitalId);
+        filterPageByDeptVO.setUserId(Long.valueOf(userId));
+    }
+
+    /**
+     * 各模块缺陷占比-科室(分页)
+     *
+     * @param filterPageByDeptVO
+     * @return
+     */
+    public IPage<DeptNumDTO> entryCountGroupByCaseAndDeptPage(FilterPageByDeptVO filterPageByDeptVO) {
+        if (StringUtil.isBlank(filterPageByDeptVO.getDeptName())) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入科室");
+        }
+        DecimalFormat df = new DecimalFormat("#0.00");
+        filterPageByDeptVOSet(filterPageByDeptVO);
+        long current = filterPageByDeptVO.getCurrent();
+        long size = filterPageByDeptVO.getSize();
+        filterPageByDeptVO.setCurrent(0);
+        filterPageByDeptVO.setSize(filterPageByDeptVO.getTotal());
+        IPage<DeptNumDTO> page = qcresultInfoFacade.entryCountGroupByCaseAndDeptPage(filterPageByDeptVO);
+        //各科室模块-质控结果
+        List<DeptNumDTO> records = page.getRecords();
+        Map<String, List<DeptNumDTO>> recordMap = ListUtil.isEmpty(records)
+                ? new HashMap<>()
+                : EntityUtil.makeEntityListMap(records, "deptName");
+        //获取每个科室的病历数
+        QcresultFilterByDeptVO qcresultFilterByDeptVO = new QcresultFilterByDeptVO();
+        BeanUtil.copyProperties(filterPageByDeptVO, qcresultFilterByDeptVO);
+        List<NumDTO> mrNumList = qcresultInfoFacade.resultCountByDept(qcresultFilterByDeptVO);
+        Map<String, NumDTO> mrMap = ListUtil.isEmpty(mrNumList)
+                ? new HashMap<>()
+                : EntityUtil.makeEntityMap(mrNumList, "name");
+        //各模块缺陷数
+        List<NumDTO> standardCaseList = qcCasesFacade.entryGroupByCase();
+        if (ListUtil.isEmpty(standardCaseList)) {
+            return null;
+        }
+        Map<String, NumDTO> standardCaseMap
+                = EntityUtil.makeEntityMap(standardCaseList, "name");
+        if (ListUtil.isNotEmpty(records)) {
+            Integer mrNum = mrMap.containsKey(filterPageByDeptVO.getDeptName())
+                    ? mrMap.get(filterPageByDeptVO.getDeptName()).getNum()
+                    : 0;
+            records.forEach(item -> {
+                if (!standardCaseMap.containsKey(item.getName())) {
+                    item.setTotleNum(0);
+                    item.setPercent(0d);
+                    item.setPercentStr("0%");
+                } else {
+                    Integer totleNum = standardCaseMap.get(item.getName()).getNum() * mrNum;
+                    item.setTotleNum(totleNum);
+                    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.setPercent(percent);
+                    item.setPercentStr(percentStr);
+                }
+            });
+            //降序排序
+            Collections.sort(records, new Comparator<NumDTO>() {
+                @Override
+                public int compare(NumDTO o1, NumDTO o2) {
+                    return o2.getPercent().compareTo(o1.getPercent());
+                }
+            });
+        }
+
+        List<DeptNumDTO> retList = Lists.newLinkedList();
+        if (current * size + size > records.size()) {
+            retList = records.subList(Long.valueOf(current * size).intValue(), records.size());
+        } else {
+            retList = records.subList(Long.valueOf(current * size).intValue(), Long.valueOf(current * size + size).intValue());
+        }
+        page.setCurrent(current);
+        page.setSize(size);
+        page.setRecords(retList);
+        return page;
+    }
+
+    /**
+     * 条目缺陷占比-科室(分页)
+     *
+     * @param filterPageByDeptVO
+     * @return
+     */
+    public IPage<DeptNumDTO> entryCountGroupByEntryAndDeptPage(FilterPageByDeptVO filterPageByDeptVO) {
+        if (StringUtil.isBlank(filterPageByDeptVO.getDeptName())) {
+            throw new CommonException(CommonErrorCode.PARAM_IS_NULL, "请输入科室");
+        }
+        DecimalFormat df = new DecimalFormat("#0.00");
+        filterPageByDeptVOSet(filterPageByDeptVO);
+        IPage<DeptNumDTO> page = qcresultInfoFacade.entryCountGroupByEntryAndDeptPage(filterPageByDeptVO);
+        List<DeptNumDTO> records = page.getRecords();
+        if (ListUtil.isNotEmpty(records)) {
+            records.forEach(item -> {
+                Double percent = BigDecimal.valueOf(item.getNum())
+                        .divide(BigDecimal.valueOf(item.getTotleNum()), 4, RoundingMode.HALF_UP)
+                        .doubleValue();
+                item.setPercent(percent);
+                String percentStr
+                        = df.format(BigDecimal.valueOf(percent).multiply(BigDecimal.valueOf(100))) + "%";
+                item.setPercentStr(percentStr);
+            });
+        }
+        page.setRecords(records);
+        return page;
+    }
+}

+ 15 - 0
src/main/java/com/diagbot/mapper/QcresultInfoMapper.java

@@ -8,6 +8,7 @@ import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.QcResultPercentDTO;
 import com.diagbot.entity.QcresultInfo;
 import com.diagbot.vo.FilterByDeptVO;
+import com.diagbot.vo.FilterPageByDeptVO;
 import com.diagbot.vo.FilterPageVO;
 import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcresultFilterByDeptVO;
@@ -130,4 +131,18 @@ public interface QcresultInfoMapper extends BaseMapper<QcresultInfo> {
      * @return
      */
     public IPage<QcResultPercentDTO> levelPercentGroupByDeptPage(@Param("filterPageVO") FilterPageVO filterPageVO);
+
+    /**
+     * 各模块缺陷占比-科室(分页)
+     * @param filterPageByDeptVO
+     * @return
+     */
+    public IPage<DeptNumDTO> entryCountGroupByCaseAndDeptPage(@Param("filterPageByDeptVO")FilterPageByDeptVO filterPageByDeptVO);
+
+    /**
+     * 条目缺陷占比-科室(分页)
+     * @param filterPageByDeptVO
+     * @return
+     */
+    public IPage<DeptNumDTO> entryCountGroupByEntryAndDeptPage(@Param("filterPageByDeptVO")FilterPageByDeptVO filterPageByDeptVO);
 }

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

@@ -8,6 +8,7 @@ import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.QcResultPercentDTO;
 import com.diagbot.entity.QcresultInfo;
 import com.diagbot.vo.FilterByDeptVO;
+import com.diagbot.vo.FilterPageByDeptVO;
 import com.diagbot.vo.FilterPageVO;
 import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcresultFilterByDeptVO;
@@ -131,4 +132,18 @@ public interface QcresultInfoService extends IService<QcresultInfo> {
      * @return
      */
     public IPage<QcResultPercentDTO> levelPercentGroupByDeptPage(@Param("filterPageVO") FilterPageVO filterPageVO);
+
+    /**
+     * 各模块缺陷占比-科室(分页)
+     * @param filterPageByDeptVO
+     * @return
+     */
+    public IPage<DeptNumDTO> entryCountGroupByCaseAndDeptPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO);
+
+    /**
+     * 条目缺陷占比-科室(分页)
+     * @param filterPageByDeptVO
+     * @return
+     */
+    public IPage<DeptNumDTO> entryCountGroupByEntryAndDeptPage(@Param("filterPageByDeptVO")FilterPageByDeptVO filterPageByDeptVO);
 }

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

@@ -10,6 +10,7 @@ import com.diagbot.entity.QcresultInfo;
 import com.diagbot.mapper.QcresultInfoMapper;
 import com.diagbot.service.QcresultInfoService;
 import com.diagbot.vo.FilterByDeptVO;
+import com.diagbot.vo.FilterPageByDeptVO;
 import com.diagbot.vo.FilterPageVO;
 import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.QcresultFilterByDeptVO;
@@ -174,4 +175,26 @@ public class QcresultInfoServiceImpl extends ServiceImpl<QcresultInfoMapper, Qcr
     public IPage<QcResultPercentDTO> levelPercentGroupByDeptPage(@Param("filterPageVO") FilterPageVO filterPageVO) {
         return baseMapper.levelPercentGroupByDeptPage(filterPageVO);
     }
+
+    /**
+     * 各模块缺陷占比-科室(分页)
+     *
+     * @param filterPageByDeptVO
+     * @return
+     */
+    @Override
+    public IPage<DeptNumDTO> entryCountGroupByCaseAndDeptPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO) {
+        return baseMapper.entryCountGroupByCaseAndDeptPage(filterPageByDeptVO);
+    }
+
+    /**
+     * 条目缺陷占比-科室(分页)
+     *
+     * @param filterPageByDeptVO
+     * @return
+     */
+    @Override
+    public IPage<DeptNumDTO> entryCountGroupByEntryAndDeptPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO) {
+        return baseMapper.entryCountGroupByEntryAndDeptPage(filterPageByDeptVO);
+    }
 }

+ 18 - 0
src/main/java/com/diagbot/vo/FilterPageByDeptVO.java

@@ -0,0 +1,18 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/5/15 11:32
+ */
+@Getter
+@Setter
+public class FilterPageByDeptVO extends FilterPageVO {
+    @ApiModelProperty(hidden = true)
+    private Long userId;
+    private String deptName;
+}

+ 21 - 0
src/main/java/com/diagbot/web/ConsoleByDeptController.java

@@ -1,10 +1,13 @@
 package com.diagbot.web;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.DeptBaseDTO;
+import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.ConsoleByDeptFacade;
 import com.diagbot.vo.FilterByDeptVO;
+import com.diagbot.vo.FilterPageByDeptVO;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -73,4 +76,22 @@ public class ConsoleByDeptController {
         List<DeptBaseDTO> data = consoleByDeptFacade.getDept();
         return RespDTO.onSuc(data);
     }
+
+    @ApiOperation(value = "各模块缺陷占比排名-科室(分页)[by:zhaops]",
+            notes = "type: 统计维度 1-本月,2-本年(必填)<br>")
+    @PostMapping("/entryCountGroupByCaseAndDeptPage")
+    @SysLogger("entryCountGroupByCaseAndDeptPage")
+    public RespDTO<IPage<DeptNumDTO>> entryCountGroupByCaseAndDeptPage(@RequestBody FilterPageByDeptVO filterPageByDeptVO) {
+        IPage<DeptNumDTO> data = consoleByDeptFacade.entryCountGroupByCaseAndDeptPage(filterPageByDeptVO);
+        return RespDTO.onSuc(data);
+    }
+
+    @ApiOperation(value = "条目缺陷占比-科室(分页)[by:zhaops]",
+            notes = "type: 统计维度 1-本月,2-本年(必填)<br>")
+    @PostMapping("/entryCountGroupByEntryAndDeptPage")
+    @SysLogger("entryCountGroupByEntryAndDeptPage")
+    public RespDTO<IPage<DeptNumDTO>> entryCountGroupByEntryAndDeptPage(@RequestBody FilterPageByDeptVO filterPageByDeptVO) {
+        IPage<DeptNumDTO> data = consoleByDeptFacade.entryCountGroupByEntryAndDeptPage(filterPageByDeptVO);
+        return RespDTO.onSuc(data);
+    }
 }

+ 16 - 15
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -634,7 +634,9 @@
 
     <!-- 各科室缺陷占比排行(分页) -->
     <select id="resultStatisticsByDeptPage" resultType="com.diagbot.dto.NumDTO">
-        SELECT
+        SELECT t.*
+        FROM
+        (SELECT
         t1.beh_dept_name AS NAME,
         t1.num AS num,
         t2.totle AS totleNum,
@@ -642,7 +644,6 @@
         concat( round( t1.num / t2.totle * 100, 2 ), '%' ) AS percentStr
         FROM
         (
-        (
         SELECT
         a.beh_dept_id,
         a.beh_dept_name,
@@ -660,14 +661,14 @@
         AND b.is_deleted = 'N'
         AND c.is_deleted = 'N'
         <![CDATA[AND a.qc_type_id <>0 ]]>
-        <if test="hospitalId != null and hospitalId != ''">
-            AND a.hospital_id = #{hospitalId}
+        <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageVO.hospitalId}
         </if>
-        <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
         </if>
-        <if test="endDate != null and endDate != ''">
-            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        <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 a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
@@ -694,19 +695,19 @@
         AND b.is_deleted = 'N'
         AND c.is_deleted = 'N'
         <![CDATA[AND a.qc_type_id <>0 ]]>
-        <if test="hospitalId != null and hospitalId != ''">
-            AND a.hospital_id = #{hospitalId}
+        <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageVO.hospitalId}
         </if>
-        <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
         </if>
-        <if test="endDate != null and endDate != ''">
-            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        <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 a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')
         </if>
         ) t2
-        )
+        )t
     </select>
 </mapper>

+ 7 - 7
src/main/resources/mapper/HomePageMapper.xml

@@ -239,7 +239,7 @@
     </select>
 
     <!-- 按科室统计平均费用(分页) -->
-    <select id="getAverageFeePage"  resultType="com.diagbot.dto.AverageStatisticsDTO">
+    <select id="getAverageFeePage"   resultType="com.diagbot.dto.AverageStatisticsDTO">
         SELECT t.*
         FROM
         (SELECT
@@ -257,14 +257,14 @@
         AND a.is_deleted = 'N'
         AND b.is_deleted = 'N'
         <![CDATA[AND a.qc_type_id <>0 ]]>
-        <if test="hospitalId != null and hospitalId != ''">
-            AND a.hospital_id = #{hospitalId}
+        <if test="filterPageVO.hospitalId != null and filterPageVO.hospitalId != ''">
+            AND a.hospital_id = #{filterPageVO.hospitalId}
         </if>
-        <if test="startDate != null and startDate != ''">
-            <![CDATA[ and a.leave_hospital_date >= DATE(#{startDate})]]>
+        <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{filterPageVO.startDate})]]>
         </if>
-        <if test="endDate != null and endDate != ''">
-            <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
+        <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 a.beh_dept_name like CONCAT('%', #{filterPageVO.name},'%')

+ 172 - 1
src/main/resources/mapper/QcresultInfoMapper.xml

@@ -554,7 +554,7 @@
         GROUP BY
         a.beh_dept_id,
         a.beh_dept_name
-        ORDER BY ROUND( sum( CAST( c.score_res AS DECIMAL ))/ count(*), 2 ) DESC )
+        ORDER BY ROUND( sum( CAST( c.score_res AS DECIMAL ))/ count(*), 2 ) DESC ) t
     </select>
 
     <!-- 按科室统计质控病历数(分页) -->
@@ -603,4 +603,175 @@
         ROUND( sum( c.`level` = '乙' )/ count(*)* 100, 2 ) DESC,
         ROUND( sum( c.`level` = '丙' )/ count(*)* 100, 2 ) DESC) t
     </select>
+
+    <!-- 按模块统计质控缺陷数-科室(分页) -->
+    <select id="entryCountGroupByCaseAndDeptPage" resultType="com.diagbot.dto.DeptNumDTO">
+        SELECT
+        d.cases_id AS id,
+        e.NAME AS 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 e,
+        qc_cases_entry f,
+        sys_user_dept g
+        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.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
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageByDeptVO.userId!=null">
+            AND g.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.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
+    </select>
+
+    <!-- 条目缺陷分组统计-科室(分页) -->
+    <select id="entryCountGroupByEntryAndDeptPage"  resultType="com.diagbot.dto.DeptNumDTO">
+        SELECT
+        t.*
+        FROM
+        (
+        SELECT
+        t1.id,
+        t1.NAME,
+        count(*) AS num,
+        t2.totleNum
+        FROM
+        (
+        SELECT
+        d.id,
+        d.NAME,
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName
+        FROM
+        med_behospital_info a,
+        med_home_page 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 a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.hospital_id = e.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND c.cases_id = d.cases_id
+        AND c.cases_entry_id = d.id
+        AND a.beh_dept_id = e.dept_id
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageByDeptVO.userId!=null">
+            AND e.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.name != null and filterPageByDeptVO.name != ''">
+            AND d.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
+        </if>
+        <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
+            AND a.beh_dept_name like CONCAT('%', #{filterPageByDeptVO.deptName},'%')
+        </if>
+        ) t1,(
+        SELECT
+        count(*) AS totleNum
+        FROM
+        med_behospital_info a,
+        med_home_page 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 a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.hospital_id = e.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND c.cases_id = d.cases_id
+        AND c.cases_entry_id = d.id
+        AND a.beh_dept_id = e.dept_id
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="filterPageByDeptVO.userId!=null">
+            AND e.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.name != null and filterPageByDeptVO.name != ''">
+            AND d.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
+        </if>
+        <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
+            AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
+        </if>
+        ) t2
+        GROUP BY
+        t1.id,
+        t1.NAME,
+        t1.deptId,
+        t1.deptName
+        ORDER BY
+        count(*) DESC
+        )t
+    </select>
 </mapper>