Browse Source

Merge remote-tracking branch 'origin/dev/20200624_1.3.6.2' into debug

zhaops 5 years atrás
parent
commit
6a6a5154ec

+ 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;
     }
 

+ 12 - 12
src/main/java/com/diagbot/dto/EntryStatisticsDTO.java

@@ -26,11 +26,11 @@ public class EntryStatisticsDTO {
     /**
      * 未在24小时内完成会诊条目id
      */
-    private Long consultationEntryId;
+    private Long consultationEntryId = 2511L;
     /**
      * 未在24小时内完成会诊条目名称
      */
-    private String consultationEntryName;
+    private String consultationEntryName = "普通会诊未在24小时内完成";
     /**
      * 未在24小时内完成会诊率
      */
@@ -46,11 +46,11 @@ public class EntryStatisticsDTO {
     /**
      * 手术记录名称不匹配条目id
      */
-    private Long operationNameEntryId;
+    private Long operationNameEntryId = 2594L;
     /**
      * 手术记录名称不匹配条目名称
      */
-    private String operationNameEntryName;
+    private String operationNameEntryName = "首页手术名称与手术记录不一致";
     /**
      * 手术记录名称不匹配数
      */
@@ -66,11 +66,11 @@ public class EntryStatisticsDTO {
     /**
      * 术后首程未在15分钟内完成条目id
      */
-    private Long operation15MinuteEntryId;
+    private Long operation15MinuteEntryId = 2166L;
     /**
      * 术后首程未在15分钟内完成条目名称
      */
-    private String operation15MinuteEntryName;
+    private String operation15MinuteEntryName = "术后首程未在手术结束1小时内完成";
     /**
      * 术后首程未在15分钟内完成数
      */
@@ -86,11 +86,11 @@ public class EntryStatisticsDTO {
     /**
      * 病案首页手术时间不匹配条目id
      */
-    private Long operationTimeEntryId;
+    private Long operationTimeEntryId = 2973L;
     /**
      * 病案首页手术时间不匹配条目名称
      */
-    private String operationTimeEntryName;
+    private String operationTimeEntryName = "手术日期与手术记录中手术日期不一致";
     /**
      * 病案首页手术时间不匹配数
      */
@@ -110,11 +110,11 @@ public class EntryStatisticsDTO {
     /**
      * 未在6小时内书写危急值条目id
      */
-    private Long crisisEntryId;
+    private Long crisisEntryId = 2419L;
     /**
      * 未在6小时内书写危急值条目名称
      */
-    private String crisisEntryName;
+    private String crisisEntryName = "危急值记录未在接到危急值报告后6小时内完成";
     /**
      * 未在6小时内书写危急值记录数
      */
@@ -134,11 +134,11 @@ public class EntryStatisticsDTO {
     /**
      * 阶段小节未书写条目id
      */
-    private Long stageSummaryEntryId;
+    private Long stageSummaryEntryId = 2495L;
     /**
      * 阶段小节未书写条目名称
      */
-    private String stageSummaryEntryName;
+    private String stageSummaryEntryName = "无阶段小结";
     /**
      * 阶段小节未书写数
      */

+ 1 - 1
src/main/java/com/diagbot/facade/ConsoleFacade.java

@@ -453,7 +453,7 @@ public class ConsoleFacade {
     }
 
     /**
-     * 各科室缺陷占比(组合)-全院-根据内外科系统统计
+     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州)
      *
      * @param filterOrderVO
      * @return

+ 2 - 2
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -182,7 +182,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
     public IPage<DeptNumDTO> resultStatisticsByDeptAndDoctorPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO);
 
     /**
-     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州)
+     * 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室
      *
      * @param filterOrderVO
      * @return
@@ -190,7 +190,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
     public List<LevelStatisticsTZDTO> levelStatisticsByDeptClass(FilterOrderVO filterOrderVO);
 
     /**
-     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(上级科室允许为空)(台州)
+     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州)
      *
      * @param filterOrderVO
      * @return

+ 2 - 2
src/main/java/com/diagbot/service/BehospitalInfoService.java

@@ -183,7 +183,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
     public IPage<DeptNumDTO> resultStatisticsByDeptAndDoctorPage(@Param("filterPageByDeptVO") FilterPageByDeptVO filterPageByDeptVO);
 
     /**
-     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州
+     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(关联上级科室
      *
      * @param filterOrderVO
      * @return
@@ -191,7 +191,7 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
     public List<LevelStatisticsTZDTO> levelStatisticsByDeptClass(FilterOrderVO filterOrderVO);
 
     /**
-     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(上级科室允许为空)(台州)
+     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州)
      *
      * @param filterOrderVO
      * @return

+ 2 - 2
src/main/java/com/diagbot/service/impl/BehospitalInfoServiceImpl.java

@@ -246,7 +246,7 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     }
 
     /**
-     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州)
+     * 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室
      *
      * @param filterOrderVO
      * @return
@@ -257,7 +257,7 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     }
 
     /**
-     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(上级科室允许为空)(台州)
+     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州)
      *
      * @param filterOrderVO
      * @return

+ 2 - 2
src/main/java/com/diagbot/web/ConsoleController.java

@@ -394,12 +394,12 @@ public class ConsoleController {
     }
 
     /**
-     * 各科室缺陷占比(组合)-全院-根据内外科系统统计
+     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州)
      *
      * @param filterOrderVO
      * @return
      */
-    @ApiOperation(value = "各科室缺陷占比(组合)-全院-根据内外科系统统计[by:zhaops]",
+    @ApiOperation(value = "各科室缺陷占比(组合)-全院-根据内外科系统统计(台州)[by:zhaops]",
             notes = "type: 统计维度 1-本月,2-本年(必填)<br>" +
                     "level: 病历等级 <br>" +
                     "name: 科室名称 <br>" +

+ 160 - 176
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -617,8 +617,11 @@
         AND a.hospital_id = c.hospital_id
         AND a.behospital_code = b.behospital_code
         AND a.beh_dept_id = c.dept_id
-        AND ( b.age IS NULL OR b.age = '-' OR b.age = '' )
-        <![CDATA[AND ( b.newborn_month IS NOT NULL OR b.newborn_month <> '' OR b.newborn_day IS NOT NULL OR b.newborn_day <> '' )]]>
+        -- AND ( b.age IS NULL OR b.age = '-' OR b.age = '' )
+        AND (
+        ( IFNULL( b.newborn_day, '' ) != '' AND b.newborn_day != '0' )
+        OR ( IFNULL( b.newborn_month, '' )!= '' AND b.newborn_month != '0' )
+        )
         AND a.is_placefile = '1'
         <![CDATA[AND a.qc_type_id <>0 ]]>
         <if test="userId!=null">
@@ -929,33 +932,18 @@
         SELECT
         a.beh_dept_id AS deptId,
         a.beh_dept_name AS deptName,
-        count( DISTINCT c.id ) AS mrNum,
+        count(*) AS mrNum,
         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( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
-        COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
-        COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
-        ) AS firstLevelPercent,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
-        ) AS secondLevelPercent,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
-        ) AS thirdLevelPercent,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
-        100, 2 ),
-        '%'
-        ) AS firstLevelPercentStr,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
-        100, 2 ),
-        '%'
-        ) AS secondLevelPercentStr,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
-        100, 2 ),
-        '%'
-        ) AS thirdLevelPercentStr
+        ROUND( avg( CAST(c.score_res as DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
+        SUM( c.`level` = '甲' ) AS firstLevelNum,
+        SUM( c.`level` = '乙' ) AS secondLevelNum,
+        SUM( c.`level` = '丙' ) AS thirdLevelNum,
+        ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
+        ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
+        ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
+        concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
+        concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
+        concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
         FROM
         med_behospital_info a,
         med_qcresult_info c
@@ -965,7 +953,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="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
@@ -1007,7 +995,7 @@
         AND d.cases_id = e.cases_id
         AND d.cases_entry_id = e.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>
@@ -1074,7 +1062,7 @@
         </if>
     </select>
 
-    <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州 -->
+    <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计-关联上级科室 -->
     <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
             resultType="com.diagbot.dto.LevelStatisticsTZDTO">
         SELECT
@@ -1281,7 +1269,7 @@
         </if>
     </select>
 
-    <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(上级科室允许为空) -->
+    <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
     <select id="levelStatisticsByDeptClass_TZ" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsTZDTO">
         SELECT
         t1.deptId,
@@ -1308,27 +1296,18 @@
         tt1.deptName,
         e.dept_id AS deptClassId,
         e.dept_name AS deptClass,
-        count( DISTINCT tt1.behospitalCode ) AS mrNum,
+        count(*) AS mrNum,
         ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
-        ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
-        COUNT( DISTINCT CASE WHEN tt1.`level` = '甲' THEN tt1.behospitalCode END ) AS firstLevelNum,
-        COUNT( DISTINCT CASE WHEN tt1.`level` = '乙' THEN tt1.behospitalCode END ) AS secondLevelNum,
-        COUNT( DISTINCT CASE WHEN tt1.`level` = '丙' THEN tt1.behospitalCode END ) AS thirdLevelNum,
-        ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '甲' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode ), 4 ) AS firstLevelPercent,
-        ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '乙' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode ), 4 ) AS secondLevelPercent,
-        ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '丙' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode ), 4 ) AS thirdLevelPercent,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '甲' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode )* 100, 2 ),
-        '%'
-        ) AS firstLevelPercentStr,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '乙' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode )* 100, 2 ),
-        '%'
-        ) AS secondLevelPercentStr,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN tt1.`level` = '丙' THEN tt1.behospitalCode END )/ count( DISTINCT tt1.behospitalCode )* 100, 2 ),
-        '%'
-        ) AS thirdLevelPercentStr
+        ROUND( avg( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
+        sum( tt1.`level` = '甲' ) AS firstLevelNum,
+        sum( tt1.`level` = '乙' ) AS secondLevelNum,
+        sum( tt1.`level` = '丙' ) AS thirdLevelNum,
+        ROUND( sum( tt1.`level` = '甲' )/ count( * ), 4 ) AS firstLevelPercent,
+        ROUND( sum( tt1.`level` = '乙' )/ count( * ), 4 ) AS secondLevelPercent,
+        ROUND( sum( tt1.`level` = '丙' )/ count( * ), 4 ) AS thirdLevelPercent,
+        concat( ROUND( sum( tt1.`level` = '甲' )/ count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
+        concat( ROUND( sum( tt1.`level` = '乙' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr,
+        concat( ROUND( sum( tt1.`level` = '丙' )/ count( * )* 100, 2 ), '%' ) AS thirdLevelPercentStr
         FROM
         (
         SELECT
@@ -1352,7 +1331,8 @@
         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.is_placefile = '1'
+        AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
@@ -1417,7 +1397,8 @@
         AND d.cases_entry_id = e.id
         AND a.beh_dept_id = f.dept_id
         AND a.is_placefile = '1'
-        <![CDATA[AND a.qc_type_id <>0 ]]>
+        AND a.is_placefile = '1'
+        AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
@@ -1525,21 +1506,15 @@
         SELECT
         a.beh_dept_id AS deptId,
         a.beh_dept_name AS deptName,
-        count( DISTINCT a.behospital_code ) AS mrNum,
+        count( * ) AS mrNum,
         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( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END ) AS firstLevelNum,
-        COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
-        '%'
-        ) AS firstLevelPercentStr,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
-        '%'
-        ) AS secondLevelPercentStr
+        ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
+        SUM( c.`level` = '合格' ) AS firstLevelNum,
+        SUM( c.`level` = '不合格' ) AS secondLevelNum,
+        ROUND( SUM( c.`level` = '合格' )/ count( * ), 4 ) AS firstLevelPercent,
+        ROUND( SUM( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
+        concat( ROUND( SUM( c.`level` = '合格' )/ count( * )* 100, 2 ),'%' ) AS firstLevelPercentStr,
+        concat( ROUND( SUM( c.`level` = '不合格' )/ count( * )* 100, 2 ),'%' ) AS secondLevelPercentStr
         FROM
         med_behospital_info a,
         med_qcresult_cases c
@@ -1763,33 +1738,18 @@
         SELECT
         a.doctor_id AS doctorId,
         a.doctor_name AS doctorName,
-        count( DISTINCT c.id ) AS mrNum,
-        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( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
-        COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END ) AS secondLevelNum,
-        COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id ), 4
-        ) AS firstLevelPercent,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id ), 4
-        ) AS secondLevelPercent,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id ), 4
-        ) AS thirdLevelPercent,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
-        100, 2 ),
-        '%'
-        ) AS firstLevelPercentStr,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
-        100, 2 ),
-        '%'
-        ) AS secondLevelPercentStr,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
-        100, 2 ),
-        '%'
-        ) AS thirdLevelPercentStr
+        count(*) AS mrNum,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
+        ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
+        SUM( c.`level` = '甲' ) AS firstLevelNum,
+        SUM( c.`level` = '乙' ) AS secondLevelNum,
+        SUM( c.`level` = '丙' ) AS thirdLevelNum,
+        ROUND( SUM( c.`level` = '甲' )/ count(*), 4 ) AS firstLevelPercent,
+        ROUND( SUM( c.`level` = '乙' )/ count(*), 4 ) AS secondLevelPercent,
+        ROUND( SUM( c.`level` = '丙' )/ count(*), 4 ) AS thirdLevelPercent,
+        concat( ROUND( SUM( c.`level` = '甲' )/ count(*)* 100, 2 ), '%' ) AS firstLevelPercentStr,
+        concat( ROUND( SUM( c.`level` = '乙' )/ count(*)* 100, 2 ), '%' ) AS secondLevelPercentStr,
+        concat( ROUND( SUM( c.`level` = '丙' )/ count(*)* 100, 2 ), '%' ) AS thirdLevelPercentStr
         FROM
         med_behospital_info a,
         med_qcresult_info c,
