|
|
@@ -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 = goodsFillDataToExcel(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,67 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
return modelMap;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据批次号设置需要被修改的信息
|
|
|
+ * @param batchList
|
|
|
+ */
|
|
|
+ private Integer goodsFillDataToExcel(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);
|
|
|
+ }
|
|
|
+ for (Goods goods : goodses) {
|
|
|
+ for (ReleaseProductByBatch aBatch : batchList) {
|
|
|
+ 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);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 给自定义标签为空的batch设置默认自定义标签
|
|
|
* @param batchList
|
|
|
@@ -531,27 +589,7 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
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;
|
|
|
}
|
|
|
@@ -677,10 +715,10 @@ 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,
|
|
|
@@ -694,37 +732,6 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 验证批次号是否正确,并为该公司下的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);
|
|
|
@@ -746,19 +753,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;
|
|
|
+// }
|
|
|
+// }
|
|
|
}
|
|
|
}
|
|
|
}
|