|
@@ -3,13 +3,16 @@ package com.lantone.daqe.facade;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.lantone.common.api.CommonResult;
|
|
|
import com.lantone.common.exception.Asserts;
|
|
|
import com.lantone.common.util.BeanUtil;
|
|
|
import com.lantone.common.util.ListUtil;
|
|
|
import com.lantone.common.util.StringUtil;
|
|
|
+import com.lantone.daqe.dto.ExportImportDiseaseErrDTO;
|
|
|
import com.lantone.daqe.dto.GetDiseasePageDTO;
|
|
|
import com.lantone.daqe.entity.DiseaseInfo;
|
|
|
import com.lantone.daqe.facade.base.DiseaseInfoFacade;
|
|
|
+import com.lantone.daqe.service.impl.DiseaseInfoServiceImpl;
|
|
|
import com.lantone.daqe.util.ExcelUtils;
|
|
|
import com.lantone.daqe.vo.AddDiseaseVO;
|
|
|
import com.lantone.daqe.vo.DelDiseaseByIdVO;
|
|
@@ -22,7 +25,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
+import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 诊断管理-业务处理类
|
|
@@ -34,6 +42,8 @@ public class DiseaseManagementFacade {
|
|
|
|
|
|
@Autowired
|
|
|
private DiseaseInfoFacade diseaseInfoFacade;
|
|
|
+ @Autowired
|
|
|
+ private DiseaseInfoServiceImpl diseaseInfoServiceImpl;
|
|
|
|
|
|
public IPage<GetDiseasePageDTO> getDiseasePage(GetDiseasePageVO getDiseasePageVO) {
|
|
|
Page<GetDiseasePageDTO> getDiseasePageDTOPage = new Page<>();
|
|
@@ -124,15 +134,65 @@ public class DiseaseManagementFacade {
|
|
|
* @param file 导入文件
|
|
|
* @Return java.lang.String
|
|
|
*/
|
|
|
- public String importDisease(MultipartFile file) {
|
|
|
+ public void importDisease(HttpServletResponse response, MultipartFile file) {
|
|
|
List<ImportDiseaseVO> diagnoseExcelVOS = ExcelUtils.importExcel(file, 0, 1, ImportDiseaseVO.class);
|
|
|
if (ListUtil.isEmpty(diagnoseExcelVOS)) {
|
|
|
Asserts.fail("Excel文件为空");
|
|
|
}
|
|
|
+ //数据规范校验
|
|
|
+ checkData(response, diagnoseExcelVOS);
|
|
|
//去重
|
|
|
+ List<ImportDiseaseVO> temp = diagnoseExcelVOS.stream().distinct().collect(Collectors.toList());
|
|
|
+ //导入
|
|
|
+ List<DiseaseInfo> insert = BeanUtil.listCopyTo(temp,DiseaseInfo.class);
|
|
|
+ boolean out = diseaseInfoServiceImpl.saveBatch(insert);
|
|
|
+ CommonResult<String> outMsg = null;
|
|
|
+ response.setContentType("text/html;charset=utf-8");
|
|
|
+ if(out){
|
|
|
+ outMsg = CommonResult.success(String.format("模板成功导入%s条数据",insert.size()));
|
|
|
+ try {
|
|
|
+ response.getWriter().println(outMsg);
|
|
|
+ response.flushBuffer();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ Asserts.fail("数据插入失败");
|
|
|
+ }
|
|
|
|
|
|
- //数据规范校验
|
|
|
|
|
|
- return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkData(HttpServletResponse response, List<ImportDiseaseVO> diagnoseExcelVOS) {
|
|
|
+ AtomicBoolean errorFlog = new AtomicBoolean(false);
|
|
|
+ List<ExportImportDiseaseErrDTO> errExports = new ArrayList<>();
|
|
|
+
|
|
|
+ diagnoseExcelVOS.stream().forEach(importDiseaseVO -> {
|
|
|
+ ExportImportDiseaseErrDTO exportImportDiseaseErrDTO = new ExportImportDiseaseErrDTO();
|
|
|
+ BeanUtil.copyProperties(importDiseaseVO,exportImportDiseaseErrDTO);
|
|
|
+ StringBuffer errMsg = new StringBuffer();
|
|
|
+ //数据校验
|
|
|
+ if (StringUtil.isEmpty(importDiseaseVO.getName())) {
|
|
|
+ errMsg.append("医院诊断名称为空").append(";");
|
|
|
+ errorFlog.set(true);
|
|
|
+ }
|
|
|
+ if (StringUtil.isEmpty(importDiseaseVO.getStandard())) {
|
|
|
+ errMsg.append("标准诊断名称为空").append(";");
|
|
|
+ errorFlog.set(true);
|
|
|
+ }
|
|
|
+ exportImportDiseaseErrDTO.setErrMsg(errMsg.toString());
|
|
|
+ });
|
|
|
+
|
|
|
+ if(errorFlog.get()){
|
|
|
+ String fileName = "诊断标准词匹配信息导入异常.xls";
|
|
|
+ ExcelUtils.exportExcelUser(errExports, null, "sheet1", ExportImportDiseaseErrDTO.class, fileName, response);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ImportDiseaseVO> delRepeat(List<ImportDiseaseVO> diagnoseExcelVOS) {
|
|
|
+
|
|
|
+ return null;
|
|
|
}
|
|
|
}
|