From f4c9d1b0bbc0d9666180c7f77fb466bd45e10a48 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 16 一月 2026 17:44:22 +0800
Subject: [PATCH] 1.开票台账 2.来漂台账 未开票数量和金额优化
---
src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java | 87 +++++++++++++++++++++++++++++++++++++++++--
1 files changed, 83 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java b/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
index 8f991e3..378a9c3 100644
--- a/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
+++ b/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
@@ -1,6 +1,8 @@
package com.ruoyi.purchase.controller;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
@@ -11,14 +13,20 @@
import com.ruoyi.purchase.dto.PurchaseLedgerDto;
import com.ruoyi.purchase.pojo.PurchaseLedger;
import com.ruoyi.purchase.service.IPurchaseLedgerService;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.sales.service.ISalesLedgerProductService;
import com.ruoyi.sales.service.ISalesLedgerService;
+import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
+import java.math.BigDecimal;
import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
/**
* 閲囪喘鍙拌处Controller
@@ -29,10 +37,12 @@
@RestController
@RequestMapping("/purchase/ledger")
@AllArgsConstructor
+@Api(tags = "111")
public class PurchaseLedgerController extends BaseController {
private IPurchaseLedgerService purchaseLedgerService;
private ISalesLedgerService salesLedgerService;
+ private ISalesLedgerProductService salesLedgerProductService;
/**
* 鏌ヨ閲囪喘鍙拌处鍒楄〃
@@ -56,6 +66,20 @@
}
/**
+ * 瀵煎嚭鏉ョエ鐧昏鍒楄〃
+ */
+ @Log(title = "瀵煎嚭鏉ョエ鐧昏鍒楄〃", businessType = BusinessType.EXPORT)
+ @PostMapping("/exportOne")
+ public void exportOne(HttpServletResponse response, PurchaseLedger purchaseLedger) {
+ Page page = new Page();
+ page.setCurrent(-1);
+ page.setSize(-1);
+ IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = purchaseLedgerService.selectPurchaseLedgerListPage(page, new PurchaseLedgerDto());
+ ExcelUtil<PurchaseLedgerDto> util = new ExcelUtil<PurchaseLedgerDto>(PurchaseLedgerDto.class);
+ util.exportExcel(response, purchaseLedgerDtoIPage.getRecords(), "瀵煎嚭鏉ョエ鐧昏鍒楄〃");
+ }
+
+ /**
* 鏂板淇敼閲囪喘鍙拌处
*/
@Log(title = "閲囪喘鍙拌处", businessType = BusinessType.INSERT)
@@ -63,7 +87,42 @@
public AjaxResult addOrEditPurchase(@RequestBody PurchaseLedgerDto purchaseLedgerDto) throws IOException {
return toAjax(purchaseLedgerService.addOrEditPurchase(purchaseLedgerDto));
}
+ /**
+ * 鏂板閲囪喘妯℃澘
+ */
+ @PostMapping("/addPurchaseTemplate")
+ public AjaxResult addPurchaseTemplate(@RequestBody PurchaseLedgerDto purchaseLedgerDto) throws IOException {
+ return toAjax(purchaseLedgerService.addPurchaseTemplate(purchaseLedgerDto));
+ }
+ /**
+ * 鏌ヨ閲囪喘妯℃澘
+ */
+ @ApiOperation("/2222")
+ @GetMapping("/getPurchaseTemplateList")
+ public AjaxResult getPurchaseTemplateList() {
+ PurchaseLedgerDto purchaseLedgerDto = new PurchaseLedgerDto();
+ purchaseLedgerDto.setApprovalStatus(3);
+ IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = purchaseLedgerService.selectPurchaseLedgerListPage(new Page(1, -1), purchaseLedgerDto);
+ List<PurchaseLedgerDto> purchaseLedgers = purchaseLedgerDtoIPage.getRecords();
+ purchaseLedgers.forEach(purchaseLedgerDto1 -> {
+ LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedgerDto1.getId())
+ .eq(SalesLedgerProduct::getType, 2);
+ List<SalesLedgerProduct> list = salesLedgerProductService.list(queryWrapper);
+ if (!list.isEmpty()) {
+ purchaseLedgerDto1.setProductData(list);
+ }
+ });
+ return AjaxResult.success(purchaseLedgers);
+ }
+ /**
+ * 淇敼閲囪喘鍙拌处瀹℃壒鐘舵��
+ */
+ @PostMapping("/updateApprovalStatus")
+ public AjaxResult addOrEditPurchase(@RequestBody PurchaseLedger purchaseLedger){
+ return toAjax(purchaseLedgerService.updateById(purchaseLedger));
+ }
/**
* 鏌ヨ閲囪喘鍙拌处鍜屼骇鍝佺埗瀛愬垪琛�
*/
@@ -134,14 +193,34 @@
* 鏌ヨ閲囪喘鍙拌处鍒楄〃
*/
@GetMapping("/listPage")
- public IPage<PurchaseLedger> listPage(Page page, PurchaseLedger purchaseLedger) {
- return purchaseLedgerService.selectPurchaseLedgerListPage(page ,purchaseLedger);
+ public AjaxResult listPage(Page page, PurchaseLedgerDto purchaseLedger) {
+ IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = Optional.ofNullable(
+ purchaseLedgerService.selectPurchaseLedgerListPage(page, purchaseLedger)
+ ).orElse(new Page<>());
+
+ // 澶勭悊null
+ Optional.ofNullable(purchaseLedgerDtoIPage.getRecords())
+ .filter(CollectionUtils::isNotEmpty)
+ .ifPresent(records -> {
+ // 杩囨护approvalStatus=3鐨勮褰�
+ records.removeIf(dto -> dto != null && dto.getApprovalStatus() == 3);
+ // 淇鏈敹浠樻閲戦
+ records.forEach(dto -> {
+ if (dto == null) return;
+ BigDecimal unReceiptAmt = Optional.ofNullable(dto.getUnReceiptPaymentAmount()).orElse(BigDecimal.ZERO);
+ if (unReceiptAmt.compareTo(BigDecimal.ZERO) == 0) {
+ dto.setUnReceiptPaymentAmount(Optional.ofNullable(dto.getContractAmount()).orElse(BigDecimal.ZERO));
+ }
+ });
+ });
+
+ return AjaxResult.success(purchaseLedgerDtoIPage);
}
@ApiOperation("鐢熸垚閲囪喘搴忓垪鍙�")
@GetMapping("/createPurchaseNo")
@Log(title = "鐢熸垚閲囪喘搴忓垪鍙�", businessType = BusinessType.OTHER)
- public String createPurchaseNo() {
- return purchaseLedgerService.getPurchaseNo();
+ public AjaxResult createPurchaseNo() {
+ return AjaxResult.success("鐢熸垚鎴愬姛",purchaseLedgerService.getPurchaseNo());
}
}
--
Gitblit v1.9.3