1
0
Эх сурвалжийг харах

fixed 后台商品导入模板功能

fushengqian 6 өдөр өмнө
parent
commit
9b8d60d4bf

+ 1 - 1
fuint-application/src/main/java/com/fuint/common/service/impl/CouponGroupServiceImpl.java

@@ -289,7 +289,7 @@ public class CouponGroupServiceImpl extends ServiceImpl<MtCouponGroupMapper, MtC
 
         List<List<String>> content = new ArrayList<>();
         try {
-            content = XlsUtil.readExcelContent(file.getInputStream(), isExcel2003, 1, null, null, null);
+            content = XlsUtil.readExcelContent(file.getInputStream(), isExcel2003, 0,1, null, null, null);
         } catch (IOException e) {
             log.error("CouponGroupServiceImpl->parseExcelContent{}", e);
             throw new BusinessCheckException("导入失败"+e.getMessage());

+ 3 - 3
fuint-application/src/main/java/com/fuint/common/service/impl/GoodsServiceImpl.java

@@ -851,9 +851,9 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
             throw new BusinessCheckException("文件类型不正确");
         }
 
-        List<List<String>> content = new ArrayList<>();
+        List<List<String>> goodsList = new ArrayList<>();
         try {
-            content = XlsUtil.readExcelContent(file.getInputStream(), isExcel2003, 1, null, null, null);
+            goodsList = XlsUtil.readExcelContent(file.getInputStream(), isExcel2003, 0, 1, null, null, null);
         } catch (IOException e) {
             logger.error("GoodsServiceImpl->parseExcelContent{}", e);
             throw new BusinessCheckException("导入失败" + e.getMessage());
@@ -861,7 +861,7 @@ public class GoodsServiceImpl extends ServiceImpl<MtGoodsMapper, MtGoods> implem
             e.printStackTrace();
         }
 
-        if (content != null && content.size() > 0) {
+        if (goodsList != null && goodsList.size() > 0) {
             // empty
         }
 

+ 3 - 2
fuint-application/src/main/java/com/fuint/common/util/XlsUtil.java

@@ -52,13 +52,14 @@ public class XlsUtil {
      *
      * @param is           文件流
      * @param isExcel2003  是否是2003的excel
+     * @param sheetIndex   工作表序号
      * @param firstRowNum  开始读取的行号(从0开始)为NULL时从第一行开始
      * @param lastRowNum   结束读取的行号(从0开始)为NULL时最后一行结束
      * @param firstCellNum 结束读取的列号(从0开始)为NULL时第一列开始
      * @param lastCellNum  结束读取的列号(从0开始)为NULL时最后一列结束
      * @return List 包含单元格数据内容的List对象
      */
-    public static List<List<String>> readExcelContent(InputStream is, boolean isExcel2003, Integer firstRowNum, Integer lastRowNum, Integer firstCellNum, Integer lastCellNum) throws Exception {
+    public static List<List<String>> readExcelContent(InputStream is, boolean isExcel2003, Integer sheetIndex, Integer firstRowNum, Integer lastRowNum, Integer firstCellNum, Integer lastCellNum) throws Exception {
         List<List<String>> content = new ArrayList<>();
         Workbook wb;
         Sheet sheet;
@@ -73,7 +74,7 @@ public class XlsUtil {
             logger.error("XlsUtil—>readExcelContent:{}", e);
             throw new Exception("导入失败");
         }
-        sheet = wb.getSheetAt(0);
+        sheet = wb.getSheetAt(sheetIndex);
         int startRowNum = 0;
         if (null != firstRowNum) {
             startRowNum = firstRowNum;

BIN
fuint-application/src/main/resources/商品导入模板.xlsx