From 4d7d9ee75f529c9e1d66f98608edf18221f76acd Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 18 七月 2024 20:53:55 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java | 35 ++---------------------------------
1 files changed, 2 insertions(+), 33 deletions(-)
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
index 103b180..830f53e 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
@@ -473,34 +473,8 @@
map.put("head", PrintChina.printChina(CostStatisticsDto.class));
Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("costStatistics");
if (map1.get("look") == 1) costStatisticsDto.setCreateUser(map1.get("userId"));
- IPage<CostStatisticsDto> costStatisticsDtoIPage = insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59"));
- List<CostStatisticsDto> costStatisticsDtoList = costStatisticsDtoIPage.getRecords();
- for (CostStatisticsDto statisticsDto : costStatisticsDtoList) {
- statisticsDto.setNum(1);
- }
- List<CostStatisticsDto> costStatisticsDtoList1 = deduplicateAndSumCounts(costStatisticsDtoList);
- costStatisticsDtoIPage.setRecords(costStatisticsDtoList1);
- map.put("body", costStatisticsDtoIPage);
+ map.put("body",insOrderMapper.selectCostStatistics(page, QueryWrappers.queryWrappers(costStatisticsDto).ge("create_time", split[0]).le("create_time", split[1] + " 23:59:59")));
return map;
- }
- private static List<CostStatisticsDto> deduplicateAndSumCounts(List<CostStatisticsDto> list) {
- // 浣跨敤涓�涓� Map 鏉ュ瓨鏀惧凡缁忓嚭鐜拌繃鐨� inspectionItem + entrustCode + sample 鐨勭粍鍚�
- Map<String, CostStatisticsDto> map = new HashMap<>();
- // 閬嶅巻鍒楄〃杩涜鍘婚噸鍜岃鏁�
- for (CostStatisticsDto dto : list) {
- String key = dto.getInspectionItem() + dto.getEntrustCode() + dto.getSample();
- if (map.containsKey(key)) {
- // 濡傛灉宸茬粡瀛樺湪锛屽垯绱姞鏁伴噺
- CostStatisticsDto existingDto = map.get(key);
- existingDto.setNum(existingDto.getNum() + dto.getNum());
- existingDto.setPrice(existingDto.getPrice().add(dto.getPrice()));
- } else {
- // 濡傛灉涓嶅瓨鍦紝鍒欐斁鍏� Map 涓�
- map.put(key, dto);
- }
- }
- // 灏� Map 涓殑鍊艰浆涓� List 杩斿洖
- return new ArrayList<>(map.values());
}
@Override
@@ -511,16 +485,11 @@
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())
+ .mapToDouble(value -> value.getPrice().doubleValue()*value.getNum())
.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
--
Gitblit v1.9.3