From 74dfb82a264f1b779e50058145953caca907f6f2 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期四, 18 十二月 2025 16:57:12 +0800
Subject: [PATCH] yys  巡检管理修改

---
 src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
index 8ddfe13..9f9123f 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java
@@ -27,9 +27,11 @@
 import com.ruoyi.project.system.domain.SysUser;
 import com.ruoyi.project.system.mapper.SysUserMapper;
 import com.ruoyi.purchase.dto.PurchaseLedgerDto;
+import com.ruoyi.purchase.mapper.PaymentRegistrationMapper;
 import com.ruoyi.purchase.mapper.ProductRecordMapper;
 import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
 import com.ruoyi.purchase.mapper.TicketRegistrationMapper;
+import com.ruoyi.purchase.pojo.PaymentRegistration;
 import com.ruoyi.purchase.pojo.ProductRecord;
 import com.ruoyi.purchase.pojo.PurchaseLedger;
 import com.ruoyi.purchase.pojo.TicketRegistration;
@@ -94,6 +96,8 @@
 
     private final ProductRecordMapper productRecordMapper;
 
+    private final PaymentRegistrationMapper paymentRegistrationMapper;
+
     private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
 
     private final StringRedisTemplate redisTemplate;
@@ -127,7 +131,8 @@
         if(ObjectUtils.isNotEmpty(loginUser) && null != loginUser.getTenantId()) {
             purchaseLedger.setTenantId(loginUser.getTenantId());
         }
-        purchaseLedger.setSalesContractNo(ObjectUtils.isNotEmpty(salesLedger) ? salesLedger.getSalesContractNo() : null);
+        purchaseLedger.setSalesContractNo(ObjectUtils.isNotEmpty(salesLedger) ? salesLedger.getSalesContractNo() : "");
+        purchaseLedger.setSalesLedgerId(ObjectUtils.isNotEmpty(salesLedger) ? salesLedger.getId() : -1);
         purchaseLedger.setSupplierName(supplierManage.getSupplierName());
         purchaseLedger.setRecorderId(purchaseLedgerDto.getRecorderId());
         purchaseLedger.setRecorderName(sysUser.getNickName());
@@ -353,12 +358,16 @@
         salesLedgerProductMapper.delete(queryWrapper);
         // 鎵归噺鍒犻櫎鍏宠仈鐨勯噰璐彴璐︾殑鏉ョエ鐧昏
         LambdaQueryWrapper<TicketRegistration> ticketRegistrationLambdaQueryWrapper = new LambdaQueryWrapper<>();
-        ticketRegistrationLambdaQueryWrapper.in(TicketRegistration::getSalesLedgerId,ids);
+        ticketRegistrationLambdaQueryWrapper.in(TicketRegistration::getPurchaseLedgerId,ids);
         ticketRegistrationMapper.delete(ticketRegistrationLambdaQueryWrapper);
         // 鎵归噺鍒犻櫎鍏宠仈鐨勯噰璐彴璐︾殑鏉ョエ鐧昏璁板綍
         LambdaQueryWrapper<ProductRecord> productRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
         productRecordLambdaQueryWrapper.in(ProductRecord::getPurchaseLedgerId,ids);
         productRecordMapper.delete(productRecordLambdaQueryWrapper);
+        // 鎵归噺鍒犻櫎浠樻鐧昏
+        LambdaQueryWrapper<PaymentRegistration> paymentRegistrationLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        paymentRegistrationLambdaQueryWrapper.in(PaymentRegistration::getPurchaseLedgerId,ids);
+        paymentRegistrationMapper.delete(paymentRegistrationLambdaQueryWrapper);
         // 鎵归噺鍒犻櫎閲囪喘鍙拌处
         return purchaseLedgerMapper.deleteBatchIds(Arrays.asList(ids));
     }
@@ -379,7 +388,8 @@
 
         // 3.鏌ヨ涓婁紶鏂囦欢
         LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>();
-        salesLedgerFileWrapper.eq(CommonFile::getCommonId, purchaseLedger.getId());
+        salesLedgerFileWrapper.eq(CommonFile::getCommonId, purchaseLedger.getId())
+                .eq(CommonFile::getType, FileNameType.PURCHASE.getValue());
         List<CommonFile> salesLedgerFiles = commonFileMapper.selectList(salesLedgerFileWrapper);
 
         // 4. 杞崲 DTO
@@ -475,7 +485,7 @@
     public IPage<PurchaseLedgerDto> selectPurchaseLedgerListPage(IPage ipage, PurchaseLedgerDto purchaseLedger) {
         IPage<PurchaseLedgerDto> purchaseLedgerDtoIPage = purchaseLedgerMapper.selectPurchaseLedgerListPage(ipage, purchaseLedger);
         purchaseLedgerDtoIPage.getRecords().forEach(purchaseLedgerDto -> {
-            List<CommonFile> commonFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>().eq(CommonFile::getCommonId, purchaseLedgerDto.getId()).eq(CommonFile::getType, FileNameType.PURCHASELEDGER.getValue()));
+            List<CommonFile> commonFiles = commonFileMapper.selectList(new LambdaQueryWrapper<CommonFile>().eq(CommonFile::getCommonId, purchaseLedgerDto.getId()).eq(CommonFile::getType, FileNameType.PURCHASE.getValue()));
             purchaseLedgerDto.setSalesLedgerFiles(commonFiles);
         });
         return purchaseLedgerDtoIPage;

--
Gitblit v1.9.3