Просмотр исходного кода

质控病历管理统计相关API

chengyao 3 лет назад
Родитель
Сommit
ff1ea82835

+ 46 - 0
common/src/main/java/com/lantone/common/util/BeanUtil.java

@@ -0,0 +1,46 @@
+package com.lantone.common.util;
+
+import org.springframework.beans.BeanUtils;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * @Description:
+ * @Author: cy
+ * @time: 2021/9/22 14:56
+ */
+public class BeanUtil {
+    public BeanUtil() {
+    }
+
+    public static void copyProperties(Object source, Object target) {
+        BeanUtils.copyProperties(source, target);
+    }
+
+    public static <E> List<E> listCopyTo(List<?> source, Class<E> destinationClass) {
+        try {
+            if (source.size() == 0) {
+                return Collections.emptyList();
+            } else {
+                List<E> res = new ArrayList(source.size());
+                Iterator var3 = source.iterator();
+
+                while(var3.hasNext()) {
+                    Object o = var3.next();
+                    E e = destinationClass.newInstance();
+                    BeanUtils.copyProperties(o, e);
+                    res.add(e);
+                }
+
+                return res;
+            }
+        } catch (IllegalAccessException var6) {
+            throw new RuntimeException(var6);
+        } catch (InstantiationException var7) {
+            throw new RuntimeException(var7);
+        }
+    }
+}

+ 19 - 0
dblayer-mbg/src/main/java/com/lantone/dblayermbg/mapper/report/BehospitalInfoMapper.java

@@ -3,8 +3,11 @@ package com.lantone.dblayermbg.mapper.report;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.lantone.common.dto.report.ExportExcelDTO;
+import com.lantone.common.dto.report.LevelStatisticsDTO;
+import com.lantone.common.dto.report.LevelStatisticsTZDTO;
 import com.lantone.common.dto.report.QcResultShortDTO;
 import com.lantone.common.dto.report.ReBeHosMergeDTO;
+import com.lantone.common.vo.report.FilterOrderVO;
 import com.lantone.common.vo.report.FilterVO;
 import com.lantone.common.vo.report.QcResultShortPageVO;
 import com.lantone.common.vo.report.ReBeHosPageVO;
@@ -83,5 +86,21 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      */
     public List<ExportExcelDTO> leaveHosMRPageExport(@Param("qcResultShortPageVO") QcResultShortPageVO qcResultShortPageVO);
 
+    /**
+     * 各科室缺陷占比(组合)
+     *
+     * @param filterOrderVO
+     * @return
+     */
+    public List<LevelStatisticsDTO> levelStatistics(FilterOrderVO filterOrderVO);
+
+    /**
+     * 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州)
+     *
+     * @param filterOrderVO
+     * @return
+     */
+    public List<LevelStatisticsTZDTO> levelStatisticsByDeptClass_TZ(FilterOrderVO filterOrderVO);
+
 
 }

+ 34 - 0
dblayer-mbg/src/main/java/com/lantone/dblayermbg/mapper/report/QcresultInfoMapper.java

@@ -2,10 +2,13 @@ package com.lantone.dblayermbg.mapper.report;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.lantone.common.dto.report.AverageStatisticsDTO;
+import com.lantone.common.dto.report.DeptNumDTO;
 import com.lantone.common.dto.report.EntryNumDTO;
 import com.lantone.common.dto.report.NumDTO;
 import com.lantone.common.vo.report.FilterPageVO;
 import com.lantone.common.vo.report.FilterVO;
+import com.lantone.common.vo.report.QcresultFilterVO;
 import com.lantone.dblayermbg.entity.report.QcresultInfo;
 import org.apache.ibatis.annotations.Param;
 
@@ -64,5 +67,36 @@ public interface QcresultInfoMapper extends BaseMapper<QcresultInfo> {
      */
     public List<EntryNumDTO> entryGroupByEntryScore(@Param("hospitalId") String hospitalId, @Param("isPlacefile") String isPlacefile, @Param("ids") Set<Long> ids);
 
+    /**
+     * 质控病历数统计
+     *
+     * @param qcresultFilterVO
+     * @return
+     */
+    public int resultCount(QcresultFilterVO qcresultFilterVO);
+
+    /**
+     * 各科室甲/乙/丙级病历占比
+     * @param filterVO
+     * @return
+     */
+    public List<DeptNumDTO> qcResultLevelPercent(FilterVO filterVO);
+
+    /**
+     * 质控平均分按科室统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<AverageStatisticsDTO> getAverageScore(FilterVO filterVO);
+
+    /**
+     * 各科室质控平均分(首页)-根据内外科系统统计
+     *
+     * @param filterVO
+     * @return
+     */
+    public List<AverageStatisticsDTO> getAverageScoreByDeptClass(FilterVO filterVO);
+
 
 }

