From 10b88a7ff17caf92f3d4e8a550c1085a70c2517a Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 28 五月 2026 17:43:26 +0800
Subject: [PATCH] Merge dev_New_pro into dev_山西_晋和园_pro
---
src/main/java/com/ruoyi/approve/service/impl/ApproveBusinessStatusService.java | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 175 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/ruoyi/approve/service/impl/ApproveBusinessStatusService.java b/src/main/java/com/ruoyi/approve/service/impl/ApproveBusinessStatusService.java
new file mode 100644
index 0000000..8135c3a
--- /dev/null
+++ b/src/main/java/com/ruoyi/approve/service/impl/ApproveBusinessStatusService.java
@@ -0,0 +1,175 @@
+package com.ruoyi.approve.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.ruoyi.common.enums.StockInQualifiedRecordTypeEnum;
+import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
+import com.ruoyi.procurementrecord.utils.StockUtils;
+import com.ruoyi.purchase.mapper.PurchaseLedgerMapper;
+import com.ruoyi.purchase.pojo.PurchaseLedger;
+import com.ruoyi.quality.mapper.QualityInspectMapper;
+import com.ruoyi.quality.mapper.QualityInspectParamMapper;
+import com.ruoyi.quality.mapper.QualityTestStandardMapper;
+import com.ruoyi.quality.mapper.QualityTestStandardParamMapper;
+import com.ruoyi.quality.pojo.QualityInspect;
+import com.ruoyi.quality.pojo.QualityInspectParam;
+import com.ruoyi.quality.pojo.QualityTestStandard;
+import com.ruoyi.quality.pojo.QualityTestStandardParam;
+import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
+import com.ruoyi.sales.mapper.SalesQuotationMapper;
+import com.ruoyi.sales.mapper.ShippingInfoMapper;
+import com.ruoyi.sales.pojo.SalesLedgerProduct;
+import com.ruoyi.sales.pojo.SalesQuotation;
+import com.ruoyi.sales.pojo.ShippingInfo;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import java.util.Date;
+import java.util.List;
+
+@Service
+@RequiredArgsConstructor
+public class ApproveBusinessStatusService {
+
+ private final PurchaseLedgerMapper purchaseLedgerMapper;
+ private final SalesQuotationMapper salesQuotationMapper;
+ private final ShippingInfoMapper shippingInfoMapper;
+ private final SalesLedgerProductMapper salesLedgerProductMapper;
+ private final StockUtils stockUtils;
+ private final QualityInspectMapper qualityInspectMapper;
+ private final QualityTestStandardMapper qualityTestStandardMapper;
+ private final QualityTestStandardParamMapper qualityTestStandardParamMapper;
+ private final QualityInspectParamMapper qualityInspectParamMapper;
+
+ /**
+ * 缁熶竴鍚屾瀹℃壒缁撴灉瀵瑰簲鐨勪笟鍔″崟鎹姸鎬併��
+ * status锛�1-瀹℃牳涓紝2-瀹℃牳瀹屾垚锛�3-瀹℃牳鏈�氳繃銆�
+ */
+ public void syncBusinessStatus(Integer approveType, String approveReason, Integer status) {
+ if (approveType == null || status == null || !StringUtils.hasText(approveReason)) {
+ return;
+ }
+ switch (approveType) {
+ case 5:
+ syncPurchaseStatus(approveReason, status);
+ break;
+ case 6:
+ syncSalesQuotationStatus(approveReason, status);
+ break;
+ case 7:
+ syncShippingStatus(approveReason, status);
+ break;
+ default:
+ break;
+ }
+ }
+
+ // 閲囪喘瀹℃壒閫氳繃鏃讹紝鎸変骇鍝佽川妫�閰嶇疆鍐冲畾鐢熸垚璐ㄦ鍗曟垨鐩存帴鍏ュ簱銆�
+ private void syncPurchaseStatus(String approveReason, Integer status) {
+ PurchaseLedger purchaseLedger = purchaseLedgerMapper.selectOne(new LambdaQueryWrapper<PurchaseLedger>()
+ .eq(PurchaseLedger::getPurchaseContractNumber, approveReason)
+ .last("limit 1"));
+ if (purchaseLedger == null) {
+ return;
+ }
+ if (status.equals(2)) {
+ purchaseLedger.setApprovalStatus(3);
+ List<SalesLedgerProduct> salesLedgerProducts = salesLedgerProductMapper.selectList(new QueryWrapper<SalesLedgerProduct>()
+ .lambda().eq(SalesLedgerProduct::getSalesLedgerId, purchaseLedger.getId()).eq(SalesLedgerProduct::getType, 2));
+ for (SalesLedgerProduct salesLedgerProduct : salesLedgerProducts) {
+ if (Boolean.TRUE.equals(salesLedgerProduct.getIsChecked())) {
+ addQualityInspect(purchaseLedger, salesLedgerProduct);
+ } else {
+ stockUtils.addStockWithBatchNo(
+ salesLedgerProduct.getProductModelId(),
+ salesLedgerProduct.getQuantity(),
+ StockInQualifiedRecordTypeEnum.PURCHASE_STOCK_IN.getCode(),
+ purchaseLedger.getId(),
+ purchaseLedger.getPurchaseContractNumber() + "-" + salesLedgerProduct.getId());
+ }
+ }
+ } else if (status.equals(3)) {
+ purchaseLedger.setApprovalStatus(4);
+ } else if (status.equals(1)) {
+ purchaseLedger.setApprovalStatus(2);
+ } else {
+ return;
+ }
+ purchaseLedgerMapper.updateById(purchaseLedger);
+ }
+
+ // 鎶ヤ环瀹℃壒鐘舵�佸洖鍐欏埌閿�鍞姤浠峰崟鐘舵�併��
+ private void syncSalesQuotationStatus(String approveReason, Integer status) {
+ SalesQuotation salesQuote = salesQuotationMapper.selectOne(new LambdaQueryWrapper<SalesQuotation>()
+ .eq(SalesQuotation::getQuotationNo, approveReason)
+ .last("limit 1"));
+ if (salesQuote == null) {
+ return;
+ }
+ if (status.equals(2)) {
+ salesQuote.setStatus("閫氳繃");
+ } else if (status.equals(3)) {
+ salesQuote.setStatus("鎷掔粷");
+ } else if (status.equals(1)) {
+ salesQuote.setStatus("瀹℃牳涓�");
+ } else {
+ return;
+ }
+ salesQuotationMapper.updateById(salesQuote);
+ }
+
+ // 鍙戣揣瀹℃壒閫氳繃鏃跺悓姝ュ彂璐х姸鎬佸拰鍑哄簱瀹℃壒鐘舵�侊紱鎷掔粷鏃跺垹闄ゅ緟纭鍑哄簱璁板綍銆�
+ private void syncShippingStatus(String approveReason, Integer status) {
+ ShippingInfo shippingInfo = shippingInfoMapper.selectOne(new LambdaQueryWrapper<ShippingInfo>()
+ .eq(ShippingInfo::getShippingNo, approveReason)
+ .orderByDesc(ShippingInfo::getCreateTime)
+ .last("limit 1"));
+ if (shippingInfo == null) {
+ return;
+ }
+ if (status.equals(2)) {
+ shippingInfo.setStatus("瀹℃牳閫氳繃");
+ shippingInfo.setShippingDate(new Date());
+ stockUtils.shipmentStatus(StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode(), shippingInfo.getId());
+ } else if (status.equals(3)) {
+ stockUtils.deleteStockOutRecord(shippingInfo.getId(), StockOutQualifiedRecordTypeEnum.SALE_SHIP_STOCK_OUT.getCode());
+ shippingInfo.setStatus("瀹℃牳鎷掔粷");
+ } else if (status.equals(1)) {
+ shippingInfo.setStatus("瀹℃牳涓�");
+ } else {
+ return;
+ }
+ shippingInfoMapper.updateById(shippingInfo);
+ }
+
+ // 鐢熸垚閲囪喘璐ㄦ鍗曪紝骞舵寜浜у搧璐ㄦ鏍囧噯鍒濆鍖栬川妫�鍙傛暟銆�
+ private void addQualityInspect(PurchaseLedger purchaseLedger, SalesLedgerProduct saleProduct) {
+ QualityInspect qualityInspect = new QualityInspect();
+ qualityInspect.setInspectType(0);
+ qualityInspect.setSupplier(purchaseLedger.getSupplierName());
+ qualityInspect.setPurchaseLedgerId(purchaseLedger.getId());
+ qualityInspect.setProductId(saleProduct.getProductId());
+ qualityInspect.setProductName(saleProduct.getProductCategory());
+ qualityInspect.setModel(saleProduct.getSpecificationModel());
+ qualityInspect.setProductModelId(saleProduct.getProductModelId());
+ qualityInspect.setUnit(saleProduct.getUnit());
+ qualityInspect.setQuantity(saleProduct.getQuantity());
+ qualityInspectMapper.insert(qualityInspect);
+ List<QualityTestStandard> qualityTestStandard = qualityTestStandardMapper.getQualityTestStandardByProductId(saleProduct.getProductId(), 0, null);
+ if (qualityTestStandard.size() > 0) {
+ qualityInspect.setTestStandardId(qualityTestStandard.get(0).getId());
+ qualityInspectMapper.updateById(qualityInspect);
+ qualityTestStandardParamMapper.selectList(Wrappers.<QualityTestStandardParam>lambdaQuery()
+ .eq(QualityTestStandardParam::getTestStandardId, qualityTestStandard.get(0).getId()))
+ .forEach(qualityTestStandardParam -> {
+ QualityInspectParam param = new QualityInspectParam();
+ com.ruoyi.common.utils.bean.BeanUtils.copyProperties(qualityTestStandardParam, param);
+ param.setId(null);
+ param.setInspectId(qualityInspect.getId());
+ qualityInspectParamMapper.insert(param);
+ });
+ }
+ }
+}
--
Gitblit v1.9.3