2026-08-12 9d3eef8f088bbf4673091b95521daa74ec5c4f7a
src/main/java/com/ruoyi/purchase/controller/AccountingReportController.java
@@ -2,40 +2,103 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.service.purchase.AccountPurchasePaymentService;
import com.ruoyi.basic.service.ISupplierService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.purchase.dto.InvoicePurchaseDto;
import com.ruoyi.purchase.dto.InvoicePurchaseReportDto;
import com.ruoyi.purchase.pojo.InvoicePurchase;
import com.ruoyi.purchase.service.IInvoicePurchaseService;
import io.swagger.annotations.Api;
import com.ruoyi.framework.web.domain.R;
import com.ruoyi.purchase.dto.SavePaymentDto;
import com.ruoyi.purchase.dto.VatDto;
import com.ruoyi.purchase.dto.VatSummaryDto;
import com.ruoyi.purchase.service.PurchaseReportService;
import com.ruoyi.purchase.vo.PurchaseReportVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@Api(tags = "采购报表")
@Tag(name = "采购报表")
@RequestMapping("/purchase/report")
@AllArgsConstructor
public class AccountingReportController {
    @Autowired
    private IInvoicePurchaseService invoicePurchaseService;
    private final ISupplierService supplierService;
    private final PurchaseReportService purchaseReportService;
    private final AccountPurchasePaymentService accountPurchasePaymentService;
    @GetMapping("/list")
    @Log(title = "采购报表-项目利润", businessType = BusinessType.OTHER)
    public AjaxResult list(Page page, InvoicePurchaseReportDto invoicePurchaseReportDto) {
        IPage<InvoicePurchaseReportDto> result =invoicePurchaseService.listPurchaseReport(page, invoicePurchaseReportDto);
        return AjaxResult.success(result);
    public R list(Page page, String customerName) {
        return R.ok(purchaseReportService.list(page, customerName));
    }
    @Log(title = "采购报表-项目利润导出", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @Operation(summary = "采购报表-项目利润导出")
    public void export(HttpServletResponse response, String customerName) {
        List<PurchaseReportVo> list = purchaseReportService.list(new Page(1, -1), customerName).getRecords();
        ExcelUtil<PurchaseReportVo> util = new ExcelUtil<>(PurchaseReportVo.class);
        util.exportExcel(response, list, "项目利润");
    }
    @Log(title = "采购报表-增值税比对", businessType = BusinessType.OTHER)
    @GetMapping("/listVat")
    public AjaxResult listVat(Page page, InvoicePurchase invoicePurchase) {
        IPage<InvoicePurchase> result = invoicePurchaseService.listVat(page, invoicePurchase);
    public R listVat(Page page, String month, String type) {
        return R.ok(purchaseReportService.listVat(page, month, type));
    }
    @Log(title = "采购报表-增值税比对", businessType = BusinessType.EXPORT)
    @PostMapping("/exportTwo")
    @Operation(summary = "采购报表-增值税比对导出")
    public void exportTwo(HttpServletResponse response, String month) {
        List<VatDto> list = purchaseReportService.listVat(new Page(1, -1), month, null).getRecords();
        ExcelUtil<VatDto> util = new ExcelUtil<>(VatDto.class);
        util.exportExcel(response, list, "增值税比对");
    }
    @Log(title = "采购报表-增值税图表数据", businessType = BusinessType.OTHER)
    @GetMapping("/vatChart")
    @Operation(summary = "增值税进销项对比图表数据")
    public R vatChart(String year) {
        List<VatSummaryDto> list = purchaseReportService.vatSummary(year);
        return R.ok(list);
    }
    @GetMapping("/listVatDetail")
    @Operation(summary = "增值税明细-按发票/订单展示")
    public AjaxResult listVatDetail(Page page, String month) {
        IPage<VatDto> result = purchaseReportService.listVatDetail(page, month);
        return AjaxResult.success(result);
    }
    @GetMapping("/supplierTransactions")
    @Log(title = "供应商往来", businessType = BusinessType.OTHER)
    @Operation(summary = "供应商往来")
    public R supplierTransactions(Page page, String supplierName) {
        return R.ok(supplierService.supplierTransactions(page, supplierName));
    }
    @GetMapping("/supplierTransactionsDetails")
    @Log(title = "供应商往来明细", businessType = BusinessType.OTHER)
    @Operation(summary = "供应商往来明细")
    public R supplierTransactionsDetails(Page page, Long supplierId) {
        return R.ok(supplierService.supplierTransactionsDetails(page, supplierId));
    }
    @PostMapping("/savePayment")
    @Log(title = "新增付款", businessType = BusinessType.INSERT)
    @Operation(summary = "新增付款")
    public R savePayment(@RequestBody SavePaymentDto dto) {
        return R.ok(accountPurchasePaymentService.savePayment(dto));
    }
}