فهرست منبع

[性能验证]添加Excel文件下载

liyuan 2 سال پیش
والد
کامیت
9566040ce1
12فایلهای تغییر یافته به همراه273 افزوده شده و 175 حذف شده
  1. 3 3
      ibps-component-root/modules/comp-poi/src/main/java/com/lc/ibps/components/poi/excel/imports/ExcelImportServer.java
  2. 6 0
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelExportReportServer.java
  3. 1 1
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelExportStyler.java
  4. 1 6
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelExportTemplateServer.java
  5. 71 5
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelImportServer.java
  6. 21 11
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelUtil.java
  7. 32 67
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVTest.java
  8. 0 67
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/model/ExcelRecordVO.java
  9. 59 0
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/model/ExcelSheetRecord.java
  10. 24 1
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/model/InspectionConfigVO.java
  11. 47 12
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/model/InspectionItemVO.java
  12. 8 2
      ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/funcs/xValue.java

+ 3 - 3
ibps-component-root/modules/comp-poi/src/main/java/com/lc/ibps/components/poi/excel/imports/ExcelImportServer.java

@@ -67,7 +67,7 @@ public class ExcelImportServer extends ImportBaseService {
 
 	private CellValueServer cellValueServer;
 
-	private boolean verfiyFail = false;
+	protected boolean verfiyFail = false;
 	/**
 	 * 异常数据styler
 	 */
@@ -145,7 +145,7 @@ public class ExcelImportServer extends ImportBaseService {
 		return excelImportEntity.getSaveUrl();
 	}
 
-	private <T> List<T> importExcel(Collection<T> result, Sheet sheet, Class<?> pojoClass, ImportParams params,
+	protected  <T> List<T> importExcel(Collection<T> result, Sheet sheet, Class<?> pojoClass, ImportParams params,
 			Map<String, PictureData> pictures) throws Exception {
 		List collection = new ArrayList();
 		Map<String, ExcelImportEntity> excelParams = new HashMap<String, ExcelImportEntity>();
@@ -531,7 +531,7 @@ public class ExcelImportServer extends ImportBaseService {
 		}
 	}
 
-	private void createErrorCellStyle(Workbook workbook) {
+	protected void createErrorCellStyle(Workbook workbook) {
 		errorCellStyle = workbook.createCellStyle();
 		Font font = workbook.createFont();
 		font.setColor(Font.COLOR_RED);

+ 6 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelExportReportServer.java

@@ -0,0 +1,6 @@
+package com.lc.ibps.components.verification.excel;
+
+import com.lc.ibps.components.poi.excel.export.ExcelExportServer;
+
+public class PVExcelExportReportServer extends ExcelExportServer {
+}

+ 1 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelExportStyler.java

@@ -13,7 +13,7 @@ public class PVExcelExportStyler extends ExcelExportStylerBorderImpl {
         keyNumberStyle = keyNumberStyle(workbook);
     }
     public CellStyle getStyles(boolean noneStyler, ExcelExportEntity entity) {
-        if(entity != null && "value".equals(entity.getKey())) {
+        if(entity != null && "input".equals(entity.getKey())) {
             return keyNumberStyle;
         }
         return super.getStyles(noneStyler, entity);

+ 1 - 6
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelExportServer.java → ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelExportTemplateServer.java

@@ -3,11 +3,6 @@ package com.lc.ibps.components.verification.excel;
 import com.lc.ibps.components.poi.excel.entity.ExportParams;
 import com.lc.ibps.components.poi.excel.entity.params.ExcelExportEntity;
 import com.lc.ibps.components.poi.excel.export.ExcelExportServer;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.hssf.usermodel.HSSFCellStyle;
-import org.apache.poi.hssf.usermodel.HSSFRow;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.ss.usermodel.CellStyle;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -16,7 +11,7 @@ import org.apache.poi.ss.util.CellRangeAddress;
 
 import java.util.List;
 
-public class PVExcelExportServer extends ExcelExportServer {
+public class PVExcelExportTemplateServer extends ExcelExportServer {
     protected int createHeaderAndTitle(ExportParams entity, Sheet sheet, Workbook workbook,
                                        List<ExcelExportEntity> excelParams) {
         int rows = 0, feildWidth = getFieldLength(excelParams);

+ 71 - 5
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelImportServer.java

@@ -2,18 +2,83 @@ package com.lc.ibps.components.verification.excel;
 
 import com.lc.ibps.components.poi.excel.entity.ImportParams;
 import com.lc.ibps.components.poi.excel.entity.params.ExcelCollectionParams;
+import com.lc.ibps.components.poi.excel.entity.result.ExcelImportResult;
 import com.lc.ibps.components.poi.excel.imports.ExcelImportServer;
+import com.lc.ibps.components.poi.util.PoiPublicUtil;
+import com.lc.ibps.components.verification.excel.model.ExcelSheetRecord;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.opc.OPCPackage;
+import org.apache.poi.poifs.filesystem.DocumentFactoryHelper;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+import org.apache.poi.ss.formula.functions.T;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.PictureData;
 import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.io.InputStream;
+import java.io.PushbackInputStream;
+import java.util.*;
 
 public class PVExcelImportServer extends ExcelImportServer {
+    private static final Logger LOGGER = LoggerFactory.getLogger(PVExcelImportServer.class);
+    public ExcelImportResult importExcelByIs(InputStream inputstream, Class<?> pojoClass, ImportParams params)
+            throws Exception {
+        if (LOGGER.isInfoEnabled()) {
+            LOGGER.info("Excel import start ,class is {}", pojoClass);
+        }
+        List<ExcelSheetRecord> result = new ArrayList<ExcelSheetRecord>();
+        Workbook book = null;
+        boolean isXSSFWorkbook = true;
+        if (!(inputstream.markSupported())) {
+            inputstream = new PushbackInputStream(inputstream, 8);
+        }
+        try{
+            if (POIFSFileSystem.hasPOIFSHeader(inputstream)) {
+                book = new HSSFWorkbook(inputstream);
+                isXSSFWorkbook = false;
+            } else if (DocumentFactoryHelper.hasOOXMLHeader(inputstream)) {
+                book = new XSSFWorkbook(OPCPackage.open(inputstream));
+            }
+        }catch (Exception e){
+            book=null;
+        }
+        if(book==null){
+            try{
+                book = new HSSFWorkbook(inputstream);
+                isXSSFWorkbook = false;
+            }catch (Exception e){
+                e.printStackTrace();
+                book = new XSSFWorkbook(OPCPackage.open(inputstream));
+                isXSSFWorkbook = true;
+            }
+        }
+        createErrorCellStyle(book);
+        for (int i = params.getStartSheetIndex(); i < params.getStartSheetIndex() + params.getSheetNum(); i++) {
+            if (LOGGER.isInfoEnabled()) {
+                LOGGER.info(" start to read excel by is ,startTime is {}", new Date().getTime());
+            }
 
+            if (LOGGER.isInfoEnabled()) {
+                LOGGER.info(" end to read excel by is ,endTime is {}", new Date().getTime());
+            }
+            List list = importExcel(result, book.getSheetAt(i), pojoClass, params, null);
+            result.add(new ExcelSheetRecord(book.getSheetAt(i).getSheetName(),list));
+            if (LOGGER.isInfoEnabled()) {
+                LOGGER.info(" end to read excel list by pos ,endTime is {}", new Date().getTime());
+            }
+        }
+        if (params.isNeedSave()) {
+            saveThisExcel(params, pojoClass, isXSSFWorkbook, book);
+        }
+        return new ExcelImportResult(result, verfiyFail, book);
+    }
     protected Map<Integer, String> getTitleMap(Iterator<Row> rows, ImportParams params,
                                                List<ExcelCollectionParams> excelCollection) {
         Map<Integer, String> titlemap = new HashMap<Integer, String>();
@@ -50,4 +115,5 @@ public class PVExcelImportServer extends ExcelImportServer {
         }
         return titlemap;
     }
-}
+
+}

+ 21 - 11
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVExcelUtil.java

@@ -6,9 +6,7 @@ import com.lc.ibps.components.poi.excel.entity.enmus.ExcelType;
 import com.lc.ibps.components.poi.excel.entity.params.ExcelExportEntity;
 import com.lc.ibps.components.poi.excel.entity.result.ExcelImportResult;
 import com.lc.ibps.components.poi.excel.export.ExcelExportServer;
-import com.lc.ibps.components.poi.excel.imports.ExcelImportServer;
 import com.lc.ibps.components.poi.exception.excel.ExcelImportException;
-import com.lc.ibps.components.poi.util.PoiCellUtil;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.util.IOUtils;
@@ -19,6 +17,7 @@ import org.slf4j.LoggerFactory;
 
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.InputStream;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
@@ -45,7 +44,21 @@ public class PVExcelUtil {
         } else {
             workbook = new SXSSFWorkbook();
         }
-        new PVExcelExportServer().createSheetForMap(workbook, entity, entityList, dataSet);
+        new PVExcelExportTemplateServer().createSheetForMap(workbook, entity, entityList, dataSet);
+        return workbook;
+    }
+
+    public static Workbook exportExcelReport(ExportParams entity, Class<?> pojoClass,
+                                       Collection<?> dataSet) {
+        Workbook workbook;
+        if (ExcelType.HSSF.equals(entity.getType())) {
+            workbook = new HSSFWorkbook();
+        } else if (dataSet.size() < 10000) {
+            workbook = new XSSFWorkbook();
+        } else {
+            workbook = new SXSSFWorkbook();
+        }
+        new PVExcelExportReportServer().createSheet(workbook, entity, pojoClass, dataSet);
         return workbook;
     }
 
@@ -57,7 +70,7 @@ public class PVExcelUtil {
      *            Collection 数据
      * @return
      */
-    public static Workbook exportExcel(List<ExportParams> entities, List<ExcelExportEntity> entityList,
+    public static Workbook exportExcelWithMultiSheet(List<ExportParams> entities, List<ExcelExportEntity> entityList,
                                        Collection<? extends Map<?, ?>> dataSet) {
         Workbook workbook;
         if (ExcelType.HSSF.equals(entities.get(0).getType())) {
@@ -68,7 +81,7 @@ public class PVExcelUtil {
             workbook = new SXSSFWorkbook();
         }
         for (ExportParams entity:entities) {
-            new PVExcelExportServer().createSheetForMap(workbook, entity, entityList, new ArrayList<>(dataSet));
+            new PVExcelExportTemplateServer().createSheetForMap(workbook, entity, entityList, new ArrayList<>(dataSet));
         }
 
         return workbook;
@@ -83,14 +96,11 @@ public class PVExcelUtil {
      * @param params
      * @return
      */
-    public static <T> List<T> importExcel(File file, Class<?> pojoClass, ImportParams params) {
+    public static <T> List<T> importExcel(InputStream inputstream, Class<?> pojoClass, ImportParams params) {
         FileInputStream in = null;
         try {
-            in = new FileInputStream(file);
-            ExcelImportResult result = new PVExcelImportServer().importExcelByIs(in, pojoClass, params);
-            Sheet sheet = result.getWorkbook().getSheetAt(0);
-            String cellValue = getCellValueByCell(sheet, 1, 1);
-            System.out.println(cellValue);
+            ExcelImportResult result = new PVExcelImportServer().importExcelByIs(inputstream, pojoClass, params);
+
             return result.getList();
         } catch (ExcelImportException e) {
             throw new ExcelImportException(e.getType(), e);

+ 32 - 67
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/PVTest.java

@@ -1,97 +1,62 @@
 package com.lc.ibps.components.verification.excel;
 
-import com.lc.ibps.components.poi.excel.ExcelImportUtil;
 import com.lc.ibps.components.poi.excel.entity.ExportParams;
 import com.lc.ibps.components.poi.excel.entity.ImportParams;
 import com.lc.ibps.components.poi.excel.entity.params.ExcelExportEntity;
 import com.lc.ibps.components.poi.excel.entity.vo.BaseEntityTypeConstants;
 import com.lc.ibps.components.poi.util.PoiPublicUtil;
+import com.lc.ibps.components.verification.excel.model.ExcelSheetRecord;
 import com.lc.ibps.components.verification.excel.model.InspectionConfigVO;
 import com.lc.ibps.components.verification.excel.model.InspectionItemVO;
 import org.apache.poi.ss.usermodel.Workbook;
 import org.junit.Test;
 
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.*;
 import java.time.LocalDate;
 import java.util.*;
 
 public class PVTest {
-    @Test
-    public  void testExport(){
-        {
-            try {
-                List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
-                ExcelExportEntity excelentity = new ExcelExportEntity("高溶度(R1)", "inspection");
-
-                ExcelExportEntity excelentity1 = new ExcelExportEntity("低溶度(R2)", "inspection");
-                ExcelExportEntity excelentity2 = new ExcelExportEntity("中溶度(R3)", "inspection");
 
-                List<ExcelExportEntity> temp = new ArrayList<ExcelExportEntity>();
-                ExcelExportEntity excelExportEntity = new ExcelExportEntity("样本编号", "number");
-                excelExportEntity.setType(BaseEntityTypeConstants.DoubleType);
-                temp.add(excelExportEntity);
-                ExcelExportEntity excelExportEntity1 = new ExcelExportEntity("检测浓度值", "value");
-                temp.add(excelExportEntity1);
-                excelentity.setList(temp);
-                excelentity1.setList(temp);
-                excelentity2.setList(temp);
-                entity.add(excelentity);
-                entity.add(excelentity1);
-                entity.add(excelentity2);
-                List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
-                Map<String, Object> map;
-                for (int i = 1; i <= 10; i++) {
-                    map = new HashMap<String, Object>();
-                    map.put("number", i);
-                    map.put("value", "");
+    @Test
+    public void mapTest() throws FileNotFoundException {
 
-                    List<Map<String, Object>> tempList = new ArrayList<Map<String, Object>>();
-                    tempList.add(map);
-                    map.put("inspection", tempList);
 
-                    list.add(map);
-                }
-                ExportParams exportParams = new ExportParams("XXX性能验证数据导入模板", "性能验证数据导入模板");
-                exportParams.setStyle(PVExcelExportStyler.class);
-                Workbook workbook = PVExcelUtil.exportExcel(exportParams, entity,
-                        list);
-                FileOutputStream fos = new FileOutputStream("D:/excel/Excel1.xls");
-                workbook.write(fos);
-                fos.close();
-            } catch (FileNotFoundException e) {
-                e.printStackTrace();
-            } catch (IOException e) {
-                e.printStackTrace();
-            }
-        }
-    }
+        long start = new Date().getTime();
+        File file = new File(PoiPublicUtil.getWebRootPath("Excel1.xlsx"));
+        FileInputStream in = new FileInputStream(file);
 
-    @Test
-    public void mapTest() {
+        InspectionConfigVO config = new InspectionConfigVO("批间精密度",5,2,
+                new String[]{"高溶度(R1)","低浓度(R2)"},10, LocalDate.now(),true);
+        InspectionItemVO item = new InspectionItemVO(config);
+        item.importExcelRecord(in);
 
-        ImportParams params = new ImportParams();
-        params.setTitleRows(2);
-        params.setHeadRows(2);
-        long start = new Date().getTime();
-        List<Map<String, Object>> list = PVExcelUtil.importExcel(
-                new File(PoiPublicUtil.getWebRootPath("check.xls")), Map.class, params);
-        System.out.println(list.size());
-        for(Map<String, Object> d : list)
-            System.out.println(d);
+        System.out.println(item);
+//        for(Map<String, Object> d : list)
+//            System.out.println(d);
 
     }
 
     @Test
-    public void test1() throws IOException {
-        InspectionConfigVO config = new InspectionConfigVO(5,2,
-                new String[]{"高溶度(R1)","低浓度(R2)"},10, LocalDate.now());
+    public void testExcelTemplateExport() throws IOException {
+        InspectionConfigVO config = new InspectionConfigVO("批间精密度",5,2,
+                new String[]{"高溶度(R1)","低浓度(R2)"},10, LocalDate.now(),true);
         InspectionItemVO item = new InspectionItemVO(config);
-        Workbook workbook = item.exportExcel();
-        FileOutputStream fos = new FileOutputStream("D:/excel/Excel1.xlsx");
+        Workbook workbook = item.exportExcelTemplate();
+        FileOutputStream fos = new FileOutputStream(String.format("D:/excel/%s.xlsx",config.getName()));
         workbook.write(fos);
         fos.close();
     }
+
+    @Test
+    public void testExcelReportExport() throws IOException {
+        File file = new File(PoiPublicUtil.getWebRootPath("Excel1.xlsx"));
+        FileInputStream in = new FileInputStream(file);
+
+        InspectionConfigVO config = new InspectionConfigVO("批间精密度",5,2,
+                new String[]{"高溶度(R1)","低浓度(R2)"},10, LocalDate.now(),true);
+        InspectionItemVO item = new InspectionItemVO(config);
+        item.importExcelRecord(in);
+
+
+    }
 }

+ 0 - 67
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/model/ExcelRecordVO.java

@@ -1,67 +0,0 @@
-package com.lc.ibps.components.verification.excel.model;
-
-import java.util.Map;
-
-/**
- * 每个检测指标下的每天需要上传的检测数据
- */
-public class ExcelRecordVO {
-    //标本数
-    private int specimensNum;
-    //重复次数
-    private int repeatNum;
-    //检测日期
-    private String date;
-
-    private String[] specimensName;
-
-    public ExcelRecordVO(int specimensNum, int repeatNum, String date, String[] specimensName) {
-        this.specimensNum = specimensNum;
-        this.repeatNum = repeatNum;
-        this.date = date;
-        this.specimensName = specimensName;
-    }
-
-    //样本名 : 检查数据
-    private Map<String,double[]> data;
-
-    public int getSpecimensNum() {
-        return specimensNum;
-    }
-
-    public void setSpecimensNum(int specimensNum) {
-        this.specimensNum = specimensNum;
-    }
-
-    public int getRepeatNum() {
-        return repeatNum;
-    }
-
-    public void setRepeatNum(int repeatNum) {
-        this.repeatNum = repeatNum;
-    }
-
-    public String getDate() {
-        return date;
-    }
-
-    public void setDate(String date) {
-        this.date = date;
-    }
-
-    public String[] getSpecimensName() {
-        return specimensName;
-    }
-
-    public void setSpecimensName(String[] specimensName) {
-        this.specimensName = specimensName;
-    }
-
-    public Map<String, double[]> getData() {
-        return data;
-    }
-
-    public void setData(Map<String, double[]> data) {
-        this.data = data;
-    }
-}

+ 59 - 0
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/model/ExcelSheetRecord.java

@@ -0,0 +1,59 @@
+package com.lc.ibps.components.verification.excel.model;
+
+import com.lc.ibps.components.verification.funcs.xValue;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class ExcelSheetRecord {
+
+    private String sheetName;
+    private List<Map> data;
+
+    private Map<String, xValue[]> convertedData;
+
+    public ExcelSheetRecord(String sheetName, List<Map> data) {
+        this.sheetName = sheetName;
+        this.data = data;
+    }
+
+    public String getSheetName() {
+        return sheetName;
+    }
+
+    public void setSheetName(String sheetName) {
+        this.sheetName = sheetName;
+    }
+
+    public List<Map> getData() {
+        return data;
+    }
+
+    public void setData(List<Map> data) {
+        this.data = data;
+    }
+
+    public Map<String, xValue[]> getConvertedData() {
+        return convertedData;
+    }
+
+    public void setConvertedData(Map<String, xValue[]> convertedData) {
+        this.convertedData = convertedData;
+    }
+
+    public void convert(InspectionConfigVO config){
+        convertedData = new HashMap<>();
+        for (String sName : config.getSpecimensName()) {
+            convertedData.put(sName,new xValue[config.getRepeatNum()]);
+        }
+        for (int i = 0; i < data.size(); i++) {
+             Map<String,String> map = data.get(i);
+            for (String sName : config.getSpecimensName()) {
+                String val = map.get(sName + "_" + InspectionItemVO.DISPLAY_VALUE);
+                convertedData.get(sName)[i] = new xValue(val);
+            }
+        }
+    }
+}
+

+ 24 - 1
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/model/InspectionConfigVO.java

@@ -5,6 +5,8 @@ import java.util.Date;
 
 public class InspectionConfigVO {
 
+    //检测指标名称
+    private String name;
     //检验天数
     private int days;
     //标本数
@@ -13,13 +15,26 @@ public class InspectionConfigVO {
     private String[] specimensName;
     //重复次数
     private int repeatNum;
+    //是否需要数据转换(对数)
+    private boolean isConvert = false;
 
-    public InspectionConfigVO(int days, int specimensNum, String[] specimensName, int repeatNum, LocalDate startDate) {
+    public InspectionConfigVO(String name, int days, int specimensNum, String[] specimensName,
+                              int repeatNum, LocalDate startDate,boolean isConvert) {
+        this.name = name;
         this.days = days;
         this.specimensNum = specimensNum;
         this.specimensName = specimensName;
         this.repeatNum = repeatNum;
         this.startDate = startDate;
+        this.isConvert = isConvert;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
     }
 
     private LocalDate startDate = LocalDate.now();
@@ -64,4 +79,12 @@ public class InspectionConfigVO {
     public void setStartDate(LocalDate startDate) {
         this.startDate = startDate;
     }
+
+    public boolean isConvert() {
+        return isConvert;
+    }
+
+    public void setConvert(boolean convert) {
+        isConvert = convert;
+    }
 }

+ 47 - 12
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/excel/model/InspectionItemVO.java

@@ -2,13 +2,17 @@ package com.lc.ibps.components.verification.excel.model;
 
 
 import com.lc.ibps.components.poi.excel.entity.ExportParams;
+import com.lc.ibps.components.poi.excel.entity.ImportParams;
 import com.lc.ibps.components.poi.excel.entity.enmus.ExcelType;
 import com.lc.ibps.components.poi.excel.entity.params.ExcelExportEntity;
 import com.lc.ibps.components.poi.excel.entity.vo.BaseEntityTypeConstants;
 import com.lc.ibps.components.verification.excel.PVExcelExportStyler;
 import com.lc.ibps.components.verification.excel.PVExcelUtil;
+import com.lc.ibps.components.verification.funcs.xValue;
+import org.apache.commons.lang3.ArrayUtils;
 import org.apache.poi.ss.usermodel.Workbook;
 
+import java.io.InputStream;
 import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -20,28 +24,26 @@ import java.util.Map;
  */
 public class InspectionItemVO {
 
+    public static String DISPLAY_NUMBER = "次数";
+    public static String DISPLAY_VALUE = "检测值";
+
     private InspectionConfigVO config;
 
-    private List<ExcelRecordVO> data = new ArrayList<>();
+    //样本名 : 检查数据
+    private Map<String, RecordCalcVO> record;
 
     public InspectionItemVO(InspectionConfigVO config) {
         this.config = config;
-        LocalDate startDate = config.getStartDate();
-        for (int i = 0; i < config.getDays(); i++) {
-            data.add(new ExcelRecordVO(config.getSpecimensNum(),config.getRepeatNum(),
-                startDate.toString(),config.getSpecimensName()));
-            startDate = startDate.plusDays(1);
-        }
     }
 
-    public Workbook exportExcel(){
+    public Workbook exportExcelTemplate() {
         List<ExcelExportEntity> entity = new ArrayList<ExcelExportEntity>();
 
         List<ExcelExportEntity> temp = new ArrayList<ExcelExportEntity>();
-        ExcelExportEntity e1 = new ExcelExportEntity("样本编号", "number");
+        ExcelExportEntity e1 = new ExcelExportEntity(DISPLAY_NUMBER, "number");
         e1.setType(BaseEntityTypeConstants.DoubleType);
         temp.add(e1);
-        ExcelExportEntity e2 = new ExcelExportEntity("检测值", "value");
+        ExcelExportEntity e2 = new ExcelExportEntity(DISPLAY_VALUE, "input");
         temp.add(e2);
 
         for (int i = 0; i < config.getSpecimensNum(); i++) {
@@ -65,14 +67,47 @@ public class InspectionItemVO {
         List<ExportParams> exportParamsList = new ArrayList<ExportParams>();
         LocalDate startDate = config.getStartDate();
         for (int i = 0; i < config.getDays(); i++) {
-            ExportParams exportParams = new ExportParams("XXX性能验证数据导入模板", startDate.toString());
+            ExportParams exportParams = new ExportParams(config.getName() + " 数据导入模板", startDate.toString());
             exportParams.setStyle(PVExcelExportStyler.class);
             exportParamsList.add(exportParams);
             startDate = startDate.plusDays(1);
             exportParams.setType(ExcelType.XSSF);
         }
-        Workbook workbook = PVExcelUtil.exportExcel(exportParamsList, entity,list);
+        Workbook workbook = PVExcelUtil.exportExcelWithMultiSheet(exportParamsList, entity, list);
 
         return workbook;
     }
+
+    public void importExcelRecord(InputStream inputstream) {
+        ImportParams params = new ImportParams();
+        params.setTitleRows(2);
+        params.setHeadRows(2);
+        params.setSheetNum(config.getDays());
+        List<ExcelSheetRecord> list = PVExcelUtil.importExcel(inputstream, Map.class, params);
+
+        for (ExcelSheetRecord record :
+                list) {
+            record.convert(config);
+        }
+        record = new HashMap<>();
+        for (String sName : config.getSpecimensName()) {
+            final xValue[] total = new xValue[config.getRepeatNum() * config.getDays()];
+            for (int j = 0; j < list.size(); j++) {
+                final xValue[] xValues = list.get(j).getConvertedData().get(sName);
+                for (int k = 0; k < xValues.length; k++) {
+                    total[j * xValues.length + k] = xValues[k];
+                }
+            }
+            record.put(sName, new RecordCalcVO(total, config.isConvert()));
+        }
+
+    }
+
+    public Map<String, RecordCalcVO> getRecord() {
+        return record;
+    }
+
+    public void setRecord(Map<String, RecordCalcVO> record) {
+        this.record = record;
+    }
 }

+ 8 - 2
ibps-provider-root/modules/provider-business/src/main/java/com/lc/ibps/components/verification/funcs/xValue.java

@@ -1,5 +1,7 @@
 package com.lc.ibps.components.verification.funcs;
 
+import org.apache.commons.lang3.StringUtils;
+
 import java.io.Serializable;
 import java.text.DecimalFormat;
 
@@ -39,8 +41,12 @@ public class xValue implements Serializable {
     //============SET METHOD SECTION============
     public xValue(){}
     public xValue(String valObj) {
-        this.iType = iSTRING;
-        this.valObj = valObj;
+        if(StringUtils.isNotBlank(valObj)){
+            this.iType = iSTRING;
+            this.valObj = valObj;
+        }
+
+
     }
     public xValue(double valDoub) {
         this.iType = iDOUBLE;