From 38159f6f72ec65aa12d78953e4c3e4d619351a09 Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 07 一月 2026 18:05:41 +0800
Subject: [PATCH] 报工联动投入
---
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java | 80 +++++++++++++++++++++++++++++++---------
1 files changed, 62 insertions(+), 18 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
index f100c7f..9472e1c 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -12,6 +12,7 @@
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.production.controller.ProductWorkOrderController;
+import com.ruoyi.production.dto.ProductStructureDto;
import com.ruoyi.production.dto.ProductionProductMainDto;
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
@@ -61,6 +62,10 @@
private QualityInspectParamMapper qualityInspectParamMapper;
+ private ProductStructureMapper productStructureMapper;
+
+ private ProductionProductInputMapper productionProductInputMapper;
+
@Override
public IPage<ProductionProductMainDto> listPageProductionProductMainDto(Page page, ProductionProductMainDto productionProductMainDto) {
@@ -74,23 +79,23 @@
throw new RuntimeException("鍙傛暟涓嶈兘涓虹┖");
}
-// if (dto.isReportWork()) {
-// // 鏇存柊閫昏緫 - 鍙洿鏂版暟閲�
-// QueryWrapper<ProductionProductOutput> outputWrapper = new QueryWrapper<>();
-// outputWrapper.eq("product_main_id", dto.getId());
-//
-// ProductionProductOutput output = productionProductOutputMapper.selectOne(outputWrapper);
-// if (output == null) {
-// throw new RuntimeException("浜у嚭璁板綍涓嶅瓨鍦�");
-// }
-//
-// // 鍙洿鏂版暟閲�
-// if (dto.getQuantity() != null) {
-// output.setQuantity(dto.getQuantity());
-// productionProductOutputMapper.updateById(output);
-// }
-// return true;
-// }
+ if (dto.isReportWork()) {
+ // 鏇存柊閫昏緫 - 鍙洿鏂版暟閲�
+ QueryWrapper<ProductionProductOutput> outputWrapper = new QueryWrapper<>();
+ outputWrapper.eq("product_main_id", dto.getProductMainId());
+
+ ProductionProductOutput output = productionProductOutputMapper.selectOne(outputWrapper);
+ if (output == null) {
+ throw new RuntimeException("浜у嚭璁板綍涓嶅瓨鍦�");
+ }
+
+ // 鍙洿鏂版暟閲�
+ if (dto.getQuantity() != null) {
+ output.setQuantity(dto.getQuantity());
+ productionProductOutputMapper.updateById(output);
+ }
+ return true;
+ }
// 鏂板閫昏緫
ProductionProductMain productionProductMain = new ProductionProductMain();
@@ -143,7 +148,8 @@
if (insert > 0) {
UpdateWrapper<ProductWorkOrder> wrapper = new UpdateWrapper<>();
wrapper.set("report_work", true)
- .set("quantity",dto.getQuantity())
+ .set("quantity", dto.getQuantity())
+ .set("product_main_id", productionProductMain.getId())
.eq("id", dto.getWorkOrderId());
productWorkOrderMapper.update(null, wrapper);
}
@@ -164,6 +170,7 @@
qualityInspect.setProcess(productProcess.getName());
qualityInspect.setInspectState(0);
qualityInspect.setInspectType(inspectType);
+ qualityInspect.setProductMainId(productionProductMain.getId());
qualityInspectMapper.insert(qualityInspect);
qualityTestStandardMapper.selectList(
@@ -177,6 +184,18 @@
qualityInspectParamMapper.insert(param);
});
}
+ // 娣诲姞鎶曞叆
+ if (productModel != null) {
+ List<ProductStructureDto> productStructureDtos = productStructureMapper.listByproductModelId(productModel.getId());
+ for (ProductStructureDto productStructureDto : productStructureDtos) {
+ ProductionProductInput productionProductInput = new ProductionProductInput();
+ productionProductInput.setProductModelId(productStructureDto.getProductModelId());
+ productionProductInput.setQuantity(productStructureDto.getUnitQuantity());
+ productionProductInput.setProductMainId(productionProductMain.getId());
+ productionProductInputMapper.insert(productionProductInput);
+ }
+ }
+
// 娣诲姞浜у嚭
ProductionProductOutput productionProductOutput = new ProductionProductOutput();
productionProductOutput.setProductMainId(productionProductMain.getId());
@@ -186,4 +205,29 @@
return true;
}
+
+ @Override
+ @Transactional
+ public Boolean removeProductMain(ProductionProductMainDto dto) {
+ Long id = dto.getId();
+
+ // 鍒犻櫎璐ㄦ鍙傛暟鍜岃川妫�璁板綍
+ qualityInspectMapper.selectList(
+ new LambdaQueryWrapper<QualityInspect>()
+ .eq(QualityInspect::getProductMainId, id)
+ ).forEach(q -> {
+ qualityInspectParamMapper.delete(
+ new LambdaQueryWrapper<QualityInspectParam>()
+ .eq(QualityInspectParam::getInspectId, q.getId()));
+ qualityInspectMapper.deleteById(q.getId());
+ });
+
+ // 鍒犻櫎浜у嚭璁板綍
+ productionProductOutputMapper.delete(new LambdaQueryWrapper<ProductionProductOutput>()
+ .eq(ProductionProductOutput::getProductMainId, id)
+ );
+
+ // 鍒犻櫎涓昏〃
+ return productionProductMainMapper.deleteById(id) > 0;
+ }
}
--
Gitblit v1.9.3