|
|
@@ -103,6 +103,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
String storeid = storeIn.getUuid(), storeName = storeIn.getStoreName();
|
|
|
Row headerRow = sheet.getRow(0);
|
|
|
int total = 0;
|
|
|
+ int blankNum = 0;
|
|
|
if (headerRow != null) {
|
|
|
if(colNum == 20) {
|
|
|
Cell errorCell = headerRow.getCell(19);
|
|
|
@@ -118,12 +119,13 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if(StringUtils.isEmpty(priceCellObj)) {
|
|
|
throw new IllegalOperatorException("您上传的信息列信息不正确,请与模板的列做比较");
|
|
|
}else{
|
|
|
+ String title = StringUtilB2C.replaceLineBreak(priceCellObj.toString());
|
|
|
if(Currency.USD.equals(currency)) {
|
|
|
- if (!priceCellObj.toString().equals("单价USD")) {
|
|
|
+ if (!title.equals("单价USD")) {
|
|
|
throw new IllegalOperatorException("您上传的文件表头与美金模板不符");
|
|
|
}
|
|
|
}else {
|
|
|
- if (!priceCellObj.toString().equals("单价RMB")) {
|
|
|
+ if (!title.equals("单价RMB(含17%税)")) {
|
|
|
throw new IllegalOperatorException("您上传的文件表头与人民币模板不符");
|
|
|
}
|
|
|
}
|
|
|
@@ -132,8 +134,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
for (int r = 1; r <= rowNum; r++) {
|
|
|
Row row = sheet.getRow(r);
|
|
|
// 英文品牌名称
|
|
|
- if (row != null && row.getCell(1) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
|
|
|
- total++;
|
|
|
+ if (row != null) {
|
|
|
+ blankNum = 0;
|
|
|
ReleaseProductByBatch releaseProductByBatch = new ReleaseProductByBatch();
|
|
|
releaseProductByBatch.setReleaseCode(ReleaseStatus.success.value());
|
|
|
releaseProductByBatch.setReleaseStatus(ReleaseStatus.success.getPhrase());
|
|
|
@@ -143,17 +145,18 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
Object cellValue = readWorkBookCell(cell, Cell.CELL_TYPE_STRING, r, 1);
|
|
|
if(StringUtils.isEmpty(cellValue)) {
|
|
|
releaseProductByBatch.addErrmsg("2:英文品牌为必填字段");
|
|
|
+ blankNum++;
|
|
|
}else {
|
|
|
- releaseProductByBatch.setBrandNameEn(String.valueOf(cellValue));
|
|
|
+ releaseProductByBatch.setBrandNameEn(StringUtilB2C.getStr(cellValue));
|
|
|
}
|
|
|
|
|
|
// 中文品牌名
|
|
|
Object brandNameCnCellValue = readWorkBookCell(row.getCell(0), Cell.CELL_TYPE_STRING, r, 0);
|
|
|
- releaseProductByBatch.setBrandNameCn(String.valueOf(brandNameCnCellValue));
|
|
|
+ releaseProductByBatch.setBrandNameCn(StringUtilB2C.getStr(brandNameCnCellValue));
|
|
|
|
|
|
// 产品型号
|
|
|
Object codeCellValue = readWorkBookCell(row.getCell(2), Cell.CELL_TYPE_STRING, r, 2);
|
|
|
- releaseProductByBatch.setCode(String.valueOf(codeCellValue));
|
|
|
+ releaseProductByBatch.setCode(StringUtilB2C.getStr(codeCellValue));
|
|
|
if(!StringUtils.isEmpty(codeCellValue)) {
|
|
|
String code = codeCellValue.toString();
|
|
|
Matcher matcher = codePattern.matcher(code);
|
|
|
@@ -162,15 +165,18 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}else {
|
|
|
releaseProductByBatch.addErrmsg("3:产品型号为必填字段");
|
|
|
+ blankNum++;
|
|
|
}
|
|
|
|
|
|
// 可拆卖
|
|
|
Object breakUpCellValue = readWorkBookCell(row.getCell(3), Cell.CELL_TYPE_STRING, r, 3);
|
|
|
- releaseProductByBatch.setBreakUpStr(String.valueOf(breakUpCellValue));
|
|
|
+ releaseProductByBatch.setBreakUpStr(StringUtilB2C.getStr(breakUpCellValue));
|
|
|
if (!StringUtils.isEmpty(breakUpCellValue)&&(ReleaseConstant.YES.equals(breakUpCellValue.toString()))) {
|
|
|
releaseProductByBatch.setBreakUp(Boolean.TRUE);
|
|
|
- }else {
|
|
|
+ }else if(!StringUtils.isEmpty(breakUpCellValue) && ReleaseConstant.NO.equals(breakUpCellValue.toString())){
|
|
|
releaseProductByBatch.setBreakUp(Boolean.FALSE);
|
|
|
+ }else {
|
|
|
+ releaseProductByBatch.addErrmsg("4:请选择可拆卖情况是或否");
|
|
|
}
|
|
|
|
|
|
// 库存类型
|
|
|
@@ -189,23 +195,25 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
// 发布库存量
|
|
|
Double reserve = null;
|
|
|
Object reserveCellValue = readWorkBookCell(row.getCell(4), Cell.CELL_TYPE_STRING, r, 4);
|
|
|
- releaseProductByBatch.setReserveStr(String.valueOf(reserveCellValue));
|
|
|
+ releaseProductByBatch.setReserveStr(StringUtilB2C.getStr(reserveCellValue));
|
|
|
if (reserveCellValue == null || !isNumber(reserveCellValue.toString())) {
|
|
|
- releaseProductByBatch.addErrmsg("5:发布数量为空或者不是数字");
|
|
|
+ releaseProductByBatch.addErrmsg("5:库存数量为空或者不是数字");
|
|
|
} else {
|
|
|
reserve = Double.valueOf(reserveCellValue.toString());
|
|
|
int compareTo = reserve.compareTo(DoubleConstant.maxReserve);
|
|
|
if(compareTo > 0) {
|
|
|
- releaseProductByBatch.addErrmsg("6:发布数量大于了我们设置的最大值" + DoubleConstant.maxReserve);
|
|
|
+ releaseProductByBatch.addErrmsg("6:库存数量大于了我们设置的最大值" + String.valueOf(DoubleConstant.maxReserve));
|
|
|
}else if(NumberUtil.compare(reserve, DoubleConstant.zero) < 1) {
|
|
|
- releaseProductByBatch.addErrmsg("6:发布数量必须大于0");
|
|
|
+ releaseProductByBatch.addErrmsg("6:库存数量必须大于0");
|
|
|
}
|
|
|
releaseProductByBatch.setReserve(reserve);
|
|
|
}
|
|
|
|
|
|
// 生产日期
|
|
|
Object produceDateCellValue = readWorkBookCell(row.getCell(5), Cell.CELL_TYPE_STRING, r, 5);
|
|
|
- releaseProductByBatch.setProductDate(String.valueOf(produceDateCellValue));
|
|
|
+ String productData = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(produceDateCellValue));
|
|
|
+ productData = (productData.length() > 11) ? productData.substring(0, 10) : productData;
|
|
|
+ releaseProductByBatch.setProductDate(productData);
|
|
|
if (StringUtils.isEmpty(produceDateCellValue)) {
|
|
|
releaseProductByBatch.addErrmsg("6:产品生产日期不可以为空");
|
|
|
}
|
|
|
@@ -213,7 +221,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
//包装方式
|
|
|
String packaging = null;
|
|
|
Object packagingCellValue = readWorkBookCell(row.getCell(6), Cell.CELL_TYPE_STRING, r, 6);
|
|
|
- releaseProductByBatch.setPackaging(String.valueOf(packagingCellValue));
|
|
|
+ String packagingData = StringUtilB2C.replaceLineBreak(StringUtilB2C.getStr(packagingCellValue));
|
|
|
+ packagingData = (packagingData.length() > 10) ? packagingData.substring(0, 9) : packagingData;
|
|
|
+ releaseProductByBatch.setPackaging(packagingData);
|
|
|
if (packagingCellValue == null || StringUtils.isEmpty(packagingCellValue.toString())) {
|
|
|
releaseProductByBatch.addErrmsg("7:包装方式不能为空");
|
|
|
} else {
|
|
|
@@ -245,7 +255,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
|
|
|
// 最小包装量
|
|
|
Object minPackQtyCellValue = readWorkBookCell(row.getCell(8), Cell.CELL_TYPE_STRING, r, 8);
|
|
|
- releaseProductByBatch.setMinPackageStr(String.valueOf(minPackQtyCellValue));
|
|
|
+ releaseProductByBatch.setMinPackageStr(StringUtilB2C.getStr(minPackQtyCellValue));
|
|
|
if ((minPackQtyCellValue != null)&&(isNumber(minPackQtyCellValue.toString()))) {
|
|
|
Double minPackQty = Double.valueOf(minPackQtyCellValue.toString());
|
|
|
if (minPackQty <= 0) {
|
|
|
@@ -256,7 +266,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}else {
|
|
|
releaseProductByBatch.setMinPackage(minPackQty);
|
|
|
}
|
|
|
- }if(StringUtils.isEmpty(minPackQtyCellValue)) {
|
|
|
+ }else if(StringUtils.isEmpty(minPackQtyCellValue)) {
|
|
|
releaseProductByBatch.setMinPackage(DoubleConstant.minReserve);
|
|
|
}else {
|
|
|
releaseProductByBatch.addErrmsg("9:最小包数量包含非数字字符");
|
|
|
@@ -264,7 +274,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
|
|
|
// 最小起订量
|
|
|
Object minBuyCellValue = readWorkBookCell(row.getCell(7), Cell.CELL_TYPE_STRING, r, 7);
|
|
|
- releaseProductByBatch.setMinBuyQtyStr(String.valueOf(minBuyCellValue));
|
|
|
+ releaseProductByBatch.setMinBuyQtyStr(StringUtilB2C.getStr(minBuyCellValue));
|
|
|
if ((minBuyCellValue != null)&&(isNumber(minBuyCellValue.toString()))) {
|
|
|
Double minBuy = Double.valueOf(minBuyCellValue.toString());
|
|
|
if (minBuy <= 0) {
|
|
|
@@ -278,7 +288,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}else {
|
|
|
releaseProductByBatch.setMinBuyQty(minBuy);
|
|
|
}
|
|
|
- if(!releaseProductByBatch.getBreakUp()) {
|
|
|
+ if((releaseProductByBatch.getBreakUp() != null) && !releaseProductByBatch.getBreakUp()) {
|
|
|
double v = releaseProductByBatch.getMinBuyQty() % releaseProductByBatch.getMinPackage();
|
|
|
if(NumberUtil.compare(v, 0.0) != 0) {
|
|
|
double sub = NumberUtil.sub(releaseProductByBatch.getMinBuyQty(), v);
|
|
|
@@ -308,7 +318,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
|
|
|
// 最小包单价
|
|
|
Object priceMinPackQtyCellValue = readWorkBookCell(row.getCell(9), Cell.CELL_TYPE_STRING, r, 9);
|
|
|
- releaseProductByBatch.setMinPackPriceStr(String.valueOf(priceMinPackQtyCellValue));
|
|
|
+ releaseProductByBatch.setMinPackPriceStr(StringUtilB2C.getStr(priceMinPackQtyCellValue));
|
|
|
if ((priceMinPackQtyCellValue != null)&&(isNumber(priceMinPackQtyCellValue.toString())) && (NumberUtil.compare(Double.valueOf(priceMinPackQtyCellValue.toString()), 0.0d) > 0)) {
|
|
|
Double price = Double.valueOf(priceMinPackQtyCellValue.toString());
|
|
|
price = fractionNumCeil(price, 6);
|
|
|
@@ -323,8 +333,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
|
|
|
Object deliveryMinCellValue = readWorkBookCell(row.getCell(10), Cell.CELL_TYPE_STRING, r, 10);
|
|
|
Object deliveryMaxCellValue = readWorkBookCell(row.getCell(11), Cell.CELL_TYPE_STRING, r, 11);
|
|
|
- releaseProductByBatch.setSelfMinDeliveryStr(String.valueOf(deliveryMinCellValue));
|
|
|
- releaseProductByBatch.setSelfMaxDeliveryStr(String.valueOf(deliveryMaxCellValue));
|
|
|
+ releaseProductByBatch.setSelfMinDeliveryStr(StringUtilB2C.getStr(deliveryMinCellValue));
|
|
|
+ releaseProductByBatch.setSelfMaxDeliveryStr(StringUtilB2C.getStr(deliveryMaxCellValue));
|
|
|
if(StringUtils.isEmpty(deliveryMinCellValue) && StringUtils.isEmpty(deliveryMaxCellValue)) {
|
|
|
releaseProductByBatch.addErrmsg("11-12:存在交期的信息为空");
|
|
|
}else {
|
|
|
@@ -413,7 +423,10 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
releaseProductByBatch.setUnit("PCS");
|
|
|
releaseProductByBatch.setCreateDate(new Date());
|
|
|
- releaseProductByBatchs.add(releaseProductByBatch);
|
|
|
+ if(blankNum != 2) {
|
|
|
+ total++;
|
|
|
+ releaseProductByBatchs.add(releaseProductByBatch);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -558,7 +571,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if(str.indexOf("\u00A0")>0){
|
|
|
str= str.replaceAll("\u00A0", "");
|
|
|
}
|
|
|
- obj = str.trim();
|
|
|
+ str = StringUtilB2C.replaceTabAndLineBreak(str);
|
|
|
+ obj = str.trim();
|
|
|
break;
|
|
|
case Cell.CELL_TYPE_NUMERIC:
|
|
|
cell.setCellType(Cell.CELL_TYPE_NUMERIC);
|
|
|
@@ -663,10 +677,10 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
ReleaseProductByBatch releaseProductByBatch, int r, int num, Double[] priceMaxMinPrice, int i) {
|
|
|
// 先跟据币别判断对应的价格是否有空值
|
|
|
Object endQtyCellValue = readWorkBookCell(cellQty, Cell.CELL_TYPE_STRING, r, num);
|
|
|
- releaseProductByBatch.setFragmentQty(String.valueOf(endQtyCellValue), i);
|
|
|
+ releaseProductByBatch.setFragmentQty(StringUtilB2C.getStr(endQtyCellValue), i);
|
|
|
|
|
|
Object priceCellValue = readWorkBookCell(cellPrice, Cell.CELL_TYPE_STRING, r, num + 1);
|
|
|
- releaseProductByBatch.setFragmentPrice(String.valueOf(priceCellValue), i);
|
|
|
+ releaseProductByBatch.setFragmentPrice(StringUtilB2C.getStr(priceCellValue), i);
|
|
|
if ((endQtyCellValue != null)&&(isNumber(endQtyCellValue.toString())) && (NumberUtil.compare(Double.valueOf(endQtyCellValue.toString()), 0.0d) > 0)) {
|
|
|
Double end = Double.valueOf(endQtyCellValue.toString());
|
|
|
GoodsQtyPrice qtyPrice = new GoodsQtyPrice();
|
|
|
@@ -801,7 +815,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
goodsService.updateComponentTradeInfos(uuid);
|
|
|
}
|
|
|
}
|
|
|
- return String.valueOf(num);
|
|
|
+ return StringUtilB2C.getStr(num);
|
|
|
}
|
|
|
|
|
|
}
|