@@ -1954,21 +1914,15 @@
         SELECT
         CASE WHEN a.doctor_id is NULL OR a.doctor_id ='' THEN '未知' ELSE a.doctor_id END AS doctorId,
         CASE WHEN a.doctor_name is NULL OR a.doctor_name ='' THEN '未知' ELSE a.doctor_name END AS doctorName,
-        count( DISTINCT a.behospital_code ) AS mrNum,
+        count( * ) AS mrNum,
         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( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END ) AS firstLevelNum,
-        COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS firstLevelPercent,
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id ), 4 ) AS secondLevelPercent,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
-        '%'
-        ) AS firstLevelPercentStr,
-        concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
-        '%'
-        ) AS secondLevelPercentStr
+        ROUND( avg( CAST( c.score_res AS DECIMAL ( 18, 2 )) ), 2 ) AS averageValue,
+        sum( c.`level` = '合格' ) AS firstLevelNum,
+        sum( c.`level` = '不合格' ) AS secondLevelNum,
+        ROUND( sum( c.`level` = '合格' ) / count( * ), 4 ) AS firstLevelPercent,
+        ROUND( sum( c.`level` = '不合格' )/ count( * ), 4 ) AS secondLevelPercent,
+        concat( ROUND( sum( c.`level` = '合格' ) / count( * )* 100, 2 ), '%' ) AS firstLevelPercentStr,
+        concat( ROUND( sum( c.`level` = '不合格' )/ count( * )* 100, 2 ), '%' ) AS secondLevelPercentStr
         FROM
         med_behospital_info a,
         med_qcresult_cases c,
