|
|
@@ -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);
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
}
|