|
@@ -102,25 +102,31 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
/**
|
|
/**
|
|
|
* 模板列
|
|
* 模板列
|
|
|
*/
|
|
*/
|
|
|
- private int mallColNum = 6;
|
|
|
|
|
|
|
+ private final int SEEK_TEMPLATE_COLNUM = 6;
|
|
|
/**
|
|
/**
|
|
|
* 上限行数
|
|
* 上限行数
|
|
|
*/
|
|
*/
|
|
|
- private int mallRowNum = 500;
|
|
|
|
|
|
|
+ private final int MAX_SEEK_NUM = 500;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* excel列名
|
|
* excel列名
|
|
|
*/
|
|
*/
|
|
|
- public static final int CODENUM = 0;
|
|
|
|
|
- public static final int BRANDNUM = 1;
|
|
|
|
|
- public static final int DEADLINENUM = 2;
|
|
|
|
|
- public static final int AMOUNTNUM = 3;
|
|
|
|
|
|
|
+ // 型号
|
|
|
|
|
+ public final int CODENUM = 2;
|
|
|
|
|
+ // 品牌
|
|
|
|
|
+ public final int BRANDNUM = 0;
|
|
|
|
|
+ // 截止日期
|
|
|
|
|
+ public final int DEADLINENUM = 4;
|
|
|
|
|
+ // 采购数量
|
|
|
|
|
+ public final int AMOUNTNUM = 5;
|
|
|
// public static final int CURRENCYNUM = 6;
|
|
// public static final int CURRENCYNUM = 6;
|
|
|
// public static final int UNITPRICENUM = 7;
|
|
// public static final int UNITPRICENUM = 7;
|
|
|
// public static final int ENCAPSULATIONNUM = 8;
|
|
// public static final int ENCAPSULATIONNUM = 8;
|
|
|
// public static final int PRODUCEDATENUM = 9;
|
|
// public static final int PRODUCEDATENUM = 9;
|
|
|
- public static final int KINDNUM = 4;
|
|
|
|
|
- public static final int SPECNUM = 5;
|
|
|
|
|
|
|
+ // 类目
|
|
|
|
|
+ public final int KINDNUM = 1;
|
|
|
|
|
+ // 规格
|
|
|
|
|
+ public final int SPECNUM = 3;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -136,12 +142,12 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
|
int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
|
|
|
|
|
- if (colNum != mallColNum) {
|
|
|
|
|
|
|
+ if (colNum != SEEK_TEMPLATE_COLNUM) {
|
|
|
return new ResultMap(CodeType.PARAMETER_ERROR, "表格模板不正确!请重新下载最新模板");
|
|
return new ResultMap(CodeType.PARAMETER_ERROR, "表格模板不正确!请重新下载最新模板");
|
|
|
}
|
|
}
|
|
|
int rowNum = sheet.getLastRowNum();
|
|
int rowNum = sheet.getLastRowNum();
|
|
|
- if (rowNum > mallRowNum) {
|
|
|
|
|
- return new ResultMap(CodeType.PARAMETER_ERROR, "您上传的信息超过500条,请拆分成2000以再在上传");
|
|
|
|
|
|
|
+ if (rowNum > MAX_SEEK_NUM) {
|
|
|
|
|
+ return new ResultMap(CodeType.PARAMETER_ERROR, "您上传的信息超过500条,请拆分成500以下再在上传");
|
|
|
}
|
|
}
|
|
|
// 插入Bom求购中
|
|
// 插入Bom求购中
|
|
|
SeekPurchaseBom seekPurchaseBom = new SeekPurchaseBom();
|
|
SeekPurchaseBom seekPurchaseBom = new SeekPurchaseBom();
|
|
@@ -151,7 +157,6 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
seekPurchaseBom = seekPurchaseBomDao.save(seekPurchaseBom);
|
|
seekPurchaseBom = seekPurchaseBomDao.save(seekPurchaseBom);
|
|
|
// 获取第一行的信息
|
|
// 获取第一行的信息
|
|
|
Row headerRow = sheet.getRow(0);
|
|
Row headerRow = sheet.getRow(0);
|
|
|
- int blankNum = 0;
|
|
|
|
|
if (headerRow != null) {
|
|
if (headerRow != null) {
|
|
|
// 验证是否为商城模板
|
|
// 验证是否为商城模板
|
|
|
if (!vaildTemplete(headerRow)) {
|
|
if (!vaildTemplete(headerRow)) {
|
|
@@ -165,10 +170,9 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
for (int r = startRow; r <= rowNum; r++) {
|
|
for (int r = startRow; r <= rowNum; r++) {
|
|
|
Row row = sheet.getRow(r);
|
|
Row row = sheet.getRow(r);
|
|
|
if (row != null) {
|
|
if (row != null) {
|
|
|
-
|
|
|
|
|
SeekPurchaseByBatch seekPurchaseByBatch = new SeekPurchaseByBatch();
|
|
SeekPurchaseByBatch seekPurchaseByBatch = new SeekPurchaseByBatch();
|
|
|
- blankNum = convertValueToSeekPurchaseByBatch(row, seekPurchaseByBatch, r);
|
|
|
|
|
- if (blankNum >= 3) {
|
|
|
|
|
|
|
+ int blankNum = convertValueToSeekPurchaseByBatch(row, seekPurchaseByBatch, r);
|
|
|
|
|
+ if (blankNum >= 4) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
seekPurchaseByBatch.setBomId(seekPurchaseBom.getId());
|
|
seekPurchaseByBatch.setBomId(seekPurchaseBom.getId());
|
|
@@ -198,9 +202,6 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
Object brandCellObj = readWorkBookCell(row.getCell(BRANDNUM), Cell.CELL_TYPE_STRING,
|
|
Object brandCellObj = readWorkBookCell(row.getCell(BRANDNUM), Cell.CELL_TYPE_STRING,
|
|
|
0, BRANDNUM);
|
|
0, BRANDNUM);
|
|
|
String brandString = StringUtilB2C.getStr(brandCellObj);
|
|
String brandString = StringUtilB2C.getStr(brandCellObj);
|
|
|
-// Object produceDateCellObj = readWorkBookCell(row.getCell(PRODUCEDATENUM), Cell.CELL_TYPE_STRING,
|
|
|
|
|
-// 0, PRODUCEDATENUM);
|
|
|
|
|
-// String produceDateString = StringUtilB2C.getStr(produceDateCellObj);
|
|
|
|
|
if ("只能填数字、英文、英文特殊符号".equals(codeString) || "请勿用中文特殊符号".equals(brandString)) {
|
|
if ("只能填数字、英文、英文特殊符号".equals(codeString) || "请勿用中文特殊符号".equals(brandString)) {
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
@@ -228,11 +229,6 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
if (!"截止时间".equals(StringUtilB2C.getStr(deadlineCellObj))) {
|
|
if (!"截止时间".equals(StringUtilB2C.getStr(deadlineCellObj))) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
-// Object produceDateCellObj = readWorkBookCell(headerRow.getCell(PRODUCEDATENUM), Cell.CELL_TYPE_STRING,
|
|
|
|
|
-// 0, PRODUCEDATENUM);
|
|
|
|
|
-// if (!"生产日期".equals(StringUtilB2C.getStr(produceDateCellObj))) {
|
|
|
|
|
-// return false;
|
|
|
|
|
-// }
|
|
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -306,6 +302,15 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // 类目
|
|
|
|
|
+ Object kindValue = readWorkBookCell(row.getCell(KINDNUM), Cell.CELL_TYPE_STRING,
|
|
|
|
|
+ rowNum, KINDNUM);
|
|
|
|
|
+ if (!StringUtils.isEmpty(kindValue)) {
|
|
|
|
|
+ seekPurchaseByBatch.setKind(convert(kindValue, 50));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ result += 1;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 求购数量
|
|
// 求购数量
|
|
|
Object amountValue = readWorkBookCell(row.getCell(AMOUNTNUM), Cell.CELL_TYPE_STRING,
|
|
Object amountValue = readWorkBookCell(row.getCell(AMOUNTNUM), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, AMOUNTNUM);
|
|
rowNum, AMOUNTNUM);
|
|
@@ -386,13 +391,6 @@ public class SeekPurchaseBomServiceImpl implements SeekPurchaseBomService {
|
|
|
if (!StringUtils.isEmpty(specValue)) {
|
|
if (!StringUtils.isEmpty(specValue)) {
|
|
|
seekPurchaseByBatch.setSpec(convert(specValue, 50));
|
|
seekPurchaseByBatch.setSpec(convert(specValue, 50));
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 类目
|
|
|
|
|
- Object kindValue = readWorkBookCell(row.getCell(KINDNUM), Cell.CELL_TYPE_STRING,
|
|
|
|
|
- rowNum, KINDNUM);
|
|
|
|
|
- if (!StringUtils.isEmpty(kindValue)) {
|
|
|
|
|
- seekPurchaseByBatch.setKind(convert(kindValue, 50));
|
|
|
|
|
- }
|
|
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|