From 124a6178ae918de05886b52199b7755d4fa1ece3 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 18 三月 2026 17:06:44 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_宁夏_中盛建材' into dev_宁夏_中盛建材
---
src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java | 96 ++++++++++++++++++++++++++++++++++++++----------
1 files changed, 76 insertions(+), 20 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 15a2d3c..7ee2e65 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductOrderServiceImpl.java
@@ -7,11 +7,11 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ruoyi.common.enums.StockOutQualifiedRecordTypeEnum;
-import com.ruoyi.common.enums.StockInUnQualifiedRecordTypeEnum;
+import com.ruoyi.appendix.service.AppendixService;
import com.ruoyi.procurementrecord.utils.StockUtils;
import com.ruoyi.production.dto.ProductOrderDto;
import com.ruoyi.production.dto.ProductStructureDto;
+import com.ruoyi.production.enums.ProductOrderStatusEnum;
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
import com.ruoyi.production.service.ProductOrderService;
@@ -20,7 +20,6 @@
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;
@@ -76,8 +75,11 @@
@Autowired
private StockUtils stockUtils;
+ @Autowired
+ private AppendixService appendixService;
+
@Override
- public IPage<ProductOrderDto> pageProductOrder(Page page, ProductOrderDto productOrder) {
+ public IPage<ProductOrderDto> pageProductOrder(Page<ProductOrder> page, ProductOrderDto productOrder) {
return productOrderMapper.pageProductOrder(page, productOrder);
}
@@ -179,28 +181,82 @@
}
@Override
+ @Transactional(rollbackFor = Exception.class)
public Boolean delete(Long[] ids) {
- //濡傛灉宸茬粡寮�濮嬬敓浜�,涓嶈兘鍒犻櫎
- //鏌ヨ鐢熶骇璁㈠崟涓嬬殑宸ュ崟
+ List<ProductOrder> orders = productOrderMapper.selectList(Wrappers.<ProductOrder>lambdaQuery().in(ProductOrder::getId, ids));
+
+ if (orders.isEmpty()) {
+ throw new RuntimeException("鐢熶骇璁㈠崟涓嶅瓨鍦�");
+ }
+ for (ProductOrder order : orders) {
+ if (!ProductOrderStatusEnum.canDelete(order.getStatus())) {
+ throw new RuntimeException("鍙湁銆愬緟寮�濮嬨�佸凡鍙栨秷銆戠姸鎬佺殑璁㈠崟鎵嶅彲浠ュ垹闄�");
+ }
+ }
+
+ // 鏄惁宸茬敓浜�
List<ProductWorkOrder> productWorkOrders = productWorkOrderMapper.selectList(Wrappers.<ProductWorkOrder>lambdaQuery().in(ProductWorkOrder::getProductOrderId, ids));
- if (productWorkOrders.size()>0){
- //鍒ゆ柇鏄惁鏈夋姤宸ユ暟鎹�
- List<ProductionProductMain> productionProductMains = productionProductMainMapper.selectList(Wrappers.<ProductionProductMain>lambdaQuery()
- .in(ProductionProductMain::getWorkOrderId, productWorkOrders.stream().map(ProductWorkOrder::getId).collect(Collectors.toList())));
- if (productionProductMains.size()>0){
+
+ if (!productWorkOrders.isEmpty()) {
+ List<Long> workOrderIds = productWorkOrders.stream()
+ .map(ProductWorkOrder::getId)
+ .collect(Collectors.toList());
+
+ List<ProductionProductMain> productionProductMains = productionProductMainMapper.selectList(Wrappers.<ProductionProductMain>lambdaQuery().in(ProductionProductMain::getWorkOrderId, workOrderIds));
+ if (!productionProductMains.isEmpty()) {
throw new RuntimeException("鐢熶骇璁㈠崟宸茬粡寮�濮嬬敓浜�,涓嶈兘鍒犻櫎");
}
- //鍒犻櫎宸ュ崟
+
+ // 鍒犻櫎宸ュ崟
productWorkOrderMapper.delete(Wrappers.<ProductWorkOrder>lambdaQuery().in(ProductWorkOrder::getProductOrderId, ids));
}
- //鍒犻櫎宸ヨ壓璺嚎
- productProcessRouteItemMapper.delete(new LambdaQueryWrapper<ProductProcessRouteItem>()
- .in(ProductProcessRouteItem::getProductOrderId, ids));
- productProcessRouteMapper.delete(new LambdaQueryWrapper<ProductProcessRoute>()
- .in(ProductProcessRoute::getProductOrderId, ids));
- //鍒犻櫎鐢熶骇璁㈠崟
- productOrderMapper.delete(new LambdaQueryWrapper<ProductOrder>()
- .in(ProductOrder::getId, ids));
+
+ // 鍥為��鐢熶骇璁″垝
+ List<ProductOrderPlan> productOrderPlans = productOrderPlanMapper.selectList(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductOrderId, ids));
+
+ for (ProductOrderPlan productOrderPlan : productOrderPlans) {
+ ProductionPlan productionPlan = productionPlanMapper.selectById(productOrderPlan.getProductionPlanId());
+
+ if (productionPlan != null) {
+ // 鍥為��鏁伴噺
+ BigDecimal newAssigned = productionPlan.getAssignedQuantity()
+ .subtract(productOrderPlan.getAssignedQuantity());
+
+ if (newAssigned.compareTo(BigDecimal.ZERO) < 0) {
+ newAssigned = BigDecimal.ZERO;
+ }
+ productionPlan.setAssignedQuantity(newAssigned);
+ BigDecimal volume = productionPlan.getVolume() == null ? BigDecimal.ZERO : productionPlan.getVolume();
+
+ int status;
+ if (newAssigned.compareTo(BigDecimal.ZERO) == 0) {
+ status = 0; // 鏈笅鍙�
+ } else if (newAssigned.compareTo(volume) < 0) {
+ status = 1; // 閮ㄥ垎涓嬪彂
+ } else {
+ status = 2; // 宸蹭笅鍙�
+ }
+ productionPlan.setStatus(status);
+
+ productionPlanMapper.updateById(productionPlan);
+ }
+ }
+
+ // 鍒犻櫎涓棿琛�
+ productOrderPlanMapper.delete(Wrappers.<ProductOrderPlan>lambdaQuery().in(ProductOrderPlan::getProductOrderId, ids));
+
+ // 鍒犻櫎闄勮〃鐨勫伐鑹鸿矾绾夸笌BOM
+ for (Long id : ids) {
+ ProductOrder productOrder = baseMapper.selectById(id);
+ appendixService.deleteData(productOrder.getRouteId());
+ }
+
+// productProcessRouteItemMapper.delete(new LambdaQueryWrapper<ProductProcessRouteItem>().in(ProductProcessRouteItem::getProductOrderId, ids));
+// productProcessRouteMapper.delete(new LambdaQueryWrapper<ProductProcessRoute>().in(ProductProcessRoute::getProductOrderId, ids));
+
+ // 鍒犻櫎璁㈠崟
+ productOrderMapper.delete(new LambdaQueryWrapper<ProductOrder>().in(ProductOrder::getId, ids));
+
return true;
}
--
Gitblit v1.9.3