+ 837 - 0
dblayer-mbg/src/main/resources/mapper/report/BehospitalInfoMapper.xml

@@ -1329,4 +1329,841 @@
         </collection>
     </resultMap>
 
+    <!-- 各科室缺陷占比(组合)-全院 -->
+    <select id="levelStatistics" resultType="com.lantone.common.dto.report.LevelStatisticsDTO">
+        SELECT
+        m1.deptId,
+        m1.deptName,
+        m1.entryNum,
+        m2.sameNum,
+        m1.mrNum,
+        m2.sameMrNum,
+        m1.totleValue,
+        m2.sameTotleValue,
+        m1.averageValue,
+        m2.sameAvgValue,
+        m1.firstLevelNum,
+        m2.sameFirstLevelNum,
+        m1.secondLevelNum,
+        m2.sameSecondLevelNum,
+        m1.thirdLevelNum,
+        m2.sameThirdLevelNum,
+        m1.firstLevelPercent,
+        m2.sameFirstLevelPercent,
+        m1.secondLevelPercent,
+        m2.sameSecondLevelPercent,
+        m1.thirdLevelPercent,
+        m2.sameThirdLevelPercent,
+        m1.firstLevelPercentStr,
+        m2.sameFirstLevelPercentStr,
+        m1.secondLevelPercentStr,
+        m2.sameSecondLevelPercentStr,
+        m1.thirdLevelPercentStr,
+        m2.sameThirdLevelPercentStr
+        FROM
+        (
+        SELECT
+        t1.deptId,
+        t1.deptName,
+        t2.entryNum,
+        t1.mrNum,
+        t1.totleValue,
+        t1.averageValue,
+        t1.firstLevelNum,
+        t1.secondLevelNum,
+        t1.thirdLevelNum,
+        t1.firstLevelPercent,
+        t1.secondLevelPercent,
+        t1.thirdLevelPercent,
+        t1.firstLevelPercentStr,
+        t1.secondLevelPercentStr,
+        t1.thirdLevelPercentStr
+        FROM
+        (
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        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
+        WHERE
+        a.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = c.behospital_code
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="level != null and level != ''">
+            and c.level = #{level}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and a.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) t1,
+        (
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        count( * ) AS entryNum
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c,
+        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 d.cases_id = e.cases_id
+        AND d.cases_entry_id = e.id
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="level != null and level != ''">
+            and c.level = #{level}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and a.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) t2
+        WHERE
+        t1.deptId = t2.deptId
+        AND t1.deptName = t2.deptName)m1 left join
+        ( SELECT
+        t1.deptId,
+        t1.deptName,
+        t2.entryNum as sameNum,
+        t1.mrNum as sameMrNum,
+        t1.totleValue as  sameTotleValue,
+        t1.averageValue as sameAvgValue,
+        t1.firstLevelNum as sameFirstLevelNum,
+        t1.secondLevelNum as sameSecondLevelNum,
+        t1.thirdLevelNum as sameThirdLevelNum,
+        t1.firstLevelPercent as sameFirstLevelPercent,
+        t1.secondLevelPercent as sameSecondLevelPercent,
+        t1.thirdLevelPercent as sameThirdLevelPercent,
+        t1.firstLevelPercentStr as sameFirstLevelPercentStr,
+        t1.secondLevelPercentStr as sameSecondLevelPercentStr,
+        t1.thirdLevelPercentStr as sameThirdLevelPercentStr
+        FROM
+        (
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        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
+        WHERE
+        a.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = c.behospital_code
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="level != null and level != ''">
+            and c.level = #{level}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and a.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) t1,
+        (
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        count( * ) AS entryNum
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c,
+        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 d.cases_id = e.cases_id
+        AND d.cases_entry_id = e.id
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="level != null and level != ''">
+            and c.level = #{level}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and a.beh_dept_name like CONCAT('%',#{deptName},'%')
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) t2
+        WHERE
+        t1.deptId = t2.deptId
+        AND t1.deptName = t2.deptName)m2
+        on
+        m1.deptId = m2.deptId
+        AND m1.deptName = m2.deptName
+        <if test="asc != null and asc !=''">
+            order by
+            <choose>
+                <when test='asc=="deptId"'>m1.deptId asc</when>
+                <when test='asc=="deptName"'>m1.deptName asc</when>
+                <when test='asc=="entryNum"'>m1.entryNum asc</when>
+                <when test='asc=="sameNum"'>m2.sameNum asc</when>
+                <when test='asc=="mrNum"'>m1.mrNum asc</when>
+                <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
+                <when test='asc=="totleValue"'>m1.totleValue asc</when>
+                <when test='asc=="averageValue"'>m1.averageValue asc</when>
+                <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
+                <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
+                <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
+                <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
+                <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
+                <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
+                <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
+                <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
+                <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
+                <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
+                <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
+                <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
+                <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
+                <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
+                <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
+                <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
+                <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
+                <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
+                <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
+                <otherwise>deptName asc</otherwise>
+            </choose>
+        </if>
+        <if test="desc != null and desc!=''">
+            order by
+            <choose>
+                <when test='desc=="deptId"'>m1.deptId desc</when>
+                <when test='desc=="deptName"'>m1.deptName desc</when>
+                <when test='desc=="entryNum"'>m1.entryNum desc</when>
+                <when test='desc=="sameNum"'>m2.sameNum desc</when>
+                <when test='desc=="mrNum"'>m1.mrNum desc</when>
+                <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
+                <when test='desc=="totleValue"'>m1.totleValue desc</when>
+                <when test='desc=="averageValue"'>m1.averageValue desc</when>
+                <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
+                <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
+                <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
+                <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
+                <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
+                <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
+                <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
+                <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
+                <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
+                <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
+                <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
+                <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
+                <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
+                <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
+                <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
+                <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
+                <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
+                <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
+                <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
+                <otherwise>deptName desc</otherwise>
+            </choose>
+        </if>
+    </select>
+
+    <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计(台州) -->
+    <select id="levelStatisticsByDeptClass_TZ" parameterType="com.lantone.common.vo.report.FilterOrderVO" resultType="com.lantone.common.dto.report.LevelStatisticsTZDTO">
+        select
+        m1.deptId,
+        m1.deptName,
+        m1.deptClassId,
+        m1.deptClass,
+        m1.entryNum,
+        m2.sameNum,
+        m1.mrNum,
+        m2.sameMrNum,
+        m1.totleValue,
+        m2.sameTotleValue,
+        m1.averageValue,
+        m2.sameAvgValue,
+        m1.firstLevelNum,
+        m2.sameFirstLevelNum,
+        m1.secondLevelNum,
+        m2.sameSecondLevelNum,
+        m1.thirdLevelNum,
+        m2.sameThirdLevelNum,
+        m1.firstLevelPercent,
+        m2.sameFirstLevelPercent,
+        m1.secondLevelPercent,
+        m2.sameSecondLevelPercent,
+        m1.thirdLevelPercent,
+        m2.sameThirdLevelPercent,
+        m1.firstLevelPercentStr,
+        m2.sameFirstLevelPercentStr,
+        m1.secondLevelPercentStr,
+        m2.sameSecondLevelPercentStr,
+        m1.thirdLevelPercentStr,
+        m2.sameThirdLevelPercentStr
+        from (
+        SELECT
+        t1.deptId,
+        t1.deptName,
+        t1.deptClassId,
+        t1.deptClass,
+        t2.entryNum,
+        t1.mrNum,
+        t1.totleValue,
+        t1.averageValue,
+        t1.firstLevelNum,
+        t1.secondLevelNum,
+        t1.thirdLevelNum,
+        t1.firstLevelPercent,
+        t1.secondLevelPercent,
+        t1.thirdLevelPercent,
+        t1.firstLevelPercentStr,
+        t1.secondLevelPercentStr,
+        t1.thirdLevelPercentStr
+        FROM
+        (
+        SELECT
+        tt1.deptId,
+        tt1.deptName,
+        e.dept_id AS deptClassId,
+        e.dept_name AS deptClass,
+        count(*) AS mrNum,
+        ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
+        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
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        d.parent_dept_id AS parentDeptId,
+        a.hospital_id AS hospitalId,
+        a.behospital_code AS behospitalCode,
+        c.score_res AS score,
+        c.LEVEL
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c,
+        bas_dept_info d
+        WHERE
+        a.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.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.beh_dept_id = d.dept_id
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="level != null and level != ''">
+            and c.level = #{level}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
+        </if>
+        ) tt1
+        LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
+        AND e.is_deleted = 'N'
+        AND tt1.hospitalId = e.hospital_id
+        <if test="deptClass != null and deptClass != ''">
+            WHERE e.dept_name = #{deptClass}
+        </if>
+        GROUP BY
+        tt1.deptId,
+        tt1.deptName,
+        e.dept_id,
+        e.dept_name
+        ) t1,
+        (
+        SELECT
+        tt2.deptId,
+        tt2.deptName,
+        g.dept_id AS deptClassId,
+        g.dept_name AS deptClass,
+        count( * ) AS entryNum
+        FROM
+        (
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        f.parent_dept_id AS parentDeptId,
+        a.hospital_id AS hospitalId,
+        a.behospital_code AS behospitalCode
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c,
+        med_qcresult_detail d,
+        qc_cases_entry e,
+        bas_dept_info 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
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="level != null and level != ''">
+            and c.level = #{level}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
+        </if>
+        ) tt2
+        LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
+        AND g.is_deleted = 'N'
+        AND tt2.hospitalId = g.hospital_id
+        <if test="deptClass != null and deptClass != ''">
+            WHERE g.dept_name = #{deptClass}
+        </if>
+        GROUP BY
+        tt2.deptId,
+        tt2.deptName,
+        g.dept_id,
+        g.dept_name
+        ) t2
+        WHERE
+        t1.deptId = t2.deptId
+        AND t1.deptName = t2.deptName)m1 left join
+        ( SELECT
+        t1.deptId,
+        t1.deptName,
+        t1.deptClassId,
+        t1.deptClass,
+        t2.entryNum as sameNum,
+        t1.mrNum as sameMrNum,
+        t1.totleValue as sameTotleValue,
+        t1.averageValue as sameAvgValue,
+        t1.firstLevelNum as sameFirstLevelNum,
+        t1.secondLevelNum as sameSecondLevelNum,
+        t1.thirdLevelNum as sameThirdLevelNum,
+        t1.firstLevelPercent as sameFirstLevelPercent,
+        t1.secondLevelPercent as sameSecondLevelPercent,
+        t1.thirdLevelPercent as sameThirdLevelPercent,
+        t1.firstLevelPercentStr as sameFirstLevelPercentStr,
+        t1.secondLevelPercentStr as sameSecondLevelPercentStr,
+        t1.thirdLevelPercentStr as sameThirdLevelPercentStr
+        FROM
+        (
+        SELECT
+        tt1.deptId,
+        tt1.deptName,
+        e.dept_id AS deptClassId,
+        e.dept_name AS deptClass,
+        count(*) AS mrNum,
+        ROUND( sum( CAST( tt1.score AS DECIMAL ( 18, 2 )) ), 2 ) AS totleValue,
+        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
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        d.parent_dept_id AS parentDeptId,
+        a.hospital_id AS hospitalId,
+        a.behospital_code AS behospitalCode,
+        c.score_res AS score,
+        c.LEVEL
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c,
+        bas_dept_info d
+        WHERE
+        a.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.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.beh_dept_id = d.dept_id
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="level != null and level != ''">
+            and c.level = #{level}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
+        </if>
+        ) tt1
+        LEFT JOIN bas_dept_info e ON tt1.parentDeptId = e.dept_id
+        AND e.is_deleted = 'N'
+        AND tt1.hospitalId = e.hospital_id
+        <if test="deptClass != null and deptClass != ''">
+            WHERE e.dept_name = #{deptClass}
+        </if>
+        GROUP BY
+        tt1.deptId,
+        tt1.deptName,
+        e.dept_id,
+        e.dept_name
+        ) t1,
+        (
+        SELECT
+        tt2.deptId,
+        tt2.deptName,
+        g.dept_id AS deptClassId,
+        g.dept_name AS deptClass,
+        count( * ) AS entryNum
+        FROM
+        (
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        f.parent_dept_id AS parentDeptId,
+        a.hospital_id AS hospitalId,
+        a.behospital_code AS behospitalCode
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c,
+        med_qcresult_detail d,
+        qc_cases_entry e,
+        bas_dept_info 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
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        AND a.qc_type_id != 0
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="level != null and level != ''">
+            and c.level = #{level}
+        </if>
+        <if test="deptName != null and deptName != ''">
+            and a.beh_dept_name LIKE CONCAT( '%', #{deptName}, '%' )
+        </if>
+        ) tt2
+        LEFT JOIN bas_dept_info g ON tt2.parentDeptId = g.dept_id
+        AND g.is_deleted = 'N'
+        AND tt2.hospitalId = g.hospital_id
+        <if test="deptClass != null and deptClass != ''">
+            WHERE g.dept_name = #{deptClass}
+        </if>
+        GROUP BY
+        tt2.deptId,
+        tt2.deptName,
+        g.dept_id,
+        g.dept_name
+        ) t2
+        WHERE
+        t1.deptId = t2.deptId
+        AND t1.deptName = t2.deptName)m2
+        on
+        m1.deptId = m2.deptId
+        and m1.deptName = m2.deptName
+        <if test="asc != null and asc !=''">
+            order by
+            <choose>
+                <when test='asc=="deptId"'>m1.deptId asc</when>
+                <when test='asc=="deptName"'>m1.deptName asc</when>
+                <when test='asc=="deptClassId"'>m1.deptClassId asc</when>
+                <when test='asc=="deptClass"'>m1.deptClass asc</when>
+                <when test='asc=="entryNum"'>m1.entryNum asc</when>
+                <when test='asc=="sameNum"'>m2.sameNum asc</when>
+                <when test='asc=="mrNum"'>m1.mrNum asc</when>
+                <when test='asc=="sameMrNum"'>m2.sameMrNum asc</when>
+                <when test='asc=="totleValue"'>m1.totleValue asc</when>
+                <when test='asc=="averageValue"'>m1.averageValue asc</when>
+                <when test='asc=="sameAvgValue"'>m2.sameAvgValue asc</when>
+                <when test='asc=="firstLevelNum"'>m1.firstLevelNum asc</when>
+                <when test='asc=="sameFirstLevelNum"'>m2.sameFirstLevelNum asc</when>
+                <when test='asc=="secondLevelNum"'>m1.secondLevelNum asc</when>
+                <when test='asc=="sameSecondLevelNum"'>m2.sameSecondLevelNum asc</when>
+                <when test='asc=="thirdLevelNum"'>m1.thirdLevelNum asc</when>
+                <when test='asc=="sameThirdLevelNum"'>m2.sameThirdLevelNum asc</when>
+                <when test='asc=="firstLevelPercent"'>m1.firstLevelPercent asc</when>
+                <when test='asc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent asc</when>
+                <when test='asc=="secondLevelPercent"'>m1.secondLevelPercent asc</when>
+                <when test='asc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent asc</when>
+                <when test='asc=="thirdLevelPercent"'>m1.thirdLevelPercent asc</when>
+                <when test='asc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent asc</when>
+                <when test='asc=="firstLevelPercentStr"'>m1.firstLevelPercent asc</when>
+                <when test='asc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr asc</when>
+                <when test='asc=="secondLevelPercentStr"'>m1.secondLevelPercent asc</when>
+                <when test='asc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr asc</when>
+                <when test='asc=="thirdLevelPercentStr"'>m1.thirdLevelPercent asc</when>
+                <when test='asc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr asc</when>
+                <otherwise>deptName asc</otherwise>
+            </choose>
+        </if>
+        <if test="desc != null and desc!=''">
+            order by
+            <choose>
+                <when test='desc=="deptId"'>m1.deptId desc</when>
+                <when test='desc=="deptName"'>m1.deptName desc</when>
+                <when test='desc=="deptClassId"'>m1.deptClassId desc</when>
+                <when test='desc=="deptClass"'>m1.deptClass desc</when>
+                <when test='desc=="entryNum"'>m1.entryNum desc</when>
+                <when test='desc=="sameNum"'>m2.sameNum desc</when>
+                <when test='desc=="mrNum"'>m1.mrNum desc</when>
+                <when test='desc=="sameMrNum"'>m2.sameMrNum desc</when>
+                <when test='desc=="totleValue"'>m1.totleValue desc</when>
+                <when test='desc=="averageValue"'>m1.averageValue desc</when>
+                <when test='desc=="sameAvgValue"'>m2.sameAvgValue desc</when>
+                <when test='desc=="firstLevelNum"'>m1.firstLevelNum desc</when>
+                <when test='desc=="sameFirstLevelNum"'>m2.sameFirstLevelNum desc</when>
+                <when test='desc=="secondLevelNum"'>m1.secondLevelNum desc</when>
+                <when test='desc=="sameSecondLevelNum"'>m2.sameSecondLevelNum desc</when>
+                <when test='desc=="thirdLevelNum"'>m1.thirdLevelNum desc</when>
+                <when test='desc=="sameThirdLevelNum"'>m2.sameThirdLevelNum desc</when>
+                <when test='desc=="firstLevelPercent"'>m1.firstLevelPercent desc</when>
+                <when test='desc=="sameFirstLevelPercent"'>m2.sameFirstLevelPercent desc</when>
+                <when test='desc=="secondLevelPercent"'>m1.secondLevelPercent desc</when>
+                <when test='desc=="sameSecondLevelPercent"'>m2.sameSecondLevelPercent desc</when>
+                <when test='desc=="thirdLevelPercent"'>m1.thirdLevelPercent desc</when>
+                <when test='desc=="sameThirdLevelPercent"'>m2.sameThirdLevelPercent desc</when>
+                <when test='desc=="firstLevelPercentStr"'>m1.firstLevelPercent desc</when>
+                <when test='desc=="sameFirstLevelPercentStr"'>m2.sameFirstLevelPercentStr desc</when>
+                <when test='desc=="secondLevelPercentStr"'>m1.secondLevelPercent desc</when>
+                <when test='desc=="sameSecondLevelPercentStr"'>m2.sameSecondLevelPercentStr desc</when>
+                <when test='desc=="thirdLevelPercentStr"'>m1.thirdLevelPercent desc</when>
+                <when test='desc=="sameThirdLevelPercentStr"'>m2.sameThirdLevelPercentStr desc</when>
+                <otherwise>deptName desc</otherwise>
+            </choose>
+        </if>
+    </select>
+
 </mapper>

+ 312 - 0
dblayer-mbg/src/main/resources/mapper/report/QcresultInfoMapper.xml

@@ -503,4 +503,316 @@
             ${item}
         </foreach>
     </select>
+
+    <!-- 质控病历数统计 -->
+    <select id="resultCount" parameterType="com.lantone.common.vo.report.QcresultFilterVO" resultType="int">
+        SELECT
+        COUNT(*)
+        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
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="gradeType != null and gradeType != ''">
+            AND c.grade_type = #{gradeType}
+        </if>
+        <if test="level != null and level != ''">
+            AND c.level = #{level}
+        </if>
+    </select>
+
+    <!-- 各科室甲/乙/丙级病历占比 -->
+    <select id="qcResultLevelPercent" parameterType="com.lantone.common.vo.report.FilterVO" resultType="com.lantone.common.dto.report.DeptNumDTO">
+        SELECT
+        a.beh_dept_id AS deptId,
+        a.beh_dept_name AS deptName,
+        <if test="level != null and level != ''">
+            sum( c.`level` = #{level} ) AS num,
+            ROUND( sum( c.`level` = #{level} )/ count(*), 4 ) AS percent,
+            concat( ROUND( sum( c.`level` = #{level} )/ count(*)* 100, 2 ), '%' ) AS percentStr,
+        </if>
+        count(*) AS totleNum
+        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
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ORDER  BY
+        percent DESC,
+        a.beh_dept_name ASC
+    </select>
+
+    <!-- 各科室质控平均分(首页) -->
+    <select id="getAverageScore" parameterType="com.lantone.common.vo.report.FilterVO" resultType="com.lantone.common.dto.report.AverageStatisticsDTO">
+        select
+        m1.id,
+        m1.name,
+        m1.totleValue,
+        m2.sameTotleValue,
+        m1.averageValue,
+        m2.lastYearAverageValue,
+        m1.num,
+        m2.sameNum
+        from(
+        SELECT
+        a.beh_dept_id AS id,
+        a.beh_dept_name AS name,
+        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(*) AS num
+        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
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name)m1 left join
+        ( SELECT
+        a.beh_dept_id AS id,
+        a.beh_dept_name AS name,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS sameTotleValue,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastYearAverageValue,
+        count(*) AS sameNum
+        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
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name)m2
+        on
+        m1.id = m2.id
+        and m1.name = m2.name
+    </select>
+
+    <!-- 各科室质控平均分(首页)-根据内外科系统统计 -->
+    <select id="getAverageScoreByDeptClass" resultType="com.lantone.common.dto.report.AverageStatisticsDTO">
+        select
+        m1.id,
+        m1.name,
+        m1.totleValue,
+        m2.sameTotleValue,
+        m1.averageValue,
+        m2.lastYearAverageValue,
+        m1.num,
+        m2.sameNum,
+        m1.deptClass
+        from(
+        SELECT
+        a.beh_dept_id AS id,
+        a.beh_dept_name AS NAME,
+        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(*) AS num ,
+        e.dept_name as deptClass
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c,
+        bas_dept_info d,
+        bas_dept_info 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.hospital_id = e.hospital_id
+        AND a.behospital_code = c.behospital_code
+        AND a.beh_dept_id = d.dept_id
+        AND d.parent_dept_id = e.dept_id
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="startDate != null and startDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{startDate}]]>
+            </if>
+            <if test="endDate != null and endDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{endDate}]]>
+            </if>
+        </if>
+        <if test="deptClass != null and deptClass != ''">
+            AND e.dept_name = #{deptClass}
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name) m1 left join
+        (SELECT
+        a.beh_dept_id AS id,
+        a.beh_dept_name AS NAME,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) )), 2 ) AS sameTotleValue,
+        ROUND( sum( CAST( c.score_res AS DECIMAL ( 18, 2 ) ))/ count(*), 2 ) AS lastYearAverageValue,
+        count(*) AS sameNum ,
+        e.dept_name as deptClass
+        FROM
+        med_behospital_info a,
+        med_qcresult_info c,
+        bas_dept_info d,
+        bas_dept_info 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.hospital_id = e.hospital_id
+        AND a.behospital_code = c.behospital_code
+        AND a.beh_dept_id = d.dept_id
+        AND d.parent_dept_id = e.dept_id
+        <if test="isPlacefile != null and isPlacefile != ''">
+            and a.is_placefile = #{isPlacefile}
+        </if>
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 0">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.behospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.behospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="isPlacefile != null and isPlacefile == 1">
+            <if test="lastStartDate != null and lastStartDate != ''">
+                <![CDATA[ AND a.leave_hospital_date >= #{lastStartDate}]]>
+            </if>
+            <if test="lastEndDate != null and lastEndDate != ''">
+                <![CDATA[ AND a.leave_hospital_date <= #{lastEndDate}]]>
+            </if>
+        </if>
+        <if test="deptClass != null and deptClass != ''">
+            AND e.dept_name = #{deptClass}
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name)m2
+        on
+        m1.id = m2.id
+        and m1.name = m2.name
+    </select>
 </mapper>

Разница между файлами не показана из-за своего большого размера
+ 1060 - 0
report-service/src/main/java/com/lantone/report/facade/MrScoreManagementFacade.java


+ 139 - 0
report-service/src/main/java/com/lantone/report/web/MrScoreManagementController.java

@@ -0,0 +1,139 @@
+package com.lantone.report.web;
+
+import com.lantone.common.api.CommonResult;
+import com.lantone.common.dto.report.AverageStatisticsDTO;
+import com.lantone.common.dto.report.DeptNumDTO;
+import com.lantone.common.dto.report.LevelStatisticsDTO;
+import com.lantone.common.dto.report.LevelStatisticsTZDTO;
+import com.lantone.common.vo.report.FilterOrderVO;
+import com.lantone.common.vo.report.FilterVO;
+
+import com.lantone.report.facade.MrScoreManagementFacade;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * <p>
+ * 质控病历管理统计相关API
+ * </p>
+ *
+ * @author zhaops
+ * @since 2020-04-27
+ */
+
+@RestController
+@RequestMapping("/console")
+@Api(value = "质控病历管理统计相关API", tags = { "质控病历管理统计相关API" })
+@SuppressWarnings("unchecked")
+public class MrScoreManagementController {
+    @Autowired
+    private MrScoreManagementFacade mrScoreManagementFacade;
+
+    /**
+     * 质控病历统计
+     *
+     * @param filterVO
+     * @return
+     */
+    @ApiOperation(value = "质控病历统计-控制台[by:zhaops]")
+    @PostMapping("/mrCount")
+    public CommonResult<Map<String, Object>> mrCount(@RequestBody @Valid FilterVO filterVO) {
+        return CommonResult.success(mrScoreManagementFacade.mrCount(filterVO));
+    }
+
+    /**
+     * 各科室病历等级占比
+     *
+     * @param filterVO
+     * @return
+     */
+    @ApiOperation(value = "各科室甲/乙/丙级病历占比-控制台[by:zhaops]")
+    @PostMapping("/qcResultLevelPercent")
+    public CommonResult<List<DeptNumDTO>> qcResultLevelPercent(@RequestBody @Valid FilterVO filterVO) {
+        return CommonResult.success(mrScoreManagementFacade.qcResultLevelPercent(filterVO));
+    }
+
+    /**
+     * 各科室缺陷占比-报表
+     *
+     * @param filterOrderVO
+     * @return
+     */
+    @ApiOperation(value = "各科室缺陷占比-报表[by:zhaops]")
+    @PostMapping("/levelStatistics")
+    public CommonResult<List<LevelStatisticsDTO>> levelStatistics(@RequestBody @Valid FilterOrderVO filterOrderVO) {
+        return CommonResult.success(mrScoreManagementFacade.levelStatistics(filterOrderVO));
+    }
+
+    /**
+     * 各科室缺陷占比-报表导出
+     *
+     * @param filterOrderVO
+     * @return
+     */
+    @ApiOperation(value = "各科室缺陷占比-报表导出[by:gaodm]")
+    @PostMapping("/levelExport")
+    public void levelExport(HttpServletResponse response, @RequestBody @Valid FilterOrderVO filterOrderVO) {
+        mrScoreManagementFacade.levelExport(response, filterOrderVO);
+    }
+
+
+    /**
+     * 各科室缺陷占比(台州)-报表
+     *
+     * @param filterOrderVO
+     * @return
+     */
+    @ApiOperation(value = "各科室缺陷占比(台州)-报表[by:zhaops]")
+    @PostMapping("/levelStatisticsByDeptClass")
+    public CommonResult<List<LevelStatisticsTZDTO>> levelStatisticsByDeptClass(@RequestBody @Valid FilterOrderVO filterOrderVO) {
+        return CommonResult.success(mrScoreManagementFacade.levelStatisticsByDeptClass_TZ(filterOrderVO));
+    }
+
+    /**
+     * 各科室缺陷占比(台州)-报表导出
+     *
+     * @param filterOrderVO
+     * @return
+     */
+    @ApiOperation(value = "各科室缺陷占比(台州)-报表导出[by:gaodm]")
+    @PostMapping("/levelExport_TZ")
+    public void levelExport_TZ(HttpServletResponse response, @RequestBody @Valid FilterOrderVO filterOrderVO) {
+        mrScoreManagementFacade.levelExport_TZ(response, filterOrderVO);
+    }
+
+    /**
+     * 各科室质控平均分柱状图-控制台
+     *
+     * @param filterVO
+     * @return
+     */
+    @ApiOperation(value = "各科室质控平均分柱状图-控制台[by:zhaops]")
+    @PostMapping("/getAverageScore")
+    public CommonResult<Map<String, Object>> getAverageScore(@RequestBody @Valid FilterVO filterVO) {
+        return CommonResult.success(mrScoreManagementFacade.getAverageScore(filterVO));
+    }
+
+    /**
+     * 各科室质控平均分柱状图(台州)-控制台
+     *
+     * @param filterVO
+     * @return
+     */
+    @ApiOperation(value = "各科室质控平均分柱状图(台州)-控制台[by:zhaops]")
+    @PostMapping("/getAverageScoreByDeptClass")
+    public CommonResult<List<AverageStatisticsDTO>> getAverageScoreByDeptClass(@RequestBody @Valid FilterVO filterVO) {
+        return CommonResult.success(mrScoreManagementFacade.getAverageScoreByDeptClass(filterVO));
+    }
+}