@@ -2725,10 +2679,10 @@
 
     <!-- 条目缺陷质控评分页(内页)-->
     <select id="qcResultShortPage" resultType="com.diagbot.dto.QcResultShortDTO">
-        SELECT
+        SELECT DISTINCT
         t1.hospital_id AS hospitalId,
         t1.behospital_code AS behospitalCode,
-        t1.LEVEL AS level,
+        t1.LEVEL AS LEVEL,
         t1.score_res AS scoreRes,
         t1.NAME AS patName,
         t1.sex AS sex,
@@ -2738,6 +2692,10 @@
         t2.age
         FROM
         (
+        SELECT
+        DISTINCT tt1.*
+        FROM
+        (
         SELECT DISTINCT
         a.hospital_id,
         a.behospital_code,
@@ -2790,7 +2748,7 @@
         <if test="qcResultShortPageVO.casesEntryName != null and qcResultShortPageVO.casesEntryName != ''">
             AND d.NAME LIKE CONCAT( '%', #{qcResultShortPageVO.casesEntryName}, '%' )
         </if>
-        <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId != ''">
+        <if test="qcResultShortPageVO.casesEntryId != null ">
             AND d.id = #{qcResultShortPageVO.casesEntryId}
         </if>
         <if test="qcResultShortPageVO.isReject != null">
@@ -2799,10 +2757,43 @@
         <if test="qcResultShortPageVO.ruleType != null">
             AND d.rule_type = #{qcResultShortPageVO.ruleType}
         </if>
+        <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2495">
+            AND TIMESTAMPDIFF(
+            DAY,
+            DATE( a.behospital_date ),
+            DATE( a.leave_hospital_date ))> 30
+        </if>
+        ) tt1
+        <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2511">
+            ,med_medical_record tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt1.hospital_id = tt2.hospital_id
+            AND tt1.behospital_code = tt2.behospital_code
+            AND tt2.mode_id = 30
+        </if>
+        <if test="qcResultShortPageVO.casesEntryId != null and qcResultShortPageVO.casesEntryId==2419">
+            ,med_crisis_info tt2
+            WHERE
+            tt2.is_deleted = 'N'
+            AND tt1.hospital_id = tt2.hospital_id
+            AND tt1.behospital_code = tt2.behospital_code
+        </if>
         ) t1
-        LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
-        AND t1.behospital_code = t2.behospital_code
-        AND t2.is_deleted = 'N'
+        <if test="qcResultShortPageVO.casesEntryId == null or (qcResultShortPageVO.casesEntryId!=2594  and qcResultShortPageVO.casesEntryId!=2973 and qcResultShortPageVO.casesEntryId!=2166)">
+            LEFT JOIN med_home_page t2 ON t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+            AND t2.is_deleted = 'N'
+        </if>
+        <if test="qcResultShortPageVO.casesEntryId != null and( qcResultShortPageVO.casesEntryId==2594  or qcResultShortPageVO.casesEntryId==2973 or qcResultShortPageVO.casesEntryId==2166)">
+            , med_home_page t2
+            , med_home_operation_info t3
+            WHERE t1.hospital_id = t2.hospital_id
+            AND t1.behospital_code = t2.behospital_code
+            AND t2.home_page_id = t3.home_page_id
+            AND t2.is_deleted = 'N'
+            AND t3.is_deleted = 'N'
+        </if>
     </select>
 
     <!-- 条目缺陷质控评分页-科室(内页)-->
@@ -2870,7 +2861,7 @@
             AND a.beh_dept_name = #{qcResultShortPageVO.behDeptName}
         </if>
         <if test="qcResultShortPageVO.doctorName != null and qcResultShortPageVO.doctorName != ''">
-            AND a.beh_dept_name = #{qcResultShortPageVO.doctorName}
+            AND a.doctor_name = #{qcResultShortPageVO.doctorName}
         </if>
         <if test="qcResultShortPageVO.level != null and qcResultShortPageVO.level != ''">
             AND b.`level` = #{qcResultShortPageVO.level}
@@ -2994,40 +2985,40 @@
         SELECT
         deptId,
         deptName,
+        consultationMRNum,
         consultationNum,
         2511 AS consultationEntryId,
         '普通会诊未在24小时内完成' AS consultationEntryName,
-        ROUND( consultationNum / consultationMRNum, 4 ) AS consultationPercent,
-        CONCAT( ROUND( consultationNum / consultationMRNum * 100, 2 ), '%' ) AS consultationPercentStr,
-        consultationMRNum,
+        ROUND( IFNULL( consultationNum / consultationMRNum, 0 ), 4 ) AS consultationPercent,
+        CONCAT( ROUND( IFNULL( consultationNum / consultationMRNum, 0 ) * 100, 2 ), '%' ) AS consultationPercentStr,
+        operationMRNum,
         2594 AS operationNameEntryId,
         '首页手术名称与手术记录不一致' AS operationNameEntryName,
         operationNameNum,
-        ROUND( operationNameNum / operationMRNum, 4 ) AS operationNamePercent,
-        CONCAT( ROUND( operationNameNum / operationMRNum * 100, 2 ), '%' ) AS operationNamePercentStr,
+        ROUND( IFNULL( operationNameNum / operationMRNum, 0 ), 4 ) AS operationNamePercent,
+        CONCAT( ROUND( IFNULL( operationNameNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationNamePercentStr,
         2973 AS operationTimeEntryId,
         '手术日期与手术记录中手术日期不一致' AS operationTimeEntryName,
         operationTimeNum,
-        ROUND( operationTimeNum / operationMRNum, 4 ) AS operationTimePercent,
-        CONCAT( ROUND( operationTimeNum / operationMRNum * 100, 2 ), '%' ) AS operationTimePercentStr,
+        ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ), 4 ) AS operationTimePercent,
+        CONCAT( ROUND( IFNULL( operationTimeNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operationTimePercentStr,
         2166 AS operation15MinuteEntryId,
         '术后首程未在手术结束1小时内完成' AS operation15MinuteEntryName,
         operation15MinuteNum,
-        ROUND( operation15MinuteNum / operationMRNum, 4 ) AS operation15MinutePercent,
-        CONCAT( ROUND( operation15MinuteNum / operationMRNum * 100, 2 ), '%' ) AS operation15MinutePercentStr,
-        operationMRNum,
+        ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ), 4 ) AS operation15MinutePercent,
+        CONCAT( ROUND( IFNULL( operation15MinuteNum / operationMRNum, 0 ) * 100, 2 ), '%' ) AS operation15MinutePercentStr,
         2419 AS crisisEntryId,
         '危急值记录未在接到危急值报告后6小时内完成' AS crisisEntryName,
-        crisisNum,
-        ROUND( crisisNum / crisisMRNum, 4 ) AS crisisPercent,
-        CONCAT( ROUND( crisisNum / crisisMRNum * 100, 2 ), '%' ) AS crisisPercentStr,
         crisisMRNum,
+        crisisNum,
+        ROUND( IFNULL( crisisNum / crisisMRNum, 0 ), 4 ) AS crisisPercent,
+        CONCAT( ROUND( IFNULL( crisisNum / crisisMRNum, 0 ) * 100, 2 ), '%' ) AS crisisPercentStr,
         2495 AS stageSummaryEntryId,
         '无阶段小结' AS stageSummaryEntryName,
+        stageSummaryMRNum,
         stageSummaryNum,
-        ROUND( stageSummaryNum / stageSummaryMRNum, 4 ) AS stageSummaryPercent,
-        CONCAT( ROUND( stageSummaryNum / stageSummaryMRNum * 100, 2 ), '%' ) AS stageSummaryPercentStr,
-        stageSummaryMRNum
+        ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ), 4 ) AS stageSummaryPercent,
+        CONCAT( ROUND( IFNULL( stageSummaryNum / stageSummaryMRNum, 0 ) * 100, 2 ), '%' ) AS stageSummaryPercentStr
         FROM
         (
         SELECT
@@ -3089,10 +3080,8 @@
         <if test="deptName != null and deptName != ''">
             AND a.beh_dept_name = #{deptName}
         </if>
-        ) c,
-        med_qcresult_detail d
-        WHERE
-        d.is_deleted = 'N'
+        ) c
+        LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
         AND c.hospital_id = d.hospital_id
         AND c.behospital_code = d.behospital_code
         GROUP BY
