From 52f814aced8d2f1bd7dddb9f2a868492ab3d707d Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期五, 09 一月 2026 16:03:51 +0800
Subject: [PATCH] 生产工单添加工序,同步数量

---
 src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java |   61 ++++++++++++++++++++++++++++++
 1 files changed, 60 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..cbb2e00 100644
--- a/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
+++ b/src/main/java/com/ruoyi/purchase/controller/PurchaseLedgerController.java
@@ -1,5 +1,6 @@
 package com.ruoyi.purchase.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -11,7 +12,10 @@
 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.*;
@@ -19,6 +23,7 @@
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 閲囪喘鍙拌处Controller
@@ -29,10 +34,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 +63,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 +84,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 +191,10 @@
      */
     @GetMapping("/listPage")
     public AjaxResult listPage(Page page, PurchaseLedgerDto purchaseLedger) {
-         return AjaxResult.success(purchaseLedgerService.selectPurchaseLedgerListPage(page ,purchaseLedger));
+        IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = purchaseLedgerService.selectPurchaseLedgerListPage(page ,purchaseLedger);
+        //杩囨护鎺塧pprovalStatus=3鐨勮褰�
+        purchaseLedgerDtoIPage.getRecords().removeIf(purchaseLedgerDto -> purchaseLedgerDto.getApprovalStatus() == 3);
+         return AjaxResult.success(purchaseLedgerDtoIPage);
     }
 
     @ApiOperation("鐢熸垚閲囪喘搴忓垪鍙�")

--
Gitblit v1.9.3