From 6c95c2f6a3602fe6f92898dd322c20bbe955e69d Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 21 四月 2026 18:03:20 +0800
Subject: [PATCH] feat: 成品入库增加审批环节,原材质检后提交入库时增加一个审批环节
---
src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java | 120 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 119 insertions(+), 1 deletions(-)
diff --git a/src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java b/src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java
index d8802c7..ee1d11d 100644
--- a/src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java
+++ b/src/main/java/com/ruoyi/approve/service/impl/ApproveNodeServiceImpl.java
@@ -13,7 +13,6 @@
import com.ruoyi.approve.service.IApproveNodeService;
import com.ruoyi.common.enums.FileNameType;
import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
-import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.device.mapper.DeviceRepairMapper;
import com.ruoyi.device.pojo.DeviceRepair;
@@ -32,6 +31,8 @@
import com.ruoyi.sales.pojo.SalesQuotation;
import com.ruoyi.sales.pojo.ShippingInfo;
import com.ruoyi.sales.service.ShippingInfoService;
+import com.ruoyi.sales.service.ISalesLedgerService;
+import com.ruoyi.quality.service.IQualityInspectService;
import com.ruoyi.sales.service.impl.CommonFileServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
@@ -39,6 +40,7 @@
import org.springframework.util.CollectionUtils;
import java.io.IOException;
+import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Comparator;
@@ -91,6 +93,12 @@
@Autowired
@Lazy
private ShippingInfoService shippingInfoService;
+ @Autowired
+ @Lazy
+ private ISalesLedgerService salesLedgerService;
+ @Autowired
+ @Lazy
+ private IQualityInspectService qualityInspectService;
public ApproveProcess getApproveById(String id) {
@@ -208,16 +216,26 @@
purchaseLedger.setApprovalStatus(3);
List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(new QueryWrapper<SalesLedgerProduct>()
.lambda().eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedger.getId()).eq(SalesLedgerProduct::getType, 2));
+ boolean hasCheckedProduct = false;
for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) {
// 璐ㄦ
if (salesLedgerProduct.getIsChecked()) {
+ hasCheckedProduct = true;
purchaseLedgerServiceImpl.addQualityInspect(purchaseLedger, salesLedgerProduct);
}else {
//鐩存帴鍏ュ簱
stockUtils.addStock(null, salesLedgerProduct.getId(), salesLedgerProduct.getProductModelId(),
salesLedgerProduct.getQuantity(), StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(), salesLedgerProduct.getId());
+ BigDecimal oldStocked = salesLedgerProduct.getStockedQuantity() == null ? BigDecimal.ZERO : salesLedgerProduct.getStockedQuantity();
+ BigDecimal orderQty = salesLedgerProduct.getQuantity() == null ? BigDecimal.ZERO : salesLedgerProduct.getQuantity();
+ BigDecimal newStocked = oldStocked.add(orderQty);
+ salesLedgerProduct.setStockedQuantity(newStocked);
+ salesLedgerProduct.setProductStockStatus(2);
+ salesLedgerProduct.fillRemainingQuantity();
+ salesLedgerProductMapper.updateById(salesLedgerProduct);
}
}
+ purchaseLedger.setStockStatus(hasCheckedProduct ? 0 : 2);
} else if (status.equals(3)) {
// 鎷掔粷
purchaseLedger.setApprovalStatus(4);
@@ -265,6 +283,104 @@
} else if(status.equals(1)){
updateSalesLedgerDeliveryStatus(salesLedger.getId(), 2);
updateShippingInfoStatusByOrder(salesLedger.getId(), "瀹℃牳涓�");
+ }
+ }
+ }
+ }
+
+ // 閿�鍞鍗曟垚鍝佸叆搴撳鎵�
+ if (approveProcess.getApproveType().equals(9)) {
+ String reason = approveProcess.getApproveReason();
+ // 閿�鍞牸寮忥細鍏ュ簱瀹℃壒:鍚堝悓鍙�:salesLedgerId:productId1,productId2
+ // 璐ㄦ鏍煎紡锛氬師鏉愭枡璐ㄦ鍏ュ簱瀹℃壒:inspectId:purchaseLedgerId
+ if (org.springframework.util.StringUtils.hasText(reason)) {
+ if (reason.startsWith("鍘熸潗鏂欒川妫�鍏ュ簱瀹℃壒:")) {
+ Integer inspectId = null;
+ String remark = approveProcess.getApproveRemark();
+ // 鏂伴�昏緫锛氫笟鍔″弬鏁版斁鍦� approveRemark
+ if (org.springframework.util.StringUtils.hasText(remark) && remark.startsWith("qualityQualifiedInbound:")) {
+ String[] split = remark.split(":");
+ if (split.length >= 2) {
+ inspectId = Integer.valueOf(split[1]);
+ }
+ }
+ if (inspectId == null) {
+ String[] split = reason.split(":");
+ if (split.length >= 2) {
+ inspectId = Integer.valueOf(split[1]);
+ }
+ }
+ if (inspectId != null) {
+ if (status.equals(2)) {
+ qualityInspectService.executeQualifiedInboundApproval(inspectId);
+ } else if (status.equals(3)) {
+ qualityInspectService.markQualifiedInboundApprovalStatus(inspectId, 4);
+ } else if (status.equals(1)) {
+ qualityInspectService.markQualifiedInboundApprovalStatus(inspectId, 2);
+ }
+ }
+ // 璐ㄦ瀹℃壒涓嶉渶瑕佺户缁蛋閿�鍞鍗曞叆搴�
+ return;
+ }
+ if (reason.startsWith("閿�鍞壂鐮佷笉鍚堟牸鍏ュ簱瀹℃壒:") || reason.startsWith("閿�鍞壂鐮佸悎鏍煎叆搴撳鎵�:")) {
+ String remark = approveProcess.getApproveRemark();
+ boolean qualified = reason.startsWith("閿�鍞壂鐮佸悎鏍煎叆搴撳鎵�:");
+ String prefix = qualified ? "scanQualified:" : "scanUnqualified:";
+ if (org.springframework.util.StringUtils.hasText(remark) && remark.startsWith(prefix)) {
+ String[] split = remark.split(":");
+ if (split.length >= 3) {
+ Long salesLedgerId = Long.valueOf(split[1]);
+ java.util.Map<Long, BigDecimal> inboundQtyByLineId = Arrays.stream(split[2].split(","))
+ .filter(org.springframework.util.StringUtils::hasText)
+ .map(s -> s.split("@"))
+ .filter(arr -> arr.length == 2)
+ .collect(java.util.stream.Collectors.toMap(
+ arr -> Long.valueOf(arr[0]),
+ arr -> new BigDecimal(arr[1]),
+ BigDecimal::add,
+ java.util.LinkedHashMap::new));
+ if (status.equals(2)) {
+ if (qualified) {
+ salesLedgerService.executeSalesScanInboundApproved(salesLedgerId, inboundQtyByLineId);
+ } else {
+ salesLedgerService.executeSalesScanInboundUnqualifiedApproved(salesLedgerId, inboundQtyByLineId);
+ }
+ }
+ }
+ }
+ return;
+ }
+ String[] split = reason.split(":");
+ Long salesLedgerId = null;
+ List<Long> productIds = null;
+ // 鍏ュ簱瀹℃壒鐞嗙敱鍙睍绀哄悎鍚屽彿 鍙傛暟鏀惧湪 approveRemark
+ if (reason.startsWith("鍏ュ簱瀹℃壒:")) {
+ String remark = approveProcess.getApproveRemark();
+ if (org.springframework.util.StringUtils.hasText(remark) && remark.startsWith("salesStock:")) {
+ String[] r = remark.split(":");
+ if (r.length >= 3) {
+ salesLedgerId = Long.valueOf(r[1]);
+ productIds = Arrays.stream(r[2].split(","))
+ .filter(org.springframework.util.StringUtils::hasText)
+ .map(Long::valueOf)
+ .collect(java.util.stream.Collectors.toList());
+ }
+ }
+ }
+ // 鍏ュ簱瀹℃壒:鍚堝悓鍙�:salesLedgerId:productId1,productId2
+ if (salesLedgerId == null && split.length >= 4) {
+ salesLedgerId = Long.valueOf(split[2]);
+ productIds = Arrays.stream(split[3].split(","))
+ .filter(org.springframework.util.StringUtils::hasText)
+ .map(Long::valueOf)
+ .collect(java.util.stream.Collectors.toList());
+ }
+
+ if (salesLedgerId != null && productIds != null) {
+
+ if (status.equals(2)) {
+ // 瀹℃壒閫氳繃鎵ц鍏ュ簱
+ salesLedgerService.executeSalesStockApproved(salesLedgerId, productIds);
}
}
}
@@ -361,6 +477,8 @@
return "鍙戣揣瀹℃壒";
case 8:
return "鍗遍櫓浣滀笟瀹℃壒";
+ case 9:
+ return "鍏ュ簱瀹℃壒";
}
return null;
}
--
Gitblit v1.9.3