@@ -3101,14 +3090,14 @@
         ) UNION
         (
         SELECT
-        c.beh_dept_id AS deptId,
-        c.beh_dept_name AS deptName,
+        d.beh_dept_id AS deptId,
+        d.beh_dept_name AS deptName,
         0 AS consultationNum,
         0 AS consultationMRNum,
-        sum( d.cases_entry_id = 2594 ) AS operationNameNum,
-        sum( d.cases_entry_id = 2973 ) AS operationTimeNum,
-        sum( d.cases_entry_id = 2166 ) AS operation15MinuteNum,
-        count( DISTINCT c.behospital_code ) AS operationMRNum,
+        sum( e.cases_entry_id = 2594 ) AS operationNameNum,
+        sum( e.cases_entry_id = 2973 ) AS operationTimeNum,
+        sum( e.cases_entry_id = 2166 ) AS operation15MinuteNum,
+        count( DISTINCT d.behospital_code ) AS operationMRNum,
         0 AS crisisNum,
         0 AS crisisMRNum,
         0 AS stageSummaryNum,
@@ -3122,13 +3111,16 @@
         a.beh_dept_id
         FROM
         med_behospital_info a,
-        med_medical_record b
+        med_home_page b,
+        med_home_operation_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 b.mode_id = 17
+        AND b.home_page_id = c.home_page_id
         AND a.is_placefile = '1'
         AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
@@ -3143,15 +3135,13 @@
         <if test="deptName != null and deptName != ''">
             AND a.beh_dept_name = #{deptName}
         </if>
-        ) c,
-        med_qcresult_detail d
-        WHERE
-        d.is_deleted = 'N'
-        AND c.hospital_id = d.hospital_id
-        AND c.behospital_code = d.behospital_code
+        ) d
+        LEFT JOIN med_qcresult_detail e ON e.is_deleted = 'N'
+        AND d.hospital_id = e.hospital_id
+        AND d.behospital_code = e.behospital_code
         GROUP BY
