From 423ac2a5e7e451248d8cdfc2cda3f32dba0ec8f8 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期三, 11 三月 2026 17:59:52 +0800
Subject: [PATCH] feat: 生产计划关联物料信息表
---
src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java | 32 +++++++++++++++++++++++++++-----
1 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
index 95e3f14..15a2d3c 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
@@ -15,10 +15,15 @@
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
import com.ruoyi.production.service.ProductOrderService;
+import com.ruoyi.productionPlan.mapper.ProductOrderPlanMapper;
+import com.ruoyi.productionPlan.mapper.ProductionPlanMapper;
+import com.ruoyi.productionPlan.pojo.ProductOrderPlan;
+import com.ruoyi.productionPlan.pojo.ProductionPlan;
import com.ruoyi.quality.mapper.QualityInspectMapper;
import com.ruoyi.quality.pojo.QualityInspect;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.time.LocalDate;
@@ -49,6 +54,12 @@
@Autowired
private ProductionProductMainMapper productionProductMainMapper;
+
+ @Autowired
+ private ProductOrderPlanMapper productOrderPlanMapper;
+
+ @Autowired
+ private ProductionPlanMapper productionPlanMapper;
@Autowired
private ProductionProductOutputMapper productionProductOutputMapper;
@@ -123,14 +134,25 @@
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public Boolean revoke(ProductOrder productOrder) {
- //鍒ゆ柇鏄惁浜х敓宸ュ崟
- List<ProductionProductMain> productionProductMains = productionProductMainMapper.selectList(Wrappers.<ProductionProductMain>lambdaQuery().eq(ProductionProductMain::getProductOrderId, productOrder.getId()));
- if (!productionProductMains.isEmpty()) {
- throw new RuntimeException("鐢熶骇璁㈠崟宸茬粡鎶ュ伐,涓嶈兘鎾ら攢");
- }
+ // todo 鍒ゆ柇鏄惁浜х敓鎶ュ伐淇℃伅
// 鏌ヨ鍚堝苟鐨勭敓浜ц鍒�
+ List<ProductOrderPlan> productOrderPlans = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductOrderId, productOrder.getId()));
+ if (productOrderPlans.isEmpty()) {
+ throw new RuntimeException("鍚堝苟鐨勭敓浜ц鍒掍笉瀛樺湪");
+ }
+ for (ProductOrderPlan productOrderPlan : productOrderPlans) {
+ ProductionPlan productionPlan = productionPlanMapper.selectById(productOrderPlan.getProductionPlanId());
+ productionPlan.setAssignedQuantity(productionPlan.getAssignedQuantity().subtract(productOrderPlan.getAssignedQuantity()));
+ productionPlanMapper.updateById(productionPlan);
+ }
+ // 鍒犻櫎鍏宠仈鍏崇郴
+ productOrderPlanMapper.delete(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductOrderId, productOrder.getId()));
+ // 鍒犻櫎璁㈠崟
+ productOrderMapper.deleteById(productOrder.getId());
+ // todo 鍒犻櫎璁㈠崟涓嬬殑宸ヨ壓璺嚎瀛愯〃
return null;
}
--
Gitblit v1.9.3