Browse Source

转库存品BUG修复

dist.1.3.0
汤建军 5 months ago
parent
commit
4b0bc711b1
  1. 80
      blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java

80
blade-service/logpm-distribution/src/main/java/com/logpm/distribution/service/impl/DistributionParcelListServiceImpl.java

@ -901,24 +901,52 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
List<DistributionParcelListEntity> distributionParcelListEntities = this.listByIds(packageIds);
List<Long> materialId = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getMaterialId).distinct().collect(Collectors.toList());
List<String> materialCode = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getMaterialCode).distinct().collect(Collectors.toList());
List<String> materialUnit = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getMaterialUnit).distinct().collect(Collectors.toList());
List<Long> mallId = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getMarketId).distinct().collect(Collectors.toList());
// List<String> materialUnit = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getMaterialUnit).distinct().collect(Collectors.toList());
// List<Long> mallId = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getMarketId).distinct().collect(Collectors.toList());
// List<String> materialName = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getMaterialName).distinct().collect(Collectors.toList());
// List<String> brandName = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getBrandName).distinct().collect(Collectors.toList());
// List<Long> brandId = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getBrandId).distinct().collect(Collectors.toList());
// if (materialId.size() != 1 || materialCode.size() != 1 || materialUnit.size() != 1 || mallId.size() != 1 || materialName.size() != 1 || brandName.size() != 1) {
// //该批次包件出现多种物料包件
// return null;
// }
List<DistributionStockListInfoEntity> infoEntities = new ArrayList<>();
if (!distributionParcelListEntities.isEmpty()) {
Map<String, List<DistributionParcelListEntity>> listMap = distributionParcelListEntities.stream().collect(Collectors.groupingBy(DistributionParcelListEntity::getMaterialName));
listMap.forEach((k,v)->{
//校验品牌
List<String> brandList = v.stream().map(DistributionParcelListEntity::getBrandName).collect(Collectors.toList());
if (brandList.size()>1){
//多个品牌
throw new RuntimeException(k+"多个品牌");
}
List<String> mallList = v.stream().map(DistributionParcelListEntity::getMallName).collect(Collectors.toList());
if (mallList.size()>1){
//多个商场
throw new RuntimeException(k+"多个商场");
}
List<Long> brandId = v.stream().map(DistributionParcelListEntity::getBrandId).distinct().collect(Collectors.toList());
if (brandId.size()>1){
//多个品牌
throw new RuntimeException(k+"多个品牌");
}
List<String> materialName = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getMaterialName).distinct().collect(Collectors.toList());
List<String> brandName = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getBrandName).distinct().collect(Collectors.toList());
List<Long> brandId = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getBrandId).distinct().collect(Collectors.toList());
if (materialId.size() != 1 || materialCode.size() != 1 || materialUnit.size() != 1 || mallId.size() != 1 || materialName.size() != 1 || brandName.size() != 1) {
//该批次包件出现多种物料包件
return null;
if (materialName.size()>1){
throw new RuntimeException(k+"存在多个物料单位");
}
int num = distributionParcelListEntities.stream().mapToInt(DistributionParcelListEntity::getQuantity).sum();
List<String> materialUnit = distributionParcelListEntities.stream().map(DistributionParcelListEntity::getMaterialUnit).distinct().collect(Collectors.toList());
if (materialUnit.size()>1){
//多个物料单位
throw new RuntimeException(k+"存在多个物料单位");
}
int num = v.stream().mapToInt(DistributionParcelListEntity::getQuantity).sum();
if (num <= 0) {
//无有效的在库数量
return null;
throw new RuntimeException("无有效的在库数量");
}
DistributionStockListEntity distributionStockListEntity = new DistributionStockListEntity();
//直接添加
// distributionStockListEntity.setIncomingBatch(distributionStockArticleEntity.get); //入库批次号
distributionStockListEntity.setServiceNumber(Optional.ofNullable(distributionStockArticleEntity.getServiceNumber()).orElse(null)); //服务号
distributionStockListEntity.setDescriptionGoods(materialName.get(0)); //物料名称
distributionStockListEntity.setCargoNumber(materialCode.get(0)); //物料编号
@ -942,14 +970,13 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
// distributionStockListEntity.setCategory(Optional.ofNullable(distributionParcelList.getBrandId()+"").orElse(null));//品分类
// 品牌
distributionStockListEntity.setBrandId(brandId.get(0));
distributionStockListEntity.setBrandName(brandName.get(0));
distributionStockListEntity.setBrandName(brandList.get(0));
distributionStockListEntity.setUnpackingQuantity(0);
distributionStockListEntity.setSourceType("1"); //类型
BasicMaterialEntity materialOwnId = basicMaterialClient.getMaterialOwnId(materialId.get(0));
distributionStockListEntity.setSku(materialOwnId.getSku());
distributionStockListEntity.setMaterialId(materialId.get(0));//货物ID
// distributionStockListEntity.setParcelListId(distributionParcelListEntities.getId());//包件id
distributionStockListEntity.setQuantityOccupied(0);//冻结数量
distributionStockListEntity.setServiceType(distributionStockArticleEntity.getTypeService());//冻结数量
DistributionStockListEntity stockListEntity = distributionStockListService.getStockListEntity(distributionStockArticleEntity.getMallId(), distributionParcelListEntities.get(0).getMaterialId(), distributionStockArticleEntity.getOrderCode(), distributionStockArticleEntity.getStoreId(), distributionStockArticleEntity.getWarehouseId());
@ -958,7 +985,6 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
//有记录
DistributionStockListEntity listEntity = new DistributionStockListEntity();
listEntity.setId(stockListEntity.getId());//id
// Integer quantity = ObjectUtils.isNull(distributionParcelListEntities.get(0).getQuantity()) ? 0 : distributionParcelListEntities.get(0).getQuantity();
Integer quantityStock = ObjectUtils.isNull(stockListEntity.getQuantityStock()) ? 0 : stockListEntity.getQuantityStock();
listEntity.setQuantityStock(num + quantityStock);
distributionStockListService.updateById(listEntity);
@ -966,19 +992,10 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
log.info("###########distributionStockListEntity>>>>>>>>,{}", distributionStockListEntity);
distributionStockListService.save(distributionStockListEntity);
}
// distributionStockListEntity.setTrayName(Optional.ofNullable(distributionParcelList.getPallet()).orElse(null)); //托盘
// distributionStockListEntity.setStorageLocation(Optional.ofNullable(distributionParcelList.getGoodsAllocation()).orElse(null)); //库位信息
// distributionStockListEntity.setFactory(Optional.ofNullable(distributionStockArticleEntity.getFactoryTrain()).orElse(null));//工厂车次
// distributionStockListEntity.setDespatch(Optional.ofNullable(distributionStockArticleEntity.getTrainNumber()).orElse(null));//车次号
// distributionStockListEntity.setStockArticleId(Optional.ofNullable(distributionStockArticleEntity.getId()).orElse(null)); //订单ID
// distributionStockListEntity.setOrderCode(Optional.ofNullable(distributionParcelListEntities.get(0).getOrderCode()).orElse(null)); //订单自编号
List<DistributionStockListInfoEntity> infoEntities = new ArrayList<>();
for (DistributionParcelListEntity distributionParcelListEntity : distributionParcelListEntities) {
for (DistributionParcelListEntity distributionParcelListEntity : v) {
//添加库存品记录
DistributionStockListInfoEntity distributionStockListInfo = new DistributionStockListInfoEntity();
// BeanUtil.copyProperties(distributionStockListEntity,distributionStockListInfo);
distributionStockListInfo.setServiceNumber(distributionStockListEntity.getServiceNumber()); //服务号
distributionStockListInfo.setStockListId(distributionStockListEntity.getId()); //库存品ID
distributionStockListInfo.setDescriptionGoods(distributionStockListEntity.getMallName()); //物料名称
@ -988,33 +1005,25 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
distributionStockListInfo.setMarketId(distributionStockListEntity.getMarketId()); //商场
distributionStockListInfo.setCargoUnit(distributionStockListEntity.getCargoUnit()); //货物单位
distributionStockListInfo.setStorageLocation(distributionParcelListEntity.getPallet()); //货物单位
distributionStockListInfo.setMallName(distributionStockListEntity.getMallName()); //商场名称
distributionStockListInfo.setQuantityStock(distributionParcelListEntity.getQuantity()); //库存数量(包件数量)
distributionStockListInfo.setIncomingBatch(distributionStockListEntity.getIncomingBatch()); //入库批次
distributionStockListInfo.setOutboundQuantity(0); //出库数量
distributionStockListInfo.setOutboundQuantity(0); //入库时间
// distributionStockListEntity.setCargoUnit(Optional.ofNullable(distributionParcelList.getMaterialUnit()).orElse(null));//单位
distributionStockListInfo.setStoreId(distributionStockListEntity.getStoreId());//门店ID
distributionStockListInfo.setMarketCode(distributionStockListEntity.getMarketCode());//商场编码
distributionStockListInfo.setMarketName(distributionStockListEntity.getMarketName());//商场名称
distributionStockListInfo.setStoreCode(distributionStockListEntity.getStoreCode());//门店编码
distributionStockListInfo.setStoreName(distributionStockListEntity.getStoreName());//门店名称
// distributionStockListEntity.setCategory(Optional.ofNullable(distributionParcelList.getBrandId()+"").orElse(null));//品分类
// 品牌
distributionStockListInfo.setBrandId(distributionStockListEntity.getBrandId());
distributionStockListInfo.setBrandName(distributionStockListEntity.getBrandName());
distributionStockListInfo.setUnpackingQuantity(0);
distributionStockListInfo.setSourceType("1"); //类型
distributionStockListInfo.setSku(distributionStockListEntity.getSku());
distributionStockListInfo.setMaterialId(distributionStockListEntity.getMaterialId());//货物ID
// distributionStockListEntity.setParcelListId(distributionParcelListEntities.getId());//包件id
distributionStockListInfo.setQuantityOccupied(0);//冻结数量
distributionStockListInfo.setServiceType(distributionStockListEntity.getServiceType());//冻结数
//需要包件维度的详情
WarehouseUpdownGoodsEntity warehouseUpdownGoodsEntity = new WarehouseUpdownGoodsEntity();
warehouseUpdownGoodsEntity.setWarehouseId(myCurrentWarehouse.getId());
@ -1022,7 +1031,6 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
warehouseUpdownGoodsEntity.setAssociationValue(distributionParcelListEntity.getOrderPackageCode());
WarehouseUpdownGoodsEntity locationInformation = warehouseUpdownGoodsClient.getLocationInformation(warehouseUpdownGoodsEntity);
if (Func.isNotEmpty(locationInformation)) {
// distributionStockListInfo.setTrayName(locationInformation.get);
distributionStockListInfo.setStorageLocation(locationInformation.getAllocationTitle());
}
distributionStockListInfo.setFactory(distributionStockArticleEntity.getFactoryTrain());
@ -1034,7 +1042,13 @@ public class DistributionParcelListServiceImpl extends BaseServiceImpl<Distribut
distributionStockListInfo.setDespatch(distributionParcelListEntity.getWaybillNumber());
infoEntities.add(distributionStockListInfo);
}
});
}
if (!infoEntities.isEmpty()) {
distributionStockListInfoService.saveBatch(infoEntities);
}
return distributionStockArticleEntity;
}

Loading…
Cancel
Save