|
|
|
@ -111,7 +111,9 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
|
public Boolean ownSaveOrUpdate(DistrilbutionBillLadingDTO distrilbutionBillLading) { |
|
|
|
|
Boolean las = false; |
|
|
|
|
if (ObjectUtils.isNotNull(distrilbutionBillLading.getId())) { |
|
|
|
|
las = true; |
|
|
|
|
//修改
|
|
|
|
|
this.updateById(distrilbutionBillLading); |
|
|
|
|
//修改图片
|
|
|
|
@ -166,6 +168,13 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
//修改
|
|
|
|
|
listDetails.forEach(i -> { |
|
|
|
|
boolean b = distrilbutionBillLading.getStockDTOList().stream().anyMatch(a -> i.getStockListId().equals(a.getId())); |
|
|
|
|
List<DistributionStockEntity> list1 = distributionStockService.list(Wrappers.<DistributionStockEntity>query().lambda() |
|
|
|
|
.eq(DistributionStockEntity::getBillLadingId, distrilbutionBillLading.getId()) |
|
|
|
|
.eq(DistributionStockEntity::getStockListId, i.getStockListId()) |
|
|
|
|
.eq(DistributionStockEntity::getType, "2") |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (b) { |
|
|
|
|
//有
|
|
|
|
|
Iterator<DistributionStockListDTO> iterator = distrilbutionBillLading.getStockDTOList().iterator(); |
|
|
|
@ -179,31 +188,70 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
Integer inventoryQuantity = next.getInventoryQuantity(); //修改数量
|
|
|
|
|
Integer quantity = i.getQuantity();//原来的数量
|
|
|
|
|
Integer num = 0; |
|
|
|
|
|
|
|
|
|
if(inventoryQuantity > quantity){ |
|
|
|
|
num = inventoryQuantity - quantity; //多
|
|
|
|
|
num = inventoryQuantity - quantity; //多 添加了数量
|
|
|
|
|
//修改库存占用数量
|
|
|
|
|
distributionAsyncService.getInventoryNumUpdate(i.getStockListId(),num,1); |
|
|
|
|
//kk备货
|
|
|
|
|
if (i.getConditions().equals("2")) { |
|
|
|
|
//xiugai
|
|
|
|
|
DistributionDeliveryDetailsEntity d = new DistributionDeliveryDetailsEntity(); |
|
|
|
|
d.setId(i.getId()); |
|
|
|
|
d.setConditions("1"); |
|
|
|
|
distributionDeliveryDetailsService.updateById(d); |
|
|
|
|
} |
|
|
|
|
}else if(inventoryQuantity < quantity){ |
|
|
|
|
num = quantity - inventoryQuantity; //少
|
|
|
|
|
//修改库存占用数量
|
|
|
|
|
distributionAsyncService.getInventoryNumUpdate(i.getStockListId(),num,2); |
|
|
|
|
num = quantity - inventoryQuantity; //少 减少了数量
|
|
|
|
|
/*if(list1.size() < 1){ |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
//有备货
|
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
if(i.getConditions().equals("2")){ |
|
|
|
|
//todo 已完成
|
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
//todo 未完成
|
|
|
|
|
int size = list1.size(); //扫描的数量
|
|
|
|
|
int i1 = quantity - size; //未扫的数量
|
|
|
|
|
if(i1 > num){ |
|
|
|
|
//可以减少
|
|
|
|
|
//修改库存占用数量
|
|
|
|
|
distributionAsyncService.getInventoryNumUpdate(i.getStockListId(),num,2); |
|
|
|
|
}else{ |
|
|
|
|
//todo 未扫小于减少
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
iterator.remove(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
|
|
|
|
|
if(list1.size() < 1){ |
|
|
|
|
//取消库存占用数量
|
|
|
|
|
distributionAsyncService.getInventoryNumUpdate(i.getStockListId(),i.getQuantity(),2); |
|
|
|
|
} |
|
|
|
|
//没有 删除
|
|
|
|
|
ids.add(i.getId()); |
|
|
|
|
//取消库存占用数量
|
|
|
|
|
distributionAsyncService.getInventoryNumUpdate(i.getStockListId(),i.getQuantity(),2); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
//删除没有的库存品
|
|
|
|
|
if(ids.size() > 0){ |
|
|
|
|
distributionDeliveryDetailsService.deleteLogic(ids); |
|
|
|
|
ids.forEach( a ->{ |
|
|
|
|
DistributionDeliveryDetailsEntity deliveryDetails = new DistributionDeliveryDetailsEntity(); |
|
|
|
|
deliveryDetails.setId(a); |
|
|
|
|
deliveryDetails.setInventoryStatus("3"); |
|
|
|
|
distributionDeliveryDetailsService.updateById(deliveryDetails); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
@ -243,12 +291,18 @@ public class DistrilbutionBillLadingServiceImpl extends BaseServiceImpl<Distrilb
|
|
|
|
|
if(distrilbutionBillLading.getStockDTOList().size() > 0){ |
|
|
|
|
//没有
|
|
|
|
|
List<DistributionDeliveryDetailsEntity> detailsEntities = new ArrayList<>(); |
|
|
|
|
Boolean finalLas = las; |
|
|
|
|
distrilbutionBillLading.getStockDTOList().forEach(i -> { |
|
|
|
|
DistributionDeliveryDetailsEntity details = new DistributionDeliveryDetailsEntity(); |
|
|
|
|
details.setBillLadingId(distrilbutionBillLading.getId()); |
|
|
|
|
details.setStockListId(i.getId()); |
|
|
|
|
details.setQuantity(i.getInventoryQuantity()); |
|
|
|
|
details.setConditions("1"); |
|
|
|
|
if(finalLas){ |
|
|
|
|
details.setInventoryStatus("2"); |
|
|
|
|
}else{ |
|
|
|
|
details.setInventoryStatus("1"); |
|
|
|
|
} |
|
|
|
|
detailsEntities.add(details); |
|
|
|
|
//修改库存数量
|
|
|
|
|
distributionAsyncService.getInventoryNumUpdate(i.getId(),i.getInventoryQuantity(),1); |
|
|
|
|