|
|
@@ -16,6 +16,7 @@ import com.uas.platform.b2c.core.utils.RegexConstant;
|
|
|
import com.uas.platform.b2c.core.utils.StringUtilB2C;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.DoubleConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.ErrorInfoConstant;
|
|
|
+import com.uas.platform.b2c.prod.commodity.constant.ModifyConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.ShortConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.constant.UploadConstant;
|
|
|
import com.uas.platform.b2c.prod.commodity.dao.GoodsDao;
|
|
|
@@ -29,14 +30,12 @@ import com.uas.platform.b2c.prod.commodity.model.Product;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.ProductPerson;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.ProductPrivate;
|
|
|
import com.uas.platform.b2c.prod.commodity.model.ReleaseProductByBatch;
|
|
|
-import com.uas.platform.b2c.prod.commodity.constant.*;
|
|
|
-import com.uas.platform.b2c.prod.commodity.dao.*;
|
|
|
-import com.uas.platform.b2c.prod.commodity.model.*;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.GoodsService;
|
|
|
import com.uas.platform.b2c.prod.commodity.service.ReleaseProductByBatchService;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.GoodsUtil;
|
|
|
import com.uas.platform.b2c.prod.commodity.util.SheetUtil;
|
|
|
import com.uas.platform.b2c.prod.product.common.service.CreateNumberService;
|
|
|
+import com.uas.platform.b2c.prod.product.kind.dao.KindInfoDao;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreIn;
|
|
|
import com.uas.platform.b2c.prod.store.model.StoreStatus;
|
|
|
import com.uas.platform.b2c.prod.store.service.StoreInService;
|
|
|
@@ -55,10 +54,13 @@ import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.Comparator;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Set;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
@@ -128,6 +130,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
@Autowired
|
|
|
private ProductPersonDao productPersonDao;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private KindInfoDao kindInfoDao;
|
|
|
+
|
|
|
@Value("#{sys.productServiceIp}")
|
|
|
private String productServiceIp;
|
|
|
|
|
|
@@ -145,7 +150,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @author hejq
|
|
|
*/
|
|
|
@Override
|
|
|
- public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer repeatImport) {
|
|
|
+ public ModelMap releaseByWorkbook(Workbook workbook, Boolean selfSale, String currency, Integer isPerson, Integer repeatImport, boolean isPcb) {
|
|
|
// 是否上传个人物料
|
|
|
boolean isAPerson = false;
|
|
|
boolean isImport = false;
|
|
|
@@ -164,15 +169,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (colNum != UploadConstant.TOTAL_COLUMN_PERSON && colNum != UploadConstant.MAX_TOTAL_COLUMN_PERSON) {
|
|
|
throw new IllegalOperatorException("表格模板不正确!请重新下载最新模板");
|
|
|
}
|
|
|
- } else {
|
|
|
- if (colNum != UploadConstant.TOTAL_COLUMN && colNum != UploadConstant.MAX_TOTAL_COLUMN) {
|
|
|
+ } else if ((isPcb && colNum != UploadConstant.TOTAL_COLUMN_PCB && colNum != UploadConstant.MAX_TOTAL_COLUMN_PCB) || (colNum != UploadConstant.TOTAL_COLUMN && colNum != UploadConstant.MAX_TOTAL_COLUMN)) {
|
|
|
throw new IllegalOperatorException("表格模板不正确!请重新下载最新模板");
|
|
|
}
|
|
|
- }
|
|
|
- int rowNum = SheetUtil.getSheetLastNum(sheet, UploadConstant.MAX_TOTAL_COLUMN);
|
|
|
+ int rowNum = SheetUtil.getSheetLastNum(sheet, isPcb ? UploadConstant.MAX_TOTAL_COLUMN_PCB : UploadConstant.MAX_TOTAL_COLUMN);
|
|
|
if (rowNum > 2000) {
|
|
|
- throw new IllegalOperatorException
|
|
|
- ("您上传的信息超过2000条,请拆分成2000以下再上传");
|
|
|
+ throw new IllegalOperatorException ("您上传的信息超过2000条,请拆分成2000以下再上传");
|
|
|
}
|
|
|
List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<>(rowNum);
|
|
|
String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);
|
|
|
@@ -180,8 +182,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
Row headerRow = sheet.getRow(0);
|
|
|
int total = 0;
|
|
|
int blankNum = 0;
|
|
|
- long time1 = new Date().getTime();
|
|
|
- System.err.println();
|
|
|
if (headerRow != null) {
|
|
|
// 验证模板是否为商城模板
|
|
|
validateTemplate(headerRow, colNum, currency, isAPerson);
|
|
|
@@ -198,11 +198,10 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
setProductDefaultInfo(releaseProductByBatch, batch, currency, storeIn);
|
|
|
// TODO 个人库验证
|
|
|
// 将excel内容对应到ReleaseProductByBatch的字段当中
|
|
|
- blankNum = convertValueToProduct(row, releaseProductByBatch, r, isAPerson);
|
|
|
+ blankNum = convertValueToProduct(row, releaseProductByBatch, r, isAPerson, isPcb);
|
|
|
// TODO 个人库验证
|
|
|
if (!isAPerson) {
|
|
|
// 解析返回分段价格list
|
|
|
- List<GoodsQtyPrice> qtyPriceList = initQtyPriceByExcel(row, releaseProductByBatch, r, false);
|
|
|
List<GoodsQtyPrice> qtyPriceList = initQtyPriceByExcel(row, true, releaseProductByBatch, r);
|
|
|
if (!CollectionUtils.isEmpty(qtyPriceList)) {
|
|
|
releaseProductByBatch.setPrices(qtyPriceList);
|
|
|
@@ -230,15 +229,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- long time2 = new Date().getTime();
|
|
|
- System.err.println((time2 - time1) + "**********************************1");
|
|
|
Long userUU = SystemSession.getUser().getUserUU();
|
|
|
Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
List<ReleaseProductByBatch> addList = new ArrayList<>(releaseProductByBatchs.size());
|
|
|
addList.addAll(releaseProductByBatchs);
|
|
|
resetRepeatData(addList, isImport, isAPerson);
|
|
|
- long time3 = new Date().getTime();
|
|
|
- System.err.println((time3 - time2) + "**********************************2");
|
|
|
if (isAPerson) {
|
|
|
for (ReleaseProductByBatch releaseProductByBatch : addList) {
|
|
|
List<Product> productList = productDao.findByEnUUAndPcmpcodeAndPbrandenAndB2cEnabled(enUU,releaseProductByBatch.getB2cCode(),
|
|
|
@@ -254,111 +249,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- long time4 = new Date().getTime();
|
|
|
- System.err.println((time4 - time3) + "**********************************3");
|
|
|
- commonDao.save(addList, ReleaseProductByBatch.class);
|
|
|
- long time5 = new Date().getTime();
|
|
|
- System.err.println((time5 - time4) + "**********************************4");
|
|
|
- releaseProductByBatchDao.callValidProcedure(enUU, batch);
|
|
|
- long time6 = new Date().getTime();
|
|
|
- System.err.println((time6 - time5) + "**********************************5");
|
|
|
- Integer filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
|
|
|
- long time7 = new Date().getTime();
|
|
|
- System.err.println((time7 - time6) + "**********************************6");
|
|
|
- Integer failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
|
|
|
- long time8 = new Date().getTime();
|
|
|
- System.err.println((time8 - time7) + "**********************************7");
|
|
|
- Integer success = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.success.value());
|
|
|
- long time9 = new Date().getTime();
|
|
|
- System.err.println((time9 - time8) + "**********************************8");
|
|
|
- modelMap.put("total", total);
|
|
|
- modelMap.put("success", success);
|
|
|
- modelMap.put("failure", failure);
|
|
|
- modelMap.put("filter", filter);
|
|
|
- modelMap.put("batch", batch);
|
|
|
- return modelMap;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap releasePCBByWorkbook(Workbook workbook, String currency, Integer repeatImport) {
|
|
|
- // 是否上传个人物料
|
|
|
- boolean isAPerson = false;
|
|
|
- boolean isImport = false;
|
|
|
- if (null != repeatImport && IntegerConstant.YES_SHORT.equals(repeatImport)) {
|
|
|
- isImport = true;
|
|
|
- }
|
|
|
- ModelMap modelMap = new ModelMap();
|
|
|
- // 获取第一个工作表
|
|
|
- Sheet sheet = workbook.getSheetAt(0);
|
|
|
- int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
-
|
|
|
- if (colNum != UploadConstant.TOTAL_COLUMN_PCB && colNum != UploadConstant.MAX_TOTAL_COLUMN_PCB) {
|
|
|
- throw new IllegalOperatorException("表格模板不正确!请重新下载最新模板");
|
|
|
- }
|
|
|
-
|
|
|
- int rowNum = sheet.getLastRowNum();
|
|
|
- if (rowNum > 2000) {
|
|
|
- throw new IllegalOperatorException
|
|
|
- ("您上传的信息超过2000条,请拆分成2000以再在上传");
|
|
|
- }
|
|
|
- List<ReleaseProductByBatch> releaseProductByBatchs = new ArrayList<>(rowNum);
|
|
|
- String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);
|
|
|
- StoreIn storeIn = getStoreInfo(true);
|
|
|
- Row headerRow = sheet.getRow(0);
|
|
|
- int total = 0;
|
|
|
- int blankNum = 0;
|
|
|
- if (headerRow != null) {
|
|
|
- // 验证模板是否为商城模板
|
|
|
- validatePCBTemplate(headerRow, colNum, currency);
|
|
|
- for (int r = 2; r <= rowNum; r++) {
|
|
|
- Row row = sheet.getRow(r);
|
|
|
- // 英文品牌名称
|
|
|
- if (row != null) {
|
|
|
- // 防止用户直接用模板进行上传
|
|
|
- if (!validateExcelData(row, r)) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- ReleaseProductByBatch releaseProductByBatch = new ReleaseProductByBatch();
|
|
|
- // 初始化默认信息
|
|
|
- setProductDefaultInfo(releaseProductByBatch, batch, currency, storeIn);
|
|
|
-// TODO 个人库验证
|
|
|
- // 将excel内容对应到ReleaseProductByBatch的字段当中
|
|
|
- blankNum = convertValueToPCBProduct(row, releaseProductByBatch, r);
|
|
|
-// TODO 个人库验证
|
|
|
- // 解析返回分段价格list
|
|
|
- List<GoodsQtyPrice> qtyPriceList = initQtyPriceByExcel(row, releaseProductByBatch, r, true);
|
|
|
- if (!CollectionUtils.isEmpty(qtyPriceList)) {
|
|
|
- releaseProductByBatch.setPrices(qtyPriceList);
|
|
|
- }
|
|
|
-
|
|
|
- if (!StringUtils.isEmpty(releaseProductByBatch.getErrmsg())) {
|
|
|
- releaseProductByBatch.setErrmsg(releaseProductByBatch.getErrmsg().substring(1));
|
|
|
- releaseProductByBatch.setReleaseCode(ReleaseStatus.lack_info.value());
|
|
|
- releaseProductByBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
- } else {
|
|
|
- // 导入成功的需要判断自定义标签是否重复
|
|
|
- if (!CollectionUtils.isEmpty(releaseProductByBatchs) && releaseProductByBatch.getTag() != null) {
|
|
|
- if (validateTagInfo(releaseProductByBatch, releaseProductByBatchs)) {
|
|
|
- releaseProductByBatch.setTag(null);
|
|
|
- }
|
|
|
- }
|
|
|
- validateRepeatInExcel(releaseProductByBatchs, releaseProductByBatch, isImport);
|
|
|
- }
|
|
|
- // 简单验证数据,防止空行保存的情况
|
|
|
- if (blankNum != 3) {
|
|
|
- total++;
|
|
|
- releaseProductByBatchs.add(releaseProductByBatch);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Long userUU = SystemSession.getUser().getUserUU();
|
|
|
- Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- List<ReleaseProductByBatch> addList = new ArrayList<>(releaseProductByBatchs.size());
|
|
|
- addList.addAll(releaseProductByBatchs);
|
|
|
- resetRepeatData(addList, isImport, isAPerson);
|
|
|
commonDao.save(addList, ReleaseProductByBatch.class);
|
|
|
-
|
|
|
releaseProductByBatchDao.callValidProcedure(enUU, batch);
|
|
|
Integer filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
|
|
|
Integer failure = releaseProductByBatchDao.getCountPublisherUuAndBatchAndReleaseCode(userUU, batch, ReleaseStatus.failure.value());
|
|
|
@@ -860,44 +751,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 验证该模板是否是商城PCB模板
|
|
|
- * @param headerRow 首行
|
|
|
- * @param colNum 总列
|
|
|
- * @param currency 币别
|
|
|
- */
|
|
|
- private void validatePCBTemplate(Row headerRow, int colNum, String currency) {
|
|
|
- if (colNum == UploadConstant.MAX_TOTAL_COLUMN_PCB) {
|
|
|
- Cell errorCell = headerRow.getCell(UploadConstant.MAX_TOTAL_COLUMN_PCB - 1);
|
|
|
- Object errorCellObj = readWorkBookCell(errorCell, Cell.CELL_TYPE_STRING, 0, 0);
|
|
|
- String errorHead = StringUtilB2C.replaceLineBreak(String.valueOf(errorCellObj));
|
|
|
- if (StringUtils.isEmpty(errorHead) || !("错误提示".equals(errorHead))) {
|
|
|
- throw new IllegalOperatorException("表格模板不正确!请重新下载最新模板");
|
|
|
- }
|
|
|
- }
|
|
|
- Object codeCellObj = readWorkBookCell(headerRow.getCell(UploadConstant.PRODUCT_CODE), Cell.CELL_TYPE_STRING,
|
|
|
- 0, UploadConstant.PRODUCT_CODE);
|
|
|
- if (!"产品名称".equals(StringUtilB2C.getStr(codeCellObj))) {
|
|
|
- throw new IllegalOperatorException("您上传的信息列信息不正确,请与模板的列做比较");
|
|
|
- }
|
|
|
- Object priceCellObj = readWorkBookCell(headerRow.getCell(UploadConstant.PRICE_START_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- 0, UploadConstant.PRICE_START_PCB);
|
|
|
- if (StringUtils.isEmpty(priceCellObj)) {
|
|
|
- throw new IllegalOperatorException("您上传的信息列信息不正确,请与模板的列做比较");
|
|
|
- } else {
|
|
|
- String title = StringUtilB2C.replaceLineBreak(priceCellObj.toString());
|
|
|
- if (Currency.USD.equals(currency)) {
|
|
|
- if (!title.equals("USD单价1")) {
|
|
|
- throw new IllegalOperatorException("您上传的文件表头与美金模板不符");
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (!title.equals("RMB单价1")) {
|
|
|
- throw new IllegalOperatorException("您上传的文件表头与人民币模板不符");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 验证是否是模板的数据
|
|
|
* @param row excel的row对象
|
|
|
@@ -1032,7 +885,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
/**
|
|
|
* 设置交期的信息
|
|
|
*/
|
|
|
- private void setDeliveryTime(ReleaseProductByBatch releaseProductByBatch, Object minDelivery, Object maxDelivery, boolean isPCB) {
|
|
|
+ private void setDeliveryTime(ReleaseProductByBatch releaseProductByBatch, Object minDelivery, Object maxDelivery) {
|
|
|
minDelivery = minDelivery == null ? maxDelivery : minDelivery;
|
|
|
maxDelivery = maxDelivery == null ? minDelivery : maxDelivery;
|
|
|
Pattern intMinP = Pattern.compile(RegexConstant.Integer);
|
|
|
@@ -1053,7 +906,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
max = max == null ? min : max;
|
|
|
if (min > ShortConstant.maxDelivery || min < ShortConstant.minDelivery
|
|
|
|| max > ShortConstant.maxDelivery || max < ShortConstant.minDelivery) {
|
|
|
- releaseProductByBatch.addErrmsg(isPCB ? ErrorInfoConstant.DELIVERY_VALUE_INFO_PCB.getInfo() : ErrorInfoConstant.DELIVERY_VALUE_INFO.getInfo());
|
|
|
+ releaseProductByBatch.addErrmsg(ErrorInfoConstant.DELIVERY_VALUE_INFO.getInfo());
|
|
|
} else {
|
|
|
if (min > max) {
|
|
|
Short delivery = max;
|
|
|
@@ -1064,7 +917,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
releaseProductByBatch.setSelfMaxDelivery(max);
|
|
|
}
|
|
|
} else {
|
|
|
- releaseProductByBatch.addErrmsg(isPCB ? ErrorInfoConstant.DELIVERY_VALUE_INFO_PCB.getInfo() : ErrorInfoConstant.DELIVERY_VALUE_INFO.getInfo());
|
|
|
+ releaseProductByBatch.addErrmsg(ErrorInfoConstant.DELIVERY_VALUE_INFO.getInfo());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -1108,8 +961,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param row 行对象
|
|
|
* @param aProduct 验证单行数据
|
|
|
* @param rowNum 行数
|
|
|
+ * @param isPcb 是否pcb模块
|
|
|
*/
|
|
|
- private int convertValueToProduct(Row row, ReleaseProductByBatch aProduct, int rowNum, boolean isAPerson) {
|
|
|
+ private int convertValueToProduct(Row row, ReleaseProductByBatch aProduct, int rowNum, boolean isAPerson, boolean isPcb) {
|
|
|
// 统计为空的个数
|
|
|
int result = 0;
|
|
|
|
|
|
@@ -1126,6 +980,9 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
result += 1;
|
|
|
}
|
|
|
aProduct.setKindByExcel(kindValue);
|
|
|
+ // pcb模块判断类目是否为商城标准pcb类目
|
|
|
+ if (isPcb && !StringUtils.isEmpty(aProduct.getKindName())) {
|
|
|
+ }
|
|
|
|
|
|
Object codeValue = readWorkBookCell(row.getCell(UploadConstant.PRODUCT_CODE), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PRODUCT_CODE);
|
|
|
@@ -1142,48 +999,48 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (!isAPerson) {
|
|
|
Object breakValue = readWorkBookCell(row.getCell(UploadConstant.BREAK_UP), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.BREAK_UP);
|
|
|
- aProduct.setBreakUpByExcel(breakValue, false);
|
|
|
+ aProduct.setBreakUpByExcel(breakValue);
|
|
|
|
|
|
Object reserveValue = readWorkBookCell(row.getCell(UploadConstant.RESERVE_NUMBER), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.RESERVE_NUMBER);
|
|
|
if (StringUtils.isEmpty(reserveValue)) {
|
|
|
result += 1;
|
|
|
}
|
|
|
- aProduct.setReserveByExcel(reserveValue, false);
|
|
|
+ aProduct.setReserveByExcel(reserveValue);
|
|
|
|
|
|
Cell productCell = row.getCell(UploadConstant.PRODUCE_DATE);
|
|
|
if (productCell != null && productCell.getCellType() == 0) {
|
|
|
if (HSSFDateUtil.isCellDateFormatted(productCell)) {
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String productStr = sdf.format(productCell.getDateCellValue());
|
|
|
- aProduct.setProductDateByExcel(productStr, false);
|
|
|
+ aProduct.setProductDateByExcel(productStr);
|
|
|
} else {
|
|
|
- aProduct.setProductDateByExcel("", false);
|
|
|
+ aProduct.setProductDateByExcel("");
|
|
|
aProduct.setProductDateByExcel(readWorkBookCell(row.getCell(ModifyConstant.PRODUCE_DATE), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, ModifyConstant.PRODUCE_DATE));
|
|
|
}
|
|
|
} else {
|
|
|
Object produceValue = readWorkBookCell(row.getCell(UploadConstant.PRODUCE_DATE), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PRODUCE_DATE);
|
|
|
- aProduct.setProductDateByExcel(produceValue, false);
|
|
|
+ aProduct.setProductDateByExcel(produceValue);
|
|
|
}
|
|
|
|
|
|
Object packageMethodValue = readWorkBookCell(row.getCell(UploadConstant.PACKAGE_METHOD), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PACKAGE_METHOD);
|
|
|
- aProduct.setPackagingByExcel(packageMethodValue , isAPerson, false);
|
|
|
+ aProduct.setPackagingByExcel(packageMethodValue , isAPerson);
|
|
|
|
|
|
Object minValue = readWorkBookCell(row.getCell(UploadConstant.MIN_DELIVERY), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.MIN_DELIVERY);
|
|
|
Object maxValue = readWorkBookCell(row.getCell(UploadConstant.MAX_DELIVERY), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.MAX_DELIVERY);
|
|
|
- aProduct.setDeliveryByExcel(minValue, maxValue, false);
|
|
|
+ aProduct.setDeliveryByExcel(minValue, maxValue);
|
|
|
if (!StringUtils.isEmpty(minValue) || !StringUtils.isEmpty(maxValue)) {
|
|
|
- setDeliveryTime(aProduct, minValue, maxValue, false);
|
|
|
+ setDeliveryTime(aProduct, minValue, maxValue);
|
|
|
}
|
|
|
|
|
|
Object packageNumValue = readWorkBookCell(row.getCell(UploadConstant.PACKAGE_NUMBER), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PACKAGE_NUMBER);
|
|
|
- aProduct.setMinPackageByExcel(packageNumValue, false);
|
|
|
+ aProduct.setMinPackageByExcel(packageNumValue);
|
|
|
|
|
|
Object buyQtyValue = readWorkBookCell(row.getCell(UploadConstant.BUY_MIN_QTY), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.BUY_MIN_QTY);
|
|
|
@@ -1199,92 +1056,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
} else {
|
|
|
Object packageMethodValue = readWorkBookCell(row.getCell(UploadConstant.SPECIFICATION), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.SPECIFICATION);
|
|
|
- aProduct.setPackagingByExcel(packageMethodValue , isAPerson, false);
|
|
|
+ aProduct.setPackagingByExcel(packageMethodValue , isAPerson);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 初始化product信息,将excel内容转换为product字段值
|
|
|
- * @param row 行对象
|
|
|
- * @param aProduct 验证单行数据
|
|
|
- * @param rowNum 行数
|
|
|
- */
|
|
|
- private int convertValueToPCBProduct(Row row, ReleaseProductByBatch aProduct, int rowNum) {
|
|
|
- // 统计为空的个数
|
|
|
- int result = 0;
|
|
|
- Object codeValue = readWorkBookCell(row.getCell(UploadConstant.PRODUCT_CODE), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.PRODUCT_CODE);
|
|
|
- if (StringUtils.isEmpty(codeValue)) {
|
|
|
- result += 1;
|
|
|
- }
|
|
|
- aProduct.setCodeByExcel(codeValue);
|
|
|
-
|
|
|
- Object brandValue = readWorkBookCell(row.getCell(UploadConstant.BRAND_ENGLISH), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.BRAND_ENGLISH);
|
|
|
- if (StringUtils.isEmpty(brandValue)) {
|
|
|
- result += 1;
|
|
|
- }
|
|
|
- aProduct.setBrandEnByExcel(brandValue);
|
|
|
-
|
|
|
- Object breakValue = readWorkBookCell(row.getCell(UploadConstant.BREAK_UP_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.BREAK_UP_PCB);
|
|
|
- aProduct.setBreakUpByExcel(breakValue, true);
|
|
|
-
|
|
|
- Object reserveValue = readWorkBookCell(row.getCell(UploadConstant.RESERVE_NUMBER_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.RESERVE_NUMBER_PCB);
|
|
|
- if (StringUtils.isEmpty(reserveValue)) {
|
|
|
- result += 1;
|
|
|
- }
|
|
|
- aProduct.setReserveByExcel(reserveValue, true);
|
|
|
-
|
|
|
- Cell productCell = row.getCell(UploadConstant.PRODUCE_DATE_PCB);
|
|
|
- if (productCell != null && productCell.getCellType() == 0) {
|
|
|
- if (HSSFDateUtil.isCellDateFormatted(productCell)) {
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- String productStr = sdf.format(productCell.getDateCellValue());
|
|
|
- aProduct.setProductDateByExcel(productStr, true);
|
|
|
- } else {
|
|
|
- aProduct.setProductDateByExcel("", true);
|
|
|
- }
|
|
|
- } else {
|
|
|
- Object produceValue = readWorkBookCell(row.getCell(UploadConstant.PRODUCE_DATE_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.PRODUCE_DATE_PCB);
|
|
|
- aProduct.setProductDateByExcel(produceValue, true);
|
|
|
- }
|
|
|
-
|
|
|
- Object packageMethodValue = readWorkBookCell(row.getCell(UploadConstant.PACKAGE_METHOD_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.PACKAGE_METHOD_PCB);
|
|
|
- aProduct.setPackagingByExcel(packageMethodValue , false, true);
|
|
|
-
|
|
|
- Object minValue = readWorkBookCell(row.getCell(UploadConstant.MIN_DELIVERY_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.MIN_DELIVERY_PCB);
|
|
|
- Object maxValue = readWorkBookCell(row.getCell(UploadConstant.MAX_DELIVERY_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.MAX_DELIVERY_PCB);
|
|
|
- aProduct.setDeliveryByExcel(minValue, maxValue, true);
|
|
|
- if (!StringUtils.isEmpty(minValue) || !StringUtils.isEmpty(maxValue)) {
|
|
|
- setDeliveryTime(aProduct, minValue, maxValue, true);
|
|
|
- }
|
|
|
-
|
|
|
- Object packageNumValue = readWorkBookCell(row.getCell(UploadConstant.PACKAGE_NUMBER_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.PACKAGE_NUMBER_PCB);
|
|
|
- aProduct.setMinPackageByExcel(packageNumValue, true);
|
|
|
-
|
|
|
- Object buyQtyValue = readWorkBookCell(row.getCell(UploadConstant.BUY_MIN_QTY_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.BUY_MIN_QTY_PCB);
|
|
|
- aProduct.setMinBuyQtyByExcel(buyQtyValue);
|
|
|
-
|
|
|
- Object tagValue = readWorkBookCell(row.getCell(UploadConstant.CUSTOM_LABEL_PCB), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, UploadConstant.CUSTOM_LABEL_PCB);
|
|
|
- aProduct.setTagByExcel(tagValue);
|
|
|
- // 自定义标签不为null,则检查是否重复
|
|
|
- if (aProduct.getCode() != null && aProduct.getBrandNameEn() != null && aProduct.getTag() != null) {
|
|
|
- resetTag(aProduct);
|
|
|
- }
|
|
|
-
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 重新设置tag标签
|
|
|
* @param aProduct
|
|
|
@@ -1323,12 +1099,10 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param aProduct 验证单行数据
|
|
|
* @param rowNum 行数
|
|
|
*/
|
|
|
- private List<GoodsQtyPrice> initQtyPriceByExcel(Row row, ReleaseProductByBatch aProduct, int rowNum, boolean isPCB) {
|
|
|
private List<GoodsQtyPrice> initQtyPriceByExcel(Row row, boolean isImport, ReleaseProductByBatch aProduct, int rowNum) {
|
|
|
List<GoodsQtyPrice> qtyPriceList = new ArrayList<>();
|
|
|
- Object firstValue = readWorkBookCell(row.getCell(isPCB ? UploadConstant.PRICE_START_PCB : UploadConstant.PRICE_START), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, isPCB ? UploadConstant.PRICE_START_PCB : UploadConstant.PRICE_START);
|
|
|
- Object firstValue = null;
|
|
|
+ Object firstValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_START), Cell.CELL_TYPE_NUMERIC,
|
|
|
+ rowNum, UploadConstant.PRICE_START);
|
|
|
if (isImport) {
|
|
|
firstValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_START), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, UploadConstant.PRICE_START);
|
|
|
@@ -1341,7 +1115,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
aProduct.setFragmentPrice(StringUtilB2C.getStr(firstValue), 0);
|
|
|
if (StringUtils.isEmpty(firstValue)) {
|
|
|
- aProduct.addErrmsg(isPCB ? ErrorInfoConstant.PRICE_INFO_PCB.getInfo() : ErrorInfoConstant.PRICE_INFO.getInfo());
|
|
|
+ aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
|
|
|
} else {
|
|
|
Double cellPrice = Double.valueOf(firstValue.toString());
|
|
|
if (validatePrice(cellPrice)) {
|
|
|
@@ -1349,19 +1123,17 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
cellPrice, aProduct.getRmbTaxRate(), aProduct.getCurrency());
|
|
|
qtyPriceList.add(qtyPrice);
|
|
|
} else {
|
|
|
- aProduct.addErrmsg(isPCB ? ErrorInfoConstant.PRICE_INFO_PCB.getInfo() : ErrorInfoConstant.PRICE_INFO.getInfo());
|
|
|
+ aProduct.addErrmsg(ErrorInfoConstant.PRICE_INFO.getInfo());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(qtyPriceList)) {
|
|
|
// 设置第二分段并设置第三分段梯度和价格
|
|
|
- setSecondPrice(row, rowNum, qtyPriceList, aProduct, isPCB);
|
|
|
setSecondPrice(row, isImport, rowNum, qtyPriceList, aProduct);
|
|
|
// 设置本批次最低和最高价格
|
|
|
setMinMaxPrice(aProduct, qtyPriceList);
|
|
|
}
|
|
|
for (int index = 0; index <= 1; index++) {
|
|
|
- setInputValueToProduct(row, aProduct, rowNum, index, isPCB);
|
|
|
setInputValueToProduct(row, isImport, aProduct, rowNum, index);
|
|
|
}
|
|
|
return qtyPriceList;
|
|
|
@@ -1409,11 +1181,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param qtyPriceList 分段价格list
|
|
|
* @param aProduct 验证单行数据
|
|
|
*/
|
|
|
- private void setSecondPrice(Row row, int rowNum, List<GoodsQtyPrice> qtyPriceList, ReleaseProductByBatch aProduct, boolean isPCB) {
|
|
|
- Object startValue = readWorkBookCell(row.getCell(isPCB ? UploadConstant.QTY_SECOND_START_PCB : UploadConstant.QTY_SECOND_START), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, isPCB ? UploadConstant.QTY_SECOND_START_PCB : UploadConstant.QTY_SECOND_START);
|
|
|
- Object priceValue = readWorkBookCell(row.getCell(isPCB ? UploadConstant.PRICE_SECOND_PCB : UploadConstant.PRICE_SECOND), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, isPCB ? UploadConstant.PRICE_SECOND_PCB : UploadConstant.PRICE_SECOND);
|
|
|
private void setSecondPrice(Row row, boolean isImport, int rowNum, List<GoodsQtyPrice> qtyPriceList, ReleaseProductByBatch aProduct) {
|
|
|
Object startValue = null;
|
|
|
Object priceValue = null;
|
|
|
@@ -1436,13 +1203,11 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
price, aProduct.getRmbTaxRate(), aProduct.getCurrency());
|
|
|
qtyPriceList.add(qtyPrice);
|
|
|
qtyPriceList.get(0).setEnd(Double.valueOf(startValue.toString()) - 1);
|
|
|
- setThirdPrice(row, rowNum, qtyPriceList, aProduct, isPCB);
|
|
|
setThirdPrice(row, isImport, rowNum, qtyPriceList, aProduct);
|
|
|
}
|
|
|
return ;
|
|
|
}
|
|
|
if (StringUtils.isEmpty(startValue) && StringUtils.isEmpty(priceValue)) {
|
|
|
- setThirdPrice(row, rowNum, qtyPriceList, aProduct, isPCB);
|
|
|
setThirdPrice(row, isImport, rowNum, qtyPriceList, aProduct);
|
|
|
}
|
|
|
}
|
|
|
@@ -1454,11 +1219,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param qtyPriceList 分段价格list
|
|
|
* @param aProduct 验证单行数据
|
|
|
*/
|
|
|
- private void setThirdPrice(Row row, int rowNum, List<GoodsQtyPrice> qtyPriceList, ReleaseProductByBatch aProduct, boolean isPCB) {
|
|
|
- Object startValue = readWorkBookCell(row.getCell(isPCB ? UploadConstant.QTY_THIRD_START_PCB : UploadConstant.QTY_THIRD_START), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, isPCB ? UploadConstant.QTY_THIRD_START_PCB : UploadConstant.QTY_THIRD_START);
|
|
|
- Object priceValue = readWorkBookCell(row.getCell(isPCB ? UploadConstant.PRICE_THIRD_PCB : UploadConstant.PRICE_THIRD), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, isPCB ? UploadConstant.PRICE_THIRD_PCB : UploadConstant.PRICE_THIRD);
|
|
|
private void setThirdPrice(Row row, boolean isImport, int rowNum, List<GoodsQtyPrice> qtyPriceList, ReleaseProductByBatch aProduct) {
|
|
|
Object startValue = null;
|
|
|
Object priceValue = null;
|
|
|
@@ -1493,8 +1253,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param rowNum
|
|
|
* @param index
|
|
|
*/
|
|
|
- private void setInputValueToProduct(Row row, ReleaseProductByBatch aProduct, int rowNum, int index, boolean isPCB) {
|
|
|
- int nextQty = (isPCB ? UploadConstant.PRICE_START_PCB : UploadConstant.PRICE_START) + 1 + (index * 2);
|
|
|
private void setInputValueToProduct(Row row, boolean isImport, ReleaseProductByBatch aProduct, int rowNum, int index) {
|
|
|
int nextQty = 0;
|
|
|
if (isImport) {
|