buhuazhen
6 天以前 161c5e12e3d7f5e2f4345ed3609fe05037ea2b23
  feat: 大屏调整
已修改4个文件
129 ■■■■■ 文件已修改
src/main/java/com/ruoyi/account/service/impl/AccountExpenseServiceImpl.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/home/controller/HomeController.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/home/service/HomeService.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java 90 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/service/impl/AccountExpenseServiceImpl.java
@@ -155,35 +155,44 @@
    @Override
    public Map<String, List<String>> analysis() {
        // 获取本周的时间范围
        LocalDate startOfWeek = LocalDate.now().with(DayOfWeek.MONDAY);
        LocalDate endOfWeek = LocalDate.now().with(DayOfWeek.SUNDAY);
        // 统计最近12个月的数据
        LocalDate today = LocalDate.now();
        Map<String, List<String>> result = new HashMap<>();
        List<String> days = new ArrayList<>();
        List<String> months = new ArrayList<>();
        List<String> totalIncomeList = new ArrayList<>();
        List<String> totalExpenseList = new ArrayList<>();
        List<String> netIncomeList = new ArrayList<>();
        // 根据时间范围循环查询每一天的总收入,总支出,净收入(总收入-总支出)
        for (LocalDate date = startOfWeek; date.isBefore(endOfWeek) || date.isEqual(endOfWeek); date = date.plusDays(1)) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM");
        // 从当前月份往前推12个月
        for (int i = 0; i < 12; i++) {
            LocalDate monthDate = today.minusMonths(i);
            LocalDate startOfMonth = monthDate.withDayOfMonth(1);
            LocalDate endOfMonth = monthDate.withDayOfMonth(monthDate.lengthOfMonth());
            // 查询该月的总收入
            BigDecimal totalIncome = accountIncomeMapper.selectList(Wrappers.<AccountIncome>lambdaQuery()
                    .eq(AccountIncome::getInputTime, date.toString()))
                    .between(AccountIncome::getInputTime, startOfMonth.toString(), endOfMonth.toString()))
                    .stream()
                    .map(AccountIncome::getIncomeMoney)
                    .filter(Objects::nonNull)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            // 查询该月的总支出
            BigDecimal totalExpense = accountExpenseMapper.selectList(Wrappers.<AccountExpense>lambdaQuery()
                    .eq(AccountExpense::getInputTime, date.toString()))
                    .between(AccountExpense::getInputTime, startOfMonth.toString(), endOfMonth.toString()))
                    .stream()
                    .map(AccountExpense::getExpenseMoney)
                    .filter(Objects::nonNull)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            BigDecimal netIncome = totalIncome.subtract(totalExpense);
            days.add(date.toString());
            months.add(monthDate.format(formatter));
            totalIncomeList.add(totalIncome.toString());
            totalExpenseList.add(totalExpense.toString());
            netIncomeList.add(netIncome.toString());
        }
        result.put("days", days);  //  天
        result.put("months", months);  // 月份
        result.put("totalIncome", totalIncomeList); // 收入
        result.put("totalExpense", totalExpenseList); // 支出
        result.put("netIncome", netIncomeList); // 净收入
src/main/java/com/ruoyi/home/controller/HomeController.java
@@ -53,6 +53,14 @@
        return AjaxResult.success(analysisCustomerContractAmounts);
    }
    @GetMapping("/analysisSupplierContractAmounts")
    @Log(title = "供应商合同金额分析", businessType = BusinessType.OTHER)
    @ApiOperation("供应商合同金额分析")
    public AjaxResult analysisSupplierContractAmounts(AnalysisCustomerContractAmountsDto req) {
        AnalysisCustomerContractAmountsDto analysisSupplierContractAmounts = homeService.analysisSupplierContractAmounts();
        return AjaxResult.success(analysisSupplierContractAmounts);
    }
    @GetMapping("/qualityStatistics")
    @Log(title = "质量分析", businessType = BusinessType.OTHER)
    @ApiOperation("质量分析")
src/main/java/com/ruoyi/home/service/HomeService.java
@@ -21,6 +21,8 @@
    AnalysisCustomerContractAmountsDto analysisCustomerContractAmounts();
    AnalysisCustomerContractAmountsDto analysisSupplierContractAmounts();
    QualityStatisticsDto qualityStatistics();
    List<ApproveProcess> todos() throws ParseException;
