This commit is contained in:
cc
2024-11-13 17:56:26 +08:00
parent 8525ca778d
commit c6a1650103

View File

@@ -421,19 +421,20 @@ public class JDUtils {
} }
case "违规排行": { case "违规排行": {
content.append("违规排行(前十):");
List<OrderRow> oneYearOrders = filterOrdersByDate(orderRows, 365); List<OrderRow> oneYearOrders = filterOrdersByDate(orderRows, 365);
// 计算出skuId 违规的前7个排行 // 计算出skuId 违规的前7个排行
Map<String, Long> skuIdViolationCountMap = oneYearOrders.stream().filter(orderRow -> orderRow.getValidCode() == 27 Map<String, Long> skuIdViolationCountMap = oneYearOrders.stream().filter(orderRow -> orderRow.getValidCode() == 27
|| orderRow.getValidCode() == 28 || orderRow.getValidCode() == 28
|| orderRow.getValidCode() == 2).filter(orderRow -> orderRow.getSkuId() != null).collect(Collectors.groupingBy(OrderRow::getSkuName, Collectors.counting())); || orderRow.getValidCode() == 2).filter(orderRow -> orderRow.getSkuName() != null).collect(Collectors.groupingBy(OrderRow::getSkuName, Collectors.counting()));
List<Map.Entry<String, Long>> sortedViolationCounts = skuIdViolationCountMap.entrySet().stream() List<Map.Entry<String, Long>> sortedViolationCounts = skuIdViolationCountMap.entrySet().stream()
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).limit(7).collect(Collectors.toList()); .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).limit(10).collect(Collectors.toList());
for (Map.Entry<String, Long> entry : sortedViolationCounts) { for (Map.Entry<String, Long> entry : sortedViolationCounts) {
String skuName = entry.getKey(); String skuName = entry.getKey();
Long count = entry.getValue(); Long count = entry.getValue();
content.append("商品:").append(skuName).append(" 违规次数:").append(count).append("\r"); content.append("商品:").append(skuName).append(" 违规次数:").append(count).append("\r");
} }
content.append("违规排行:");
} }
break; break;