Browse Source

excel导出

gaodm 5 years ago
parent
commit
a22c54e2e2

+ 9 - 0
pom.xml

@@ -35,6 +35,7 @@
         <poi.version>4.1.1</poi.version>
         <poi.version>4.1.1</poi.version>
         <aggregator.version>1.1.0</aggregator.version>
         <aggregator.version>1.1.0</aggregator.version>
         <okhttp.version>4.2.2</okhttp.version>
         <okhttp.version>4.2.2</okhttp.version>
+        <easypoi.version>4.2.0</easypoi.version>
         <docker-maven-plugin.version>1.2.1</docker-maven-plugin.version>
         <docker-maven-plugin.version>1.2.1</docker-maven-plugin.version>
         <docker.image.prefix>192.168.2.236:5000/diagbotcloud</docker.image.prefix>
         <docker.image.prefix>192.168.2.236:5000/diagbotcloud</docker.image.prefix>
         <registryUrl>http://192.168.2.236:5000/repository/diagbotcloud/</registryUrl>
         <registryUrl>http://192.168.2.236:5000/repository/diagbotcloud/</registryUrl>
@@ -189,6 +190,14 @@
             <version>${aggregator.version}</version>
             <version>${aggregator.version}</version>
         </dependency>
         </dependency>
 
 
+        <!-- easypoi -->
+        <dependency>
+            <groupId>cn.afterturn</groupId>
+            <artifactId>easypoi-spring-boot-starter</artifactId>
+            <version>${easypoi.version}</version>
+        </dependency>
+
+
     </dependencies>
     </dependencies>
 
 
     <!-- 私有仓库 -->
     <!-- 私有仓库 -->

+ 1 - 0
src/main/java/com/diagbot/config/ResourceServerConfigurer.java

@@ -61,6 +61,7 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/qc/behospitalInfo/page_person").permitAll()
                 .antMatchers("/qc/behospitalInfo/page_person").permitAll()
                 .antMatchers("/consoleByDept/getDept").permitAll()
                 .antMatchers("/consoleByDept/getDept").permitAll()
                 .antMatchers("/qc/casesEntryHospital/findQcCasesEntry").permitAll()
                 .antMatchers("/qc/casesEntryHospital/findQcCasesEntry").permitAll()
+                .antMatchers("/qc/behospitalInfo/exportExcel").permitAll()
                 .antMatchers("/**").authenticated();
                 .antMatchers("/**").authenticated();
 //                .antMatchers("/**").permitAll();
 //                .antMatchers("/**").permitAll();
     }
     }

+ 1 - 0
src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java

@@ -104,6 +104,7 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/qc/behospitalInfo/page_person", request)
                 || matchers("/qc/behospitalInfo/page_person", request)
                 || matchers("/consoleByDept/getDept", request)
                 || matchers("/consoleByDept/getDept", request)
                 || matchers("/qc/casesEntryHospital/findQcCasesEntry", request)
                 || matchers("/qc/casesEntryHospital/findQcCasesEntry", request)
+                || matchers("/qc/behospitalInfo/exportExcel", request)
                 || matchers("/", request)) {
                 || matchers("/", request)) {
             return true;
             return true;
         }
         }

+ 33 - 0
src/main/java/com/diagbot/dto/ExportExcelBehospitalDTO.java

@@ -0,0 +1,33 @@
+package com.diagbot.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/6/2 19:35
+ */
+@Getter
+@Setter
+public class ExportExcelBehospitalDTO {
+    @Excel(name = "主管医生", needMerge = true)
+    private String behDoctorName;
+    @Excel(name = "患者姓名", needMerge = true)
+    private String patName;
+    @Excel(name = "住院号", needMerge = true)
+    private String behospitalCode;
+    @Excel(name = "入院时间", needMerge = true, exportFormat = "yyyy/MM/dd")
+    private String behospitalDate;
+    @Excel(name = "出院时间", needMerge = true, exportFormat = "yyyy/MM/dd")
+    private String leaveHospitalDate;
+    @Excel(name = "分数", needMerge = true)
+    private String score;
+    @ExcelCollection(name = "")
+    private List<ExportExcelCaseDTO> exportExcelCaseDTOS;
+
+}

+ 23 - 0
src/main/java/com/diagbot/dto/ExportExcelCaseDTO.java

@@ -0,0 +1,23 @@
+package com.diagbot.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/6/2 19:47
+ */
+@Getter
+@Setter
+public class ExportExcelCaseDTO {
+    @Excel(name = "错误所属区块", needMerge = true)
+    private String caseName;
+    @ExcelCollection(name = "")
+    private List<ExportExcelMsgDTO> exportExcelMsgDTOS;
+
+}

