From e43a488b51555d87a4225bfb7dfc93b8f0e95a39 Mon Sep 17 00:00:00 2001
From: maven <2163098428@qq.com>
Date: 星期二, 16 十二月 2025 13:21:41 +0800
Subject: [PATCH] yys 采购,销售删除修改
---
src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java | 3 +
src/main/java/com/ruoyi/purchase/service/impl/PurchaseLedgerServiceImpl.java | 10 ++++
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 54 ++++++++++++++++++++++++---
3 files changed, 60 insertions(+), 7 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 6d548f8..03a7fea 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;
@@ -93,6 +95,8 @@
private final TicketRegistrationMapper ticketRegistrationMapper;
private final ProductRecordMapper productRecordMapper;
+
+ private final PaymentRegistrationMapper paymentRegistrationMapper;
private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
@@ -353,12 +357,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));
}
diff --git a/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java b/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
index 287997d..4d06156 100644
--- a/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
+++ b/src/main/java/com/ruoyi/purchase/service/impl/TicketRegistrationServiceImpl.java
@@ -21,6 +21,7 @@
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;
@@ -271,6 +272,8 @@
// 灏忎簬绛変簬0鍒犻櫎 锛屽ぇ浜�0淇敼
if(subtract.compareTo(BigDecimal.ZERO) <= 0){
ticketRegistrationMapper.deleteById(ticketRegistrations.get(0));
+ // 鍒犻櫎浠樻娴佹按璁板綍
+ paymentRegistrationMapper.delete(new LambdaQueryWrapper<PaymentRegistration>().eq(PaymentRegistration::getTicketRegistrationId, ticketRegistrations.get(0).getId()));
}else if(subtract.compareTo(BigDecimal.ZERO) > 0){
ticketRegistrations.get(0).setInvoiceAmount(subtract);
ticketRegistrationMapper.updateById(ticketRegistrations.get(0));
diff --git a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
index ab9b1ca..2065238 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -19,8 +19,12 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.other.mapper.TempFileMapper;
import com.ruoyi.other.pojo.TempFile;
+import com.ruoyi.production.mapper.SalesLedgerProductionAccountingMapper;
import com.ruoyi.production.mapper.SalesLedgerSchedulingMapper;
+import com.ruoyi.production.mapper.SalesLedgerWorkMapper;
+import com.ruoyi.production.pojo.SalesLedgerProductionAccounting;
import com.ruoyi.production.pojo.SalesLedgerScheduling;
+import com.ruoyi.production.pojo.SalesLedgerWork;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.mapper.SysDeptMapper;
import com.ruoyi.sales.dto.MonthlyAmountDto;
@@ -82,6 +86,14 @@
private final InvoiceLedgerMapper invoiceLedgerMapper;
private final SalesLedgerSchedulingMapper salesLedgerSchedulingMapper;
+
+ private final SalesLedgerWorkMapper salesLedgerWorkMapper;
+
+ private final SalesLedgerProductionAccountingMapper salesLedgerProductionAccountingMapper;
+
+ private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
+
+ private final InvoiceRegistrationMapper invoiceRegistrationMapper;
@Autowired
private SysDeptMapper sysDeptMapper;
@@ -348,20 +360,50 @@
if (CollectionUtils.isEmpty(idList)) {
return 0;
}
- // 鐢熶骇璁㈠崟鏈夊緟鎺掍骇鏁版嵁锛屽彴璐︿笉鍙垹闄�
- LambdaQueryWrapper<SalesLedgerScheduling> salesLedgerSchedulingLambdaQueryWrapper = new LambdaQueryWrapper<SalesLedgerScheduling>()
- .in(SalesLedgerScheduling::getSalesLedgerId, idList);
- if (salesLedgerSchedulingMapper.selectCount(salesLedgerSchedulingLambdaQueryWrapper) > 0) {
- throw new BaseException("鏈夋帓浜ф暟鎹紝涓嶅彲鍒犻櫎");
- }
+ // 鍒犻櫎閿�鍞鐞嗘暟鎹�
// 1. 鍏堝垹闄ゅ瓙琛ㄦ暟鎹�
LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>();
productWrapper.in(SalesLedgerProduct::getSalesLedgerId, idList);
salesLedgerProductMapper.delete(productWrapper);
+
+ LambdaQueryWrapper<InvoiceRegistrationProduct> wrapper = new LambdaQueryWrapper<>();
+ wrapper.in(InvoiceRegistrationProduct::getSalesLedgerId, idList);
+ List<InvoiceRegistrationProduct> invoiceRegistrationProducts = invoiceRegistrationProductMapper.selectList(wrapper);
+ List<Integer> invoiceLedgerIds = new ArrayList<>();
+ if(CollectionUtils.isNotEmpty(invoiceRegistrationProducts)){
+ LambdaQueryWrapper<InvoiceLedger> wrapperOne = new LambdaQueryWrapper<>();
+ wrapperOne.in(InvoiceLedger::getInvoiceRegistrationProductId, invoiceRegistrationProducts.stream().map(InvoiceRegistrationProduct::getId).collect(Collectors.toList()));
+ List<InvoiceLedger> invoiceLedgers = invoiceLedgerMapper.selectList(wrapperOne);
+ if(CollectionUtils.isNotEmpty(invoiceLedgers)){
+ invoiceLedgerIds = invoiceLedgers.stream().map(InvoiceLedger::getId).collect(Collectors.toList());
+ }
+ invoiceLedgerMapper.delete(wrapperOne);
+ }
+ invoiceRegistrationProductMapper.delete(wrapper);
+ LambdaQueryWrapper<InvoiceRegistration> wrapperTwo = new LambdaQueryWrapper<>();
+ wrapperTwo.in(InvoiceRegistration::getSalesLedgerId, idList);
+ invoiceRegistrationMapper.delete(wrapperTwo);
+
+ if(CollectionUtils.isNotEmpty(invoiceLedgerIds)){
+ LambdaQueryWrapper<ReceiptPayment> wrapperTree = new LambdaQueryWrapper<>();
+ wrapperTree.in(ReceiptPayment::getInvoiceLedgerId, invoiceLedgerIds);
+ receiptPaymentMapper.delete(wrapperTree);
+ }
+
+
+ // 鍒犻櫎鐢熶骇绠℃帶鏁版嵁
// 鍒犻櫎鐢熶骇璁㈠崟鏁版嵁
LambdaQueryWrapper<SalesLedgerScheduling> in = new LambdaQueryWrapper<SalesLedgerScheduling>()
.in(SalesLedgerScheduling::getSalesLedgerId, idList);
salesLedgerSchedulingMapper.delete(in);
+ // 鍒犻櫎鐢熶骇娲惧伐鏁版嵁
+ LambdaQueryWrapper<SalesLedgerWork> workOrderWrapper = new LambdaQueryWrapper<>();
+ workOrderWrapper.in(SalesLedgerWork::getSalesLedgerId, idList);
+ salesLedgerWorkMapper.delete(workOrderWrapper);
+ // 鍒犻櫎鐢熶骇鎶ュ伐鏁版嵁
+ LambdaQueryWrapper<SalesLedgerProductionAccounting> reportWrapper = new LambdaQueryWrapper<>();
+ reportWrapper.in(SalesLedgerProductionAccounting::getSalesLedgerId, idList);
+ salesLedgerProductionAccountingMapper.delete(reportWrapper);
// 2. 鍐嶅垹闄や富琛ㄦ暟鎹�
return salesLedgerMapper.deleteBatchIds(idList);
}
--
Gitblit v1.9.3