Browse Source

危急值

zhoutg 4 years ago
parent
commit
f7cfa7e39a

+ 3 - 3
src/main/java/com/diagbot/facade/TestFacade.java

@@ -42,7 +42,7 @@ public class TestFacade {
      */
     public Map<String, Object> importExcel(MultipartFile file, TestLineVO testLineVO) {
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
-        List<TestIndicationVO> data = ExcelUtils.importExcel(file, 0, 1, TestIndicationVO.class);
+        List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
             if (StringUtil.isNotEmpty(testLineVO.getIdNum()) && !testLineVO.getIdNum().equals(bean.getIdNum())) {
                 continue;
@@ -167,13 +167,13 @@ public class TestFacade {
 
 
     /**
-     * 开单项数据测试
+     * 危急值数据测试
      *
      * @param file
      */
     public Map<String, Object> importCriticalExcel(MultipartFile file, TestLineVO testLineVO) {
         List<IndicationPushVO> indicationPushVOList = new ArrayList<>();
-        List<TestIndicationVO> data = ExcelUtils.importExcel(file, 0, 1, TestIndicationVO.class);
+        List<TestIndicationVO> data = ExcelUtils.importExcelMultiSheets(file, 0, 1, testLineVO.getSheetIndex(), TestIndicationVO.class);
         for (TestIndicationVO bean : data) {
             if (StringUtil.isNotEmpty(testLineVO.getIdNum()) && !testLineVO.getIdNum().equals(bean.getIdNum())) {
                 continue;

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

@@ -175,4 +175,24 @@ public class ExcelUtils {
         return list;
     }
 
+    public static <T> List<T> importExcelMultiSheets(MultipartFile file, Integer titleRows, Integer headerRows, int sheetIndex,
+                                          Class<T> pojoClass) {
+        if (file == null) {
+            return null;
+        }
+        ImportParams params = new ImportParams();
+        params.setTitleRows(titleRows);
+        params.setHeadRows(headerRows);
+        params.setStartSheetIndex(sheetIndex);
+        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;
+    }
 }

+ 3 - 0
src/main/java/com/diagbot/vo/TestLineVO.java

@@ -18,4 +18,7 @@ public class TestLineVO implements Serializable {
     private static final long serialVersionUID = 1L;
 
     private String idNum;
+
+    // sheet的索引,从0开始
+    private int sheetIndex = 0;
 }

+ 6 - 2
src/main/java/com/diagbot/web/TestController.java

@@ -33,13 +33,17 @@ public class TestController {
     @Autowired
     private TestFacade testFacade;
 
-    @ApiOperation(value = "开单合理性测试API[zhoutg]", notes = "")
+    @ApiOperation(value = "开单合理性测试API[zhoutg]",
+            notes = "idNum:指定行测试<br>" +
+                    "sheetIndex:sheet的下标,默认为0,表示第一个sheet")
     @PostMapping("/testIndication")
     public RespDTO<Map<String, Object>> testIndication(@RequestParam("file") MultipartFile file, TestLineVO testLineVO) {
         return RespDTO.onSuc(testFacade.importExcel(file, testLineVO));
     }
 
-    @ApiOperation(value = "危急值测试API[zhoutg]", notes = "")
+    @ApiOperation(value = "危急值测试API[zhoutg]",
+            notes = "idNum:指定行测试<br>" +
+                    "sheetIndex:sheet的下标,默认为0,表示第一个sheet")
     @PostMapping("/testCritical")
     public RespDTO<Map<String, Object>> testCritical(@RequestParam("file") MultipartFile file, TestLineVO testLineVO) {
         return RespDTO.onSuc(testFacade.importCriticalExcel(file, testLineVO));