|
@@ -3,6 +3,7 @@ package com.diagbot.facade;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.diagbot.dto.KlConceptSimDTO;
|
|
|
+import com.diagbot.dto.KlDrugExportDTO;
|
|
|
import com.diagbot.dto.KlDrugRegisterDTO;
|
|
|
import com.diagbot.entity.CommonParam;
|
|
|
import com.diagbot.entity.KlConcept;
|
|
@@ -17,6 +18,7 @@ import com.diagbot.service.KlDrugRegisterService;
|
|
|
import com.diagbot.service.impl.KlDrugRegisterServiceImpl;
|
|
|
import com.diagbot.util.BeanUtil;
|
|
|
import com.diagbot.util.DateUtil;
|
|
|
+import com.diagbot.util.ExcelUtils;
|
|
|
import com.diagbot.util.ListUtil;
|
|
|
import com.diagbot.util.UserUtils;
|
|
|
import com.diagbot.vo.KlDrugMappingGetVO;
|
|
@@ -34,6 +36,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -202,12 +205,11 @@ public class KlDrugRegisterFacade extends KlDrugRegisterServiceImpl {
|
|
|
* @param file
|
|
|
* @return
|
|
|
*/
|
|
|
- public Map importRegister(MultipartFile file) {
|
|
|
+ public void importRegister(MultipartFile file, HttpServletResponse response) {
|
|
|
Map res = new LinkedMap();
|
|
|
Long t1 = System.currentTimeMillis();
|
|
|
List<KlDrugRegisterTestVO> list = XLSXCovertCSVReader.readData(file, "注册药品",
|
|
|
30, KlDrugRegisterTestVO.class);
|
|
|
- // List<KlDrugRegisterTestVO> list = ExcelBigUtil.readData(file, null, 0, KlDrugRegisterTestVO.class);
|
|
|
Long t2 = System.currentTimeMillis();
|
|
|
res.put("读取sheet耗时:", (t2 - t1) / 1000.0 + "秒");
|
|
|
try {
|
|
@@ -216,7 +218,7 @@ public class KlDrugRegisterFacade extends KlDrugRegisterServiceImpl {
|
|
|
Map<String, Long> druMap = klConceptList.stream().collect(Collectors.toMap(k -> k.getLibName(), v -> v.getId(), (r1, r2) -> (r2)));
|
|
|
List<String> errMsg = Lists.newArrayList();
|
|
|
List<KlDrugRegister> drugRegisterList = Lists.newLinkedList();
|
|
|
- int i = 2;
|
|
|
+ // int i = 2;
|
|
|
for (KlDrugRegisterTestVO klDrugRegisterTestVO : list) {
|
|
|
KlDrugRegister klDrugRegister = new KlDrugRegister();
|
|
|
BeanUtil.copyProperties(klDrugRegisterTestVO, klDrugRegister);
|
|
@@ -231,22 +233,20 @@ public class KlDrugRegisterFacade extends KlDrugRegisterServiceImpl {
|
|
|
// } else if (druMap.get(drugName) == null) {
|
|
|
// errMsg.add(String.format("第%s行【%s】不是标准词", i, drugName));
|
|
|
// }
|
|
|
- i++;
|
|
|
+ // i++;
|
|
|
}
|
|
|
if (ListUtil.isNotEmpty(errMsg)) {
|
|
|
errMsg = errMsg.stream().distinct().collect(Collectors.toList());
|
|
|
+ List<KlDrugExportDTO> klDrugExportDTOList = Lists.newLinkedList();
|
|
|
for (String s : errMsg) {
|
|
|
- System.out.println(s);
|
|
|
+ KlDrugExportDTO klDrugExportDTO = new KlDrugExportDTO();
|
|
|
+ klDrugExportDTO.setName(s);
|
|
|
+ klDrugExportDTOList.add(klDrugExportDTO);
|
|
|
}
|
|
|
- // List<KlDrugExportDTO> klDrugExportDTOList = Lists.newLinkedList();
|
|
|
- // for (String s : errMsg) {
|
|
|
- // KlDrugExportDTO klDrugExportDTO = new KlDrugExportDTO();
|
|
|
- // klDrugExportDTO.setName(s);
|
|
|
- // klDrugExportDTOList.add(klDrugExportDTO);
|
|
|
- // }
|
|
|
- // ExcelUtils.exportExcel(klDrugExportDTOList, null, "title");
|
|
|
+ ExcelUtils.exportExcel(klDrugExportDTOList, null, "药品通用名", KlDrugExportDTO.class,
|
|
|
+ "未校验通过的药品通用名", response, 12.8f);
|
|
|
res.put("错误", StringUtils.join(errMsg, ";"));
|
|
|
- return res;
|
|
|
+ return;
|
|
|
}
|
|
|
this.remove(new QueryWrapper<KlDrugRegister>()); // 删除主表
|
|
|
Long t3 = System.currentTimeMillis();
|
|
@@ -271,7 +271,6 @@ public class KlDrugRegisterFacade extends KlDrugRegisterServiceImpl {
|
|
|
}
|
|
|
Long end = System.currentTimeMillis();
|
|
|
res.put("总耗时:", (end - t1) / 1000.0 + "秒");
|
|
|
- return res;
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|