From 61f1de60e6f58dd8e19f01c56f2e56e40885d65b Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 23 六月 2026 17:39:58 +0800
Subject: [PATCH] 点击发货-》发货审核-》出厂质检-》出库审核-》出库通过
---
src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java b/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
index 5da3984..317ecfb 100644
--- a/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
+++ b/src/main/java/com/ruoyi/approve/service/impl/ApprovalInstanceServiceImpl.java
@@ -40,12 +40,15 @@
import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
import com.ruoyi.purchase.pojo.PurchaseLedger;
import com.ruoyi.quality.utils.QualityInspectHelper;
+import com.ruoyi.sales.mapper.SalesLedgerMapper;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.mapper.SalesQuotationMapper;
import com.ruoyi.sales.mapper.ShippingInfoMapper;
+import com.ruoyi.sales.mapper.ShippingProductDetailMapper;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
import com.ruoyi.sales.pojo.SalesQuotation;
import com.ruoyi.sales.pojo.ShippingInfo;
+import com.ruoyi.sales.pojo.ShippingProductDetail;
import com.ruoyi.staff.mapper.HolidayApplicationMapper;
import com.ruoyi.staff.pojo.HolidayApplication;
import lombok.RequiredArgsConstructor;
@@ -94,9 +97,13 @@
private final EnterpriseNewsMapper enterpriseNewsMapper;
private final EnterpriseNewsScopeDeptMapper enterpriseNewsScopeDeptMapper;
private final ApprovalTemplateNodeApproverMapper approvalTemplateNodeApproverMapper;
+ private final ShippingProductDetailMapper shippingProductDetailMapper;
+ private final SalesLedgerMapper salesLedgerMapper;
@Override
public R listPage(Page<ApprovalInstanceVo> page, ApprovalInstanceDto approvalInstanceDto) {
+ // 娉ㄥ叆褰撳墠鐢ㄦ埛ID锛岀敤浜庤繃婊ゅ彧鏌ョ湅鐢宠浜哄拰瀹℃牳浜烘槸鑷繁鐨勬暟鎹�
+ approvalInstanceDto.setCurrentUserId(SecurityUtils.getUserId());
IPage<ApprovalInstanceVo> approvalInstanceVoIPage = approvalInstanceMapper.listPage(page, approvalInstanceDto);
List<ApprovalInstanceVo> records = approvalInstanceVoIPage.getRecords();
@@ -253,6 +260,12 @@
ApprovalInstance instance = getPendingApprovalInstance(approvalInstanceDto.getId());
if (instance == null) {
return R.fail("瀹℃壒瀹炰緥涓嶅瓨鍦�");
+ }
+
+ // 濡傛灉鍓嶇浼犻�掍簡浠撳簱淇℃伅锛屾洿鏂板鎵瑰疄渚嬬殑浠撳簱瀛楁
+ if (StringUtils.hasText(approvalInstanceDto.getWarehouse())) {
+ instance.setWarehouse(approvalInstanceDto.getWarehouse());
+ this.updateById(instance);
}
ApprovalInstanceNode currentNode = approveProcessConfigNodeUtils.getCurrentNode(instance.getId());
@@ -647,7 +660,9 @@
salesLedgerProduct.getQuantity(),
StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(),
purchaseLedger.getId(),
- purchaseLedger.getPurchaseContractNumber() + "-" + salesLedgerProduct.getId()
+ purchaseLedger.getPurchaseContractNumber() + "-" + salesLedgerProduct.getId(),
+ null,
+ instance.getWarehouse()
);
}
}
@@ -682,8 +697,7 @@
private void handleShippingApprovalFinished(ApprovalInstance instance, String status) {
ShippingInfo shippingInfo = shippingInfoMapper.selectOne(
new LambdaQueryWrapper<ShippingInfo>()
- .eq(ShippingInfo::getId, instance.getTitle())
- .orderByDesc(ShippingInfo::getCreateTime)
+ .eq(ShippingInfo::getId, instance.getBusinessId())
.last("limit 1")
);
if (shippingInfo == null) {
@@ -694,6 +708,9 @@
shippingInfo.setStatus(ShippingStatusEnum.APPROVED.getCode());
shippingInfo.setShippingDate(new Date());
stockUtils.shipmentStatus(StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), shippingInfo.getId());
+
+ // 鍙戣揣瀹℃壒閫氳繃鍚庯紝鑷姩鐢熸垚鍑哄巶妫�楠屽崟
+ createFactoryInspectForShipping(shippingInfo);
} else if ("REJECTED".equals(status)) {
stockUtils.deleteStockOutRecord(shippingInfo.getId(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode());
shippingInfo.setStatus(ShippingStatusEnum.REJECTED.getCode());
@@ -703,6 +720,40 @@
shippingInfoMapper.updateById(shippingInfo);
}
+ /**
+ * 鍙戣揣瀹℃壒閫氳繃鍚庯紝鑷姩鐢熸垚鍑哄巶妫�楠屽崟
+ */
+ private void createFactoryInspectForShipping(ShippingInfo shippingInfo) {
+ // 鏌ヨ鍙戣揣浜у搧鏄庣粏
+ List<ShippingProductDetail> detailList = shippingProductDetailMapper.selectList(
+ new LambdaQueryWrapper<ShippingProductDetail>()
+ .eq(ShippingProductDetail::getShippingInfoId, shippingInfo.getId())
+ );
+
+ if (detailList == null || detailList.isEmpty()) {
+ return;
+ }
+
+ // 鑾峰彇瀹㈡埛鍚嶇О
+ String customerName = null;
+ if (shippingInfo.getSalesLedgerId() != null) {
+ com.ruoyi.sales.pojo.SalesLedger salesLedger = salesLedgerMapper.selectById(shippingInfo.getSalesLedgerId());
+ if (salesLedger != null) {
+ customerName = salesLedger.getCustomerName();
+ }
+ }
+
+ // 涓烘瘡涓彂璐т骇鍝佸垱寤哄嚭鍘傛楠屽崟
+ for (ShippingProductDetail detail : detailList) {
+ qualityInspectHelper.addFactoryInspect(
+ shippingInfo,
+ detail,
+ customerName,
+ shippingInfo.getSalesLedgerId()
+ );
+ }
+ }
+
private List<ApprovalTask> createNodeAndTasks(ApprovalInstance instance, ApprovalTemplateNode templateNode) {
List<ApprovalTemplateNodeApprover> approvers = approvalTemplateNodeApproverMapper.selectList(
new LambdaQueryWrapper<ApprovalTemplateNodeApprover>()
--
Gitblit v1.9.3