zss
6 天以前 e4f9df46dc6671ae68b3888e3573cea5c43c0eda
refactor(account): 重构财务报表相关代码,完善财务报表功能
已添加2个文件
已重命名1个文件
已修改2个文件
已删除3个文件
260 ■■■■■ 文件已修改
src/main/java/com/ruoyi/account/bean/dto/AccountDto.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/bean/dto/AccountDto2.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/bean/dto/AccountDto3.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/bean/dto/AccountReportDto.java 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/bean/vo/AccountReportVo.java 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/controller/AccountingController.java 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/service/AccountingService.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/service/impl/AccountingServiceImpl.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/bean/dto/AccountDto.java
ÎļþÒÑɾ³ý
src/main/java/com/ruoyi/account/bean/dto/AccountDto2.java
ÎļþÒÑɾ³ý
src/main/java/com/ruoyi/account/bean/dto/AccountDto3.java
ÎļþÒÑɾ³ý
src/main/java/com/ruoyi/account/bean/dto/AccountReportDto.java
ÎļþÃû´Ó src/main/java/com/ruoyi/account/bean/dto/ReportDateDto.java ÐÞ¸Ä
@@ -1,17 +1,16 @@
package com.ruoyi.account.bean.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDate;
/**
 * @author :yys
 * @date : 2026/1/16 16:57
 */