-        c.beh_dept_id,
-        c.beh_dept_name
+        d.beh_dept_id,
+        d.beh_dept_name
         ) UNION
         (
         SELECT
@@ -3176,13 +3166,12 @@
         a.beh_dept_id
         FROM
         med_behospital_info a,
-        med_medical_record b
+        med_crisis_info b
         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 b.mode_id = 23
         AND a.is_placefile = '1'
         AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
@@ -3197,10 +3186,8 @@
         <if test="deptName != null and deptName != ''">
             AND a.beh_dept_name = #{deptName}
         </if>
-        ) c,
-        med_qcresult_detail d
-        WHERE
-        d.is_deleted = 'N'
+        ) c
+        LEFT JOIN med_qcresult_detail d ON d.is_deleted = 'N'
         AND c.hospital_id = d.hospital_id
         AND c.behospital_code = d.behospital_code
         GROUP BY
@@ -3209,8 +3196,8 @@
         ) UNION
         (
         SELECT
-        c.beh_dept_id AS deptId,
-        c.beh_dept_name AS deptName,
+        b.beh_dept_id AS deptId,
+        b.beh_dept_name AS deptName,
         0 AS consultationNum,
         0 AS consultationMRNum,
         0 AS operationNameNum,
@@ -3219,8 +3206,8 @@
         0 AS operationMRNum,
         0 AS crisisNum,
         0 AS crisisMRNum,
-        sum( d.cases_entry_id = 2495 ) AS stageSummaryNum,
-        count( DISTINCT c.behospital_code ) AS stageSummaryMRNum
+        sum( c.cases_entry_id = 2495 ) AS stageSummaryNum,
+        count( DISTINCT b.behospital_code ) AS stageSummaryMRNum
         FROM
         (
         SELECT DISTINCT
@@ -3229,14 +3216,13 @@
         a.beh_dept_name,
         a.beh_dept_id
         FROM
-        med_behospital_info a,
-        med_medical_record b
+        med_behospital_info 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 b.mode_id = 23
+        AND TIMESTAMPDIFF(
+        DAY,
+        DATE( behospital_date ),
+        DATE( leave_hospital_date ))> 30
         AND a.is_placefile = '1'
         AND a.qc_type_id != 0
         <if test="hospitalId != null and hospitalId != ''">
@@ -3251,15 +3237,13 @@
         <if test="deptName != null and deptName != ''">
             AND a.beh_dept_name = #{deptName}
         </if>
-        ) c,
-        med_qcresult_detail d
-        WHERE
-        d.is_deleted = 'N'
-        AND c.hospital_id = d.hospital_id
-        AND c.behospital_code = d.behospital_code
+        ) b
+        LEFT JOIN med_qcresult_detail c ON c.is_deleted = 'N'
+        AND b.hospital_id = c.hospital_id
+        AND b.behospital_code = c.behospital_code
         GROUP BY
