From 56c6afb58c29c785b0a363d1dac183c4b1b2e1aa Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期六, 17 一月 2026 15:53:31 +0800
Subject: [PATCH] Merge branch 'jtwy' into dev_New
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 117 ++++++++++++++++++++++++++--------------------------------
1 files changed, 52 insertions(+), 65 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 06d6437..43d90f8 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -9,25 +9,30 @@
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.mapper.ProductModelMapper;
import com.ruoyi.basic.pojo.Customer;
+import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.common.enums.FileNameType;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.other.mapper.TempFileMapper;
import com.ruoyi.other.pojo.TempFile;
+import com.ruoyi.production.dto.ProductStructureDto;
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
import com.ruoyi.project.system.domain.SysDept;
import com.ruoyi.project.system.mapper.SysDeptMapper;
+import com.ruoyi.quality.mapper.QualityInspectMapper;
+import com.ruoyi.quality.pojo.QualityInspect;
import com.ruoyi.sales.dto.MonthlyAmountDto;
import com.ruoyi.sales.dto.SalesLedgerDto;
import com.ruoyi.sales.mapper.*;
import com.ruoyi.sales.pojo.*;
+import com.ruoyi.sales.service.ISalesLedgerProductService;
import com.ruoyi.sales.service.ISalesLedgerService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@@ -73,6 +78,7 @@
private final CustomerMapper customerMapper;
private final SalesLedgerProductMapper salesLedgerProductMapper;
+ private final SalesLedgerProductServiceImpl salesLedgerProductServiceImpl;
private final CommonFileMapper commonFileMapper;
@@ -86,7 +92,7 @@
private final SalesLedgerWorkMapper salesLedgerWorkMapper;
- private final SalesLedgerProductionAccountingMapper salesLedgerProductionAccountingMapper;
+ private final SalesLedgerProductionAccountingMapper salesLedgerProductionAccountingMapper;
private final InvoiceRegistrationProductMapper invoiceRegistrationProductMapper;
@@ -95,10 +101,21 @@
private final ProductOrderMapper productOrderMapper;
private final ProcessRouteMapper processRouteMapper;
+ private final ProductProcessRouteMapper productProcessRouteMapper;
private final ProcessRouteItemMapper processRouteItemMapper;
private final ProductProcessRouteItemMapper productProcessRouteItemMapper;
+
+ private final ProductWorkOrderMapper productWorkOrderMapper;
+
+ private final ProductionProductMainMapper productionProductMainMapper;
+
+ private final ProductionProductOutputMapper productionProductOutputMapper;
+
+ private final ProductionProductInputMapper productionProductInputMapper;
+
+ private final QualityInspectMapper qualityInspectMapper;
@Autowired
private SysDeptMapper sysDeptMapper;
@@ -111,6 +128,10 @@
private static final long LOCK_EXPIRE_TIME = 30; // 閿佽嚜鍔ㄨ繃鏈熸椂闂达紙绉掞級
private final RedisTemplate<String, String> redisTemplate;
+ @Autowired
+ private ProductModelMapper productModelMapper;
+ @Autowired
+ private ProductStructureMapper productStructureMapper;
@Override
public List<SalesLedger> selectSalesLedgerList(SalesLedgerDto salesLedgerDto) {
@@ -198,8 +219,8 @@
// 鏌ヨ鍘熷鏁版嵁
LambdaQueryWrapper<SalesLedger> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.select(SalesLedger::getCustomerId,
- SalesLedger::getCustomerName,
- SalesLedger::getContractAmount)
+ SalesLedger::getCustomerName,
+ SalesLedger::getContractAmount)
.orderByDesc(SalesLedger::getContractAmount);
List<SalesLedger> records = salesLedgerMapper.selectList(queryWrapper);
@@ -207,7 +228,7 @@
Map<Long, GroupedCustomer> groupedMap = new LinkedHashMap<>(); // 浣跨敤LinkedHashMap淇濇寔鎺掑簭
for (SalesLedger record : records) {
groupedMap.computeIfAbsent(record.getCustomerId(),
- k -> new GroupedCustomer(record.getCustomerId(), record.getCustomerName()))
+ k -> new GroupedCustomer(record.getCustomerId(), record.getCustomerName()))
.addAmount(record.getContractAmount());
}
@@ -366,20 +387,31 @@
return 0;
}
// 鍒犻櫎閿�鍞鐞嗘暟鎹�
- // 1. 鍏堝垹闄ゅ瓙琛ㄦ暟鎹�
- LambdaQueryWrapper<SalesLedgerProduct> productWrapper = new LambdaQueryWrapper<>();
- productWrapper.in(SalesLedgerProduct::getSalesLedgerId, idList);
- salesLedgerProductMapper.delete(productWrapper);
+ LambdaQueryWrapper<SalesLedgerProduct> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.in(SalesLedgerProduct::getSalesLedgerId, idList)
+ .select(SalesLedgerProduct::getId);
+
+ List<SalesLedgerProduct> products = salesLedgerProductMapper.selectList(queryWrapper);
+ List<Long> productIds = products.stream()
+ .map(SalesLedgerProduct::getId)
+ .collect(Collectors.toList());
+ //鍒犻櫎鐢熶骇鏁版嵁
+ salesLedgerProductServiceImpl.deleteProductionData(productIds);
+
+ // 鎵归噺鍒犻櫎浜у搧瀛愯〃
+ if (!productIds.isEmpty()) {
+ salesLedgerProductMapper.deleteBatchIds(productIds);
+ }
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)){
+ 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)){
+ if (CollectionUtils.isNotEmpty(invoiceLedgers)) {
invoiceLedgerIds = invoiceLedgers.stream().map(InvoiceLedger::getId).collect(Collectors.toList());
}
invoiceLedgerMapper.delete(wrapperOne);
@@ -389,12 +421,11 @@
wrapperTwo.in(InvoiceRegistration::getSalesLedgerId, idList);
invoiceRegistrationMapper.delete(wrapperTwo);
- if(CollectionUtils.isNotEmpty(invoiceLedgerIds)){
+ if (CollectionUtils.isNotEmpty(invoiceLedgerIds)) {
LambdaQueryWrapper<ReceiptPayment> wrapperTree = new LambdaQueryWrapper<>();
wrapperTree.in(ReceiptPayment::getInvoiceLedgerId, invoiceLedgerIds);
receiptPaymentMapper.delete(wrapperTree);
}
-
// 鍒犻櫎鐢熶骇绠℃帶鏁版嵁
// 鍒犻櫎鐢熶骇璁㈠崟鏁版嵁
@@ -405,7 +436,7 @@
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);
@@ -427,39 +458,13 @@
SalesLedger salesLedger = convertToEntity(salesLedgerDto);
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. 澶勭悊瀛愯〃鏁版嵁
@@ -585,27 +590,10 @@
salesLedgerProduct.setType(type);
salesLedgerProduct.setNoInvoiceNum(salesLedgerProduct.getQuantity());
salesLedgerProduct.setNoInvoiceAmount(salesLedgerProduct.getTaxInclusiveTotalPrice());
+ salesLedgerProduct.setPendingInvoiceTotal(salesLedgerProduct.getTaxInclusiveTotalPrice());
salesLedgerProductMapper.insert(salesLedgerProduct);
-
- ProductOrder productOrder = new ProductOrder();
- productOrder.setSalesLedgerId(salesLedgerProduct.getSalesLedgerId());
- productOrder.setProductModelId(salesLedgerProduct.getId());
- productOrder.setNpsNo("SC" + String.format("%08d", salesLedgerProduct.getId()));
- productOrderMapper.insert(productOrder);
-
- ProcessRoute processRoute = processRouteMapper.selectOne(new QueryWrapper<ProcessRoute>().lambda().eq(ProcessRoute::getProductModelId, salesLedgerProduct.getProductModelId()));
- if (processRoute != null) {
- List<ProcessRouteItem> processRouteItems = processRouteItemMapper.selectList(new QueryWrapper<ProcessRouteItem>().lambda().eq(ProcessRouteItem::getRouteId, processRoute.getId()));
- for (ProcessRouteItem processRouteItem : processRouteItems) {
- ProductProcessRouteItem productProcessRouteItem = new ProductProcessRouteItem();
- productProcessRouteItem.setProductModelId(productOrder.getProductModelId());
- productProcessRouteItem.setProcessId(processRouteItem.getProcessId());
- productProcessRouteItem.setRouteId(productOrder.getId());
- productProcessRouteItemMapper.insert(productProcessRouteItem);
- }
- productOrder.setRouteId(processRoute.getId());
- productOrderMapper.updateById(productOrder);
- }
+ // 娣诲姞鐢熶骇鏁版嵁
+ salesLedgerProductServiceImpl.addProductionData(salesLedgerProduct);
}
}
}
@@ -659,12 +647,12 @@
return datePart + String.format("%03d", nextSequence);
} finally {
- // 3. 閲婃斁閿侊紙浣跨敤Lua鑴氭湰淇濊瘉鍘熷瓙鎬э紝閬垮厤璇垹鍏朵粬绾跨▼鐨勯攣锛�
+ // 3. 閲婃斁閿�
String luaScript = "if redis.call('GET', KEYS[1]) == ARGV[1] then return redis.call('DEL', KEYS[1]) else return 0 end";
redisTemplate.execute(
new DefaultRedisScript<>(luaScript, Long.class),
Collections.singletonList(lockKey),
- lockValue // 鍙湁鎸佹湁鐩稿悓鍊肩殑绾跨▼鎵嶈兘鍒犻櫎閿�
+ lockValue
);
}
}
@@ -673,7 +661,7 @@
if (sequences.isEmpty()) {
return 1;
}
- // 鎺掑簭鍚庢煡鎵剧涓�涓己澶辩殑姝f暣鏁帮紙涓庡師閫昏緫涓�鑷达級
+ // 鎺掑簭鍚庢煡鎵剧涓�涓己澶辩殑姝f暣鏁�
sequences.sort(Integer::compareTo);
int next = 1;
for (int seq : sequences) {
@@ -703,14 +691,13 @@
.filter(Objects::nonNull)
.reduce(BigDecimal.ZERO, BigDecimal::add);
- // 鏋勯�犱富琛ㄦ洿鏂板璞★紙鏀寔浠绘剰涓昏〃绫诲瀷锛�
+ // 鏋勯�犱富琛ㄦ洿鏂板璞�
try {
S entity = mainEntityClass.getDeclaredConstructor().newInstance();
Field idField = mainEntityClass.getDeclaredField("id");
idField.setAccessible(true);
idField.set(entity, mainId);
- // 璁剧疆 contractAmount 瀛楁锛屾敞鎰忚繖閲屽亣璁惧瓧娈靛悕涓� "contractAmount"
Field amountField = mainEntityClass.getDeclaredField("contractAmount");
amountField.setAccessible(true);
amountField.set(entity, totalAmount);
--
Gitblit v1.9.3