|
|
@@ -532,13 +532,22 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
if (CollectionUtils.isEmpty(batchList)) {
|
|
|
return result;
|
|
|
}
|
|
|
+ List<Long> productIds = new ArrayList<>(batchList.size());
|
|
|
List<String> batchCodes = new ArrayList<>();
|
|
|
for (ReleaseProductByBatch aBatch : batchList) {
|
|
|
+ if (!StringUtilB2C.isEmpty(aBatch.getBatchCode()) && RegexConstant.isNumber(aBatch.getBatchCode())) {
|
|
|
+ productIds.add(Long.parseLong(aBatch.getBatchCode()));
|
|
|
+ continue;
|
|
|
+ }
|
|
|
if (!StringUtilB2C.isEmpty(aBatch.getBatchCode())) {
|
|
|
batchCodes.add(aBatch.getBatchCode());
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+ List<Product> products = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(productIds)) {
|
|
|
+ products = productDao.findProductInIds(productIds);
|
|
|
+ }
|
|
|
+ Product newProduct = null;
|
|
|
List<Goods> goodses = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(batchCodes)) {
|
|
|
goodses = goodsService.findGoodsByBatchCodes(batchCodes);
|
|
|
@@ -547,49 +556,90 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
List<GoodsHistory> goodsHistoryList = new ArrayList<>();
|
|
|
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());
|
|
|
+ if (!RegexConstant.isNumber(aBatch.getBatchCode())) {
|
|
|
+ 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;
|
|
|
}
|
|
|
- fillInGoods(goods, aBatch);
|
|
|
- newGoods = goods;
|
|
|
- break;
|
|
|
}
|
|
|
- }
|
|
|
- if (newGoods == null) {
|
|
|
- newGoods = new Goods();
|
|
|
- TradeDeliveryDelayTime delayTime = getDelayTime(aBatch);
|
|
|
- newGoods.setGoodsByReleaseProductByBatch(aBatch, delayTime);
|
|
|
- goodsHistoryList.add(goodsHistoryService.converTGoodsHist(newGoods, GoodsHistory.OperateType.Publish.getPhrase(), false));
|
|
|
- }
|
|
|
- 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++;
|
|
|
+ if (newGoods == null) {
|
|
|
+ newGoods = new Goods();
|
|
|
+ TradeDeliveryDelayTime delayTime = getDelayTime(aBatch);
|
|
|
+ newGoods.setGoodsByReleaseProductByBatch(aBatch, delayTime);
|
|
|
+ goodsHistoryList.add(goodsHistoryService.converTGoodsHist(newGoods, GoodsHistory.OperateType.Publish.getPhrase(), false));
|
|
|
+ }
|
|
|
+ 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 {
|
|
|
- aBatch.setErrmsg(offMap.getMessage());
|
|
|
- aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
|
|
|
- aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
+ result++;
|
|
|
}
|
|
|
} else {
|
|
|
- result++;
|
|
|
+ aBatch.setErrmsg(resultMap.getMessage());
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
}
|
|
|
} else {
|
|
|
- aBatch.setErrmsg(resultMap.getMessage());
|
|
|
- aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
|
|
|
- aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
+ for (Product product : products) {
|
|
|
+ if (product.getId().equals(Long.parseLong(aBatch.getBatchCode()))) {
|
|
|
+ aBatch.setB2cCode(product.getPcmpcode());
|
|
|
+ aBatch.setProductNum(product.getProdNum());
|
|
|
+ aBatch.setBrandNameEn(product.getBrand());
|
|
|
+ aBatch.setKindName(product.getProdName());
|
|
|
+ aBatch.setCurrency(product.getCurrency());
|
|
|
+ aBatch.setProductNum(product.getProdNum());
|
|
|
+ InOutboundDetail inOutboundDetail = new InOutboundDetail(newProduct);
|
|
|
+ fillInProduct(product, aBatch, inOutboundDetail);
|
|
|
+ newProduct = product;
|
|
|
+ Set<InOutboundDetail> set = new HashSet<>();
|
|
|
+ set.add(inOutboundDetail);
|
|
|
+ if (CollectionUtils.isNotEmpty(set)) {
|
|
|
+ Map<String, Set<InOutboundDetail>> inOutMap = inOutboundDetailService.initInOutboundDetailByQty(set);
|
|
|
+ Set<String> stringSet = inOutMap.keySet();
|
|
|
+ for (String type : stringSet) {
|
|
|
+ CommodityInOutbound commodityInOutbound = commodityInOutboundService.produceCommodityInOutbound(inOutMap.get(type), type);
|
|
|
+ if (commodityInOutbound != null) {
|
|
|
+ commodityInOutboundService.save(commodityInOutbound);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ productDao.save(newProduct);
|
|
|
+ result++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(newProduct)) {
|
|
|
+ aBatch.setErrmsg("物料SKU码有误");
|
|
|
+ aBatch.setReleaseCode(ReleaseStatus.lack_info.value());
|
|
|
+ aBatch.setReleaseStatus(ReleaseStatus.lack_info.getPhrase());
|
|
|
+ } else {
|
|
|
+ Goods needGoods = new Goods();
|
|
|
+ needGoods.setProductInfo(newProduct);
|
|
|
+ goodsService.setGoodsDefault(needGoods);
|
|
|
+ goodsDao.save(needGoods);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
@@ -711,6 +761,43 @@ public class ReleaseProductByBatchServiceImpl implements ReleaseProductByBatchSe
|
|
|
goods.setStatus(aBatch.getStatus());
|
|
|
}
|
|
|
|
|
|
+ private void fillInProduct(Product product, ReleaseProductByBatch aBatch, InOutboundDetail inOutboundDetail) {
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getSpec())) {
|
|
|
+ product.setSpec(aBatch.getSpec());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getPackaging())) {
|
|
|
+ product.setPackaging(aBatch.getPackaging());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getSelfMinDelivery())) {
|
|
|
+ product.setMinDelivery(aBatch.getSelfMinDelivery());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getSelfMaxDelivery())) {
|
|
|
+ product.setMaxDelivery(aBatch.getSelfMaxDelivery());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getBreakUp())) {
|
|
|
+ product.setBreakUp(aBatch.getBreakUp());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getMinPackage())) {
|
|
|
+ product.setMinPackQty(aBatch.getMinPackage());
|
|
|
+ } else {
|
|
|
+ product.setMinPackQty(1d);
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getCostPrice())) {
|
|
|
+ product.setPrice(aBatch.getCostPrice());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(aBatch.getReserve())) {
|
|
|
+ product.setErpReserve(aBatch.getReserve());
|
|
|
+ Double qty = NumberUtil.sub(aBatch.getReserve(), product.getErpReserve());
|
|
|
+ if (NumberUtil.compare(qty, DoubleConstant.zero) != 0) {
|
|
|
+ //做出入库记录
|
|
|
+ product.setErpReserve(aBatch.getReserve());
|
|
|
+ inOutboundDetail = new InOutboundDetail(product);
|
|
|
+ inOutboundDetail.setQty(qty);
|
|
|
+ inOutboundDetail.setPrice(aBatch.getCostPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private StoreIn getModifyStoreInfo(Object value, StoreIn self, StoreIn consignment) {
|
|
|
List<String> sellList = Arrays.asList("自营", "寄售");
|
|
|
if (StringUtils.isEmpty(value) || !sellList.contains(StringUtilB2C.getStr(value))) {
|