+ 26 - 0
src/main/java/com/diagbot/dto/ExportExcelDTO.java

@@ -0,0 +1,26 @@
+package com.diagbot.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.List;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/6/2 19:00
+ */
+@Getter
+@Setter
+public class ExportExcelDTO {
+    @Excel(name = "出院科室", needMerge = true)
+    private String behDeptName;
+    @Excel(name = "平均分数", needMerge = true)
+    private String avgScore;
+    @ExcelCollection(name = "")
+    private List<ExportExcelBehospitalDTO> excelBehospitalDTOS;
+
+
+}

+ 17 - 0
src/main/java/com/diagbot/dto/ExportExcelMsgDTO.java

@@ -0,0 +1,17 @@
+package com.diagbot.dto;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/6/2 19:47
+ */
+@Getter
+@Setter
+public class ExportExcelMsgDTO {
+    @Excel(name = "存在问题")
+    private String msg;
+}

+ 9 - 0
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -10,6 +10,7 @@ import com.diagbot.dto.AnalyzeDTO;
 import com.diagbot.dto.AnalyzeRunDTO;
 import com.diagbot.dto.AnalyzeRunDTO;
 import com.diagbot.dto.BehosDTO;
 import com.diagbot.dto.BehosDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
+import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.MedicalRecordDTO;
 import com.diagbot.dto.MedicalRecordDTO;
 import com.diagbot.dto.MsgApiDTO;
 import com.diagbot.dto.MsgApiDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.MsgDTO;
@@ -35,6 +36,7 @@ import com.diagbot.util.BeanUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.DateUtil;
 import com.diagbot.util.EncrypDES;
 import com.diagbot.util.EncrypDES;
 import com.diagbot.util.EntityUtil;
 import com.diagbot.util.EntityUtil;
+import com.diagbot.util.ExcelUtils;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.ListUtil;
 import com.diagbot.util.MapUtil;
 import com.diagbot.util.MapUtil;
 import com.diagbot.util.StringUtil;
 import com.diagbot.util.StringUtil;
@@ -56,6 +58,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;
 
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.ArrayList;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.Date;
@@ -920,4 +923,10 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
             behospitalPageVO.setLeaveHosDateEnd(DateUtil.parseDate(endDate));
             behospitalPageVO.setLeaveHosDateEnd(DateUtil.parseDate(endDate));
         }
         }
     }
     }
+
+    public void exportExcelFac(HttpServletResponse response){
+        List<ExportExcelDTO> res = this.exportExcel();
+        response.setContentType("text/html;charset=UTF-8");
+        ExcelUtils.exportExcel(res, null, "导出sheet1", ExportExcelDTO.class, "测试user.xls", response);
+    }
 }
 }

+ 4 - 0
src/main/java/com/diagbot/mapper/BehospitalInfoMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.DeptNumDTO;
+import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.NumDTO;
@@ -178,4 +179,7 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
      * @return
      * @return
      */
      */
     public List<LevelStatisticsDTO> levelStatisticsByDeptClass(FilterOrderVO filterOrderVO);
     public List<LevelStatisticsDTO> levelStatisticsByDeptClass(FilterOrderVO filterOrderVO);
+
+
+    List<ExportExcelDTO> exportExcel();
 }
 }

+ 3 - 0
src/main/java/com/diagbot/service/BehospitalInfoService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.DeptNumDTO;
+import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.NumDTO;
@@ -179,4 +180,6 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
      * @return
      * @return
      */
      */
     public List<LevelStatisticsDTO> levelStatisticsByDeptClass(FilterOrderVO filterOrderVO);
     public List<LevelStatisticsDTO> levelStatisticsByDeptClass(FilterOrderVO filterOrderVO);
+
+    List<ExportExcelDTO> exportExcel();
 }
 }

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

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.DeptNumDTO;
+import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.NumDTO;
 import com.diagbot.dto.NumDTO;
@@ -242,4 +243,9 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     public List<LevelStatisticsDTO> levelStatisticsByDeptClass(FilterOrderVO filterOrderVO) {
     public List<LevelStatisticsDTO> levelStatisticsByDeptClass(FilterOrderVO filterOrderVO) {
         return baseMapper.levelStatisticsByDeptClass(filterOrderVO);
         return baseMapper.levelStatisticsByDeptClass(filterOrderVO);
     }
     }
