From 34e986e6e158450ee35319f1cac872a4bc974a74 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期五, 16 一月 2026 18:02:41 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New' into dev_New

---
 src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 80 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java b/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
index 21a601e..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));
+    }
     /**
      * 鏌ヨ閲囪喘鍙拌处鍜屼骇鍝佺埗瀛愬垪琛�
      */
@@ -135,7 +194,27 @@
      */
     @GetMapping("/listPage")
     public AjaxResult listPage(Page page, PurchaseLedgerDto purchaseLedger) {
-         return AjaxResult.success(purchaseLedgerService.selectPurchaseLedgerListPage(page ,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("鐢熸垚閲囪喘搴忓垪鍙�")

--
Gitblit v1.9.3