| | |
| | | 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; |
| | |
| | | |
| | | @GetMapping("/approve-process-list") |
| | | @Operation(summary = "获取付款单审批流程列表") |
| | | @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')") |
| | | public CommonResult<List<Map<String, Object>>> getApproveProcessList() { |
| | | return success(financePaymentService.getFinancePaymentApproveProcessDefinitionList()); |
| | | } |
| | |
| | | @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) { |
| | |
| | | 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)); |
| | |
| | | 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) { |
| | |
| | | // 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())); |