From dfe6c610fe4a6b2c99dc9ee66ef8f6fe1c89ceda Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 22 四月 2026 11:19:29 +0800
Subject: [PATCH] feat: 入库审批添加关联订单信息和产品明细
---
src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java | 311 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 307 insertions(+), 4 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 280568a..a740d29 100644
--- a/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
+++ b/src/main/java/com/ruoyi/sales/service/impl/SalesLedgerServiceImpl.java
@@ -9,6 +9,10 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.account.service.AccountIncomeService;
+import com.ruoyi.approve.service.IApproveProcessService;
+import com.ruoyi.approve.vo.ApproveProcessVO;
+import com.ruoyi.approve.pojo.ApproveProcess;
+import com.ruoyi.common.enums.ApproveTypeEnum;
import com.ruoyi.basic.mapper.CustomerMapper;
import com.ruoyi.basic.mapper.ProductMapper;
import com.ruoyi.basic.mapper.ProductModelMapper;
@@ -103,6 +107,9 @@
private static final String LOCK_PREFIX = "contract_no_lock:";
private static final long LOCK_WAIT_TIMEOUT = 10; // 閿佺瓑寰呰秴鏃舵椂闂达紙绉掞級
private static final long LOCK_EXPIRE_TIME = 30; // 閿佽嚜鍔ㄨ繃鏈熸椂闂达紙绉掞級
+ private static final int INBOUND_BIZ_TYPE_WEB = 1;
+ private static final int INBOUND_BIZ_TYPE_SCAN_QUALIFIED = 2;
+ private static final int INBOUND_BIZ_TYPE_SCAN_UNQUALIFIED = 3;
private final AccountIncomeService accountIncomeService;
private final SalesLedgerMapper salesLedgerMapper;
private final CustomerMapper customerMapper;
@@ -144,6 +151,8 @@
private final StockInRecordService stockInRecordService;
private final StockOutRecordService stockOutRecordService;
private final StockUtils stockUtils;
+ @Autowired
+ private IApproveProcessService approveProcessService;
@Autowired
private SysDeptMapper sysDeptMapper;
@@ -418,7 +427,112 @@
@Override
public IPage<SalesLedger> selectSalesLedgerListPage(Page page, SalesLedgerDto salesLedgerDto) {
- return salesLedgerMapper.selectSalesLedgerListPage(page, salesLedgerDto);
+ IPage<SalesLedger> iPage = salesLedgerMapper.selectSalesLedgerListPage(page, salesLedgerDto);
+
+ if (CollectionUtils.isEmpty(iPage.getRecords())) {
+ return iPage;
+ }
+
+ List<Long> salesLedgerIds = iPage.getRecords().stream().map(SalesLedger::getId).collect(Collectors.toList());
+
+ boolean hasWidthHeightFilter = salesLedgerDto.getWidth() != null || salesLedgerDto.getHeight() != null;
+ Map<Long, List<SalesLedgerProduct>> matchedProductsMap = Collections.emptyMap();
+ if (hasWidthHeightFilter) {
+ LambdaQueryWrapper<SalesLedgerProduct> productQueryWrapper = new LambdaQueryWrapper<SalesLedgerProduct>()
+ .in(SalesLedgerProduct::getSalesLedgerId, salesLedgerIds)
+ .eq(SalesLedgerProduct::getType, 1);
+ if (salesLedgerDto.getWidth() != null) {
+ productQueryWrapper.eq(SalesLedgerProduct::getWidth, salesLedgerDto.getWidth());
+ }
+ if (salesLedgerDto.getHeight() != null) {
+ productQueryWrapper.eq(SalesLedgerProduct::getHeight, salesLedgerDto.getHeight());
+ }
+ List<SalesLedgerProduct> matchedProducts = salesLedgerProductMapper.selectList(productQueryWrapper);
+ matchedProductsMap = CollectionUtils.isEmpty(matchedProducts) ? Collections.emptyMap()
+ : matchedProducts.stream().collect(Collectors.groupingBy(SalesLedgerProduct::getSalesLedgerId));
+ }
+
+ List<SalesLedgerProductTotalsDto> productTotals = salesLedgerProductMapper.selectSalesLedgerProductTotals(salesLedgerIds, 1);
+ Map<Long, SalesLedgerProductTotalsDto> productTotalsMap = CollectionUtils.isEmpty(productTotals)
+ ? Collections.emptyMap()
+ : productTotals.stream()
+ .filter(t -> t.getSalesLedgerId() != null)
+ .collect(Collectors.toMap(SalesLedgerProductTotalsDto::getSalesLedgerId, Function.identity(), (a, b) -> a));
+
+ List<InvoiceLedgerDto> invoiceLedgerDtoList = invoiceLedgerMapper.invoicedTotal(salesLedgerIds);
+ if (CollectionUtils.isEmpty(invoiceLedgerDtoList)) {
+ invoiceLedgerDtoList = Collections.emptyList();
+ }
+
+ Map<Long, BigDecimal> invoiceTotals = invoiceLedgerDtoList.stream()
+ .filter(dto -> dto.getSalesLedgerId() != null && dto.getInvoiceTotal() != null)
+ .collect(Collectors.toMap(
+ dto -> dto.getSalesLedgerId().longValue(),
+ InvoiceLedgerDto::getInvoiceTotal,
+ BigDecimal::add
+ ));
+
+ List<ReceiptPayment> receiptPayments = Collections.emptyList();
+ if (!CollectionUtils.isEmpty(salesLedgerIds)) {
+ receiptPayments = receiptPaymentMapper.selectList(new LambdaQueryWrapper<ReceiptPayment>()
+ .in(ReceiptPayment::getSalesLedgerId, salesLedgerIds));
+ }
+
+ Map<Long, BigDecimal> receiptTotals = new HashMap<>();
+ if (!CollectionUtils.isEmpty(receiptPayments)) {
+ for (ReceiptPayment receiptPayment : receiptPayments) {
+ if (receiptPayment.getSalesLedgerId() != null && receiptPayment.getReceiptPaymentAmount() != null) {
+ receiptTotals.merge(receiptPayment.getSalesLedgerId(), receiptPayment.getReceiptPaymentAmount(), BigDecimal::add);
+ }
+ }
+ }
+
+ for (SalesLedger salesLedger : iPage.getRecords()) {
+ Long ledgerId = salesLedger.getId();
+
+ SalesLedgerProductTotalsDto totals = productTotalsMap.get(ledgerId);
+ if (totals != null) {
+ salesLedger.setProductTotalQuantity(totals.getTotalQuantity() != null ? totals.getTotalQuantity() : BigDecimal.ZERO);
+ salesLedger.setProductTotalArea(totals.getTotalArea() != null ? totals.getTotalArea() : BigDecimal.ZERO);
+ } else {
+ salesLedger.setProductTotalQuantity(BigDecimal.ZERO);
+ salesLedger.setProductTotalArea(BigDecimal.ZERO);
+ }
+ if (hasWidthHeightFilter) {
+ salesLedger.setMatchedProducts(matchedProductsMap.getOrDefault(ledgerId, Collections.emptyList()));
+ }
+
+ BigDecimal contractAmount = salesLedger.getContractAmount() == null ? BigDecimal.ZERO : salesLedger.getContractAmount();
+ BigDecimal invoiceTotal = invoiceTotals.getOrDefault(ledgerId, BigDecimal.ZERO);
+ BigDecimal receiptPaymentAmountTotal = receiptTotals.getOrDefault(ledgerId, BigDecimal.ZERO);
+
+ BigDecimal noInvoiceAmountTotal = contractAmount.subtract(invoiceTotal);
+ if (noInvoiceAmountTotal.compareTo(BigDecimal.ZERO) < 0) {
+ noInvoiceAmountTotal = BigDecimal.ZERO;
+ }
+
+ BigDecimal noReceiptPaymentAmountTotal = invoiceTotal.subtract(receiptPaymentAmountTotal);
+ if (noReceiptPaymentAmountTotal.compareTo(BigDecimal.ZERO) < 0) {
+ noReceiptPaymentAmountTotal = BigDecimal.ZERO;
+ }
+
+ salesLedger.setNoInvoiceAmountTotal(noInvoiceAmountTotal);
+ salesLedger.setInvoiceTotal(invoiceTotal);
+ salesLedger.setReceiptPaymentAmountTotal(receiptPaymentAmountTotal);
+ salesLedger.setNoReceiptAmount(noReceiptPaymentAmountTotal);
+
+ boolean hasInvoiceOperation = invoiceTotal.compareTo(BigDecimal.ZERO) > 0;
+ boolean hasReceiptOperation = receiptPaymentAmountTotal.compareTo(BigDecimal.ZERO) > 0;
+ salesLedger.setIsEdit(!(hasInvoiceOperation || hasReceiptOperation));
+ }
+
+ if (salesLedgerDto.getStatus() != null && salesLedgerDto.getStatus()) {
+ iPage.getRecords().removeIf(salesLedger ->
+ Objects.equals(salesLedger.getNoInvoiceAmountTotal(), new BigDecimal("0.00")));
+ iPage.setTotal(iPage.getRecords().size());
+ }
+
+ return iPage;
}
@Override
@@ -1032,6 +1146,11 @@
BigDecimal orderQty = salesLedgerProduct.getQuantity();
salesLedgerProduct.setProductStockStatus(calculateProductStockStatus(stockedQty, orderQty));
salesLedgerProduct.fillRemainingQuantity();
+ ProductModel productModel = productModelMapper.selectById(salesLedgerProduct.getProductModelId());
+ if (productModel == null) {
+ throw new ServiceException("鏂板閿�鍞彴璐﹀け璐�,閿�鍞骇鍝佷笉瀛樺湪");
+ }
+ salesLedgerProduct.setUnit(productModel.getUnit());
salesLedgerProductMapper.insert(salesLedgerProduct);
// 缁戝畾浜у搧棰濆鍔犲伐
// 娓呯┖閿�鍞骇鍝佺粦瀹氱殑鍔犲伐
@@ -1536,6 +1655,7 @@
Set<String> orderNos = groupOrderNos.getOrDefault(key, Collections.emptySet());
group.setSalesContractNo(String.join(",", orderNos));
group.setProductName(productName);
+ group.setSpecificationModel(specificationModel);
Map<String, SalesInvoicesDto.InvoiceItemDto> mergedItems = new LinkedHashMap<>();
BigDecimal groupQty = BigDecimal.ZERO;
@@ -1751,6 +1871,9 @@
if (ledger.getStockStatus() == null) {
throw new ServiceException("鍏ュ簱澶辫触,閿�鍞鍗曞叆搴撶姸鎬佸紓甯�");
}
+ if (ledger.getStockStatus() == 3) {
+ throw new ServiceException("鍏ュ簱澶辫触,璇ラ攢鍞鍗曟鍦ㄥ叆搴撳鎵逛腑,璇峰嬁閲嶅鎻愪氦");
+ }
if (ledger.getStockStatus() == 2) {
throw new ServiceException("鍏ュ簱澶辫触,璇ラ攢鍞鍗曞凡鍏ュ簱,璇峰嬁閲嶅鍏ュ簱");
}
@@ -1763,6 +1886,42 @@
if (salesLedgerProducts == null || salesLedgerProducts.isEmpty()) {
throw new ServiceException("鍏ュ簱澶辫触,鏈煡璇㈠埌璇ラ攢鍞鍗曠殑閿�鍞骇鍝�");
}
+ String approveUserIds = resolveApproveUserIds(dto.getApproveUserIds(), ledger.getId(), INBOUND_BIZ_TYPE_WEB);
+ if (StringUtils.isEmpty(approveUserIds)) {
+ throw new ServiceException("鍏ュ簱澶辫触,璇烽�夋嫨瀹℃壒浜�");
+ }
+
+ String productIds = products.stream().map(String::valueOf).collect(Collectors.joining(","));
+ LoginUser loginUser = SecurityUtils.getLoginUser();
+ ApproveProcessVO approveProcessVO = new ApproveProcessVO();
+ approveProcessVO.setApproveType(ApproveTypeEnum.STOCK_IN.getCode());
+ approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
+ approveProcessVO.setApproveReason("鍏ュ簱瀹℃壒:" + ledger.getSalesContractNo());
+ approveProcessVO.setApproveRemark("salesStock:" + ledger.getId() + ":" + productIds);
+ approveProcessVO.setApproveUserIds(approveUserIds);
+ approveProcessVO.setApproveUser(loginUser.getUserId());
+ approveProcessVO.setApproveTime(LocalDate.now().toString());
+ try {
+ approveProcessService.addApprove(approveProcessVO);
+ } catch (Exception e) {
+ throw new ServiceException("鍏ュ簱瀹℃壒鍙戣捣澶辫触:" + e.getMessage());
+ }
+ // 瀹℃壒涓�
+ ledger.setStockStatus(3);
+ baseMapper.updateById(ledger);
+ }
+
+ @Override
+ public void executeSalesStockApproved(Long salesLedgerId, List<Long> products) {
+ SalesProductStockDto dto = new SalesProductStockDto();
+ dto.setSalesLedgerId(salesLedgerId);
+ dto.setSalesLedgerProducts(products);
+
+ SalesLedger ledger = baseMapper.selectById(dto.getSalesLedgerId());
+ if (ledger == null) {
+ throw new ServiceException("鍏ュ簱澶辫触,閿�鍞鍗曚笉瀛樺湪");
+ }
+ List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(Wrappers.<SalesLedgerProduct>lambdaQuery().in(SalesLedgerProduct::getId, products));
for (SalesLedgerProduct product : salesLedgerProducts) {
if (!Objects.equals(product.getSalesLedgerId(), ledger.getId())) {
throw new ServiceException("鍏ュ簱澶辫触,瀛樺湪涓嶅睘浜庡綋鍓嶉攢鍞鍗曠殑浜у搧");
@@ -1872,11 +2031,71 @@
}
inboundQtyByLineId.merge(inbound.getId(), inboundQty, BigDecimal::add);
}
+ List<SalesLedgerProduct> selectedProducts = salesLedgerProductMapper.selectList(Wrappers.<SalesLedgerProduct>lambdaQuery()
+ .in(SalesLedgerProduct::getId, inboundQtyByLineId.keySet()));
+ if (CollectionUtils.isEmpty(selectedProducts)) {
+ throw new ServiceException("鍏ュ簱澶辫触,鏈煡璇㈠埌鍏ュ簱浜у搧");
+ }
+ if (selectedProducts.size() != inboundQtyByLineId.size()) {
+ throw new ServiceException("鍏ュ簱澶辫触,閮ㄥ垎浜у搧涓嶅瓨鍦�");
+ }
+ for (SalesLedgerProduct selectedProduct : selectedProducts) {
+ if (!Objects.equals(selectedProduct.getSalesLedgerId(), salesLedger.getId())) {
+ throw new ServiceException("鍏ュ簱澶辫触,閿�鍞骇鍝佷笌璁㈠崟涓嶅尮閰�");
+ }
+ if (!Objects.equals(selectedProduct.getType(), SaleEnum.SALE.getCode())) {
+ throw new ServiceException("鍏ュ簱澶辫触,浠呮敮鎸侀攢鍞鍗曚骇鍝佽");
+ }
+ if (selectedProduct.getProductModelId() == null) {
+ throw new ServiceException("鍏ュ簱澶辫触,浜у搧瑙勬牸鏈淮鎶�,鏃犳硶鍏ュ簱");
+ }
+ }
+ String approveUserIds = resolveApproveUserIds(dto.getApproveUserIds(), salesLedger.getId(), INBOUND_BIZ_TYPE_SCAN_QUALIFIED);
+ if (StringUtils.isEmpty(approveUserIds)) {
+ throw new ServiceException("鍏ュ簱澶辫触,璇烽�夋嫨瀹℃壒浜�");
+ }
+ String lines = inboundQtyByLineId.entrySet().stream()
+ .map(e -> e.getKey() + "@" + e.getValue().stripTrailingZeros().toPlainString())
+ .collect(Collectors.joining(","));
+ String reason = "閿�鍞壂鐮佸悎鏍煎叆搴撳鎵�:" + salesLedger.getSalesContractNo();
+ String remark = "scanQualified:" + salesLedger.getId() + ":" + lines;
+ ApproveProcess exist = approveProcessService.getOne(new LambdaQueryWrapper<ApproveProcess>()
+ .eq(ApproveProcess::getApproveType, ApproveTypeEnum.STOCK_IN.getCode())
+ .eq(ApproveProcess::getApproveRemark, remark)
+ .eq(ApproveProcess::getApproveDelete, 0)
+ .orderByDesc(ApproveProcess::getCreateTime)
+ .last("limit 1"));
+ if (exist != null && !Objects.equals(exist.getApproveStatus(), 3)) {
+ throw new ServiceException("鍏ュ簱澶辫触,璇ョ敵璇峰凡鎻愪氦瀹℃壒");
+ }
+ LoginUser loginUser = SecurityUtils.getLoginUser();
+ ApproveProcessVO approveProcessVO = new ApproveProcessVO();
+ approveProcessVO.setApproveType(ApproveTypeEnum.STOCK_IN.getCode());
+ approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
+ approveProcessVO.setApproveReason(reason);
+ approveProcessVO.setApproveRemark(remark);
+ approveProcessVO.setApproveUserIds(approveUserIds);
+ approveProcessVO.setApproveUser(loginUser.getUserId());
+ approveProcessVO.setApproveTime(LocalDate.now().toString());
+ try {
+ approveProcessService.addApprove(approveProcessVO);
+ } catch (Exception e) {
+ throw new ServiceException("鍏ュ簱瀹℃壒鍙戣捣澶辫触:" + e.getMessage());
+ }
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void executeSalesScanInboundApproved(Long salesLedgerId, Map<Long, BigDecimal> inboundQtyByLineId) {
+ SalesLedger salesLedger = baseMapper.selectById(salesLedgerId);
+ if (salesLedger == null) {
+ throw new ServiceException("鍏ュ簱澶辫触,閿�鍞鍗曚笉瀛樺湪");
+ }
Long ledgerId = salesLedger.getId();
for (Map.Entry<Long, BigDecimal> entry : inboundQtyByLineId.entrySet()) {
Long salesLedgerProductId = entry.getKey();
BigDecimal inboundThisLine = entry.getValue();
- if (inboundThisLine.compareTo(BigDecimal.ZERO) == 0) {
+ if (inboundThisLine == null || inboundThisLine.compareTo(BigDecimal.ZERO) <= 0) {
continue;
}
SalesLedgerProduct dbProduct = salesLedgerProductMapper.selectById(salesLedgerProductId);
@@ -1959,11 +2178,71 @@
}
inboundQtyByLineId.merge(inbound.getId(), inboundQty, BigDecimal::add);
}
+ List<SalesLedgerProduct> selectedProducts = salesLedgerProductMapper.selectList(Wrappers.<SalesLedgerProduct>lambdaQuery()
+ .in(SalesLedgerProduct::getId, inboundQtyByLineId.keySet()));
+ if (CollectionUtils.isEmpty(selectedProducts)) {
+ throw new ServiceException("涓嶅悎鏍煎叆搴撳け璐�,鏈煡璇㈠埌鍏ュ簱浜у搧");
+ }
+ if (selectedProducts.size() != inboundQtyByLineId.size()) {
+ throw new ServiceException("涓嶅悎鏍煎叆搴撳け璐�,閮ㄥ垎浜у搧涓嶅瓨鍦�");
+ }
+ for (SalesLedgerProduct selectedProduct : selectedProducts) {
+ if (!Objects.equals(selectedProduct.getSalesLedgerId(), salesLedger.getId())) {
+ throw new ServiceException("涓嶅悎鏍煎叆搴撳け璐�,閿�鍞骇鍝佷笌璁㈠崟涓嶅尮閰�");
+ }
+ if (!Objects.equals(selectedProduct.getType(), SaleEnum.SALE.getCode())) {
+ throw new ServiceException("涓嶅悎鏍煎叆搴撳け璐�,浠呮敮鎸侀攢鍞鍗曚骇鍝佽");
+ }
+ if (selectedProduct.getProductModelId() == null) {
+ throw new ServiceException("涓嶅悎鏍煎叆搴撳け璐�,浜у搧瑙勬牸鏈淮鎶�,鏃犳硶鍏ュ簱");
+ }
+ }
+ String approveUserIds = resolveApproveUserIds(dto.getApproveUserIds(), salesLedger.getId(), INBOUND_BIZ_TYPE_SCAN_UNQUALIFIED);
+ if (StringUtils.isEmpty(approveUserIds)) {
+ throw new ServiceException("涓嶅悎鏍煎叆搴撳け璐�,璇烽�夋嫨瀹℃壒浜�");
+ }
+ String lines = inboundQtyByLineId.entrySet().stream()
+ .map(e -> e.getKey() + "@" + e.getValue().stripTrailingZeros().toPlainString())
+ .collect(Collectors.joining(","));
+ String reason = "閿�鍞壂鐮佷笉鍚堟牸鍏ュ簱瀹℃壒:" + salesLedger.getSalesContractNo();
+ String remark = "scanUnqualified:" + salesLedger.getId() + ":" + lines;
+ ApproveProcess exist = approveProcessService.getOne(new LambdaQueryWrapper<ApproveProcess>()
+ .eq(ApproveProcess::getApproveType, ApproveTypeEnum.STOCK_IN.getCode())
+ .eq(ApproveProcess::getApproveRemark, remark)
+ .eq(ApproveProcess::getApproveDelete, 0)
+ .orderByDesc(ApproveProcess::getCreateTime)
+ .last("limit 1"));
+ if (exist != null && !Objects.equals(exist.getApproveStatus(), 3)) {
+ throw new ServiceException("涓嶅悎鏍煎叆搴撳け璐�,璇ョ敵璇峰凡鎻愪氦瀹℃壒");
+ }
+ LoginUser loginUser = SecurityUtils.getLoginUser();
+ ApproveProcessVO approveProcessVO = new ApproveProcessVO();
+ approveProcessVO.setApproveType(ApproveTypeEnum.STOCK_IN.getCode());
+ approveProcessVO.setApproveDeptId(loginUser.getCurrentDeptId());
+ approveProcessVO.setApproveReason(reason);
+ approveProcessVO.setApproveRemark(remark);
+ approveProcessVO.setApproveUserIds(approveUserIds);
+ approveProcessVO.setApproveUser(loginUser.getUserId());
+ approveProcessVO.setApproveTime(LocalDate.now().toString());
+ try {
+ approveProcessService.addApprove(approveProcessVO);
+ } catch (Exception e) {
+ throw new ServiceException("涓嶅悎鏍煎叆搴撳鎵瑰彂璧峰け璐�:" + e.getMessage());
+ }
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void executeSalesScanInboundUnqualifiedApproved(Long salesLedgerId, Map<Long, BigDecimal> inboundQtyByLineId) {
+ SalesLedger salesLedger = baseMapper.selectById(salesLedgerId);
+ if (salesLedger == null) {
+ throw new ServiceException("涓嶅悎鏍煎叆搴撳け璐�,閿�鍞鍗曚笉瀛樺湪");
+ }
Long ledgerId = salesLedger.getId();
for (Map.Entry<Long, BigDecimal> entry : inboundQtyByLineId.entrySet()) {
Long salesLedgerProductId = entry.getKey();
BigDecimal inboundThisLine = entry.getValue();
- if (inboundThisLine.compareTo(BigDecimal.ZERO) == 0) {
+ if (inboundThisLine == null || inboundThisLine.compareTo(BigDecimal.ZERO) <= 0) {
continue;
}
SalesLedgerProduct dbProduct = salesLedgerProductMapper.selectById(salesLedgerProductId);
@@ -1981,7 +2260,6 @@
}
stockUtils.addUnStock(ledgerId, dbProduct.getId(), dbProduct.getProductModelId(), inboundThisLine,
StockInUnQualifiedRecordTypeEnum.SALES_SCAN_UNSTOCK_IN.getCode(), dbProduct.getId());
-
BigDecimal oldUnStocked = dbProduct.getUnqualifiedStockedQuantity() == null ? BigDecimal.ZERO : dbProduct.getUnqualifiedStockedQuantity();
dbProduct.setUnqualifiedStockedQuantity(oldUnStocked.add(inboundThisLine));
dbProduct.fillRemainingQuantity();
@@ -1989,6 +2267,31 @@
}
}
+ private String resolveApproveUserIds(String approveUserIds, Long salesLedgerId, Integer bizType) {
+ if (StringUtils.isNotEmpty(approveUserIds)) {
+ return approveUserIds;
+ }
+ LambdaQueryWrapper<ApproveProcess> wrapper = new LambdaQueryWrapper<ApproveProcess>()
+ .eq(ApproveProcess::getApproveType, ApproveTypeEnum.STOCK_IN.getCode())
+ .eq(ApproveProcess::getApproveDelete, 0)
+ .orderByDesc(ApproveProcess::getCreateTime)
+ .last("limit 1");
+ if (Objects.equals(bizType, INBOUND_BIZ_TYPE_WEB)) {
+ wrapper.likeRight(ApproveProcess::getApproveReason, "鍏ュ簱瀹℃壒:")
+ .likeRight(ApproveProcess::getApproveRemark, "salesStock:" + salesLedgerId + ":");
+ } else if (Objects.equals(bizType, INBOUND_BIZ_TYPE_SCAN_QUALIFIED)) {
+ wrapper.likeRight(ApproveProcess::getApproveReason, "閿�鍞壂鐮佸悎鏍煎叆搴撳鎵�:")
+ .likeRight(ApproveProcess::getApproveRemark, "scanQualified:" + salesLedgerId + ":");
+ } else if (Objects.equals(bizType, INBOUND_BIZ_TYPE_SCAN_UNQUALIFIED)) {
+ wrapper.likeRight(ApproveProcess::getApproveReason, "閿�鍞壂鐮佷笉鍚堟牸鍏ュ簱瀹℃壒:")
+ .likeRight(ApproveProcess::getApproveRemark, "scanUnqualified:" + salesLedgerId + ":");
+ } else {
+ return null;
+ }
+ ApproveProcess latest = approveProcessService.getOne(wrapper);
+ return latest == null ? null : latest.getApproveUserIds();
+ }
+
@Override
@Transactional(rollbackFor = Exception.class)
public void scanOutbound(SalesScanInboundDto dto) {
--
Gitblit v1.9.3