-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Days of supply #15
Days of supply #15
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall solid work. I left some comments for improvement. Also, when you're done with the improvements please remove the data injection.
...end/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java
Outdated
Show resolved
Hide resolved
...end/src/main/java/org/eclipse/tractusx/puris/backend/demand/controller/DemandController.java
Outdated
Show resolved
Hide resolved
...main/java/org/eclipse/tractusx/puris/backend/production/controller/ProductionController.java
Outdated
Show resolved
Hide resolved
backend/src/main/java/org/eclipse/tractusx/puris/backend/supply/logic/dto/SupplyDto.java
Show resolved
Hide resolved
...n/java/org/eclipse/tractusx/puris/backend/production/logic/service/OwnProductionService.java
Outdated
Show resolved
Hide resolved
...end/src/main/java/org/eclipse/tractusx/puris/backend/supply/controller/SupplyController.java
Outdated
Show resolved
Hide resolved
.../main/java/org/eclipse/tractusx/puris/backend/delivery/logic/service/OwnDeliveryService.java
Outdated
Show resolved
Hide resolved
.../java/org/eclipse/tractusx/puris/backend/delivery/logic/service/ReportedDeliveryService.java
Outdated
Show resolved
Hide resolved
@@ -105,6 +111,41 @@ public final List<T> findByPartnerBpnlAndOwnMaterialNumber(String partnerBpnl, S | |||
return repository.getForPartnerBpnlAndOwnMatNbr(partnerBpnl, ownMaterialNumber); | |||
} | |||
|
|||
public final List<T> findAllByMaterialAndDate(String ownMaterialNumber, String partnerBpnl, String siteBpns, Date date) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method is not necessary. By definition all stocks are always current. You can simply query all stocks for the given filters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean that its not necessary to check by date? I can just create a method in the repository to filter by material number, partner bpnl and site bpns using the naming convention stuff?
Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); | ||
|
||
if (i == numberOfDays - 1) { | ||
stockQuantity += deliveries.get(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand this statement. On the last day the delivery amount is added twice. What is the reasoning behind this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the last day I need to add the delivery amount before it goes to calculate, because after it calculates, it adjusts the stock with demand and delivery, but then the loop is already finished. Maybe I complicated it and there is a better way :D And then it doesnt matter if its added again, because the loop is finished anyways.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll have another look into the logic. Fix the rest of the comments for now and I'll let you know if something needs to be changed here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alright, deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more small change. Otherwise looks good to me. Please also remove the changes in the DataInjectionCommandLineRunner
now
Stream<OwnDelivery> stream = repository.findAll().stream(); | ||
if (ownMaterialNumber.isPresent()) { | ||
stream = stream.filter(delivery -> delivery.getMaterial().getOwnMaterialNumber().equals(ownMaterialNumber.get())); | ||
} | ||
if (bpns.isPresent()) { | ||
stream = stream.filter(delivery -> delivery.getDestinationBpns().equals(bpns.get()) || delivery.getOriginBpns().equals(bpns.get())); | ||
if (direction.isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The direction filter should be independent of the BPNS filter. For incoming you should filter all deliveries where the Destination is one of the user's sites for outgoing where it's not.
Stream<ReportedDelivery> stream = repository.findAll().stream(); | ||
if (ownMaterialNumber.isPresent()) { | ||
stream = stream.filter(delivery -> delivery.getMaterial().getOwnMaterialNumber().equals(ownMaterialNumber.get())); | ||
} | ||
if (bpns.isPresent()) { | ||
stream = stream.filter(delivery -> delivery.getDestinationBpns().equals(bpns.get()) || delivery.getOriginBpns().equals(bpns.get())); | ||
if (direction.isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as own delivery
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.