gaoluyang
5 天以前 70ea74cfb981f812bfa4e3ef91843c5ad93f7b27
yudao-module-erp/src/main/java/cn/iocoder/yudao/module/erp/controller/admin/finance/ErpFinancePaymentController.java
@@ -16,6 +16,7 @@
import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpFinancePaymentItemDO;
import cn.iocoder.yudao.module.erp.dal.dataobject.purchase.ErpPurchaseInvoiceDO;
import cn.iocoder.yudao.module.erp.enums.finance.ErpFinancePaymentSourceTypeEnum;
import cn.iocoder.yudao.module.srm.api.supplier.SrmSupplierApi;
import cn.iocoder.yudao.module.srm.api.supplier.dto.SrmSupplierRespDTO;
import cn.iocoder.yudao.module.erp.service.finance.ErpFinancePaymentService;
@@ -88,7 +89,6 @@
    @GetMapping("/approve-process-list")
    @Operation(summary = "获取付款单审批流程列表")
    @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')")
    public CommonResult<List<Map<String, Object>>> getApproveProcessList() {
        return success(financePaymentService.getFinancePaymentApproveProcessDefinitionList());
    }
@@ -105,7 +105,6 @@
    @GetMapping("/get")
    @Operation(summary = "获得付款单")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')")
    public CommonResult<ErpFinancePaymentRespVO> getFinancePayment(@RequestParam("id") Long id) {
        ErpFinancePaymentDO payment = financePaymentService.getFinancePayment(id);
        if (payment == null) {
@@ -127,13 +126,13 @@
        ErpPurchaseInvoiceRespVO invoiceFinal = invoiceVO;
        return BeanUtils.toBean(payment, ErpFinancePaymentRespVO.class, financePaymentVO ->
                financePaymentVO.setInvoice(invoiceFinal)
                .setSourceTypeName(resolveSourceTypeName(payment.getSourceType()))
                .setItems(BeanUtils.toBean(paymentItemList, ErpFinancePaymentRespVO.Item.class))
                .setAttachmentList(storageAttachmentApi.listAttachments("erp_finance_payment", payment.getId())));
    }
    @GetMapping("/page")
    @Operation(summary = "获得付款单分页")
    @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')")
    public CommonResult<PageResult<ErpFinancePaymentRespVO>> getFinancePaymentPage(@Valid ErpFinancePaymentPageReqVO pageReqVO) {
        PageResult<ErpFinancePaymentDO> pageResult = financePaymentService.getFinancePaymentPage(pageReqVO);
        return success(buildFinancePaymentVOPageResult(pageResult));
@@ -149,6 +148,11 @@
        List<ErpFinancePaymentRespVO> list = buildFinancePaymentVOPageResult(financePaymentService.getFinancePaymentPage(pageReqVO)).getList();
        // 导出 Excel
        ExcelUtils.write(response, "付款单.xls", "数据", ErpFinancePaymentRespVO.class, list);
    }
    private String resolveSourceTypeName(Integer sourceType) {
        ErpFinancePaymentSourceTypeEnum sourceTypeEnum = ErpFinancePaymentSourceTypeEnum.valueOf(sourceType);
        return sourceTypeEnum != null ? sourceTypeEnum.getName() : null;
    }
    private PageResult<ErpFinancePaymentRespVO> buildFinancePaymentVOPageResult(PageResult<ErpFinancePaymentDO> pageResult) {
@@ -172,6 +176,7 @@
        // 2. 开始拼接
        return BeanUtils.toBean(pageResult, ErpFinancePaymentRespVO.class, payment -> {
            payment.setItems(BeanUtils.toBean(financePaymentItemMap.get(payment.getId()), ErpFinancePaymentRespVO.Item.class));
            payment.setSourceTypeName(resolveSourceTypeName(payment.getSourceType()));
            MapUtils.findAndThen(supplierMap, payment.getSupplierId(), supplier -> payment.setSupplierName(supplier.getName()));
            MapUtils.findAndThen(userMap, Long.parseLong(payment.getCreator()), user -> payment.setCreatorName(user.getNickname()));
            MapUtils.findAndThen(userMap, payment.getFinanceUserId(), user -> payment.setFinanceUserName(user.getNickname()));