+
+    @Override
+    public List<ExportExcelDTO> exportExcel(){
+        return baseMapper.exportExcel();
+    }
 }
 }

+ 110 - 0
src/main/java/com/diagbot/util/ExcelUtils.java

@@ -0,0 +1,110 @@
+package com.diagbot.util;
+
+
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.ExcelImportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.afterturn.easypoi.excel.entity.ImportParams;
+import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+/**
+ * @Description: excel 导入导出工具类
+ * @author: gaodm
+ * @time: 2020/6/2 19:18
+ */
+public class ExcelUtils {
+    public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName,
+                                   boolean isCreateHeader, HttpServletResponse response) {
+        ExportParams exportParams = new ExportParams(title, sheetName);
+        exportParams.setCreateHeadRows(isCreateHeader);
+        defaultExport(list, pojoClass, fileName, response, exportParams);
+    }
+
+    public static void exportExcel(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName,
+                                   HttpServletResponse response) {
+        defaultExport(list, pojoClass, fileName, response, new ExportParams(title, sheetName));
+    }
+
+    public static void exportExcel(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
+        defaultExport(list, fileName, response);
+    }
+
+    private static void defaultExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response,
+                                      ExportParams exportParams) {
+        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
+        if (workbook != null) {
+            ;
+        }
+        downLoadExcel(fileName, response, workbook);
+    }
+
+    private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
+        try {
+            response.setCharacterEncoding("UTF-8");
+            response.setHeader("content-Type", "application/vnd.ms-excel");
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
+            workbook.write(response.getOutputStream());
+        } catch (IOException e) {
+            // throw new NormalException(e.getMessage());
+        }
+    }
+
+    private static void defaultExport(List<Map<String, Object>> list, String fileName, HttpServletResponse response) {
+        Workbook workbook = ExcelExportUtil.exportExcel(list, ExcelType.HSSF);
+        if (workbook != null) {
+            ;
+        }
+        downLoadExcel(fileName, response, workbook);
+    }
+
+    public static <T> List<T> importExcel(String filePath, Integer titleRows, Integer headerRows, Class<T> pojoClass) {
+        if (StringUtils.isBlank(filePath)) {
+            return null;
+        }
+        ImportParams params = new ImportParams();
+        params.setTitleRows(titleRows);
+        params.setHeadRows(headerRows);
+        List<T> list = null;
+        try {
+            list = ExcelImportUtil.importExcel(new File(filePath), pojoClass, params);
+        } catch (NoSuchElementException e) {
+            // throw new NormalException("模板不能为空");
+        } catch (Exception e) {
+            e.printStackTrace();
+            // throw new NormalException(e.getMessage());
+        }
+        return list;
+    }
+
+    public static <T> List<T> importExcel(MultipartFile file, Integer titleRows, Integer headerRows,
+                                          Class<T> pojoClass) {
+        if (file == null) {
+            return null;
+        }
+        ImportParams params = new ImportParams();
+        params.setTitleRows(titleRows);
+        params.setHeadRows(headerRows);
+        List<T> list = null;
+        try {
+            list = ExcelImportUtil.importExcel(file.getInputStream(), pojoClass, params);
+        } catch (NoSuchElementException e) {
+            // throw new NormalException("excel文件不能为空");
+        } catch (Exception e) {
+            // throw new NormalException(e.getMessage());
+            System.out.println(e.getMessage());
+        }
+        return list;
+    }
+
+}

+ 12 - 0
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -5,6 +5,7 @@ import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.AnalyzeDTO;
 import com.diagbot.dto.AnalyzeDTO;
 import com.diagbot.dto.AnalyzeRunDTO;
 import com.diagbot.dto.AnalyzeRunDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
+import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.BehospitalInfoFacade;
 import com.diagbot.facade.BehospitalInfoFacade;
 import com.diagbot.facade.QcresultInfoFacade;
 import com.diagbot.facade.QcresultInfoFacade;
@@ -25,7 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.bind.annotation.RestController;
 import springfox.documentation.annotations.ApiIgnore;
 import springfox.documentation.annotations.ApiIgnore;
 
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import javax.validation.Valid;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -188,4 +191,13 @@ public class BehospitalInfoController {
         IPage<BehospitalInfoDTO> data = behospitalInfoFacade.pagePerson(behospitalPageVO);
         IPage<BehospitalInfoDTO> data = behospitalInfoFacade.pagePerson(behospitalPageVO);
         return RespDTO.onSuc(data);
         return RespDTO.onSuc(data);
     }
     }
