浏览代码

修改bom上传开始行数判断

liusw 8 年之前
父节点
当前提交
9212d6d0a2

+ 26 - 3
src/main/java/com/uas/platform/b2c/trade/seek/service/impl/SeekPurchaseBomServiceImpl.java

@@ -109,7 +109,7 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
 
     private int mallColNum = 8;
     private int mallRowNum = 500;
-    private int startRow = 3;
+    private int startRow = 2;
 
     /**
      * 导入bom
@@ -134,8 +134,6 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         // 插入Bom求购中
         SeekPurchaseBom seekPurchaseBom = new SeekPurchaseBom();
         seekPurchaseBom.setReleaseDate(new Date(System.currentTimeMillis()));
-//        seekPurchaseBom.setEnuu(user.getEnterprise().getUu());
-//        seekPurchaseBom.setUu(user.getUserUU());
         seekPurchaseBom.setName(bomName);
         seekPurchaseBom.setStatus(0);
         seekPurchaseBom = seekPurchaseBomDao.save(seekPurchaseBom);
@@ -149,9 +147,13 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
                 return new ResultMap(CodeType.PARAMETER_ERROR, "您上传的信息列信息不正确,请与模板的列做比较");
             }
             List<SeekPurchaseByBatch> seekPurchaseByBatchList = new ArrayList<>();
+            if (vaidSample(sheet.getRow(startRow))) {
+                startRow = 3;
+            }
             for (int r = startRow; r <= rowNum; r++) {
                 Row row = sheet.getRow(r);
                 if (row != null) {
+
                     SeekPurchaseByBatch seekPurchaseByBatch = new SeekPurchaseByBatch();
                     blankNum = convertValueToSeekPurchaseByBatch(row, seekPurchaseByBatch, r);
                     if (blankNum >= 3) {
@@ -167,6 +169,27 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
         return ResultMap.success(seekPurchaseBom.getId());
     }
 
+    /**
+     * 校验第二行是否为商城示例
+     * @param row
+     * @return
+     */
+    private boolean vaidSample(Row row) {
+        Object codeCellObj = readWorkBookCell(row.getCell(0), Cell.CELL_TYPE_STRING,
+                0, 0);
+        String codeString = StringUtilB2C.getStr(codeCellObj);
+        Object brandCellObj = readWorkBookCell(row.getCell(1), Cell.CELL_TYPE_STRING,
+                0, 1);
+        String brandString = StringUtilB2C.getStr(brandCellObj);
+        Object produceDateCellObj = readWorkBookCell(row.getCell(7), Cell.CELL_TYPE_STRING,
+                0, 7);
+        String produceDateString = StringUtilB2C.getStr(produceDateCellObj);
+        if ("只能填数字、英文、英文特殊符号".equals(codeString) || "请勿用中文特殊符号".equals(brandCellObj) || "不超过6个汉字或12个字符".equals(produceDateString)) {
+            return true;
+        }
+        return false;
+    }
+
     /**
      * 验证是否为商城模板
      * @param headerRow