zss
5 天以前 0da945da9f19f45d849fe8b14dc06bb59c5e4283
feat(purchase): 完善采购报表及增值税比对功能
已添加3个文件
已修改7个文件
193 ■■■■■ 文件已修改
src/main/java/com/ruoyi/account/mapper/AccountStatementMapper.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/purchase/controller/AccountingReportController.java 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/purchase/dto/VatDto.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/purchase/service/PurchaseReportService.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/purchase/service/impl/PurchaseReportServiceImpl.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/purchase/vo/PurchaseReportVo.java 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/sales/mapper/SalesLedgerMapper.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/account/AccountStatementMapper.xml 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sales/SalesLedgerMapper.xml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/account/mapper/AccountStatementMapper.java
@@ -6,6 +6,7 @@
import com.ruoyi.account.bean.dto.StatementAccountDto;
import com.ruoyi.account.bean.vo.StatementAccountVo;
import com.ruoyi.account.pojo.AccountStatement;
import com.ruoyi.purchase.dto.VatDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -22,4 +23,6 @@
    IPage<StatementAccountVo> listPageAccountStatement(Page page, @Param("req") StatementAccountDto statementAccountDto);
    IPage<VatDto> selectVatDtoPage(Page page, @Param("month") String month);
}
src/main/java/com/ruoyi/purchase/controller/AccountingReportController.java
@@ -2,10 +2,13 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.framework.web.domain.R;
import com.ruoyi.purchase.dto.VatDto;
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;
@@ -15,6 +18,8 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@Tag(name = "采购报表")
@RequestMapping("/purchase/report")
@@ -22,31 +27,38 @@
public class AccountingReportController {
    private final ISupplierService supplierService;
    private final PurchaseReportService purchaseReportService;
    @GetMapping("/list")
    @Log(title = "采购报表-项目利润", businessType = BusinessType.OTHER)
    public AjaxResult list(Page page) {
        return AjaxResult.success();
    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) {
    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,String month) {
        return AjaxResult.success();
    public R listVat(Page page,String month) {
        return R.ok(purchaseReportService.listVat(page,month));
    }
    @Log(title = "采购报表-增值税比对", businessType = BusinessType.EXPORT)
    @PostMapping("/exportTwo")
    @Operation(summary = "采购报表-增值税比对")
    public void exportTwo(HttpServletResponse response) {
    public void exportTwo(HttpServletResponse response,String month) {
        List<VatDto> list = purchaseReportService.listVat(new Page(1,-1),month).getRecords();
        ExcelUtil<VatDto> util = new ExcelUtil<>(VatDto.class);
        util.exportExcel(response, list , "增值税比对");
    }
    @GetMapping("/supplierTransactions")
src/main/java/com/ruoyi/purchase/dto/VatDto.java
@@ -1,27 +1,30 @@
package com.ruoyi.purchase.dto;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDate;
@Data
@Schema(name = "VatDto", description = "管理驾驶舱--增值税比对参数")
@ExcelIgnoreUnannotated
public class VatDto {
    //月份
    @Excel(name = "月份")
    @Schema(description = "月份")
    private String month ;
    //进项税
    @Excel(name = "进项税额")
    @Excel(name = "销项税额")
    @Schema(description = "销项税额")
    private BigDecimal jTaxAmount;
    //销项税
    @Excel(name = "销项税额")
    @Excel(name = "进项税额")
    @Schema(description = "进项税额")
    private BigDecimal xTaxAmount;
    @Excel(name = "销-进")
    @Schema(description = "销-进")
    private BigDecimal taxAmount;
}
src/main/java/com/ruoyi/purchase/service/PurchaseReportService.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,14 @@
package com.ruoyi.purchase.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.purchase.dto.VatDto;
import com.ruoyi.purchase.vo.PurchaseReportVo;
public interface PurchaseReportService {
    IPage<PurchaseReportVo> list(Page page, String customerName);
    IPage<VatDto> listVat(Page page, String month);
}
src/main/java/com/ruoyi/purchase/service/impl/PurchaseReportServiceImpl.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,32 @@
package com.ruoyi.purchase.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.account.mapper.AccountStatementMapper;
import com.ruoyi.purchase.dto.VatDto;
import com.ruoyi.purchase.service.PurchaseReportService;
import com.ruoyi.purchase.vo.PurchaseReportVo;
import com.ruoyi.sales.mapper.SalesLedgerMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
@RequiredArgsConstructor
public class PurchaseReportServiceImpl implements PurchaseReportService {
    private final SalesLedgerMapper salesLedgerMapper;
    private final AccountStatementMapper accountStatementMapper;
    @Override
    public IPage<PurchaseReportVo> list(Page page, String customerName) {
        return salesLedgerMapper.selectPurchaseReportVoPage(page, customerName);
    }
    @Override
    public IPage<VatDto> listVat(Page page, String month) {
        return accountStatementMapper.selectVatDtoPage(page, month);
    }
}
src/main/java/com/ruoyi/purchase/vo/PurchaseReportVo.java
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,44 @@
package com.ruoyi.purchase.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Data
@Schema(name = "PurchaseReportVo", description = "管理驾驶舱--项目利润参数")
@ExcelIgnoreUnannotated
public class PurchaseReportVo {
    @Schema(description = "销售合同号")
    @Excel(name = "销售合同号")
    private String customerContractNo;
    @Schema(description = "客户名称")
    @Excel(name = "客户名称")
    private String customerName;
    @Schema(description = "项目名称")
    @Excel(name = "项目名称")
    private String projectName;
    @Excel(name = "合同金额")
    @Schema(description = "合同金额")
    private BigDecimal contractAmount;
    @Excel(name = "采购金额")
    @Schema(description = "采购金额")
    private BigDecimal purchaseAmount;
    @Schema(description = "利润")
    @Excel(name = "利润")
    private BigDecimal balance;
    @Schema(description = "利润率")
    @Excel(name = "利润率")
    private BigDecimal balanceRatio;
}
src/main/java/com/ruoyi/sales/mapper/SalesLedgerMapper.java
@@ -6,6 +6,7 @@
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.home.dto.IncomeExpenseAnalysisDto;
import com.ruoyi.purchase.vo.PurchaseReportVo;
import com.ruoyi.sales.dto.SalesLedgerDto;
import com.ruoyi.sales.dto.SalesTrendDto;
import com.ruoyi.sales.dto.StatisticsTableDto;
@@ -86,4 +87,7 @@
    List<SalesTrendDto> statisticsTable(@Param("statisticsTableDto")StatisticsTableDto statisticsTableDto);
    IPage<SalesLedgerDto> listSalesLedgerAndShipped(Page page, @Param("ew") SalesLedgerDto salesLedgerDto);
    IPage<PurchaseReportVo> selectPurchaseReportVoPage(Page page, @Param("customerName") String customerName);
}
src/main/resources/application.yml
@@ -3,7 +3,7 @@
  main:
    allow-circular-references: true
  profiles:
    active: dev
    active: dev-pro
langchain4j:
  mcp:
    # MCP æœåŠ¡ç«¯åœ°å€ï¼ˆæ ¹æ®å®žé™…éƒ¨ç½²çš„ MCP æœåŠ¡è°ƒæ•´ï¼‰
src/main/resources/mapper/account/AccountStatementMapper.xml
@@ -40,4 +40,39 @@
            </if>
    ORDER BY lj.statement_month DESC
    </select>
    <select id="selectVatDtoPage" resultType="com.ruoyi.purchase.dto.VatDto">
    SELECT
        month,
        jTaxAmount,
        xTaxAmount,
        (jTaxAmount - xTaxAmount) AS taxAmount
    FROM (
        SELECT
            month,
            SUM(IF(type = 'purchase', tax_price, 0)) AS xTaxAmount,
            SUM(IF(type = 'sales', tax_price, 0)) AS jTaxAmount
        FROM (
            SELECT
                DATE_FORMAT(issue_date, '%Y-%m') AS month,
                tax_price,
                'sales' AS type
            FROM account_sales_invoice
            WHERE status != 1
            UNION ALL
            SELECT
                DATE_FORMAT(issue_date, '%Y-%m') AS month,
                tax_price,
                'purchase' AS type
            FROM account_purchase_invoice
            WHERE status != 1
        ) AS all_data
    GROUP BY month
    ) AS TT
     <where>
            <if test="month != null">
                and TT.month = #{month}
            </if>
     </where>
    ORDER BY TT.month
    </select>
</mapper>
src/main/resources/mapper/sales/SalesLedgerMapper.xml
@@ -121,5 +121,21 @@
        </if>
        order by sl.execution_date desc
    </select>
    <select id="selectPurchaseReportVoPage" resultType="com.ruoyi.purchase.vo.PurchaseReportVo">
        select sl.sales_contract_no customerContractNo,
               c.customer_name,
               sl.project_name,
               sl.contract_amount contractAmount,
               pl.contract_amount purchaseAmount,
               sl.contract_amount-pl.contract_amount balance,
               (sl.contract_amount-pl.contract_amount)/sl.contract_amount balanceRatio
        from sales_ledger sl
        left join purchase_ledger pl on sl.id = pl.sales_ledger_id
        left join customer c on sl.customer_id = c.id
        where 1=1
        <if test="customerName != null and customerName != '' ">
            and c.customer_name like concat('%',#{customerName},'%')
        </if>
    </select>
</mapper>