Selaa lähdekoodia

Merge branch 'dev/20200522temp' into debug

# Conflicts:
#	src/main/java/com/diagbot/config/security/UrlAccessDecisionManager.java
zhoutg 5 vuotta sitten
vanhempi
commit
1dccb0587a

+ 5 - 1
doc/005.20200528v1.2.x/qc_init.sql

@@ -67,7 +67,11 @@ INSERT INTO `qc_mode` VALUES ('55', '其他', '999', '-1', 'N', '1970-01-01 12:0
 
 ALTER TABLE `sys_task_cron` ADD COLUMN `param` varchar(500) DEFAULT '' COMMENT '参数' AFTER `cron`;
 UPDATE `sys_task_cron` SET `param` = 1,`is_deleted` = 'N' where cron_code = 'TASK_CX';
-UPDATE `sys_task_cron` SET `param` = 3,`is_deleted` = 'N',`remark` = '评分未评分的数据' where cron_code = 'TASK001';
+UPDATE `sys_task_cron` SET `id` = -2,`param` = 3,`is_deleted` = 'N',`remark` = '评分未评分的数据' where cron_code = 'TASK001';
+
+UPDATE `sys_task_cron` SET `id`='-2', `is_deleted`='N', `gmt_create`='1970-01-01 12:00:00', `gmt_modified`='1970-01-01 12:00:00', `creator`='0', `modifier`='0', `cron_code`='TASK001', `cron`='0 0 23 * * ?', `param`='3', `is_used`='1', `remark`='评分未评分的数据' WHERE (`id`='-2');
+UPDATE `sys_task_cron` SET `id`='-1', `is_deleted`='N', `gmt_create`='1970-01-01 12:00:00', `gmt_modified`='1970-01-01 12:00:00', `creator`='0', `modifier`='0', `cron_code`='TASK_CX', `cron`='0 0 22 * * ?', `param`='1', `is_used`='1', `remark`='每天晚上自动评分出院日期之前3天的未评分数据' WHERE (`id`='-1');
+
 
 INSERT INTO `sys_permission`(`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `permissionUrl`, `method`, `descritpion`, `remark`) VALUES (89, 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '条目缺陷占比(内页)', 'FUNC000089', '/console/entryGroupByEntryInnerPage', 'ALL', '控制台-条目缺陷占比(内页)', NULL);
 INSERT INTO `sys_permission`(`id`, `is_deleted`, `gmt_create`, `gmt_modified`, `creator`, `modifier`, `name`, `code`, `permissionUrl`, `method`, `descritpion`, `remark`) VALUES (90, 'N', '1970-01-01 12:00:00', '1970-01-01 12:00:00', '0', '0', '条目缺陷占比-科室(内页)', 'FUNC000090', '/consoleByDept/entryGroupByEntryAndDeptInnerPage', 'ALL', '控制台(科室)-条目缺陷占比-科室(内页)', NULL);

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

@@ -64,6 +64,8 @@ public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter {
                 .antMatchers("/qc/dataimport/import").permitAll()
                 .antMatchers("/qc/dataimport/test").permitAll()
                 .antMatchers("/qc/behospitalInfo/exportExcel").permitAll()
+                .antMatchers("/qc/behospitalInfo/exportQcresult").permitAll()
+                .antMatchers("/qc/behospitalInfo/exportQcresultByDept").permitAll()
                 .antMatchers("/**").authenticated();
 //                .antMatchers("/**").permitAll();
     }

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

@@ -107,6 +107,8 @@ public class UrlAccessDecisionManager implements AccessDecisionManager {
                 || matchers("/qc/behospitalInfo/exportExcel", request)
                 || matchers("/qc/dataimport/import", request)
                 || matchers("/qc/dataimport/test", request)
+                || matchers("/qc/behospitalInfo/exportQcresult", request)
+                || matchers("/qc/behospitalInfo/exportQcresultByDept", request)
                 || matchers("/", request)) {
             return true;
         }

+ 9 - 0
src/main/java/com/diagbot/dto/ExportExcelCase.java

@@ -0,0 +1,9 @@
+package com.diagbot.dto;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/6/2 19:47
+ */
+public class ExportExcelCase {
+}

+ 1 - 1
src/main/java/com/diagbot/dto/ExportExcelMsgDTO.java

@@ -12,6 +12,6 @@ import lombok.Setter;
 @Getter
 @Setter
 public class ExportExcelMsgDTO {
-    @Excel(name = "存在问题")
+    @Excel(name = "存在问题", isWrap = false)
     private String msg;
 }

+ 58 - 0
src/main/java/com/diagbot/dto/ExportQcresultDTO.java

@@ -0,0 +1,58 @@
+package com.diagbot.dto;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/6/2 19:57
+ */
+@Getter
+@Setter
+public class ExportQcresultDTO {
+    /**
+     * 科室编码/科室id
+     */
+    private String deptId;
+    /**
+     * 科室名称
+     */
+    private String deptName;
+    /**
+     * 主管医生名称(主任医生+主治医生)
+     */
+    private String doctorName;
+    /**
+     * 患者姓名
+     */
+    private String patientName;
+    /**
+     * 病历号
+     */
+    private String behospitalCode;
+    /**
+     * 入院日期
+     */
+    private String behospitalDate;
+    /**
+     * 出院日期
+     */
+    private String leaveHospitalDate;
+    /**
+     * 质控评分
+     */
+    private Double scoreRes;
+    /**
+     * 科室质控平均分
+     */
+    private Double averageScore;
+    /**
+     * 存在问题
+     */
+    private String msg;
+    /**
+     * 错误所属区块
+     */
+    private String casesName;
+}

+ 57 - 1
src/main/java/com/diagbot/facade/BehospitalInfoFacade.java

@@ -28,6 +28,7 @@ import com.diagbot.entity.HomeDiagnoseInfo;
 import com.diagbot.entity.HomeOperationInfo;
 import com.diagbot.entity.HomePage;
 import com.diagbot.entity.MedicalRecord;
+import com.diagbot.entity.SysUserDept;
 import com.diagbot.enums.IsDeleteEnum;
 import com.diagbot.exception.CommonErrorCode;
 import com.diagbot.exception.CommonException;
@@ -47,6 +48,8 @@ import com.diagbot.vo.AnalyzeCodeVO;
 import com.diagbot.vo.AnalyzeRunVO;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.ExportQcresultVO;
+import com.diagbot.vo.FilterVO;
 import com.diagbot.vo.GetDetailVO;
 import com.diagbot.vo.MedrecVo;
 import com.diagbot.vo.QcResultAlgQueryVO;
@@ -59,6 +62,7 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import javax.servlet.http.HttpServletResponse;
+import java.text.DateFormat;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Date;
@@ -925,8 +929,60 @@ public class BehospitalInfoFacade extends BehospitalInfoServiceImpl {
         }
     }
 
-    public void exportExcelFac(HttpServletResponse response){
+    public void exportExcelFac(HttpServletResponse response) {
         List<ExportExcelDTO> res = this.exportExcel();
+        String fileName = "mrqc";
+        ExcelUtils.exportExcelUser(res, null, "病案质控", ExportExcelDTO.class, fileName + ".xls", response);
+    }
+
+    /**
+     * 质控结果导出
+     *
+     * @param response
+     * @param exportQcresultVO
+     */
+    public void exportQcresult(HttpServletResponse response, ExportQcresultVO exportQcresultVO) {
+        String hospitalId = SysUserUtils.getCurrentHospitalID();
+        exportQcresultVO.setHospitalId(hospitalId);
+        Date startDate = exportQcresultVO.getLeaveHosDateStart();
+        Date endDate = exportQcresultVO.getLeaveHosDateEnd();
+        //时间间隔7天
+        long interval = 7 * 24 * 60 * 60 * 1000;
+        if (endDate.getTime() < startDate.getTime()) {
+            throw new CommonException(CommonErrorCode.PARAM_ERROR, "截止时间不能小于起始时间");
+        }
+        if (endDate.getTime() - startDate.getTime() > interval) {
+            throw new CommonException(CommonErrorCode.PARAM_ERROR, "统计区间不能大于7天");
+        }
+
+        List<ExportExcelDTO> res = this.exportQcresult(exportQcresultVO);
+        response.setContentType("text/html;charset=UTF-8");
+        ExcelUtils.exportExcel(res, null, "导出sheet1", ExportExcelDTO.class, "测试user.xls", response);
+    }
+
+    /**
+     * 科室质控结果导出
+     *
+     * @param response
+     * @param exportQcresultVO
+     */
+    public void exportQcresultByDept(HttpServletResponse response, ExportQcresultVO exportQcresultVO) {
+        String hospitalId = SysUserUtils.getCurrentHospitalID();
+        String userId = SysUserUtils.getCurrentPrincipleID();
+        exportQcresultVO.setHospitalId(hospitalId);
+        exportQcresultVO.setUserId(Long.valueOf(userId));
+        Date startDate = exportQcresultVO.getLeaveHosDateStart();
+        Date endDate = exportQcresultVO.getLeaveHosDateEnd();
+        //时间间隔7天
+        long interval = 7 * 24 * 60 * 60 * 1000;
+        if (endDate.getTime() < startDate.getTime()) {
+            throw new CommonException(CommonErrorCode.PARAM_ERROR, "截止时间不能小于起始时间");
+        }
+        if (endDate.getTime() - startDate.getTime() > interval) {
+            throw new CommonException(CommonErrorCode.PARAM_ERROR, "统计区间不能大于7天");
+        }
+
+        List<ExportExcelDTO> res = this.exportQcresultByDept(exportQcresultVO);
         response.setContentType("text/html;charset=UTF-8");
         ExcelUtils.exportExcel(res, null, "导出sheet1", ExportExcelDTO.class, "测试user.xls", response);
     }

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

@@ -12,6 +12,7 @@ import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.vo.AnalyzeCodeVO;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.ExportQcresultVO;
 import com.diagbot.vo.FilterOrderByDeptVO;
 import com.diagbot.vo.FilterOrderVO;
 import com.diagbot.vo.FilterPageByDeptVO;
@@ -182,4 +183,20 @@ public interface BehospitalInfoMapper extends BaseMapper<BehospitalInfo> {
 
 
     List<ExportExcelDTO> exportExcel();
+
+    /**
+     * 质控评分导出到excel
+     *
+     * @param exportQcresultVO
+     * @return
+     */
+    public List<ExportExcelDTO> exportQcresult(ExportQcresultVO exportQcresultVO);
+
+    /**
+     * 科室质控评分导出到excel
+     *
+     * @param exportQcresultVO
+     * @return
+     */
+    public List<ExportExcelDTO> exportQcresultByDept(ExportQcresultVO exportQcresultVO);
 }

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

@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptNumDTO;
 import com.diagbot.dto.ExportExcelDTO;
+import com.diagbot.dto.ExportQcresultDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.MsgDTO;
 import com.diagbot.dto.NumDTO;
@@ -12,6 +13,7 @@ import com.diagbot.entity.BehospitalInfo;
 import com.diagbot.vo.AnalyzeCodeVO;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.ExportQcresultVO;
 import com.diagbot.vo.FilterOrderByDeptVO;
 import com.diagbot.vo.FilterOrderVO;
 import com.diagbot.vo.FilterPageByDeptVO;
@@ -182,4 +184,20 @@ public interface BehospitalInfoService extends IService<BehospitalInfo> {
     public List<LevelStatisticsDTO> levelStatisticsByDeptClass(FilterOrderVO filterOrderVO);
 
     List<ExportExcelDTO> exportExcel();
+
+    /**
+     * 质控评分导出到excel
+     *
+     * @param exportQcresultVO
+     * @return
+     */
+    public List<ExportExcelDTO> exportQcresult(ExportQcresultVO exportQcresultVO);
+
+    /**
+     * 科室质控评分导出到excel
+     *
+     * @param exportQcresultVO
+     * @return
+     */
+    public List<ExportExcelDTO> exportQcresultByDept(ExportQcresultVO exportQcresultVO);
 }

+ 22 - 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.diagbot.dto.BehospitalInfoDTO;
 import com.diagbot.dto.DeptNumDTO;
+import com.diagbot.dto.ExportQcresultDTO;
 import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.LevelStatisticsDTO;
 import com.diagbot.dto.MsgDTO;
@@ -14,6 +15,7 @@ import com.diagbot.service.BehospitalInfoService;
 import com.diagbot.vo.AnalyzeCodeVO;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.ExportQcresultVO;
 import com.diagbot.vo.FilterOrderByDeptVO;
 import com.diagbot.vo.FilterOrderVO;
 import com.diagbot.vo.FilterPageByDeptVO;
@@ -248,4 +250,24 @@ public class BehospitalInfoServiceImpl extends ServiceImpl<BehospitalInfoMapper,
     public List<ExportExcelDTO> exportExcel(){
         return baseMapper.exportExcel();
     }
+
+    /**
+     * 质控评分导出到excel
+     *
+     * @param exportQcresultVO
+     * @return
+     */
+    public List<ExportExcelDTO> exportQcresult(ExportQcresultVO exportQcresultVO) {
+        return baseMapper.exportQcresult(exportQcresultVO);
+    }
+
+    /**
+     * 科室质控评分导出到excel
+     *
+     * @param exportQcresultVO
+     * @return
+     */
+    public List<ExportExcelDTO> exportQcresultByDept(ExportQcresultVO exportQcresultVO){
+        return baseMapper.exportQcresultByDept(exportQcresultVO);
+    }
 }

+ 66 - 0
src/main/java/com/diagbot/service/impl/ExcelExportStylerUserImpl.java

@@ -0,0 +1,66 @@
+package com.diagbot.service.impl;
+
+import cn.afterturn.easypoi.excel.export.styler.AbstractExcelExportStyler;
+import cn.afterturn.easypoi.excel.export.styler.IExcelExportStyler;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.VerticalAlignment;
+import org.apache.poi.ss.usermodel.Workbook;
+
+/**
+ * @Description:
+ * @author: gaodm
+ * @time: 2020/6/3 11:45
+ */
+public class ExcelExportStylerUserImpl extends AbstractExcelExportStyler implements IExcelExportStyler {
+    public ExcelExportStylerUserImpl(Workbook workbook) {
+        super.createStyles(workbook);
+    }
+
+    public CellStyle getTitleStyle(short color) {
+        CellStyle titleStyle = this.workbook.createCellStyle();
+        titleStyle.setAlignment(HorizontalAlignment.CENTER);
+        titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        titleStyle.setWrapText(true);
+        return titleStyle;
+    }
+
+    public CellStyle stringSeptailStyle(Workbook workbook, boolean isWarp) {
+        CellStyle style = workbook.createCellStyle();
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setDataFormat(STRING_FORMAT);
+        if (isWarp) {
+            style.setWrapText(true);
+        } else {
+            style.setAlignment(HorizontalAlignment.LEFT);
+        }
+
+        return style;
+    }
+
+    public CellStyle getHeaderStyle(short color) {
+        CellStyle titleStyle = this.workbook.createCellStyle();
+        Font font = this.workbook.createFont();
+        font.setFontHeightInPoints((short) 12);
+        titleStyle.setFont(font);
+        titleStyle.setAlignment(HorizontalAlignment.CENTER);
+        titleStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        return titleStyle;
+    }
+
+    public CellStyle stringNoneStyle(Workbook workbook, boolean isWarp) {
+        CellStyle style = workbook.createCellStyle();
+        style.setAlignment(HorizontalAlignment.CENTER);
+        style.setVerticalAlignment(VerticalAlignment.CENTER);
+        style.setDataFormat(STRING_FORMAT);
+        if (isWarp) {
+            style.setWrapText(true);
+        } else {
+            style.setAlignment(HorizontalAlignment.LEFT);
+        }
+
+        return style;
+    }
+}

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

@@ -6,7 +6,14 @@ 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 com.diagbot.exception.CommonErrorCode;
+import com.diagbot.exception.CommonException;
+import com.diagbot.service.impl.ExcelExportStylerUserImpl;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -31,6 +38,13 @@ public class ExcelUtils {
         defaultExport(list, pojoClass, fileName, response, exportParams);
     }
 
+    public static void exportExcelUser(List<?> list, String title, String sheetName, Class<?> pojoClass, String fileName,
+                                       HttpServletResponse response) {
+        ExportParams exportParams = new ExportParams(title, sheetName);
+        exportParams.setStyle(ExcelExportStylerUserImpl.class);
+        userExport(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));
@@ -49,6 +63,24 @@ public class ExcelUtils {
         downLoadExcel(fileName, response, workbook);
     }
 
+    private static void userExport(List<?> list, Class<?> pojoClass, String fileName, HttpServletResponse response,
+                                      ExportParams exportParams) {
+        Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, list);
+        if (workbook != null) {
+            Sheet sheet = workbook.getSheetAt(0);
+            //列宽设置
+            sheet.setColumnWidth(8, 256*20);
+            sheet.setColumnWidth(9, 256*50);
+            int rowNum = sheet.getLastRowNum();
+            Row row = sheet.getRow(0);
+            for (int i = 1; i <= rowNum; i++) {
+                row = sheet.getRow(i);
+                row.setHeightInPoints(12.8f);
+            }
+        }
+        downLoadExcel(fileName, response, workbook);
+    }
+
     private static void downLoadExcel(String fileName, HttpServletResponse response, Workbook workbook) {
         try {
             response.setCharacterEncoding("UTF-8");
@@ -57,6 +89,7 @@ public class ExcelUtils {
             workbook.write(response.getOutputStream());
         } catch (IOException e) {
             // throw new NormalException(e.getMessage());
+            throw new CommonException(CommonErrorCode.SERVER_IS_ERROR, "导出Excel异常");
         }
     }
 

+ 23 - 0
src/main/java/com/diagbot/vo/ExportQcresultVO.java

@@ -0,0 +1,23 @@
+package com.diagbot.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Getter;
+import lombok.Setter;
+
+import java.util.Date;
+
+/**
+ * @Description:
+ * @Author:zhaops
+ * @time: 2020/6/2 20:09
+ */
+@Getter
+@Setter
+public class ExportQcresultVO {
+    private Date leaveHosDateStart;
+    private Date leaveHosDateEnd;
+    @ApiModelProperty(hidden = true)
+    private String hospitalId;
+    @ApiModelProperty(hidden = true)
+    private Long userId;
+}

+ 22 - 7
src/main/java/com/diagbot/web/BehospitalInfoController.java

@@ -5,7 +5,6 @@ import com.diagbot.annotation.SysLogger;
 import com.diagbot.dto.AnalyzeDTO;
 import com.diagbot.dto.AnalyzeRunDTO;
 import com.diagbot.dto.BehospitalInfoDTO;
-import com.diagbot.dto.ExportExcelDTO;
 import com.diagbot.dto.RespDTO;
 import com.diagbot.facade.BehospitalInfoFacade;
 import com.diagbot.facade.QcresultInfoFacade;
@@ -13,6 +12,7 @@ import com.diagbot.vo.AnalyzeApiVO;
 import com.diagbot.vo.AnalyzeRunVO;
 import com.diagbot.vo.AnalyzeVO;
 import com.diagbot.vo.BehospitalPageVO;
+import com.diagbot.vo.ExportQcresultVO;
 import com.diagbot.vo.GetDetailVO;
 import com.diagbot.vo.QcresultVO;
 import com.diagbot.vo.TaskVO;
@@ -28,7 +28,6 @@ import springfox.documentation.annotations.ApiIgnore;
 
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -112,7 +111,7 @@ public class BehospitalInfoController {
     @PostMapping("/analyze_api")
     @SysLogger("analyze_api")
     @Transactional
-//    @ApiIgnore
+    //    @ApiIgnore
     public RespDTO<Map<String, Object>> analyzeApi(@RequestBody AnalyzeApiVO analyzeApiVO) {
         return RespDTO.onSuc(behospitalInfoFacade.analyzeApi(analyzeApiVO));
     }
@@ -123,7 +122,7 @@ public class BehospitalInfoController {
     @PostMapping("/addCase")
     @SysLogger("addCase")
     @Transactional
-    public RespDTO<AnalyzeDTO> addCase(@RequestBody QcresultVO qcresultVO){
+    public RespDTO<AnalyzeDTO> addCase(@RequestBody QcresultVO qcresultVO) {
         qcresultVO.setType(1);
         return RespDTO.onSuc(qcresultInfoFacade.changeQcResult(qcresultVO));
     }
@@ -134,7 +133,7 @@ public class BehospitalInfoController {
     @PostMapping("/delCase")
     @SysLogger("delCase")
     @Transactional
-    public RespDTO<AnalyzeDTO> delCase(@RequestBody QcresultVO qcresultVO){
+    public RespDTO<AnalyzeDTO> delCase(@RequestBody QcresultVO qcresultVO) {
         qcresultVO.setType(2);
         return RespDTO.onSuc(qcresultInfoFacade.changeQcResult(qcresultVO));
     }
@@ -144,7 +143,7 @@ public class BehospitalInfoController {
     @PostMapping("/updCase")
     @SysLogger("updCase")
     @Transactional
-    public RespDTO<AnalyzeDTO> updCase(@RequestBody QcresultVO qcresultVO){
+    public RespDTO<AnalyzeDTO> updCase(@RequestBody QcresultVO qcresultVO) {
         qcresultVO.setType(3);
         return RespDTO.onSuc(qcresultInfoFacade.changeQcResult(qcresultVO));
     }
@@ -157,7 +156,7 @@ public class BehospitalInfoController {
                     "filterFlag: 筛选病历数据:0:未评分的病历,【推荐使用】;1:全部病历,【谨慎使用】")
     @PostMapping("/execule")
     @SysLogger("execule")
-    public RespDTO<Boolean> execule(@RequestBody TaskVO taskVO){
+    public RespDTO<Boolean> execule(@RequestBody TaskVO taskVO) {
         behospitalInfoFacade.execute(taskVO, "");
         return RespDTO.onSuc(true);
     }
@@ -200,4 +199,20 @@ public class BehospitalInfoController {
     public void exportExcel(HttpServletResponse response) {
         behospitalInfoFacade.exportExcelFac(response);
     }
+
+    @ApiOperation(value = "质控结果导出[by:zhaops]",
+            notes = "")
+    @PostMapping("/exportQcresult")
+    @SysLogger("exportQcresult")
+    public void exportQcresult(HttpServletResponse response, @RequestBody ExportQcresultVO exportQcresultVO) {
+        behospitalInfoFacade.exportQcresult(response, exportQcresultVO);
+    }
+
+    @ApiOperation(value = "科室质控结果导出[by:zhaops]",
+            notes = "")
+    @PostMapping("/exportQcresultByDept")
+    @SysLogger("exportQcresultByDept")
+    public void exportQcresultByDept(HttpServletResponse response, @RequestBody ExportQcresultVO exportQcresultVO) {
+        behospitalInfoFacade.exportQcresultByDept(response, exportQcresultVO);
+    }
 }

+ 208 - 1
src/main/resources/mapper/BehospitalInfoMapper.xml

@@ -106,7 +106,7 @@
         and c.hospital_id = d.hospital_id
         and c.hospital_id = #{hospitalId}
         and c.behospital_code = #{behospitalCode}
-        order by b.order_no, a.order_no
+        order by b.order_no, c.grade_type desc, a.order_no
     </select>
 
     <select id="getMsgByEntryCode" resultType="com.diagbot.dto.MsgDTO">
@@ -1764,4 +1764,211 @@
         t1.behospital_code ASC,
         t4.`name` ASC
     </select>
+
+
+    <!-- 质控评分导出到excel-->
+    <select id="exportQcresult" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
+        SELECT
+        t1.behDeptId,
+        t1.behDeptName,
+        t1.behDoctorName,
+        t1.patName,
+        t1.behospitalCode,
+        t1.behospitalDate,
+        t1.leaveHospitalDate,
+        t1.score,
+        t2.avgScore,
+        t1.msg,
+        t1.caseName
+        FROM
+        (
+        SELECT
+        CONCAT(
+        ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
+        a.doctor_name
+        ) AS behDoctorName,
+        a.`name` AS patName,
+        a.behospital_code AS behospitalCode,
+        a.behospital_date AS behospitalDate,
+        a.leave_hospital_date AS leaveHospitalDate,
+        b.score_res AS score,
+        c.msg AS msg,
+        d.NAME AS caseName,
+        a.beh_dept_id AS behDeptId,
+        a.beh_dept_name AS behDeptName
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b,
+        med_qcresult_detail c,
+        qc_cases d
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND c.cases_id = d.id
+        AND a.is_placefile = '1'
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="leaveHosDateStart != null ">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
+        </if>
+        <if test="leaveHosDateEnd != null ">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
+        </if>
+        ) t1,
+        (
+        SELECT
+        ROUND( AVG( b.score_res ), 2 ) AS avgScore,
+        a.beh_dept_id AS behDeptId,
+        a.beh_dept_name AS behDeptName
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.is_placefile = '1'
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="leaveHosDateStart != null ">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
+        </if>
+        <if test="leaveHosDateEnd != null ">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) t2
+        WHERE
+        t1.behDeptId = t2.behDeptId
+        AND t1.behDeptName = t2.behDeptName
+        ORDER BY
+        t1.behDeptName,
+        t1.behDeptName,
+        t1.patName,
+        t1.behospitalCode,
+        t1.caseName
+    </select>
+
+    <!-- 科室质控评分导出到excel-->
+    <select  id="exportQcresultByDept" resultMap="ExportExcelMap" parameterType="com.diagbot.vo.ExportQcresultVO">
+        SELECT
+        t1.behDeptId,
+        t1.behDeptName,
+        t1.behDoctorName,
+        t1.patName,
+        t1.behospitalCode,
+        t1.behospitalDate,
+        t1.leaveHospitalDate,
+        t1.score,
+        t2.avgScore,
+        t1.msg,
+        t1.casesName
+        FROM
+        (
+        SELECT
+        CONCAT(
+        ( CASE WHEN a.director_doctor_name IS NOT NULL AND a.director_doctor_name != '' THEN concat( a.director_doctor_name, '\n' ) ELSE '' END ),
+        a.doctor_name
+        ) AS behDoctorName,
+        a.`name` AS patName,
+        a.behospital_code AS behospitalCode,
+        a.behospital_date AS behospitalDate,
+        a.leave_hospital_date AS leaveHospitalDate,
+        b.score_res AS score,
+        c.msg AS msg,
+        d.NAME AS casesName,
+        a.beh_dept_id AS behDeptId,
+        a.beh_dept_name AS behDeptName
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b,
+        med_qcresult_detail c,
+        qc_cases d,
+        sys_user_dept e
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND d.is_deleted = 'N'
+        AND e.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.hospital_id = e.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.behospital_code = c.behospital_code
+        AND c.cases_id = d.id
+        AND a.beh_dept_id = e.dept_id
+        AND a.is_placefile = '1'
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="userId != null ">
+            AND e.user_id = #{userId}
+        </if>
+        <if test="leaveHosDateStart != null ">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
+        </if>
+        <if test="leaveHosDateEnd != null ">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
+        </if>
+        ) t1,
+        (
+        SELECT
+        ROUND( AVG( b.score_res ), 2 ) AS avgScore,
+        a.beh_dept_id AS behDeptId,
+        a.beh_dept_name AS behDeptName
+        FROM
+        med_behospital_info a,
+        med_qcresult_info b,
+        sys_user_dept c
+        WHERE
+        a.is_deleted = 'N'
+        AND b.is_deleted = 'N'
+        AND c.is_deleted = 'N'
+        AND a.hospital_id = b.hospital_id
+        AND a.hospital_id = c.hospital_id
+        AND a.behospital_code = b.behospital_code
+        AND a.beh_dept_id = c.dept_id
+        AND a.is_placefile = '1'
+        <![CDATA[AND a.qc_type_id <>0 ]]>
+        <if test="hospitalId != null and hospitalId != ''">
+            AND a.hospital_id = #{hospitalId}
+        </if>
+        <if test="userId != null ">
+            AND c.user_id = #{userId}
+        </if>
+        <if test="leaveHosDateStart != null ">
+            <![CDATA[ and a.leave_hospital_date >= DATE(#{leaveHosDateStart})]]>
+        </if>
+        <if test="leaveHosDateEnd != null ">
+            <![CDATA[AND a.leave_hospital_date < DATE(#{leaveHosDateEnd})]]>
+        </if>
+        GROUP BY
+        a.beh_dept_id,
+        a.beh_dept_name
+        ) t2
+        WHERE
+        t1.behDeptId = t2.behDeptId
+        AND t1.behDeptName = t2.behDeptName
+        ORDER BY
+        t1.behDeptName,
+        t1.behDeptName,
+        t1.patName,
+        t1.behospitalCode,
+        t1.casesName
+    </select>
 </mapper>