|
|
@@ -7,12 +7,14 @@ import com.uas.platform.b2c.common.base.dao.CommonDao;
|
|
|
import com.uas.platform.b2c.core.config.SysConf;
|
|
|
import com.uas.platform.b2c.core.constant.IntegerConstant;
|
|
|
import com.uas.platform.b2c.core.constant.ReleaseStatus;
|
|
|
+import com.uas.platform.b2c.core.constant.Status;
|
|
|
import com.uas.platform.b2c.core.support.SystemSession;
|
|
|
import com.uas.platform.b2c.core.utils.NumberUtil;
|
|
|
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;
|
|
|
@@ -34,6 +36,7 @@ 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;
|
|
|
import com.uas.platform.b2c.trade.order.StringConstant.Currency;
|
|
|
+import com.uas.platform.b2c.trade.support.ResultMap;
|
|
|
import com.uas.platform.core.exception.IllegalOperatorException;
|
|
|
import com.uas.platform.core.model.PageInfo;
|
|
|
import com.uas.platform.core.persistence.criteria.CriterionExpression;
|
|
|
@@ -71,10 +74,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;
|
|
|
@@ -195,7 +201,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
// TODO 个人库验证
|
|
|
if (!isAPerson) {
|
|
|
// 解析返回分段价格list
|
|
|
- List<GoodsQtyPrice> qtyPriceList = initQtyPriceByExcel(row, releaseProductByBatch, r);
|
|
|
+ List<GoodsQtyPrice> qtyPriceList = initQtyPriceByExcel(row, true, releaseProductByBatch, r);
|
|
|
if (!CollectionUtils.isEmpty(qtyPriceList)) {
|
|
|
releaseProductByBatch.setPrices(qtyPriceList);
|
|
|
}
|
|
|
@@ -256,6 +262,336 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return modelMap;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public ModelMap modifyByWorkbook(Workbook workbook) {
|
|
|
+ ModelMap modelMap = new ModelMap();
|
|
|
+ StoreIn self = getStoreIn(true);
|
|
|
+ StoreIn consignment = getStoreIn(false);
|
|
|
+ // 获取第一个工作表
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ int colNum = sheet.getRow(0).getPhysicalNumberOfCells();
|
|
|
+ if (colNum != ModifyConstant.TOTAL_COLUMN && colNum != ModifyConstant.MAX_TOTAL_COLUMN) {
|
|
|
+ throw new IllegalOperatorException("表格模板不正确!请重新下载最新模板");
|
|
|
+ }
|
|
|
+ int rowNum = sheet.getLastRowNum();
|
|
|
+ if (rowNum > ModifyConstant.EXCEL_MAX_ROW) {
|
|
|
+ throw new IllegalOperatorException("您上传的信息超过2000条,请拆分成2000以再在上传");
|
|
|
+ }
|
|
|
+ List<ReleaseProductByBatch> batchList = new ArrayList<>(rowNum);
|
|
|
+ String batch = createNumberService.getTimeNumber("product$goods", 8, rowNum);
|
|
|
+ Row headerRow = sheet.getRow(1);
|
|
|
+ validateModifyExcel(headerRow);
|
|
|
+ int total = 0;
|
|
|
+ for (int r = 2; r <= rowNum; r++) {
|
|
|
+ Row row = sheet.getRow(r);
|
|
|
+ ReleaseProductByBatch aBatch = new ReleaseProductByBatch();
|
|
|
+ Object skuObj = readWorkBookCell(row.getCell(ModifyConstant.SKU_CODE), Cell.CELL_TYPE_STRING,
|
|
|
+ r, ModifyConstant.SKU_CODE);
|
|
|
+ aBatch.setBatchCodeByExcel(skuObj);
|
|
|
+ if (!validateBatchCode(aBatch.getBatchCode(), aBatch)) {
|
|
|
+ aBatch.addErrmsg(ErrorInfoConstant.BATCH_ERROR.getInfo());
|
|
|
+ }
|
|
|
+
|
|
|
+ Object sellObj = readWorkBookCell(row.getCell(ModifyConstant.SALE_METHOD), Cell.CELL_TYPE_STRING,
|
|
|
+ r, ModifyConstant.SALE_METHOD);
|
|
|
+ aBatch.setSaleMethod(StringUtilB2C.getStr(sellObj).trim());
|
|
|
+ StoreIn storeIn = getModifyStoreInfo(sellObj, self, consignment);
|
|
|
+ if (storeIn == null) {
|
|
|
+ aBatch.addErrmsg(ErrorInfoConstant.STORE_ERROR.getInfo());
|
|
|
+ aBatch.setErrmsg(aBatch.getErrmsg().substring(1));
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ setProductDefaultInfo(aBatch, batch, aBatch.getCurrency(), storeIn);
|
|
|
+ convertModifyToBatch(aBatch, row, r);
|
|
|
+ // 解析返回分段价格list
|
|
|
+ List<GoodsQtyPrice> qtyPriceList = initQtyPriceByExcel(row, false, aBatch, r);
|
|
|
+ if (!CollectionUtils.isEmpty(qtyPriceList)) {
|
|
|
+ aBatch.setPrices(qtyPriceList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getErrmsg())) {
|
|
|
+ aBatch.setErrmsg(aBatch.getErrmsg().substring(1));
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
+ } else {
|
|
|
+ // 导入成功的需要判断自定义标签是否重复
|
|
|
+ if (CollectionUtils.isNotEmpty(batchList) && aBatch.getTag() != null) {
|
|
|
+ if (validateTagInfo(aBatch, batchList)) {
|
|
|
+ aBatch.setTag(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ validateRepeatInExcel(batchList, aBatch, true);
|
|
|
+ }
|
|
|
+ batchList.add(aBatch);
|
|
|
+ total++;
|
|
|
+ }
|
|
|
+ Long userUU = SystemSession.getUser().getUserUU();
|
|
|
+ Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ resetRepeatData(batchList, true, false);
|
|
|
+ setDefaultTag(batchList);
|
|
|
+ int success = modifyGoodsByBatch(batchList);
|
|
|
+ commonDao.save(batchList, ReleaseProductByBatch.class);
|
|
|
+ Integer filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
|
|
|
+ modelMap.put("total", total);
|
|
|
+ modelMap.put("success", success);
|
|
|
+ modelMap.put("fail", batchList.size() - success);
|
|
|
+ modelMap.put("filter", filter);
|
|
|
+ modelMap.put("batch", batch);
|
|
|
+ return modelMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 给自定义标签为空的batch设置默认自定义标签
|
|
|
+ * @param batchList
|
|
|
+ */
|
|
|
+ private void setDefaultTag(List<ReleaseProductByBatch> batchList) {
|
|
|
+ List<Integer> statusList = Arrays.asList(ReleaseStatus.success.value(), ReleaseStatus.failure.value());
|
|
|
+ Map<Long, String> tagMap = new HashMap<>(batchList.size());
|
|
|
+ for (ReleaseProductByBatch aBatch : batchList) {
|
|
|
+ if (aBatch.getErrmsg() != null || !statusList.contains(aBatch.getReleaseCode())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (aBatch.getTag() == null) {
|
|
|
+ Goods goods = goodsDao.findByBatchCode(aBatch.getBatchCode());
|
|
|
+ if (!tagMap.containsKey(goods.getProductid())) {
|
|
|
+ List<String> tagStr = goodsDao.getTagByProductId(goods.getProductid());
|
|
|
+ if (CollectionUtils.isEmpty(tagStr)) {
|
|
|
+ tagMap.put(goods.getProductid(), "类型1");
|
|
|
+ } else {
|
|
|
+ Collections.sort(tagStr, new Comparator<String>() {
|
|
|
+ @Override
|
|
|
+ public int compare(String o1, String o2) {
|
|
|
+ // 按类型降序排序
|
|
|
+ int a = Integer.parseInt(o1.substring(2));
|
|
|
+ int b = Integer.parseInt(o2.substring(2));
|
|
|
+ return b > a ? 1 : b == a ? 0 : -1;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ String str = "类型" + (Integer.parseInt(tagStr.get(0).substring(2)) + 1);
|
|
|
+ tagMap.put(goods.getProductid(), str);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ String str = "类型" + (Integer.parseInt(tagMap.get(goods.getProductid()).substring(2)) + 1);
|
|
|
+ tagMap.put(goods.getProductid(), str);
|
|
|
+ }
|
|
|
+ aBatch.setTag(tagMap.get(goods.getProductid()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 通过导入excel内容修改goods信息
|
|
|
+ * @param batchList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private int modifyGoodsByBatch(List<ReleaseProductByBatch> batchList) {
|
|
|
+ int result = 0;
|
|
|
+ List<Integer> statusList = Arrays.asList(ReleaseStatus.success.value(), ReleaseStatus.failure.value());
|
|
|
+ for (ReleaseProductByBatch aBatch : batchList) {
|
|
|
+ if (aBatch.getErrmsg() != null || !statusList.contains(aBatch.getReleaseCode())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Goods goods = goodsDao.findByBatchCode(aBatch.getBatchCode());
|
|
|
+ fillInGoods(goods, aBatch);
|
|
|
+ ResultMap resultMap = goodsService.updateGoods(goods);
|
|
|
+ if (resultMap.isSuccess()) {
|
|
|
+ Goods goods1 = (Goods) resultMap.getData();
|
|
|
+ if (Status.REMOVED.value() == aBatch.getStatus() && Status.REMOVED.value() != goods1.getStatus()) {
|
|
|
+ ResultMap offMap = goodsService.offShelfGoodsByProvider(goods.getBatchCode(), null, false);
|
|
|
+ if (offMap.isSuccess()) {
|
|
|
+ result++;
|
|
|
+ } else {
|
|
|
+ aBatch.setErrmsg(offMap.getMessage());
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ result++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ aBatch.setErrmsg(resultMap.getMessage());
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void fillInGoods(Goods goods, ReleaseProductByBatch aBatch) {
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getProductDate())) {
|
|
|
+ goods.setProduceDate(aBatch.getProductDate());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getPackaging())) {
|
|
|
+ goods.setPackaging(aBatch.getPackaging());
|
|
|
+ }
|
|
|
+ if (null != aBatch.getSelfMinDelivery()) {
|
|
|
+ goods.setMinDelivery(aBatch.getSelfMinDelivery());
|
|
|
+ }
|
|
|
+ if (null != aBatch.getSelfMaxDelivery()) {
|
|
|
+ goods.setMaxDelivery(aBatch.getSelfMaxDelivery());
|
|
|
+ }
|
|
|
+ if (null != aBatch.getBreakUp()) {
|
|
|
+ goods.setBreakUp(aBatch.getBreakUp());
|
|
|
+ }
|
|
|
+ if (null != aBatch.getMinPackage()) {
|
|
|
+ goods.setMinPackQty(aBatch.getMinPackage());
|
|
|
+ } else {
|
|
|
+ goods.setMinPackQty(1d);
|
|
|
+ }
|
|
|
+ if (null != aBatch.getMinBuyQty()) {
|
|
|
+ goods.setMinBuyQty(aBatch.getMinBuyQty());
|
|
|
+ }
|
|
|
+ if (null != aBatch.getPrices()) {
|
|
|
+ goods.setPrices(aBatch.getPrices());
|
|
|
+ }
|
|
|
+ if (null != aBatch.getReserve()) {
|
|
|
+ goods.setReserve(aBatch.getReserve());
|
|
|
+ }
|
|
|
+ goods.setTag(aBatch.getTag());
|
|
|
+ if (SysConf.getStoreid().equals(aBatch.getStoreid())) {
|
|
|
+ goods.setSelfSale("2");
|
|
|
+ } else {
|
|
|
+ goods.setSelfSale("1");
|
|
|
+ }
|
|
|
+ goods.setStatus(aBatch.getStatus());
|
|
|
+ }
|
|
|
+
|
|
|
+ private StoreIn getModifyStoreInfo(Object value, StoreIn self, StoreIn consignment) {
|
|
|
+ List<String> sellList = Arrays.asList("自营", "寄售");
|
|
|
+ if (StringUtils.isEmpty(value) || !sellList.contains(StringUtilB2C.getStr(value))) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ boolean selfValue = "自营".equals(StringUtilB2C.getStr(value));
|
|
|
+ return selfValue ? self : consignment;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void convertModifyToBatch(ReleaseProductByBatch aProduct, Row row, int rowNum) {
|
|
|
+ Object kindValue = readWorkBookCell(row.getCell(ModifyConstant.PRODUCT_KIND), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PRODUCT_KIND);
|
|
|
+ aProduct.setKindName(StringUtilB2C.getStr(kindValue));
|
|
|
+
|
|
|
+ Object brandValue = readWorkBookCell(row.getCell(ModifyConstant.PRODUCT_BRAND), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PRODUCT_BRAND);
|
|
|
+ aProduct.setBrandNameEn(StringUtilB2C.getStr(brandValue));
|
|
|
+
|
|
|
+ Object codeValue = readWorkBookCell(row.getCell(ModifyConstant.PRODUCT_CODE), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PRODUCT_CODE);
|
|
|
+ aProduct.setCode(StringUtilB2C.getStr(codeValue));
|
|
|
+
|
|
|
+ Cell productCell = row.getCell(ModifyConstant.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);
|
|
|
+ } else {
|
|
|
+ aProduct.setProductDateByExcel(readWorkBookCell(row.getCell(ModifyConstant.PRODUCE_DATE), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PRODUCE_DATE));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ Object produceValue = readWorkBookCell(row.getCell(ModifyConstant.PRODUCE_DATE), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PRODUCE_DATE);
|
|
|
+ aProduct.setProductDateByExcel(produceValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ Object packageMethodValue = readWorkBookCell(row.getCell(ModifyConstant.PACKAGE_METHOD), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PACKAGE_METHOD);
|
|
|
+ if (!StringUtils.isEmpty(packageMethodValue)) {
|
|
|
+ aProduct.setPackagingByExcel(packageMethodValue, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ Object minValue = readWorkBookCell(row.getCell(ModifyConstant.MIN_DELIVERY), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.MIN_DELIVERY);
|
|
|
+ Object maxValue = readWorkBookCell(row.getCell(ModifyConstant.MAX_DELIVERY), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.MAX_DELIVERY);
|
|
|
+ aProduct.setDeliveryByExcel(minValue, maxValue);
|
|
|
+ if (!StringUtils.isEmpty(minValue) || !StringUtils.isEmpty(maxValue)) {
|
|
|
+ setDeliveryTime(aProduct, minValue, maxValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ Object breakValue = readWorkBookCell(row.getCell(ModifyConstant.BREAK_UP), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.BREAK_UP);
|
|
|
+ if (!StringUtils.isEmpty(breakValue)) {
|
|
|
+ aProduct.setBreakUpByExcel(breakValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ Object packageNumValue = readWorkBookCell(row.getCell(ModifyConstant.PACKAGE_NUMBER), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PACKAGE_NUMBER);
|
|
|
+ if (!StringUtils.isEmpty(packageNumValue)) {
|
|
|
+ aProduct.setMinPackageByExcel(packageNumValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ Object buyQtyValue = readWorkBookCell(row.getCell(ModifyConstant.BUY_MIN_QTY), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.BUY_MIN_QTY);
|
|
|
+ if (!StringUtils.isEmpty(buyQtyValue)) {
|
|
|
+ aProduct.setMinBuyQtyByExcel(buyQtyValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ Object reserveValue = readWorkBookCell(row.getCell(ModifyConstant.RESERVE_NUMBER), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.RESERVE_NUMBER);
|
|
|
+ if (!StringUtils.isEmpty(reserveValue)) {
|
|
|
+ aProduct.setReserveByExcel(reserveValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ Object statusValue = readWorkBookCell(row.getCell(ModifyConstant.SALE_STATUS), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.SALE_STATUS);
|
|
|
+ if (!StringUtils.isEmpty(statusValue)) {
|
|
|
+ aProduct.setStatusByExcel(statusValue);
|
|
|
+ }
|
|
|
+
|
|
|
+ Object tagValue = readWorkBookCell(row.getCell(ModifyConstant.CUSTOM_LABEL), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.CUSTOM_LABEL);
|
|
|
+ if (!StringUtils.isEmpty(tagValue)) {
|
|
|
+ aProduct.setTagByExcel(tagValue.toString().trim());
|
|
|
+ }
|
|
|
+ // 自定义标签不为null,则检查是否重复
|
|
|
+ if (aProduct.getCode() != null && aProduct.getBrandNameEn() != null && aProduct.getTag() != null) {
|
|
|
+ resetTag(aProduct);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 验证批次号是否正确,并为该公司下的goods
|
|
|
+ * @param batchCode
|
|
|
+ * @param aBatch
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean validateBatchCode(String batchCode, ReleaseProductByBatch aBatch) {
|
|
|
+ if (StringUtils.isEmpty(batchCode)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ Goods goods = goodsDao.findByBatchCode(batchCode);
|
|
|
+ if (goods == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ aBatch.setB2cBranden(goods.getBrandNameEn());
|
|
|
+ aBatch.setBrandNameEn(goods.getBrandNameEn());
|
|
|
+ aBatch.setKindName(goods.getKindNameCn());
|
|
|
+ aBatch.setB2cCode(goods.getCode());
|
|
|
+ aBatch.setCode(goods.getCode());
|
|
|
+ aBatch.setCurrency(goods.getCurrencyName());
|
|
|
+ if (goods.getUuid() == null) {
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.failure.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.failure.getPhrase());
|
|
|
+ }
|
|
|
+ Long enuu = SystemSession.getUser().getEnterprise() != null ? SystemSession.getUser().getEnterprise().getUu() : null;
|
|
|
+ if (goods.getEnUU() != null) {
|
|
|
+ return goods.getEnUU().equals(enuu);
|
|
|
+ }
|
|
|
+ return goods.getEnUU() == null && enuu == null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void validateModifyExcel(Row headerRow) {
|
|
|
+ Object skuCellObj = readWorkBookCell(headerRow.getCell(ModifyConstant.SKU_CODE), Cell.CELL_TYPE_STRING,
|
|
|
+ 1, ModifyConstant.SKU_CODE);
|
|
|
+ String skuStr = StringUtilB2C.getStr(skuCellObj);
|
|
|
+ if (StringUtilB2C.isEmpty(skuCellObj) || !"SKU编码(不可修改)".equals(skuStr)) {
|
|
|
+ throw new IllegalOperatorException("表格模板不正确!请重新下载最新模板");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 验证Excel中数据是否重复
|
|
|
*
|
|
|
@@ -309,7 +645,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
}
|
|
|
List<Product> productList = productDao.findByEnUUAndPcmpcodeAndPbrandenAndB2cEnabled(enuu, each.getB2cCode(), each.getB2cBranden(), IntegerConstant.YES_SHORT);
|
|
|
if (!CollectionUtils.isEmpty(productList)) {
|
|
|
- List<Goods> goodsList = goodsDao.findRepeatGoodsInProductId(productList.get(0).getId(), each.getProductDate(), each.getPackaging(), each.getMinPackage(), each.getMinBuyQty(), each.getSelfMaxDelivery(), each.getSelfMinDelivery(), each.getUnit());
|
|
|
+ List<Goods> goodsList = null;
|
|
|
+ if (each.getBatchCode() != null) {
|
|
|
+ goodsList = goodsDao.findRepeatGoodsInProductIdNotBatch(productList.get(0).getId(), each.getBatchCode(), each.getProductDate(), each.getPackaging(), each.getMinPackage(), each.getMinBuyQty(), each.getSelfMaxDelivery(), each.getSelfMinDelivery(), each.getUnit());
|
|
|
+ } else {
|
|
|
+ goodsList = goodsDao.findRepeatGoodsInProductId(productList.get(0).getId(), each.getProductDate(), each.getPackaging(), each.getMinPackage(), each.getMinBuyQty(), each.getSelfMaxDelivery(), each.getSelfMinDelivery(), each.getUnit());
|
|
|
+ }
|
|
|
if (!CollectionUtils.isEmpty(goodsList)) {
|
|
|
if (!isImport) {
|
|
|
each.setErrmsg(ErrorInfoConstant.REPEAT_INFO.getInfo());
|
|
|
@@ -513,6 +854,24 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return storeIn;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取店铺的信息
|
|
|
+ * @param selfSale
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private StoreIn getStoreIn(Boolean selfSale) {
|
|
|
+ StoreIn storeIn = null;
|
|
|
+ if (selfSale) {
|
|
|
+ storeIn = storeInService.findByEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ if((storeIn == null) || (storeIn.getStatus() != StoreStatus.OPENED)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ storeIn = storeInService.findByUuid(SysConf.getStoreid());
|
|
|
+ }
|
|
|
+ return storeIn;
|
|
|
+ }
|
|
|
+
|
|
|
private Boolean isNumber(String str) {
|
|
|
Pattern numberPattern = Pattern.compile(RegexConstant.NumberData);
|
|
|
Matcher matcher = numberPattern.matcher(str);
|
|
|
@@ -635,7 +994,8 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
String productStr = sdf.format(productCell.getDateCellValue());
|
|
|
aProduct.setProductDateByExcel(productStr);
|
|
|
} else {
|
|
|
- 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,
|
|
|
@@ -688,11 +1048,22 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
int count = 0;
|
|
|
List<Product> productList = productDao.findMatchStandard(enuu, aProduct.getBrandNameEn(), aProduct.getCode(), IntegerConstant.YES_SHORT);
|
|
|
if (!CollectionUtils.isEmpty(productList)) {
|
|
|
- count = goodsDao.findCountByTagInGoods(enuu, productList.get(0).getPbranden(),
|
|
|
- productList.get(0).getPcmpcode(), aProduct.getTag());
|
|
|
+ if (aProduct.getBatchCode() != null) {
|
|
|
+ count = goodsDao.findCountByTagNotBatch(enuu, aProduct.getBatchCode(), productList.get(0).getPbranden(),
|
|
|
+ productList.get(0).getPcmpcode(), aProduct.getTag());
|
|
|
+ } else {
|
|
|
+ count = goodsDao.findCountByTagInGoods(enuu, productList.get(0).getPbranden(),
|
|
|
+ productList.get(0).getPcmpcode(), aProduct.getTag());
|
|
|
+ }
|
|
|
+
|
|
|
} else {
|
|
|
- count = goodsDao.findCountByTagInGoods(SystemSession.getUser().getEnterprise().getUu(), aProduct.getBrandNameEn(),
|
|
|
- aProduct.getCode(), aProduct.getTag());
|
|
|
+ if (aProduct.getBatchCode() != null) {
|
|
|
+ count = goodsDao.findCountByTagNotBatch(enuu, aProduct.getBatchCode(), aProduct.getBrandNameEn(),
|
|
|
+ aProduct.getCode(), aProduct.getTag());
|
|
|
+ } else {
|
|
|
+ count = goodsDao.findCountByTagInGoods(enuu, aProduct.getBrandNameEn(),
|
|
|
+ aProduct.getCode(), aProduct.getTag());
|
|
|
+ }
|
|
|
}
|
|
|
// 如果在该型号品牌已有重复,则忽略该自定义标签
|
|
|
if (count != 0) {
|
|
|
@@ -706,10 +1077,16 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param aProduct 验证单行数据
|
|
|
* @param rowNum 行数
|
|
|
*/
|
|
|
- private List<GoodsQtyPrice> initQtyPriceByExcel(Row row, ReleaseProductByBatch aProduct, int rowNum) {
|
|
|
+ private List<GoodsQtyPrice> initQtyPriceByExcel(Row row, boolean isImport, ReleaseProductByBatch aProduct, int rowNum) {
|
|
|
List<GoodsQtyPrice> qtyPriceList = new ArrayList<>();
|
|
|
- Object firstValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_START), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, UploadConstant.PRICE_START);
|
|
|
+ Object firstValue = null;
|
|
|
+ if (isImport) {
|
|
|
+ firstValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_START), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, UploadConstant.PRICE_START);
|
|
|
+ } else {
|
|
|
+ firstValue = readWorkBookCell(row.getCell(ModifyConstant.PRICE_FIRST), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PRICE_FIRST);
|
|
|
+ }
|
|
|
if (aProduct.getMinBuyQty() != null) {
|
|
|
aProduct.setFragmentQty(aProduct.getMinBuyQty().toString(), 0);
|
|
|
}
|
|
|
@@ -729,12 +1106,12 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(qtyPriceList)) {
|
|
|
// 设置第二分段并设置第三分段梯度和价格
|
|
|
- setSecondPrice(row, rowNum, qtyPriceList, aProduct);
|
|
|
+ setSecondPrice(row, isImport, rowNum, qtyPriceList, aProduct);
|
|
|
// 设置本批次最低和最高价格
|
|
|
setMinMaxPrice(aProduct, qtyPriceList);
|
|
|
}
|
|
|
for (int index = 0; index <= 1; index++) {
|
|
|
- setInputValueToProduct(row, aProduct, rowNum, index);
|
|
|
+ setInputValueToProduct(row, isImport, aProduct, rowNum, index);
|
|
|
}
|
|
|
return qtyPriceList;
|
|
|
}
|
|
|
@@ -781,11 +1158,20 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param qtyPriceList 分段价格list
|
|
|
* @param aProduct 验证单行数据
|
|
|
*/
|
|
|
- private void setSecondPrice(Row row, int rowNum, List<GoodsQtyPrice> qtyPriceList, ReleaseProductByBatch aProduct) {
|
|
|
- Object startValue = readWorkBookCell(row.getCell(UploadConstant.QTY_SECOND_START), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, UploadConstant.QTY_SECOND_START);
|
|
|
- Object priceValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_SECOND), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, UploadConstant.PRICE_SECOND);
|
|
|
+ private void setSecondPrice(Row row, boolean isImport, int rowNum, List<GoodsQtyPrice> qtyPriceList, ReleaseProductByBatch aProduct) {
|
|
|
+ Object startValue = null;
|
|
|
+ Object priceValue = null;
|
|
|
+ if (isImport) {
|
|
|
+ startValue = readWorkBookCell(row.getCell(UploadConstant.QTY_SECOND_START), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, UploadConstant.QTY_SECOND_START);
|
|
|
+ priceValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_SECOND), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, UploadConstant.PRICE_SECOND);
|
|
|
+ } else {
|
|
|
+ startValue = readWorkBookCell(row.getCell(ModifyConstant.QTY_SECOND_START), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.QTY_SECOND_START);
|
|
|
+ priceValue = readWorkBookCell(row.getCell(ModifyConstant.PRICE_SECOND), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PRICE_SECOND);
|
|
|
+ }
|
|
|
if (!StringUtils.isEmpty(startValue) && !StringUtils.isEmpty(priceValue)) {
|
|
|
Double price = Double.valueOf(priceValue.toString());
|
|
|
Double start = Double.valueOf(startValue.toString());
|
|
|
@@ -794,12 +1180,12 @@ 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);
|
|
|
+ setThirdPrice(row, isImport, rowNum, qtyPriceList, aProduct);
|
|
|
}
|
|
|
return ;
|
|
|
}
|
|
|
if (StringUtils.isEmpty(startValue) && StringUtils.isEmpty(priceValue)) {
|
|
|
- setThirdPrice(row, rowNum, qtyPriceList, aProduct);
|
|
|
+ setThirdPrice(row, isImport, rowNum, qtyPriceList, aProduct);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -810,11 +1196,20 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param qtyPriceList 分段价格list
|
|
|
* @param aProduct 验证单行数据
|
|
|
*/
|
|
|
- private void setThirdPrice(Row row, int rowNum, List<GoodsQtyPrice> qtyPriceList, ReleaseProductByBatch aProduct) {
|
|
|
- Object startValue = readWorkBookCell(row.getCell(UploadConstant.QTY_THIRD_START), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, UploadConstant.QTY_THIRD_START);
|
|
|
- Object priceValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_THIRD), Cell.CELL_TYPE_NUMERIC,
|
|
|
- rowNum, UploadConstant.PRICE_THIRD);
|
|
|
+ private void setThirdPrice(Row row, boolean isImport, int rowNum, List<GoodsQtyPrice> qtyPriceList, ReleaseProductByBatch aProduct) {
|
|
|
+ Object startValue = null;
|
|
|
+ Object priceValue = null;
|
|
|
+ if (isImport) {
|
|
|
+ startValue = readWorkBookCell(row.getCell(UploadConstant.QTY_THIRD_START), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, UploadConstant.QTY_THIRD_START);
|
|
|
+ priceValue = readWorkBookCell(row.getCell(UploadConstant.PRICE_THIRD), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, UploadConstant.PRICE_THIRD);
|
|
|
+ } else {
|
|
|
+ startValue = readWorkBookCell(row.getCell(ModifyConstant.QTY_THIRD_START), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.QTY_THIRD_START);
|
|
|
+ priceValue = readWorkBookCell(row.getCell(ModifyConstant.PRICE_THIRD), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.PRICE_THIRD);
|
|
|
+ }
|
|
|
if (!StringUtils.isEmpty(startValue) && !StringUtils.isEmpty(priceValue)) {
|
|
|
Double price = Double.valueOf(priceValue.toString());
|
|
|
Double start = Double.valueOf(startValue.toString());
|
|
|
@@ -835,8 +1230,13 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
* @param rowNum
|
|
|
* @param index
|
|
|
*/
|
|
|
- private void setInputValueToProduct(Row row, ReleaseProductByBatch aProduct, int rowNum, int index) {
|
|
|
- int nextQty = UploadConstant.PRICE_START + 1 + (index * 2);
|
|
|
+ private void setInputValueToProduct(Row row, boolean isImport, ReleaseProductByBatch aProduct, int rowNum, int index) {
|
|
|
+ int nextQty = 0;
|
|
|
+ if (isImport) {
|
|
|
+ nextQty = UploadConstant.PRICE_START + 1 + (index * 2);
|
|
|
+ } else {
|
|
|
+ nextQty = ModifyConstant.PRICE_FIRST + 1 + (index * 2);
|
|
|
+ }
|
|
|
Object startValue = readWorkBookCell(row.getCell(nextQty), Cell.CELL_TYPE_STRING,
|
|
|
rowNum, nextQty);
|
|
|
Object priceValue = readWorkBookCell(row.getCell(nextQty + 1), Cell.CELL_TYPE_STRING,
|