src/main/java/com/ruoyi/home/service/impl/HomeServiceImpl.java
@@ -258,6 +258,96 @@
        return analysisCustomerContractAmountsDto;
    }
    @Override
    public AnalysisCustomerContractAmountsDto analysisSupplierContractAmounts() {
        List<PurchaseLedger> purchaseLedgers = purchaseLedgerMapper.selectList(null);
        // 合计合同金额
        BigDecimal contractAmount = purchaseLedgers.stream().map(PurchaseLedger::getContractAmount)
                .filter(Objects::nonNull)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        // 计算周同比
        // 获取当前时间
        LocalDate today = LocalDate.now();
        // 获取本周周一
        LocalDate startOfWeek = today.with(DayOfWeek.MONDAY);
        // 获取本周周日
        LocalDate endOfWeek = today.with(DayOfWeek.SUNDAY);
        List<PurchaseLedger> purchaseLedgers1 = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>()
                .ge(PurchaseLedger::getEntryDate, startOfWeek)  // 大于等于本周周一
                .lt(PurchaseLedger::getEntryDate, endOfWeek.plusDays(1))); // 使用 lt 并加上一天来包含周日
        BigDecimal weekContractAmount = purchaseLedgers1.stream().map(PurchaseLedger::getContractAmount)
                .filter(Objects::nonNull)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        // 获取去年本周时间
        LocalDate lastYearStartOfWeek = today.minusYears(1).with(DayOfWeek.MONDAY);
        LocalDate lastYearEndOfWeek = today.minusYears(1).with(DayOfWeek.SUNDAY);
        List<PurchaseLedger> purchaseLedgers2 = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>()
                .ge(PurchaseLedger::getEntryDate, lastYearStartOfWeek)  // 大于等于去年本周周一
                .lt(PurchaseLedger::getEntryDate, lastYearEndOfWeek.plusDays(1))); // 使用 lt 并加上一天来包含周日
        BigDecimal lastYearWeekContractAmount = purchaseLedgers2.stream().map(PurchaseLedger::getContractAmount)
                .filter(Objects::nonNull)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal subtract = weekContractAmount.subtract(lastYearWeekContractAmount);
        String weekYny = "";
        // 周同比
        if(subtract.compareTo(BigDecimal.ZERO) == 0 || lastYearWeekContractAmount.compareTo(BigDecimal.ZERO) == 0){
            weekYny = "0.00";
        }else{
            weekYny = String.format("%.2f", subtract.divide(lastYearWeekContractAmount, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")));
        }
        // 计算日环比
        LocalDate yesterday = today.minusDays(1);
        LocalDate plusDays = today.plusDays(1);
        List<PurchaseLedger> purchaseLedgers3 = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>()
                .ge(PurchaseLedger::getEntryDate, today)  // 大于等于今天
                .lt(PurchaseLedger::getEntryDate, plusDays)); // 使用 lt 并加上一天来包含当天
        BigDecimal todayContractAmount = purchaseLedgers3.stream().map(PurchaseLedger::getContractAmount)
                .filter(Objects::nonNull)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        List<PurchaseLedger> purchaseLedgers4 = purchaseLedgerMapper.selectList(new LambdaQueryWrapper<PurchaseLedger>()
                .ge(PurchaseLedger::getEntryDate, yesterday)  // 大于等于昨天
                .lt(PurchaseLedger::getEntryDate, today)); // 使用 lt
        BigDecimal yesterdayContractAmount = purchaseLedgers4.stream().map(PurchaseLedger::getContractAmount)
                .filter(Objects::nonNull)
                .reduce(BigDecimal.ZERO, BigDecimal::add);
        BigDecimal subtract1 = todayContractAmount.subtract(yesterdayContractAmount);
        // 日环比
        String chain = "";
        if(subtract1.compareTo(BigDecimal.ZERO) == 0 || yesterdayContractAmount.compareTo(BigDecimal.ZERO) == 0){
            chain = "0.00";
        }else{
            chain = String.format("%.2f", subtract1.divide(yesterdayContractAmount, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100")));
        }
        AnalysisCustomerContractAmountsDto analysisCustomerContractAmountsDto = new AnalysisCustomerContractAmountsDto();
        // 将合同金额保留两位小数
        analysisCustomerContractAmountsDto.setSum(contractAmount.setScale(2, RoundingMode.HALF_UP).toString());
        analysisCustomerContractAmountsDto.setYny(weekYny);
        analysisCustomerContractAmountsDto.setChain(chain);
        // 按供应商名称分组统计
        Map<String, BigDecimal> collect = purchaseLedgers.stream().collect(Collectors.groupingBy(PurchaseLedger::getSupplierName, Collectors.reducing(BigDecimal.ZERO,
                PurchaseLedger::getContractAmount, BigDecimal::add)));
        List<MapDto> mapDtos = new ArrayList<>();
        collect.forEach((k,v)->{
            MapDto mapDto = new MapDto();
            mapDto.setName(k);
            // 将金额值保留两位小数
            mapDto.setValue(v.setScale(2, RoundingMode.HALF_UP).toString());
            if(contractAmount.compareTo(new BigDecimal(0)) == 0){
                mapDto.setRate("0");
            }else{
                mapDto.setRate(String.format("%.2f", v.divide(contractAmount, 2, RoundingMode.HALF_UP).multiply(new BigDecimal("100"))));
            }
            mapDtos.add(mapDto);
        });
        analysisCustomerContractAmountsDto.setItem(mapDtos);
        return analysisCustomerContractAmountsDto;
    }
    @Override
    public QualityStatisticsDto qualityStatistics() {