| | |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.*; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.function.Function; |
| | | import java.util.function.Predicate; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | costStatisticsDto.setDates(null); |
| | | List<CostStatisticsDto> costStatisticsDtos = insOrderMapper.selectCostStatistics2(QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")); |
| | | double totalPrice = costStatisticsDtos.stream() |
| | | .filter(distinctByKey(dto -> Arrays.asList(dto.getEntrustCode(), dto.getSample(), dto.getCost()))) |
| | | .filter(dto -> dto.getPrice() != null) // 过滤掉价格为 null 的对象 |
| | | .mapToDouble(value -> value.getPrice().doubleValue()) |
| | | .sum(); |
| | | map.put("total", totalPrice); |
| | | return map; |
| | | } |
| | | public static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) { |
| | | Map<Object, Boolean> seen = new ConcurrentHashMap<>(); |
| | | return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> selectSampleDefects(Page page, String inspectionItems, String orderNumber) { |