Fix
This commit is contained in:
Binary file not shown.
@@ -23,6 +23,8 @@ public interface ArticleService {
|
|||||||
|
|
||||||
Article save(Article article);
|
Article save(Article article);
|
||||||
|
|
||||||
|
Article update(Article article);
|
||||||
|
|
||||||
double getRating(Long id);
|
double getRating(Long id);
|
||||||
|
|
||||||
double getRating(UUID uuid);
|
double getRating(UUID uuid);
|
||||||
|
|||||||
@@ -69,6 +69,12 @@ public class ArticleServiceImpl implements ArticleService {
|
|||||||
return articleRepository.save(article);
|
return articleRepository.save(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public Article update(Article article) {
|
||||||
|
return articleRepository.save(article);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getRating(Long id) {
|
public double getRating(Long id) {
|
||||||
return reviewRepository.streamReviewsByArticleId(id)
|
return reviewRepository.streamReviewsByArticleId(id)
|
||||||
|
|||||||
@@ -12,10 +12,8 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.BinaryOperator;
|
import java.util.function.BinaryOperator;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
@@ -84,7 +82,14 @@ public class StatisticsServiceImpl implements StatisticsService {
|
|||||||
articleService.findAll().forEach(article -> {
|
articleService.findAll().forEach(article -> {
|
||||||
int percent = (int) Math.floor(((1.0d * article.getStock() / article.getStockExpected()) * 100) / 10) * 10;
|
int percent = (int) Math.floor(((1.0d * article.getStock() / article.getStockExpected()) * 100) / 10) * 10;
|
||||||
log.info("Stock percent: {} {}", article.getUuid(), percent);
|
log.info("Stock percent: {} {}", article.getUuid(), percent);
|
||||||
log.info("Cat: {}", article.getCategory());
|
for (ArticleCategory value : ArticleCategory.values()) {
|
||||||
|
if (article.getCategory().equalsIgnoreCase(value.loc)) {
|
||||||
|
log.info("Fixing Article Category {} to {}", article.getCategory(), value.loc);
|
||||||
|
article.setCategory(value.loc);
|
||||||
|
articleService.update(article);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
map.get(article.getCategory()).putIfAbsent(percent, 0);
|
map.get(article.getCategory()).putIfAbsent(percent, 0);
|
||||||
map.get(article.getCategory()).computeIfPresent(percent, (k,v) -> ++v);
|
map.get(article.getCategory()).computeIfPresent(percent, (k,v) -> ++v);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user