|
|
@ -3937,17 +3937,224 @@ public class WarehouseTrayTypeServiceImpl extends BaseServiceImpl<WarehouseTrayT |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void changeTrayWarehouseInfo(String trayCode, Long warehouseId) { |
|
|
|
public void changeTrayWarehouseInfo(String trayCode, Long warehouseId) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BasicdataTrayEntity basicdataTrayEntity = basicdataTrayClient.getTrayByTrayCode(trayCode); |
|
|
|
|
|
|
|
if(Objects.isNull(basicdataTrayEntity)){ |
|
|
|
|
|
|
|
log.warn("#############changeTrayWarehouseInfo: 托盘信息不存在 trayCode={}",trayCode); |
|
|
|
|
|
|
|
throw new CustomerException(403,"托盘信息不存在"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String palletName = basicdataTrayEntity.getPalletName(); |
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<WarehouseTrayTypeEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
QueryWrapper<WarehouseTrayTypeEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
queryWrapper.eq("tray_code",trayCode) |
|
|
|
queryWrapper.eq("tray_code",trayCode) |
|
|
|
.eq("is_deleted",0); |
|
|
|
.eq("is_deleted",0); |
|
|
|
WarehouseTrayTypeEntity trayTypeEntity = baseMapper.selectOne(queryWrapper); |
|
|
|
WarehouseTrayTypeEntity trayTypeEntity = baseMapper.selectOne(queryWrapper); |
|
|
|
trayTypeEntity.setWarehouseId(warehouseId); |
|
|
|
trayTypeEntity.setWarehouseId(warehouseId); |
|
|
|
updateById(trayTypeEntity); |
|
|
|
updateById(trayTypeEntity); |
|
|
|
|
|
|
|
|
|
|
|
Long trayTypeId = trayTypeEntity.getId(); |
|
|
|
Long trayTypeId = trayTypeEntity.getId(); |
|
|
|
|
|
|
|
|
|
|
|
warehouseTrayGoodsService.updeteWarehouseIdByTrayTypeId(trayTypeId,warehouseId); |
|
|
|
warehouseTrayGoodsService.updeteWarehouseIdByTrayTypeId(trayTypeId,warehouseId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<WarehouseTrayGoodsEntity> trayGoodsEntityQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
trayGoodsEntityQueryWrapper.eq("tray_type_id",trayTypeId); |
|
|
|
|
|
|
|
List<WarehouseTrayGoodsEntity> trayGoodsEntities = warehouseTrayGoodsService.list(trayGoodsEntityQueryWrapper); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<DistributionStockArticleEntity> updateStockArticleList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<Long> clearStockArticleIdList = new ArrayList<>(); |
|
|
|
|
|
|
|
List<DistributionParcelListEntity> updateParceList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//把trayGoodsEntities中所有元素的associationType进行分组
|
|
|
|
|
|
|
|
Map<String, List<WarehouseTrayGoodsEntity>> map = trayGoodsEntities.stream().collect(Collectors.groupingBy(WarehouseTrayGoodsEntity::getAssociationType)); |
|
|
|
|
|
|
|
map.keySet().forEach(associationType -> { |
|
|
|
|
|
|
|
List<WarehouseTrayGoodsEntity> warehouseTrayGoodsEntities = map.get(associationType); |
|
|
|
|
|
|
|
if("1".equals(associationType)){ |
|
|
|
|
|
|
|
//把warehouseTrayGoodsEntities中所有的associationId放入一个Set
|
|
|
|
|
|
|
|
Set<Long> orderIdSet = warehouseTrayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationId).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
List<DistributionStockArticleEntity> stockArticleEntityList = distributionStockArticleClient.findListByIds(orderIdSet); |
|
|
|
|
|
|
|
stockArticleEntityList.forEach(stockArticleEntity -> { |
|
|
|
|
|
|
|
String trays = stockArticleEntity.getTrays(); |
|
|
|
|
|
|
|
if(!StringUtil.isBlank(trays)){ |
|
|
|
|
|
|
|
if(trays.contains(palletName)){ |
|
|
|
|
|
|
|
List<String> list = Arrays.asList(trays.split(trays)); |
|
|
|
|
|
|
|
List<String> trayList = new ArrayList<>(list); |
|
|
|
|
|
|
|
trayList.remove(palletName); |
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(trayList)){ |
|
|
|
|
|
|
|
DistributionStockArticleEntity updateStockArticle = new DistributionStockArticleEntity(); |
|
|
|
|
|
|
|
updateStockArticle.setId(stockArticleEntity.getId()); |
|
|
|
|
|
|
|
updateStockArticle.setTrays(StringUtil.join(trayList.toArray(),",")); |
|
|
|
|
|
|
|
updateStockArticleList.add(updateStockArticle); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
clearStockArticleIdList.add(stockArticleEntity.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if ("3".equals(associationType)){ |
|
|
|
|
|
|
|
//把trayGoodsEntities中的所有元素的associationId放入一个List
|
|
|
|
|
|
|
|
List<Long> orderPackageIdList = warehouseTrayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationId).collect(Collectors.toList()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//清除原来仓库的包件上的托盘信息
|
|
|
|
|
|
|
|
distributionParcelListClient.clearPallet(orderPackageIdList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询原仓库有哪些包件
|
|
|
|
|
|
|
|
List<DistributionParcelListEntity> oldParceList = distributionParcelListClient.findListByIds(orderPackageIdList); |
|
|
|
|
|
|
|
//把oldParceList中的所有元素的stockArticleId放入一个set
|
|
|
|
|
|
|
|
Set<Long> stockArticleIdSet = oldParceList.stream().map(DistributionParcelListEntity::getStockArticleId).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
List<DistributionStockArticleEntity> oldStockArticleList = distributionStockArticleClient.findListByIds(stockArticleIdSet); |
|
|
|
|
|
|
|
oldStockArticleList.forEach(stockArticleEntity -> { |
|
|
|
|
|
|
|
String trays = stockArticleEntity.getTrays(); |
|
|
|
|
|
|
|
if(!StringUtil.isBlank(trays)){ |
|
|
|
|
|
|
|
if(trays.contains(palletName)){ |
|
|
|
|
|
|
|
List<String> list = Arrays.asList(trays.split(trays)); |
|
|
|
|
|
|
|
List<String> trayList = new ArrayList<>(list); |
|
|
|
|
|
|
|
trayList.remove(palletName); |
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(trayList)){ |
|
|
|
|
|
|
|
DistributionStockArticleEntity updateStockArticle = new DistributionStockArticleEntity(); |
|
|
|
|
|
|
|
updateStockArticle.setId(stockArticleEntity.getId()); |
|
|
|
|
|
|
|
updateStockArticle.setTrays(StringUtil.join(trayList.toArray(),",")); |
|
|
|
|
|
|
|
updateStockArticleList.add(updateStockArticle); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
clearStockArticleIdList.add(stockArticleEntity.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if(CollUtil.isNotEmpty(updateStockArticleList)){
|
|
|
|
|
|
|
|
// distributionStockArticleClient.updateByBatchId(updateStockArticleList);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if(CollUtil.isNotEmpty(clearStockArticleIdList)){
|
|
|
|
|
|
|
|
// distributionStockArticleClient.clearTraysByIds(clearStockArticleIdList);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<WarehouseTrayGoodsEntity> updateTrayGoodsList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//处理新的
|
|
|
|
|
|
|
|
map.keySet().forEach(associationType -> { |
|
|
|
|
|
|
|
List<WarehouseTrayGoodsEntity> warehouseTrayGoodsEntities = map.get(associationType); |
|
|
|
|
|
|
|
//把warehouseTrayGoodsEntities转化成以associationValue为key的Map
|
|
|
|
|
|
|
|
Map<String, WarehouseTrayGoodsEntity> warehouseTrayGoodsMap = warehouseTrayGoodsEntities.stream() |
|
|
|
|
|
|
|
.collect(Collectors.toMap( |
|
|
|
|
|
|
|
WarehouseTrayGoodsEntity::getAssociationValue, // key
|
|
|
|
|
|
|
|
entity -> entity, // value
|
|
|
|
|
|
|
|
(existing, replacement) -> existing // 如果key重复,保留第一个值
|
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if("1".equals(associationType)){ |
|
|
|
|
|
|
|
//把warehouseTrayGoodsEntities中所有元素的associationValue放入一个Set
|
|
|
|
|
|
|
|
Set<String> orderCodeSet = warehouseTrayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
FindParamterDTO findParamterDTO = new FindParamterDTO(); |
|
|
|
|
|
|
|
findParamterDTO.setOrderCodeSet(orderCodeSet); |
|
|
|
|
|
|
|
findParamterDTO.setWarehouseId(warehouseId); |
|
|
|
|
|
|
|
List<DistributionStockArticleEntity> stockArticleEntityList = distributionStockArticleClient.findListByOrderCodesAndWarehouseId(findParamterDTO); |
|
|
|
|
|
|
|
stockArticleEntityList.forEach(stockArticleEntity -> { |
|
|
|
|
|
|
|
WarehouseTrayGoodsEntity warehouseTrayGoodsEntity = warehouseTrayGoodsMap.get(stockArticleEntity.getOrderCode()); |
|
|
|
|
|
|
|
if(!Objects.isNull(warehouseTrayGoodsEntity)){ |
|
|
|
|
|
|
|
warehouseTrayGoodsEntity.setAssociationId(stockArticleEntity.getId()); |
|
|
|
|
|
|
|
warehouseTrayGoodsEntity.setWarehouseId(warehouseId); |
|
|
|
|
|
|
|
updateTrayGoodsList.add(warehouseTrayGoodsEntity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
String trays = stockArticleEntity.getTrays(); |
|
|
|
|
|
|
|
if(!StringUtil.isBlank(trays)){ |
|
|
|
|
|
|
|
if(!trays.contains(palletName)){ |
|
|
|
|
|
|
|
List<String> list = Arrays.asList(trays.split(trays)); |
|
|
|
|
|
|
|
List<String> trayList = new ArrayList<>(list); |
|
|
|
|
|
|
|
trayList.add(palletName); |
|
|
|
|
|
|
|
DistributionStockArticleEntity updateStockArticle = new DistributionStockArticleEntity(); |
|
|
|
|
|
|
|
updateStockArticle.setId(stockArticleEntity.getId()); |
|
|
|
|
|
|
|
updateStockArticle.setTrays(StringUtil.join(trayList.toArray(),",")); |
|
|
|
|
|
|
|
updateStockArticleList.add(updateStockArticle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
DistributionStockArticleEntity updateStockArticle = new DistributionStockArticleEntity(); |
|
|
|
|
|
|
|
updateStockArticle.setId(stockArticleEntity.getId()); |
|
|
|
|
|
|
|
updateStockArticle.setTrays(palletName); |
|
|
|
|
|
|
|
updateStockArticleList.add(updateStockArticle); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}else if ("3".equals(associationType)){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//把warehouseTrayGoodsEntities中所有元素的associationValue放入一个Set
|
|
|
|
|
|
|
|
Set<String> orderPackageCodeSet = warehouseTrayGoodsEntities.stream().map(WarehouseTrayGoodsEntity::getAssociationValue).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
FindParamterDTO findParamterDTO = new FindParamterDTO(); |
|
|
|
|
|
|
|
findParamterDTO.setOrderPackageCodeList(new ArrayList<>(orderPackageCodeSet)); |
|
|
|
|
|
|
|
findParamterDTO.setWarehouseId(warehouseId); |
|
|
|
|
|
|
|
List<DistributionParcelListEntity> parcelListEntityList = distributionParcelListClient.findListByOrderPackageCodeList(findParamterDTO); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//把parcelListEntityList转化成以orderPackageCode为key的Map
|
|
|
|
|
|
|
|
Map<String, DistributionParcelListEntity> parcelListEntityMap = parcelListEntityList.stream() |
|
|
|
|
|
|
|
.collect(Collectors.toMap( |
|
|
|
|
|
|
|
DistributionParcelListEntity::getOrderPackageCode, // key
|
|
|
|
|
|
|
|
entity -> entity, // value
|
|
|
|
|
|
|
|
(existing, replacement) -> existing // 如果key重复,保留第一个值
|
|
|
|
|
|
|
|
)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
warehouseTrayGoodsEntities.forEach(warehouseTrayGoodsEntity -> { |
|
|
|
|
|
|
|
DistributionParcelListEntity parcelList = parcelListEntityMap.get(warehouseTrayGoodsEntity.getAssociationValue()); |
|
|
|
|
|
|
|
if(!Objects.isNull(parcelList)){ |
|
|
|
|
|
|
|
warehouseTrayGoodsEntity.setAssociationId(parcelList.getId()); |
|
|
|
|
|
|
|
warehouseTrayGoodsEntity.setWarehouseId(warehouseId); |
|
|
|
|
|
|
|
updateTrayGoodsList.add(warehouseTrayGoodsEntity); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DistributionParcelListEntity updateParceEntity = new DistributionParcelListEntity(); |
|
|
|
|
|
|
|
updateParceEntity.setId(parcelList.getId()); |
|
|
|
|
|
|
|
updateParceEntity.setPallet(palletName); |
|
|
|
|
|
|
|
updateParceList.add(updateParceEntity); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//把parcelListEntityList中所有元素的orderCode放入一个Set
|
|
|
|
|
|
|
|
Set<String> orderCodeSet = parcelListEntityList.stream().map(DistributionParcelListEntity::getOrderCode).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
findParamterDTO.setOrderCodeSet(orderCodeSet); |
|
|
|
|
|
|
|
findParamterDTO.setWarehouseId(warehouseId); |
|
|
|
|
|
|
|
List<DistributionStockArticleEntity> stockArticleEntityList = distributionStockArticleClient.findListByOrderCodesAndWarehouseId(findParamterDTO); |
|
|
|
|
|
|
|
stockArticleEntityList.forEach(stockArticleEntity -> { |
|
|
|
|
|
|
|
String trays = stockArticleEntity.getTrays(); |
|
|
|
|
|
|
|
if(!StringUtil.isBlank(trays)){ |
|
|
|
|
|
|
|
if(trays.contains(palletName)){ |
|
|
|
|
|
|
|
List<String> list = Arrays.asList(trays.split(trays)); |
|
|
|
|
|
|
|
List<String> trayList = new ArrayList<>(list); |
|
|
|
|
|
|
|
trayList.remove(palletName); |
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(trayList)){ |
|
|
|
|
|
|
|
DistributionStockArticleEntity updateStockArticle = new DistributionStockArticleEntity(); |
|
|
|
|
|
|
|
updateStockArticle.setId(stockArticleEntity.getId()); |
|
|
|
|
|
|
|
updateStockArticle.setTrays(StringUtil.join(trayList.toArray(),",")); |
|
|
|
|
|
|
|
updateStockArticleList.add(updateStockArticle); |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
clearStockArticleIdList.add(stockArticleEntity.getId()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(updateParceList)){ |
|
|
|
|
|
|
|
distributionParcelListClient.updateList(updateParceList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(updateStockArticleList)){ |
|
|
|
|
|
|
|
distributionStockArticleClient.updateByBatchId(updateStockArticleList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(CollUtil.isNotEmpty(clearStockArticleIdList)){ |
|
|
|
|
|
|
|
distributionStockArticleClient.clearTraysByIds(clearStockArticleIdList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|