From bc2511f841b01c0a6cc62a621246eb6594ebf4db Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期一, 22 十二月 2025 16:27:44 +0800
Subject: [PATCH] 创建工序表
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 86 +++++++++++++++++++++++++++++++++++++++---
1 files changed, 79 insertions(+), 7 deletions(-)
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 37366dc..2065238 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -8,6 +8,9 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ruoyi.account.pojo.AccountExpense;
+import com.ruoyi.account.pojo.AccountIncome;
+import com.ruoyi.account.service.AccountIncomeService;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.pojo.Customer;
import com.ruoyi.common.enums.FileNameType;
@@ -16,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;
@@ -62,6 +69,7 @@
@RequiredArgsConstructor
@Slf4j
public class SalesLedgerServiceImpl extends ServiceImpl<SalesLedgerMapper, SalesLedger> implements ISalesLedgerService {
+ private final AccountIncomeService accountIncomeService;
private final SalesLedgerMapper salesLedgerMapper;
@@ -78,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;
@@ -120,7 +136,8 @@
// 3.鏌ヨ涓婁紶鏂囦欢
LambdaQueryWrapper<CommonFile> salesLedgerFileWrapper = new LambdaQueryWrapper<>();
- salesLedgerFileWrapper.eq(CommonFile::getCommonId, salesLedger.getId());
+ salesLedgerFileWrapper.eq(CommonFile::getCommonId, salesLedger.getId())
+ .eq(CommonFile::getType, FileNameType.SALE.getValue());
List<CommonFile> salesLedgerFiles = commonFileMapper.selectList(salesLedgerFileWrapper);
// 4. 杞崲 DTO
@@ -343,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);
}
@@ -376,13 +423,38 @@
salesLedger.setCustomerName(customer.getCustomerName());
salesLedger.setTenantId(customer.getTenantId());
+ AccountIncome accountIncome = new AccountIncome();
+ accountIncome.setIncomeDate(salesLedger.getEntryDate());
+ accountIncome.setIncomeType("0");
+ accountIncome.setCustomerName(customer.getCustomerName());
+ accountIncome.setIncomeMoney(salesLedger.getContractAmount());
+ accountIncome.setIncomeMethod("0");
+ accountIncome.setInputTime(new Date());
+ accountIncome.setInputUser(salesLedger.getEntryPerson());
// 3. 鏂板鎴栨洿鏂颁富琛�
if (salesLedger.getId() == null) {
String contractNo = generateSalesContractNo();
salesLedger.setSalesContractNo(contractNo);
salesLedgerMapper.insert(salesLedger);
+ accountIncome.setIncomeDescribed("閿�鍞悎鍚岋細" + salesLedger.getSalesContractNo());
+ accountIncome.setInvoiceNumber(salesLedger.getSalesContractNo());
+ accountIncomeService.save(accountIncome);
} else {
salesLedgerMapper.updateById(salesLedger);
+ SalesLedger salesLedgerDB = salesLedgerMapper.selectById(salesLedger.getId());
+ List<AccountIncome> accountIncomeDBs = accountIncomeService.getByInvoiceNumberList(salesLedger.getSalesContractNo());
+ if (!org.springframework.util.CollectionUtils.isEmpty(accountIncomeDBs)) {
+ accountIncomeDBs.forEach(accountIncomeDB -> {
+ accountIncomeDB.setCustomerName(salesLedgerDB.getCustomerName());
+ accountIncomeDB.setIncomeMoney(salesLedgerDB.getContractAmount());
+ accountIncomeDB.setIncomeDescribed("閿�鍞悎鍚岋細" + salesLedgerDB.getSalesContractNo());
+ accountIncomeDB.setInvoiceNumber(salesLedgerDB.getSalesContractNo());
+ accountIncomeDB.setInputTime(new Date());
+ accountIncomeDB.setInputUser(salesLedgerDB.getEntryPerson());
+ accountIncomeService.updateById(accountIncomeDB);
+ });
+ }
+
}
// 4. 澶勭悊瀛愯〃鏁版嵁
--
Gitblit v1.9.3