|
|
@@ -425,9 +425,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
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);
|
|
|
@@ -454,21 +451,21 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
} else {
|
|
|
// 导入成功的需要判断自定义标签是否重复
|
|
|
- if (CollectionUtils.isNotEmpty(batchList) && aBatch.getTag() != null) {
|
|
|
- if (validateTagInfo(aBatch, batchList)) {
|
|
|
- aBatch.setTag(null);
|
|
|
- }
|
|
|
- }
|
|
|
+// if (CollectionUtils.isNotEmpty(batchList) && aBatch.getTag() != null) {
|
|
|
+// if (validateTagInfo(aBatch, batchList)) {
|
|
|
+// aBatch.setTag(null);
|
|
|
+// }
|
|
|
+// }
|
|
|
validateRepeatInExcel(batchList, aBatch, true);
|
|
|
}
|
|
|
batchList.add(aBatch);
|
|
|
total++;
|
|
|
}
|
|
|
+ int success = goodsFillDataToExcelAndUpdate(batchList);
|
|
|
Long userUU = SystemSession.getUser().getUserUU();
|
|
|
- Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- resetRepeatData(batchList, true, false);
|
|
|
- setDefaultTag(batchList);
|
|
|
- int success = modifyGoodsByBatch(batchList);
|
|
|
+// Long enUU = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+// resetRepeatData(batchList, true, false);
|
|
|
+// setDefaultTag(batchList);
|
|
|
commonDao.save(batchList, ReleaseProductByBatch.class);
|
|
|
Integer filter = releaseProductByBatchDao.getCountOfImportFail(userUU, batch, failCode);
|
|
|
modelMap.put("total", total);
|
|
|
@@ -479,6 +476,73 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return modelMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据批次号设置需要被修改的信息
|
|
|
+ * @param batchList
|
|
|
+ */
|
|
|
+ private Integer goodsFillDataToExcelAndUpdate(List<ReleaseProductByBatch> batchList) {
|
|
|
+ int result = 0;
|
|
|
+ if (CollectionUtils.isEmpty(batchList)) {
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ List<String> batchCodes = new ArrayList<>();
|
|
|
+ for (ReleaseProductByBatch aBatch : batchList) {
|
|
|
+ if (!StringUtilB2C.isEmpty(aBatch.getBatchCode())) {
|
|
|
+ batchCodes.add(aBatch.getBatchCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Goods> goodses = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(batchCodes)) {
|
|
|
+ goodses = goodsService.findGoodsByBatchCodes(batchCodes);
|
|
|
+ }
|
|
|
+ Goods newGoods = null;
|
|
|
+ for (ReleaseProductByBatch aBatch : batchList) {
|
|
|
+ newGoods = null;
|
|
|
+ for (Goods goods : goodses) {
|
|
|
+ if (goods.getBatchCode().equals(aBatch.getBatchCode())) {
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ fillInGoods(goods, aBatch);
|
|
|
+ newGoods = goods;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (newGoods == null) {
|
|
|
+ newGoods = aBatch.releaseProductByBatchConvertToGoods(aBatch);
|
|
|
+ }
|
|
|
+ ResultMap resultMap = goodsService.updateGoods(newGoods);
|
|
|
+ if (resultMap.isSuccess()) {
|
|
|
+ Goods goods1 = (Goods) resultMap.getData();
|
|
|
+ if (Status.REMOVED.value() == aBatch.getStatus() && Status.REMOVED.value() != goods1.getStatus()) {
|
|
|
+ ResultMap offMap = goodsService.offShelfGoodsByProvider(newGoods.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;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 给自定义标签为空的batch设置默认自定义标签
|
|
|
* @param batchList
|
|
|
@@ -622,21 +686,21 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
rowNum, ModifyConstant.PRODUCT_SPEC);
|
|
|
aProduct.setSpec(StringUtilB2C.getStr(specValue));
|
|
|
|
|
|
- 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);
|
|
|
- }
|
|
|
+// 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);
|
|
|
@@ -677,52 +741,21 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
aProduct.setReserveByExcel(reserveValue);
|
|
|
}
|
|
|
|
|
|
- Object statusValue = readWorkBookCell(row.getCell(ModifyConstant.SALE_STATUS), Cell.CELL_TYPE_STRING,
|
|
|
- rowNum, ModifyConstant.SALE_STATUS);
|
|
|
+ Object statusValue = readWorkBookCell(row.getCell(ModifyConstant.COST_PRICE), Cell.CELL_TYPE_STRING,
|
|
|
+ rowNum, ModifyConstant.COST_PRICE);
|
|
|
if (!StringUtils.isEmpty(statusValue)) {
|
|
|
- aProduct.setStatusByExcel(statusValue);
|
|
|
+ aProduct.setCostPriceByExcel(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;
|
|
|
+// 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);
|
|
|
+// }
|
|
|
}
|
|
|
|
|
|
private void validateModifyExcel(Row headerRow) {
|
|
|
@@ -746,19 +779,22 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return ;
|
|
|
for (ReleaseProductByBatch each : batchList) {
|
|
|
if (StringUtils.isEmpty(each.getErrmsg()) && each.equals(aBatch)) {
|
|
|
- if (!isImport) {
|
|
|
- aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
- aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
- aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
- break;
|
|
|
- } else {
|
|
|
- if (GoodsUtil.compareWithQtyPrice(each.getPrices(), aBatch.getPrices(), each.getCurrency())) {
|
|
|
- aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
- aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
- aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
+// if (!isImport) {
|
|
|
+// aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
+// aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
+// aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
+// break;
|
|
|
+// } else {
|
|
|
+// if (GoodsUtil.compareWithQtyPrice(each.getPrices(), aBatch.getPrices(), each.getCurrency())) {
|
|
|
+// aBatch.setErrmsg(ErrorInfoConstant.REPEAT_IN_EXCEL.getInfo());
|
|
|
+// aBatch.setReleaseCode(ReleaseStatus.had_exists.value());
|
|
|
+// aBatch.setReleaseStatus(ReleaseStatus.had_exists.getPhrase());
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -934,7 +970,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
aProduct.setUsdTaxRate(0d);
|
|
|
} else {
|
|
|
aProduct.setCurrency("RMB");
|
|
|
- aProduct.setRmbTaxRate(0.17d);
|
|
|
+ aProduct.setRmbTaxRate(0.16d);
|
|
|
}
|
|
|
}
|
|
|
|