From 11534b3436f18d6a86de5b4993c33c5e14d6160e Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Tue, 7 Jan 2025 16:04:59 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=B1=8Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/LargeScreenController.java | 17 ++++++++++------- .../mapper/material/order/OrderInfoMapper.xml | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/LargeScreenController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/LargeScreenController.java index 05a7cb5..73bdb8e 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/LargeScreenController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/LargeScreenController.java @@ -20,9 +20,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.stream.Collectors; /** @@ -73,11 +71,16 @@ public class LargeScreenController { @GetMapping("/getLeaseCouples") public AjaxResult getLeaseCouples() { List list = orderMapper.getBuyerAndSellerCouples(); - Map> groupedMap = list.stream() + Map> groupedBuyerMap = list.stream() .collect(Collectors.groupingBy(OrderData::getBuyerCompany)); - List> groupedList = new ArrayList<>(groupedMap.values()); - int randomValue = (int) (Math.random() * groupedList.size()); - return AjaxResult.success(groupedList.get(randomValue)); + List> groupedList = new ArrayList<>(groupedBuyerMap.values()); + int randomIndex = (int) (Math.random() * groupedList.size()); + List orderDataList = groupedList.get(randomIndex); + Map> resultMap = new HashMap(); + Map sellerCount = orderDataList.stream() + .collect(Collectors.groupingBy(OrderData::getSellerCompany, Collectors.counting())); + resultMap.put(orderDataList.get(0).getBuyerCompany(), sellerCount); + return AjaxResult.success(resultMap); } @ApiOperation("装备上架统计") diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/order/OrderInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/order/OrderInfoMapper.xml index 5e9a334..aa5d7a4 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/order/OrderInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/order/OrderInfoMapper.xml @@ -472,6 +472,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" LEFT JOIN ma_dev_info mdi on mdi.ma_id=modd.ma_id LEFT JOIN sys_dept sd1 on sd1.dept_id=moi.buyer_company LEFT JOIN sys_dept sd2 on sd2.dept_id=mdi.own_co + where sd2.dept_name is not null order by moi.buyer_company \ No newline at end of file