| | |
| | | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentAuditReqVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentPageReqVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentRespVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.finance.vo.payment.ErpFinancePaymentSaveReqVO; |
| | | import cn.iocoder.yudao.module.erp.controller.admin.purchase.vo.invoice.ErpPurchaseInvoiceRespVO; |
| | | import cn.iocoder.yudao.module.erp.dal.dataobject.finance.ErpAccountDO; |
| | | 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.srm.api.supplier.SrmSupplierApi; |
| | | import cn.iocoder.yudao.module.srm.api.supplier.dto.SrmSupplierRespDTO; |
| | | import cn.iocoder.yudao.module.erp.service.finance.ErpAccountService; |
| | | import cn.iocoder.yudao.module.erp.service.finance.ErpFinancePaymentService; |
| | | import cn.iocoder.yudao.module.erp.service.purchase.ErpPurchaseInvoiceService; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| | | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import java.util.stream.Stream; |
| | | |
| | | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| | |
| | | private SrmSupplierApi srmSupplierApi; |
| | | @Resource |
| | | private ErpAccountService accountService; |
| | | @Resource |
| | | private ErpPurchaseInvoiceService invoiceService; |
| | | |
| | | @Resource |
| | | private AdminUserApi adminUserApi; |
| | |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/update-status") |
| | | @Operation(summary = "更新付款单的状态") |
| | | @PreAuthorize("@ss.hasPermission('erp:finance-payment:update-status')") |
| | | public CommonResult<Boolean> updateFinancePaymentStatus(@RequestParam("id") Long id, |
| | | @RequestParam("status") Integer status) { |
| | | financePaymentService.updateFinancePaymentStatus(id, status); |
| | | @PutMapping("/submit") |
| | | @Operation(summary = "提交付款单审批(未审核 → 审批中),审批人由审批配置统一指定") |
| | | @Parameter(name = "id", description = "编号", required = true) |
| | | @PreAuthorize("@ss.hasPermission('erp:finance-payment:update')") |
| | | public CommonResult<Boolean> submitFinancePayment(@RequestParam("id") Long id) { |
| | | financePaymentService.submitFinancePayment(id); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/audit") |
| | | @Operation(summary = "审核付款单(审批中 → 审核通过/审核不通过),仅审批人本人可操作") |
| | | @PreAuthorize("@ss.hasPermission('erp:finance-payment:audit')") |
| | | public CommonResult<Boolean> auditFinancePayment(@Valid @RequestBody ErpFinancePaymentAuditReqVO auditReqVO) { |
| | | financePaymentService.auditFinancePayment(auditReqVO.getId(), auditReqVO.getPass(), |
| | | auditReqVO.getReviewRemark()); |
| | | return success(true); |
| | | } |
| | | |
| | | @GetMapping("/approver-ids") |
| | | @Operation(summary = "获得付款单的审批人编号集合,供前端判断是否展示审核按钮") |
| | | @PreAuthorize("@ss.hasPermission('erp:finance-payment:query')") |
| | | public CommonResult<Set<Long>> getApproverUserIds() { |
| | | return success(financePaymentService.getFinancePaymentApproverUserIds()); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | |
| | | return success(null); |
| | | } |
| | | List<ErpFinancePaymentItemDO> paymentItemList = financePaymentService.getFinancePaymentItemListByPaymentId(id); |
| | | return success(BeanUtils.toBean(payment, ErpFinancePaymentRespVO.class, financePaymentVO -> |
| | | financePaymentVO.setItems(BeanUtils.toBean(paymentItemList, ErpFinancePaymentRespVO.Item.class)) |
| | | .setAttachmentList(storageAttachmentApi.listAttachments("erp_finance_payment", id)))); |
| | | return success(buildFinancePaymentVO(payment, paymentItemList)); |
| | | } |
| | | |
| | | private ErpFinancePaymentRespVO buildFinancePaymentVO(ErpFinancePaymentDO payment, |
| | | List<ErpFinancePaymentItemDO> paymentItemList) { |
| | | ErpPurchaseInvoiceRespVO invoiceVO = null; |
| | | if (payment.getInvoiceId() != null) { |
| | | ErpPurchaseInvoiceDO invoice = invoiceService.getPurchaseInvoice(payment.getInvoiceId()); |
| | | if (invoice != null) { |
| | | invoiceVO = BeanUtils.toBean(invoice, ErpPurchaseInvoiceRespVO.class); |
| | | } |
| | | } |
| | | ErpPurchaseInvoiceRespVO invoiceFinal = invoiceVO; |
| | | return BeanUtils.toBean(payment, ErpFinancePaymentRespVO.class, financePaymentVO -> |
| | | financePaymentVO.setInvoice(invoiceFinal) |
| | | .setItems(BeanUtils.toBean(paymentItemList, ErpFinancePaymentRespVO.Item.class)) |
| | | .setAttachmentList(storageAttachmentApi.listAttachments("erp_finance_payment", payment.getId()))); |
| | | } |
| | | |
| | | @GetMapping("/page") |
| | |
| | | // 1.4 管理员信息 |
| | | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertListByFlatMap(pageResult.getList(), |
| | | contact -> Stream.of(NumberUtils.parseLong(contact.getCreator()), contact.getFinanceUserId()))); |
| | | // 1.5 来票信息 |
| | | Map<Long, ErpPurchaseInvoiceDO> invoiceMap = invoiceService.getPurchaseInvoiceMap( |
| | | convertSet(pageResult.getList(), ErpFinancePaymentDO::getInvoiceId)); |
| | | // 2. 开始拼接 |
| | | return BeanUtils.toBean(pageResult, ErpFinancePaymentRespVO.class, payment -> { |
| | | payment.setItems(BeanUtils.toBean(financePaymentItemMap.get(payment.getId()), ErpFinancePaymentRespVO.Item.class)); |
| | |
| | | MapUtils.findAndThen(accountMap, payment.getAccountId(), account -> payment.setAccountName(account.getName())); |
| | | MapUtils.findAndThen(userMap, Long.parseLong(payment.getCreator()), user -> payment.setCreatorName(user.getNickname())); |
| | | MapUtils.findAndThen(userMap, payment.getFinanceUserId(), user -> payment.setFinanceUserName(user.getNickname())); |
| | | MapUtils.findAndThen(invoiceMap, payment.getInvoiceId(), invoice -> |
| | | payment.setInvoice(BeanUtils.toBean(invoice, ErpPurchaseInvoiceRespVO.class))); |
| | | }); |
| | | } |
| | | |