@Data
public class ReportDateDto {
@Schema(name = "AccountReportDto", description = "财务报表--日期参数")
public class AccountReportDto {
    /**
     * å¼€å§‹æ—¶é—´
@@ -26,15 +25,5 @@
    @JsonFormat(pattern = "yyyy-MM-dd")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private LocalDate entryDateEnd;
    /**
     * å¼€å§‹æœˆä»½
     */
    private Integer startMonth;
    /**
     * ç»“束月份
     */
    private Integer endMonth;
}
src/main/java/com/ruoyi/account/bean/vo/AccountReportVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,28 @@
package com.ruoyi.account.bean.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Data
@Schema(name = "AccountReportVo", description = "财务报表--返回参数")
public class AccountReportVo {
    @Schema(description = "总营收")
    private BigDecimal totalIncome;
    @Schema(description = "总支出")
    private BigDecimal totalExpense;
    @Schema(description = "总收入笔数")
    private Integer incomeNumber;
    @Schema(description = "总支出笔数")
    private Integer expenseNumber;
    @Schema(description = "净收入")
    private BigDecimal netRevenue;
}
src/main/java/com/ruoyi/account/controller/AccountingController.java
@@ -1,12 +1,16 @@
package com.ruoyi.account.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.service.impl.AccountingServiceImpl;
import com.ruoyi.account.bean.dto.AccountReportDto;
import com.ruoyi.account.service.AccountingService;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.ruoyi.framework.web.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import lombok.AllArgsConstructor;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@@ -19,11 +23,11 @@
@Tag(name = "会计核算")
@RestController
@RequestMapping("/accounting")
@AllArgsConstructor
@RequiredArgsConstructor
public class AccountingController extends BaseController {
    private AccountingServiceImpl accountingService;
    private final AccountingService accountingService;
    @Operation(summary = "总计")
    @GetMapping("/total")
@@ -43,4 +47,14 @@
        return accountingService.calculateDepreciation(page,year);
    }
    /*****************************************财务报表******************************************************************************/
    @GetMapping("/accountStatementDetailsByMonth")
    @Log(title = "统计总应收+总支出+总收入笔数+总支出笔数+净收入", businessType = BusinessType.OTHER)
    @Operation(summary = "财务报表--统计总应收+总支出+总收入笔数+总支出笔数+净收入")
    public R getAccountStatementDetailsByMonth(AccountReportDto accountReportDto) {
        return R.ok(accountingService.getAccountStatementDetailsByMonth(accountReportDto));
    }
}
src/main/java/com/ruoyi/account/service/AccountingService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,19 @@
package com.ruoyi.account.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.bean.dto.AccountReportDto;
import com.ruoyi.account.bean.vo.AccountReportVo;
import com.ruoyi.framework.web.domain.AjaxResult;
public interface AccountingService {
    AjaxResult total(Integer year);
    AjaxResult deviceTypeDistribution(Integer year);
    AjaxResult calculateDepreciation(Page page, Integer year);
    AccountReportVo getAccountStatementDetailsByMonth(AccountReportDto accountReportDto);
}
src/main/java/com/ruoyi/account/service/impl/AccountingServiceImpl.java
@@ -3,9 +3,17 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.bean.dto.AccountReportDto;
import com.ruoyi.account.bean.dto.DeviceTypeDetail;
import com.ruoyi.account.bean.dto.DeviceTypeDistributionVO;
import com.ruoyi.account.bean.vo.AccountReportVo;
import com.ruoyi.account.mapper.purchase.AccountPurchasePaymentMapper;
import com.ruoyi.account.mapper.sales.AccountSalesCollectionMapper;
import com.ruoyi.account.pojo.purchase.AccountPurchasePayment;
import com.ruoyi.account.pojo.sales.AccountSalesCollection;
import com.ruoyi.account.service.AccountingService;
import com.ruoyi.device.mapper.DeviceLedgerMapper;
import com.ruoyi.device.pojo.DeviceLedger;
import com.ruoyi.framework.web.domain.AjaxResult;
@@ -33,13 +41,17 @@
@Service
@Slf4j
@RequiredArgsConstructor
public class AccountingServiceImpl {
public class AccountingServiceImpl implements AccountingService {
    private final DeviceLedgerMapper deviceLedgerMapper;
    private final CustomStorageMapper customStorageMapper;
    private final ProcurementRecordMapper procurementRecordMapper;
    private final ProcurementRecordOutMapper procurementRecordOutMapper;
    private final AccountSalesCollectionMapper accountSalesCollectionMapper;
    private final AccountPurchasePaymentMapper accountPurchasePaymentMapper;
    @Override
    public AjaxResult total(Integer year) {
        Map<String,Object> map = new HashMap<>();
        map.put("deprAmount",0); // æŠ˜æ—§é‡‘额
@@ -233,6 +245,7 @@
        return totalDepreciation.setScale(2, BigDecimal.ROUND_HALF_UP);
    }
    @Override
    public AjaxResult deviceTypeDistribution(Integer year) {
        // 2. ç»„装返回VO
       DeviceTypeDistributionVO vo = new DeviceTypeDistributionVO();
@@ -256,6 +269,7 @@
        return AjaxResult.success(vo);
    }
    @Override
    public AjaxResult calculateDepreciation(Page page, Integer year) {
        LambdaQueryWrapper<DeviceLedger> deviceLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>();
        deviceLedgerLambdaQueryWrapper.like(DeviceLedger::getCreateTime,year)
@@ -267,4 +281,24 @@
        }
        return AjaxResult.success(deviceLedgerIPage);
    }
    @Override
    public AccountReportVo getAccountStatementDetailsByMonth(AccountReportDto accountReportDto) {
        AccountReportVo accountReportVo = new AccountReportVo();
        //总营收=收款单总金额
        //总收入笔数=收款单总笔数
        List<AccountSalesCollection> accountSalesCollections = accountSalesCollectionMapper.selectList(Wrappers.<AccountSalesCollection>lambdaQuery()
                .between(AccountSalesCollection::getCollectionDate, accountReportDto.getEntryDateStart(), accountReportDto.getEntryDateEnd()));
        accountReportVo.setTotalIncome(accountSalesCollections.stream().map(AccountSalesCollection::getCollectionAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
        accountReportVo.setIncomeNumber(accountSalesCollections.size());
        //总支出=付款单总金额
        //总支出笔数=付款单总笔数
        List<AccountPurchasePayment> accountPurchasePayments = accountPurchasePaymentMapper.selectList(Wrappers.<AccountPurchasePayment>lambdaQuery()
                .between(AccountPurchasePayment::getPaymentDate, accountReportDto.getEntryDateStart(), accountReportDto.getEntryDateEnd()));
        accountReportVo.setTotalExpense(accountPurchasePayments.stream().map(AccountPurchasePayment::getPaymentAmount).reduce(BigDecimal.ZERO, BigDecimal::add));
        accountReportVo.setExpenseNumber(accountPurchasePayments.size());
        //净利润=总营收-总支出
        accountReportVo.setNetRevenue(accountReportVo.getTotalIncome().subtract(accountReportVo.getTotalExpense()));
        return accountReportVo;
    }
}