Browse Source

效率优化

24282 1 năm trước cách đây
mục cha
commit
cb9828ee90

+ 4 - 2
sd-business/src/main/java/com/sd/business/strategy/impl/DocumentByOrderExcelExportStrategy.java

@@ -22,6 +22,8 @@ import org.springframework.core.io.ClassPathResource;
 
 import java.io.*;
 import java.math.BigDecimal;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -127,11 +129,11 @@ public class DocumentByOrderExcelExportStrategy implements ExcelExportStrategy<M
 
             ClassPathResource classPathResource = new ClassPathResource("template" + File.separator + "orderDocument.xlsx");
             InputStream is = null;
-            FileOutputStream os = null;
+            BufferedOutputStream os = null;
             ExcelWriter excelWriter = null;
             try {
                 is = classPathResource.getInputStream();
-                os = new FileOutputStream(filePath);
+                os = new BufferedOutputStream(Files.newOutputStream(Paths.get(filePath)));
                 excelWriter = EasyExcel.write(os).withTemplate(is).build();
                 DocumentByOrderExcelCellMergeStrategy strategy = new DocumentByOrderExcelCellMergeStrategy(list);
                 WriteSheet writeSheet = EasyExcel.writerSheet().registerWriteHandler(strategy).build();