-        c.beh_dept_id,
-        c.beh_dept_name
+        b.beh_dept_id,
+        b.beh_dept_name
         )
         ) tt
         GROUP BY

+ 297 - 234
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>
 
     <!-- 条目缺陷占比(首页) -->
@@ -205,27 +267,28 @@
         FROM
         (
         SELECT
-        e.id,
-        e.NAME,
+        tt2.id,
+        tt2.NAME,
+        tt1.num
+        FROM
+        (
+        SELECT
+        d.cases_entry_id,
         count(*) AS num
         FROM
         med_behospital_info a,
         med_qcresult_info c,
-        med_qcresult_detail d,
-        qc_cases_entry e
+        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 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.cases_id
-        AND d.cases_entry_id = e.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>
@@ -236,8 +299,12 @@
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         GROUP BY
-        e.id,
-        e.NAME
+        d.cases_entry_id
+        ) tt1,
+        qc_cases_entry tt2
+        WHERE
+        tt2.is_deleted = 'N'
+        AND tt1.cases_entry_id = tt2.id
         ) t1,
         (
         SELECT
@@ -251,7 +318,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="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
@@ -268,9 +335,11 @@
 
     <!-- 条目缺陷占比(内页) -->
     <select id="entryGroupByEntryInnerPage" resultType="com.diagbot.dto.EntryNumDTO">
-        SELECT t.*
+        SELECT
+        t.*
         FROM
-        (SELECT
+        (
+        SELECT
         t1.id AS id,
         t1.NAME AS NAME,
         t1.casesId AS casesId,
@@ -284,61 +353,67 @@
         FROM
         (
         SELECT
-        e.id,
-        e.NAME,
-        e.cases_id AS casesId,
-        e.cases_name AS casesName,
+        tt2.id,
+        tt2.NAME,
+        tt2.cases_id AS casesId,
+        tt2.cases_name AS casesName,
+        tt3.score,
+        tt1.num,
+        tt1.is_reject AS isReject
+        FROM
+        (
+        SELECT
+        a.hospital_id,
+        d.cases_entry_id,
+        d.cases_id,
         count(*) AS num,
-        f.score,
-        d.is_reject AS isReject
+        d.is_reject
         FROM
         med_behospital_info a,
         med_qcresult_info c,
-        med_qcresult_detail d,
-        qc_cases_entry e,
-        qc_cases_entry_hospital 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.hospital_id = f.hospital_id
         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 e.id = f.cases_entry_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>
         <if test="filterPageVO.startDate != null and filterPageVO.startDate != ''">
-            <![CDATA[ and a.leave_hospital_date >= DATE(#{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>
-        <if test="filterPageVO.name != null and filterPageVO.name != ''">
-            AND e.name like CONCAT('%', #{filterPageVO.name},'%')
-        </if>
-        <if test="filterPageVO.casesName != null and filterPageVO.casesName != ''">
-            AND e.cases_name = #{filterPageVO.casesName}
-        </if>
         <if test="filterPageVO.isReject != null">
             AND d.is_reject = #{filterPageVO.isReject}
         </if>
         GROUP BY
-        e.id,
-        e.NAME,
-        <if test="filterPageVO.isReject == null">
-            d.is_reject,
+        d.cases_entry_id,
+        d.is_reject,
+        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 tt1.cases_entry_id = tt3.cases_entry_id
+        <if test="filterPageVO.name != null and filterPageVO.name != ''">
+            AND tt2.name like CONCAT('%', #{filterPageVO.name},'%')
+        </if>
+        <if test="filterPageVO.casesName != null and filterPageVO.casesName != ''">
+            AND tt2.cases_name = #{filterPageVO.casesName}
         </if>
-        e.cases_id,
-        e.cases_name
         ) t1,
         (
         SELECT
@@ -352,7 +427,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>
@@ -363,7 +438,7 @@
             <![CDATA[AND a.leave_hospital_date < DATE(#{filterPageVO.endDate})]]>
         </if>
         ) t2
-        )t
+        ) t
     </select>
 
     <!-- 单项否决缺陷占比(首页) -->
@@ -382,36 +457,36 @@
         FROM
         (
         SELECT
-        e.id,
-        e.NAME,
-        e.cases_id AS casesId,
-        e.cases_name AS casesName,
+        tt2.id,
+        tt2.NAME,
+        tt2.cases_id AS casesId,
+        tt2.cases_name AS casesName,
+        tt1.num,
+        tt3.score,
+        tt1.is_reject AS isReject
+        FROM
+        (
+        SELECT
+        d.cases_entry_id,
+        d.cases_id,
+        a.hospital_id,
         count(*) AS num,
-        f.score,
-        d.is_reject AS isReject
+        d.is_reject
         FROM
         med_behospital_info a,
         med_qcresult_info c,
-        med_qcresult_detail d,
-        qc_cases_entry e,
-        qc_cases_entry_hospital 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.hospital_id = f.hospital_id
         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 e.id = f.cases_entry_id
         AND a.is_placefile = '1'
         AND d.is_reject = 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>
@@ -422,10 +497,18 @@
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         GROUP BY
-        e.id,
-        e.NAME,
-        e.cases_id,
-        e.cases_name
+        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
         ) t1,
         (
         SELECT
@@ -439,7 +522,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="hospitalId != null and hospitalId != ''">
             AND a.hospital_id = #{hospitalId}
         </if>
@@ -576,53 +659,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>
 
     <!-- 条目缺陷占比-科室(首页) -->
@@ -638,33 +728,36 @@
         FROM
         (
         SELECT
-        e.id,
-        e.NAME,
-        a.beh_dept_id AS deptId,
-        a.beh_dept_name AS deptName,
-        count(*) AS num
+        tt2.id,
+        tt2.NAME,
+        tt1.beh_dept_id AS deptId,
+        tt1.beh_dept_name AS deptName,
+        tt1.num
+        FROM
+        (
+        SELECT
+        a.beh_dept_id,
+        a.beh_dept_name,
+        count(*) AS num,
+        d.cases_entry_id
         FROM
         med_behospital_info a,
         med_qcresult_info c,
         med_qcresult_detail d,
-        qc_cases_entry e,
         sys_user_dept f
         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.hospital_id = f.hospital_id
         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
         AND a.is_placefile = '1'
-        <![CDATA[AND a.qc_type_id <>0 ]]>
+        AND a.qc_type_id != 0
         <if test="userId!=null">
             AND f.user_id = #{userId}
         </if>
@@ -678,10 +771,14 @@
             <![CDATA[AND a.leave_hospital_date < DATE(#{endDate})]]>
         </if>
         GROUP BY
-        e.id,
-        e.NAME,
+        d.cases_entry_id,
         a.beh_dept_id,
         a.beh_dept_name
+        ) tt1,
+        qc_cases_entry tt2
+        WHERE
+        tt2.is_deleted = 'N'
+        AND tt1.cases_entry_id = tt2.id
         ) t1,
         (
         SELECT
@@ -701,7 +798,7 @@
         AND a.behospital_code = c.behospital_code
         AND a.beh_dept_id = f.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 f.user_id = #{userId}
         </if>
@@ -748,41 +845,43 @@
         FROM
         (
         SELECT
-        e.id,
-        e.NAME,
-        a.beh_dept_id AS deptId,
-        a.beh_dept_name AS deptName,
-        e.cases_id AS casesId,
-        e.cases_name AS casesName,
+        tt2.id,
+        tt2.NAME,
+        tt1.beh_dept_id AS deptId,
+        tt1.beh_dept_name AS deptName,
+        tt2.cases_id AS casesId,
+        tt2.cases_name AS casesName,
+        tt1.num,
+        tt3.score,
+        tt1.is_reject AS isReject
+        FROM
+        (
+        SELECT
+        a.hospital_id,
+        a.beh_dept_id,
+        a.beh_dept_name,
         count(*) AS num,
-        g.score,
-        d.is_reject AS isReject
+        d.cases_id,
+        d.cases_entry_id,
+        d.is_reject
         FROM
         med_behospital_info a,
         med_qcresult_info c,
         med_qcresult_detail d,
-        qc_cases_entry e,
-        sys_user_dept f,
-        qc_cases_entry_hospital g
+        sys_user_dept f
         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 = f.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.cases_id
-        AND d.cases_entry_id = e.id
-        AND e.id = g.cases_entry_id
         AND a.beh_dept_id = f.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 f.user_id = #{filterPageByDeptVO.userId}
         </if>
@@ -798,25 +897,31 @@
         <if test="filterPageByDeptVO.deptName != null and filterPageByDeptVO.deptName != ''">
             AND a.beh_dept_name = #{filterPageByDeptVO.deptName}
         </if>
-        <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
-            AND e.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
-        </if>
-        <if test="filterPageByDeptVO.casesName != null and filterPageByDeptVO.casesName != ''">
-            AND e.cases_name = #{filterPageByDeptVO.casesName}
-        </if>
         <if test="filterPageByDeptVO.isReject != null">
             AND d.is_reject = #{filterPageByDeptVO.isReject}
         </if>
         GROUP BY
-        e.id,
-        e.NAME,
+        d.cases_entry_id,
         a.beh_dept_id,
         a.beh_dept_name,
-        <if test="filterPageByDeptVO.isReject == null">
-             d.is_reject,
+        d.is_reject,
+        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
+        <if test="filterPageByDeptVO.name != null and filterPageByDeptVO.name != ''">
+            AND tt2.name like CONCAT('%', #{filterPageByDeptVO.name},'%')
+        </if>
+        <if test="filterPageByDeptVO.casesName != null and filterPageByDeptVO.casesName != ''">
+            AND tt2.cases_name = #{filterPageByDeptVO.casesName}
         </if>
-        e.cases_id,
-        e.cases_name
         ) t1,
         (
         SELECT
@@ -836,7 +941,7 @@
         AND a.behospital_code = c.behospital_code
         AND a.beh_dept_id = f.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 f.user_id = #{filterPageByDeptVO.userId}
         </if>
@@ -874,8 +979,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 +990,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 +1021,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 +1047,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 +1063,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 +1081,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>
 
@@ -1007,27 +1112,15 @@
         d.is_reject as isReject
         FROM
         med_behospital_info a,
-        <if test="filterPageVO.casesId != null and filterPageVO.casesId ==243">
-            med_qcresult_cases c,
-        </if>
-        <if test="filterPageVO.casesId == null or filterPageVO.casesId ==0">
-            med_qcresult_info c,
-        </if>
         med_qcresult_detail d,
         qc_cases_entry 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.behospital_code = c.behospital_code
         AND a.behospital_code = d.behospital_code
         AND a.is_placefile = '1'
-        <if test="filterPageVO.casesId != null and filterPageVO.casesId ==243">
-            AND c.cases_id = d.cases_id
-        </if>
         AND d.cases_id = e.cases_id
         AND d.cases_entry_id = e.id
         <![CDATA[AND a.qc_type_id <>0 ]]>
@@ -1063,27 +1156,15 @@
         count(*) AS totleNum
         FROM
         med_behospital_info a,
-        <if test="filterPageVO.casesId != null and filterPageVO.casesId ==243">
-            med_qcresult_cases c,
-        </if>
-        <if test="filterPageVO.casesId == null or filterPageVO.casesId ==0">
-            med_qcresult_info c,
-        </if>
         med_qcresult_detail d,
         qc_cases_entry 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.behospital_code = c.behospital_code
         AND a.behospital_code = d.behospital_code
         AND a.is_placefile = '1'
-        <if test="filterPageVO.casesId != null and filterPageVO.casesId ==243">
-            AND c.cases_id = d.cases_id
-        </if>
         AND d.cases_id = e.cases_id
         AND d.cases_entry_id = e.id
         <![CDATA[AND a.qc_type_id <>0 ]]>
@@ -1207,6 +1288,8 @@
         SELECT
         t.id,
         t.`NAME`,
+        t.deptId,
+        t.deptName,
         t.num,
         t.totleNum,
         t.percent,
@@ -1216,6 +1299,8 @@
         SELECT
         t1.caseId AS id,
         t1.caseName AS NAME,
+        t1.deptId,
+        t1.deptName,
         t1.num AS num,
         t2.mrNum,
         t3.originalNum,
@@ -1225,36 +1310,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 +1352,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 +1386,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 +1427,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>
 
@@ -1375,30 +1462,18 @@
         a.beh_dept_name AS deptName
         FROM
         med_behospital_info a,
-        <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId ==243">
-            med_qcresult_cases c,
-        </if>
-        <if test="filterPageByDeptVO.casesId == null or filterPageByDeptVO.casesId ==0">
-            med_qcresult_info c,
-        </if>
         med_qcresult_detail d,
         qc_cases_entry e,
         sys_user_dept f
         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.hospital_id = f.hospital_id
-        AND a.behospital_code = c.behospital_code
         AND a.behospital_code = d.behospital_code
         AND a.is_placefile = '1'
-        <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId ==243">
-            AND c.cases_id = d.cases_id
-        </if>
         AND d.cases_id = e.cases_id
         AND d.cases_entry_id = e.id
         AND a.beh_dept_id = f.dept_id
@@ -1446,30 +1521,18 @@
         count(*) AS totleNum
         FROM
         med_behospital_info a,
-        <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId ==243">
-            med_qcresult_cases c,
-        </if>
-        <if test="filterPageByDeptVO.casesId == null or filterPageByDeptVO.casesId ==0">
-            med_qcresult_info c,
-        </if>
         med_qcresult_detail d,
         qc_cases_entry e,
         sys_user_dept f
         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.hospital_id = f.hospital_id
-        AND a.behospital_code = c.behospital_code
         AND a.behospital_code = d.behospital_code
         AND a.is_placefile = '1'
-        <if test="filterPageByDeptVO.casesId != null and filterPageByDeptVO.casesId ==243">
-            AND c.cases_id = d.cases_id
-        </if>
         AND d.cases_id = e.cases_id
         AND d.cases_entry_id = e.id
         AND a.beh_dept_id = f.dept_id