+
+
+    @ApiOperation(value = "导出病历[by:gaodm]",
+            notes = "")
+    @PostMapping("/exportExcel")
+    @SysLogger("exportExcel")
+    public void exportExcel(HttpServletResponse response) {
+        behospitalInfoFacade.exportExcelFac(response);
+    }
 }
 }

+ 201 - 102
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -1,56 +1,60 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.diagbot.mapper.BehospitalInfoMapper">
 <mapper namespace="com.diagbot.mapper.BehospitalInfoMapper">
 
 
     <!-- 通用查询映射结果 -->
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
     <resultMap id="BaseResultMap" type="com.diagbot.entity.BehospitalInfo">
-        <id column="behospital_code" property="behospitalCode" />
-        <result column="hospital_id" property="hospitalId" />
-        <result column="name" property="name" />
-        <result column="sex" property="sex" />
-        <result column="birthday" property="birthday" />
-        <result column="file_code" property="fileCode" />
-        <result column="qc_type_id" property="qcTypeId" />
-        <result column="ward_code" property="wardCode" />
-        <result column="ward_name" property="wardName" />
-        <result column="beh_dept_id" property="behDeptId" />
-        <result column="beh_dept_name" property="behDeptName" />
-        <result column="bed_code" property="bedCode" />
-        <result column="bed_name" property="bedName" />
-        <result column="insurance_name" property="insuranceName" />
-        <result column="job_type" property="jobType" />
-        <result column="behospital_date" property="behospitalDate" />
-        <result column="leave_hospital_date" property="leaveHospitalDate" />
-        <result column="diagnose_icd" property="diagnoseIcd" />
-        <result column="diagnose" property="diagnose" />
-        <result column="beh_doctor_id" property="behDoctorId" />
-        <result column="beh_doctor_name" property="behDoctorName" />
-        <result column="doctor_id" property="doctorId" />
-        <result column="doctor_name" property="doctorName" />
-        <result column="director_doctor_id" property="directorDoctorId" />
-        <result column="director_doctor_name" property="directorDoctorName" />
-        <result column="is_placefile" property="isPlacefile" />
-        <result column="is_deleted" property="isDeleted" />
-        <result column="gmt_create" property="gmtCreate" />
-        <result column="gmt_modified" property="gmtModified" />
-        <result column="creator" property="creator" />
-        <result column="modifier" property="modifier" />
+        <id column="behospital_code" property="behospitalCode"/>
+        <result column="hospital_id" property="hospitalId"/>
+        <result column="name" property="name"/>
+        <result column="sex" property="sex"/>
+        <result column="birthday" property="birthday"/>
+        <result column="file_code" property="fileCode"/>
+        <result column="qc_type_id" property="qcTypeId"/>
+        <result column="ward_code" property="wardCode"/>
+        <result column="ward_name" property="wardName"/>
+        <result column="beh_dept_id" property="behDeptId"/>
+        <result column="beh_dept_name" property="behDeptName"/>
+        <result column="bed_code" property="bedCode"/>
+        <result column="bed_name" property="bedName"/>
+        <result column="insurance_name" property="insuranceName"/>
+        <result column="job_type" property="jobType"/>
+        <result column="behospital_date" property="behospitalDate"/>
+        <result column="leave_hospital_date" property="leaveHospitalDate"/>
+        <result column="diagnose_icd" property="diagnoseIcd"/>
+        <result column="diagnose" property="diagnose"/>
+        <result column="beh_doctor_id" property="behDoctorId"/>
+        <result column="beh_doctor_name" property="behDoctorName"/>
+        <result column="doctor_id" property="doctorId"/>
+        <result column="doctor_name" property="doctorName"/>
+        <result column="director_doctor_id" property="directorDoctorId"/>
+        <result column="director_doctor_name" property="directorDoctorName"/>
+        <result column="is_placefile" property="isPlacefile"/>
+        <result column="is_deleted" property="isDeleted"/>
+        <result column="gmt_create" property="gmtCreate"/>
+        <result column="gmt_modified" property="gmtModified"/>
+        <result column="creator" property="creator"/>
+        <result column="modifier" property="modifier"/>
     </resultMap>
     </resultMap>
 
 
     <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
     <select id="getPage" resultType="com.diagbot.dto.BehospitalInfoDTO">
         select * from (
         select * from (
-            select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as grade_time, c.age from med_behospital_info a
-            LEFT JOIN med_qcresult_info b
-            on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
-            left join med_home_page c
-            on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
+        select a.*, ifnull(b.level,'未评分') as `level`, b.grade_type, b.score_res, b.gmt_create as
+        grade_time, c.age from med_behospital_info a
+        LEFT JOIN med_qcresult_info b
+        on a.behospital_code = b.behospital_code and b.is_deleted = 'N'
+        left join med_home_page c
+        on a.behospital_code = c.behospital_code and c.is_deleted = 'N'
         ) t
         ) t
         where t.is_deleted = 'N'
         where t.is_deleted = 'N'
         <if test="deptId != null and deptId != ''">
         <if test="deptId != null and deptId != ''">
             and t.beh_dept_id = #{deptId}
             and t.beh_dept_id = #{deptId}
         </if>
         </if>
         <if test="doctorName != null and doctorName != ''">
         <if test="doctorName != null and doctorName != ''">
