每个店铺每个店铺的报表统计 List分组 Map 循环

@Override

public ListfindByFillingDate(String fillingDate) {

List page =courseReportRecordRepository.findByFillingDate("%" + fillingDate +"%");

    List content = page.stream().map(this::getCourseReportRecordDataResponse).collect(Collectors.toList());

    Map> map = groupList(content);

    List list =new ArrayList<>();

    Iterator>> it = map.entrySet().iterator();

    while (it.hasNext()) {

ReportRecordDataResponse response =new ReportRecordDataResponse();

        Map.Entry> entry = it.next();

        //Integer a = 0;

//Integer b = 0;

        entry.getValue().forEach(item -> {

//a=a+item.getRegistrationAmount();

//b=b+item.getExpendituresMoney();

        });

        response.setList(entry.getValue());

        response.setFillingDate(entry.getKey());

        response.setTotalRevenue("0");

        response.setTotalExpenses("0");

        list.add(response);

    }

return list;

}

public Map>groupList(List students) {

Map> map = students.stream().collect(Collectors.groupingBy(CourseReportRecordDataResponse::getFillingDate));

    return map;

}

public CourseReportRecordDataResponsegetCourseReportRecordDataResponse(CourseReportRecord courseReportRecord) {

CourseReportRecordDataResponse dataResponse =new CourseReportRecordDataResponse();

    if (Objects.isNull(courseReportRecord)) {

return dataResponse;

    }

BeanUtils.copyProperties(courseReportRecord, dataResponse);

    CourseShop shop =courseShopRepository.findByShopId(courseReportRecord.getShopId());

    if (!Objects.isNull(shop)) {

dataResponse.setShopName(shop.getName());

    }

//报名人数

    Map regMap =courseReportRecordRepository.findByRegistrationNumber(courseReportRecord.getReportRecordId());

    if (!regMap.isEmpty()) {

dataResponse.setRegistrationNumber(String.valueOf(regMap.get("registrationNumber")));

        dataResponse.setRegistrationAmount(String.valueOf(regMap.get("registrationAmount")));

    }

//销售金额

    Map orderMap =courseReportRecordRepository.findByOrderMoney(courseReportRecord.getReportRecordId());

    if (!orderMap.isEmpty()) {

dataResponse.setOrderMoney(String.valueOf(orderMap.get("orderMoney")));

    }

//今日访客

    Map customerMap =courseReportRecordRepository.findByCustomerNumber(courseReportRecord.getReportRecordId());

    if (!customerMap.isEmpty()) {

dataResponse.setCustomerNumber(String.valueOf(customerMap.get("customerNumber")));

    }

//支出金额

    Map expendituresMap =courseReportRecordRepository.findByDetailsExpenditures(courseReportRecord.getReportRecordId());

;

    if (!expendituresMap.isEmpty()) {

dataResponse.setExpendituresMoney(String.valueOf(expendituresMap.get("expendituresMoney")));

    }

return dataResponse;

}

你可能感兴趣的:(每个店铺每个店铺的报表统计 List分组 Map 循环)