From aa0e37185b47cb59a8f90bcd81c2416ed0f24cfb Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期四, 16 一月 2025 21:26:34 +0800 Subject: [PATCH] 补充 --- ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java b/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java index 13c1741..b39d003 100644 --- a/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java +++ b/ManagementOKTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TDriverController.java @@ -26,6 +26,7 @@ import org.apache.poi.ss.usermodel.*; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; +import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.ui.Model; @@ -42,6 +43,7 @@ import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.*; +import java.util.stream.Collectors; /** * 司机审核列表控制器 @@ -57,6 +59,8 @@ @Autowired private ITDriverService tDriverService; + @Autowired + private ITOrderTaxiService orderTaxiService; @Autowired private ITCompanyService tCompanyService; @@ -578,6 +582,18 @@ Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage(); List<Map<String, Object>> driverList = tDriverService.getDriverList(page, ShiroKit.getUser().getRoleType(), ShiroKit.getUser().getObjectId(), beginTime, endTime, companyName, phone, name, addType, authState); + List<Integer> driverIds = driverList.stream().map(map -> Integer.valueOf(map.get("id").toString())).collect(Collectors.toList()); + // 查询司机订单 + List<TOrderTaxi> orderTaxiList = orderTaxiService.selectList(new EntityWrapper<TOrderTaxi>() + .in("driverId", driverIds)); + // 查询司机所有的收入 + List<TPubTransactionDetails> tPubTransactionDetailsIncome = pubTransactionDetailsService.selectList(new EntityWrapper<TPubTransactionDetails>() + .in("userId", driverIds) + .eq("userType", 2) + .eq("type", 1) + .eq("state",1) + .eq("orderType", 2)); + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); for (Map<String, Object> stringObjectMap : driverList) { // 司机id Integer id = Integer.valueOf(stringObjectMap.get("id").toString()); @@ -596,6 +612,30 @@ String formattedV = df.format(v); stringObjectMap.put("fraction",formattedV); } + + // 司机订单统计 + if(CollectionUtils.isEmpty(orderTaxiList)){ + stringObjectMap.put("dayReceivingOrders", 0); + stringObjectMap.put("sumReceivingOrders", 0); + stringObjectMap.put("dayIncome", 0); + stringObjectMap.put("sumIncome", 0); + }else { + long dayReceivingOrders = orderTaxiList.stream().filter(orderTaxi -> orderTaxi.getDriverId().equals(id) && format.format(orderTaxi.getTravelTime()).equals(format.format(new Date()))).count(); + stringObjectMap.put("dayReceivingOrders", dayReceivingOrders); + long sumReceivingOrders = orderTaxiList.stream().filter(orderTaxi -> orderTaxi.getDriverId().equals(id)).count(); + stringObjectMap.put("sumReceivingOrders", sumReceivingOrders); + // 今日统计收入 + Optional<BigDecimal> dayReduceIncome = tPubTransactionDetailsIncome.stream().filter(pubTransactionDetails -> pubTransactionDetails.getUserId().equals(id) + && format.format(pubTransactionDetails.getInsertTime()).equals(format.format(new Date()))) + .map(TPubTransactionDetails::getMoney).reduce(BigDecimal::add); + dayReduceIncome.ifPresent(bigDecimal -> stringObjectMap.put("dayIncome", bigDecimal)); + + // 过滤所有统计 + Optional<BigDecimal> sumReduceIncome = tPubTransactionDetailsIncome.stream().filter(pubTransactionDetails -> pubTransactionDetails.getUserId().equals(id)) + .map(TPubTransactionDetails::getMoney).reduce(BigDecimal::add); + sumReduceIncome.ifPresent(bigDecimal -> stringObjectMap.put("sumIncome", bigDecimal)); + } + } page.setRecords(driverList); return super.packForBT(page); -- Gitblit v1.7.1