-            and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
+            and CONCAT(
+            IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
+            like CONCAT('%',#{doctorName},'%')
         </if>
         </if>
         <if test="name != null and name != ''">
         <if test="name != null and name != ''">
             and t.name like CONCAT('%',#{name},'%')
             and t.name like CONCAT('%',#{name},'%')
@@ -106,9 +110,9 @@
     </select>
     </select>
 
 
     <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
     <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
-        SELECT  b.id model_id,b.`name` model_name,
-                d.score,d.msg,d.cases_entry_id,d.is_reject,
-                a.cases_id cases_id, a.name standard_msg,a.code
+        SELECT b.id model_id,b.`name` model_name,
+        d.score,d.msg,d.cases_entry_id,d.is_reject,
+        a.cases_id cases_id, a.name standard_msg,a.code
         FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
         FROM `qc_cases_entry` a, qc_mode b, qc_cases_entry_hospital d
         where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
         where a.is_deleted = 'N' and b.is_deleted = 'N' and d.is_deleted = 'N'
         and a.mode_id = b.id
         and a.mode_id = b.id
@@ -126,7 +130,8 @@
     </select>
     </select>
 
 
     <!-- 各科室缺陷占比-全院-首页 -->
     <!-- 各科室缺陷占比-全院-首页 -->
-    <select id="entryByDept"  parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
+    <select id="entryByDept" parameterType="com.diagbot.vo.FilterVO"
+            resultType="com.diagbot.dto.NumDTO">
         SELECT
         SELECT
         a.beh_dept_id as id,
         a.beh_dept_id as id,
         a.beh_dept_name as name,
         a.beh_dept_name as name,
@@ -162,7 +167,7 @@
     </select>
     </select>
 
 
     <!-- 质控结果缺陷总数查询-->
     <!-- 质控结果缺陷总数查询-->
-    <select id="getTotleResultNum"  parameterType="com.diagbot.vo.FilterVO" resultType="int">
+    <select id="getTotleResultNum" parameterType="com.diagbot.vo.FilterVO" resultType="int">
         SELECT
         SELECT
         count(*) AS totle
         count(*) AS totle
         FROM
         FROM
@@ -192,28 +197,28 @@
 
 
     <!--获取病历-->
     <!--获取病历-->
     <select id="getNoGrade" resultMap="BaseResultMap">
     <select id="getNoGrade" resultMap="BaseResultMap">
-         select * from med_behospital_info a
-         where a.is_deleted = 'N'
-         and a.qc_type_id != 0
-         <if test="filterFlag != null and filterFlag == 0">
+        select * from med_behospital_info a
+        where a.is_deleted = 'N'
+        and a.qc_type_id != 0
+        <if test="filterFlag != null and filterFlag == 0">
             and
             and
             not EXISTS (
             not EXISTS (
             SELECT
             SELECT
-                1
+            1
             FROM
             FROM
-                med_qcresult_info b
+            med_qcresult_info b
             WHERE
             WHERE
-                b.is_deleted = 'N'
+            b.is_deleted = 'N'
             AND a.hospital_id = b.hospital_id
             AND a.hospital_id = b.hospital_id
             AND a.behospital_code = b.behospital_code
             AND a.behospital_code = b.behospital_code
             )
             )
-         </if>
-         <if test="leaveDate != null">
-             <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
-         </if>
+        </if>
+        <if test="leaveDate != null">
+            <![CDATA[ and a.leave_hospital_date < #{leaveDate}]]>
+        </if>
         <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
         <if test="hosptialIdList != null and hosptialIdList.size > 0 ">
             and a.hospital_id in
             and a.hospital_id in
-            <foreach collection="hosptialIdList" item="item" open="("  separator=","  close=")">
+            <foreach collection="hosptialIdList" item="item" open="(" separator="," close=")">
                 #{item}
                 #{item}
             </foreach>
             </foreach>
         </if>
         </if>
@@ -224,7 +229,7 @@
         SELECT
         SELECT
         *
         *
         FROM
         FROM
-        (     SELECT
+        ( SELECT
         a.*,
         a.*,
         IFNULL(b.level, '未评分') AS `level`,
         IFNULL(b.level, '未评分') AS `level`,
         b.grade_type,
         b.grade_type,
@@ -250,7 +255,9 @@
             and t.beh_dept_id = #{deptId}
             and t.beh_dept_id = #{deptId}
         </if>
         </if>
         <if test="doctorName != null and doctorName != ''">
         <if test="doctorName != null and doctorName != ''">
-            and CONCAT( IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,'')) like CONCAT('%',#{doctorName},'%')
+            and CONCAT(
+            IFNULL(t.doctor_name,''),IFNULL(t.beh_doctor_name,''),IFNULL(t.director_doctor_name,''))
+            like CONCAT('%',#{doctorName},'%')
         </if>
         </if>
         <if test="doctorCode != null and doctorCode != ''">
         <if test="doctorCode != null and doctorCode != ''">
             and (t.doctor_id = #{doctorCode}
             and (t.doctor_id = #{doctorCode}
@@ -464,7 +471,8 @@
     </select>
     </select>
 
 
     <!-- 出院总人数统计-科室-首页 -->
     <!-- 出院总人数统计-科室-首页 -->
-    <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
+    <select id="leaveHosCountByDept" parameterType="com.diagbot.vo.FilterVO"
+            resultType="com.diagbot.dto.NumDTO">
         SELECT
         SELECT
         a.beh_dept_id AS id,
         a.beh_dept_id AS id,
         a.beh_dept_name AS NAME,
         a.beh_dept_name AS NAME,
@@ -497,7 +505,8 @@
     </select>
     </select>
 
 
     <!-- 新生儿出院人数统计-科室-首页 -->
     <!-- 新生儿出院人数统计-科室-首页 -->
-    <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
+    <select id="newBornCountByDept" parameterType="com.diagbot.vo.FilterVO"
+            resultType="com.diagbot.dto.NumDTO">
         SELECT
         SELECT
         a.beh_dept_id AS id,
         a.beh_dept_id AS id,
         a.beh_dept_name AS NAME,
         a.beh_dept_name AS NAME,
@@ -536,7 +545,8 @@
     </select>
     </select>
 
 
     <!-- 死亡人数统计-科室-首页 -->
     <!-- 死亡人数统计-科室-首页 -->
-    <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
+    <select id="deathCountByDept" parameterType="com.diagbot.vo.FilterVO"
+            resultType="com.diagbot.dto.NumDTO">
         SELECT
         SELECT
         a.beh_dept_id AS id,
         a.beh_dept_id AS id,
         a.beh_dept_name AS NAME,
         a.beh_dept_name AS NAME,
@@ -574,7 +584,8 @@
     </select>
     </select>
 
 
     <!-- 手术人数统计-科室-首页 -->
     <!-- 手术人数统计-科室-首页 -->
-    <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO" resultType="com.diagbot.dto.NumDTO">
+    <select id="operationCountByDept" parameterType="com.diagbot.vo.FilterVO"
+            resultType="com.diagbot.dto.NumDTO">
         SELECT
         SELECT
         a.beh_dept_id AS id,
         a.beh_dept_id AS id,
         a.beh_dept_name AS NAME,
         a.beh_dept_name AS NAME,
@@ -801,7 +812,8 @@
     </select>
     </select>
 
 
     <!-- 各科室缺陷占比(组合)-全院 -->
     <!-- 各科室缺陷占比(组合)-全院 -->
-    <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
+    <select id="levelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
+            resultType="com.diagbot.dto.LevelStatisticsDTO">
         SELECT
         SELECT
         t1.deptId,
         t1.deptId,
         t1.deptName,
         t1.deptName,
@@ -829,19 +841,25 @@
         COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
         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 secondLevelNum,
         COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
         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,
+        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(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS firstLevelPercentStr,
         ) AS firstLevelPercentStr,
         concat(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS secondLevelPercentStr,
         ) AS secondLevelPercentStr,
         concat(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS thirdLevelPercentStr
         ) AS thirdLevelPercentStr
         FROM
         FROM
@@ -936,7 +954,7 @@
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
                 <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
                 <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
-                <otherwise> deptName asc </otherwise>
+                <otherwise>deptName asc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
         <if test="desc != null and desc!=''">
         <if test="desc != null and desc!=''">
@@ -957,13 +975,14 @@
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
                 <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
                 <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
-                <otherwise> deptName desc </otherwise>
+                <otherwise>deptName desc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
     </select>
     </select>
 
 
     <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计 -->
     <!-- 各科室缺陷占比(组合)-全院-根据内外科系统统计 -->
-    <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
+    <select id="levelStatisticsByDeptClass" parameterType="com.diagbot.vo.FilterOrderVO"
+            resultType="com.diagbot.dto.LevelStatisticsDTO">
         SELECT
         SELECT
         t1.deptId,
         t1.deptId,
         t1.deptName,
         t1.deptName,
@@ -995,19 +1014,25 @@
         COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
         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 secondLevelNum,
         COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
         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,
+        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(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS firstLevelPercentStr,
         ) AS firstLevelPercentStr,
         concat(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS secondLevelPercentStr,
         ) AS secondLevelPercentStr,
         concat(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS thirdLevelPercentStr
         ) AS thirdLevelPercentStr
         FROM
         FROM
@@ -1134,7 +1159,7 @@
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
                 <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
                 <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
-                <otherwise> deptName asc </otherwise>
+                <otherwise>deptName asc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
         <if test="desc != null and desc!=''">
         <if test="desc != null and desc!=''">
@@ -1157,13 +1182,14 @@
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
                 <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
                 <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
-                <otherwise> deptName desc </otherwise>
+                <otherwise>deptName desc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
     </select>
     </select>
 
 
     <!-- 病案首页合格率占比 -全院-->
     <!-- 病案首页合格率占比 -全院-->
-    <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
+    <select id="homePageLevelStatistics" parameterType="com.diagbot.vo.FilterOrderVO"
+            resultType="com.diagbot.dto.LevelStatisticsDTO">
         SELECT
         SELECT
         t1.deptId,
         t1.deptId,
         t1.deptName,
         t1.deptName,
@@ -1187,14 +1213,18 @@
         ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
         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 firstLevelNum,
         COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
         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,
+        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(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS firstLevelPercentStr,
         ) AS firstLevelPercentStr,
         concat(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS secondLevelPercentStr
         ) AS secondLevelPercentStr
         FROM
         FROM
@@ -1289,7 +1319,7 @@
                 <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
                 <when test='asc=="secondLevelPercent"'>secondLevelPercent asc</when>
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
-                <otherwise> deptName asc </otherwise>
+                <otherwise>deptName asc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
         <if test="desc != null and desc!=''">
         <if test="desc != null and desc!=''">
@@ -1307,13 +1337,14 @@
                 <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
                 <when test='desc=="secondLevelPercent"'>secondLevelPercent desc</when>
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
-                <otherwise> deptName desc </otherwise>
+                <otherwise>deptName desc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
     </select>
     </select>
 
 
     <!-- 各科室缺陷占比-科室 -->
     <!-- 各科室缺陷占比-科室 -->
-    <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
+    <select id="levelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
+            resultType="com.diagbot.dto.LevelStatisticsDTO">
         SELECT
         SELECT
         t1.doctorId,
         t1.doctorId,
         t1.doctorName,
         t1.doctorName,
@@ -1341,19 +1372,25 @@
         COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END ) AS firstLevelNum,
         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 secondLevelNum,
         COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END ) AS thirdLevelNum,
         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,
+        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(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '甲' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS firstLevelPercentStr,
         ) AS firstLevelPercentStr,
         concat(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '乙' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS secondLevelPercentStr,
         ) AS secondLevelPercentStr,
         concat(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '丙' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS thirdLevelPercentStr
         ) AS thirdLevelPercentStr
         FROM
         FROM
@@ -1466,7 +1503,7 @@
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
                 <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
                 <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
-                <otherwise> doctorName asc </otherwise>
+                <otherwise>doctorName asc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
         <if test="desc != null and desc!=''">
         <if test="desc != null and desc!=''">
@@ -1487,13 +1524,14 @@
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
                 <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
                 <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
-                <otherwise> doctorName desc </otherwise>
+                <otherwise>doctorName desc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
     </select>
     </select>
 
 
     <!-- 病案首页合格率占比-科室 -->
     <!-- 病案首页合格率占比-科室 -->
-    <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO" resultType="com.diagbot.dto.LevelStatisticsDTO">
+    <select id="homePageLevelStatisticsByDept" parameterType="com.diagbot.vo.FilterOrderByDeptVO"
+            resultType="com.diagbot.dto.LevelStatisticsDTO">
         SELECT
         SELECT
         t1.doctorId,
         t1.doctorId,
         t1.doctorName,
         t1.doctorName,
@@ -1517,14 +1555,18 @@
         ROUND( sum( CAST(c.score_res as DECIMAL ( 18, 2 )) )/ count(*), 2 ) AS averageValue,
         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 firstLevelNum,
         COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END ) AS secondLevelNum,
         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,
+        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(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '合格' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS firstLevelPercentStr,
         ) AS firstLevelPercentStr,
         concat(
         concat(
-        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )* 100, 2 ),
+        ROUND( COUNT( DISTINCT CASE WHEN c.`level` = '不合格' THEN c.id END )/ count( DISTINCT c.id )*
+        100, 2 ),
         '%'
         '%'
         ) AS secondLevelPercentStr
         ) AS secondLevelPercentStr
         FROM
         FROM
@@ -1640,7 +1682,7 @@
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="firstLevelPercentStr"'>firstLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
                 <when test='asc=="secondLevelPercentStr"'>secondLevelPercent asc</when>
                 <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
                 <when test='asc=="thirdLevelPercentStr"'>thirdLevelPercent asc</when>
-                <otherwise> doctorName asc </otherwise>
+                <otherwise>doctorName asc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
         <if test="desc != null and desc!=''">
         <if test="desc != null and desc!=''">
@@ -1661,8 +1703,65 @@
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="firstLevelPercentStr"'>firstLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
                 <when test='desc=="secondLevelPercentStr"'>secondLevelPercent desc</when>
                 <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
                 <when test='desc=="thirdLevelPercentStr"'>thirdLevelPercent desc</when>
-                <otherwise> doctorName desc </otherwise>
+                <otherwise>doctorName desc</otherwise>
             </choose>
             </choose>
         </if>
         </if>
     </select>
     </select>
+
+    <resultMap id="ExportExcelMap" type="com.diagbot.dto.ExportExcelDTO">
+        <result column="behDeptName" property="behDeptName"/>
+        <result column="avgScore" property="avgScore"/>
+        <collection property="excelBehospitalDTOS"
+                    ofType="com.diagbot.dto.ExportExcelBehospitalDTO">
+            <result column="behDoctorName" property="behDoctorName"/>
+            <result column="patName" property="patName"/>
+            <result column="behospitalCode" property="behospitalCode"/>
+            <result column="behospitalDate" property="behospitalDate"/>
+            <result column="leaveHospitalDate" property="leaveHospitalDate"/>
+            <result column="score" property="score"/>
+            <collection property="exportExcelCaseDTOS" ofType="com.diagbot.dto.ExportExcelCaseDTO">
+                <result column="caseName" property="caseName"/>
+                <collection property="exportExcelMsgDTOS"
+                            ofType="com.diagbot.dto.ExportExcelMsgDTO">
+                    <result column="msg" property="msg"/>
+                </collection>
+            </collection>
+        </collection>
+    </resultMap>
+
+    <select id="exportExcel" resultMap="ExportExcelMap">
+        SELECT DISTINCT
+        t1.beh_dept_name AS behDeptName,
+        t1.beh_doctor_name AS behDoctorName,
+        t1.`name` AS patName,
+        t1.behospital_code AS behospitalCode,
+        t1.behospital_date AS behospitalDate,
+        t1.leave_hospital_date AS leaveHospitalDate,
+        t2.score_res AS score,
+        "1" AS avgScore,
+        t4.`name` AS caseName,
+        t3.msg AS msg
+        FROM
+        med_behospital_info t1,
+        med_qcresult_info t2,
+        med_qcresult_detail t3,
+        qc_cases t4
+        WHERE
+        t1.is_deleted = 'N'
+        AND t2.is_deleted = 'N'
+        AND t3.is_deleted = 'N'
+        AND t4.is_deleted = 'N'
+        <![CDATA[AND t1.leave_hospital_date >= '2020-03-03 00:00:00']]>
+        <![CDATA[AND t1.leave_hospital_date <= '2020-03-03 23:00:00']]>
+        AND t1.hospital_id = t2.hospital_id
+        AND t1.behospital_code = t2.behospital_code
+        AND t1.hospital_id = t3.hospital_id
+        AND t1.behospital_code = t3.behospital_code
+        AND t3.cases_id = t4.id
+        ORDER BY
+        t1.beh_dept_id ASC,
+        t1.leave_hospital_date DESC,
+        t1.behospital_code ASC,
+        t4.`name` ASC
+    </select>
 </mapper>
 </mapper>