From 9f1c36a2ba4e13f9592bbf2e49afd95fd77cadfb Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期三, 01 四月 2026 13:29:55 +0800
Subject: [PATCH] fix:1.仓储物流区分原材料/成品 2.生产订单/报工领料优化
---
src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java | 56 +++++++++++++++++++++++++++++++++++---------------------
1 files changed, 35 insertions(+), 21 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 578ea2d..61e1dfc 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionProductMainServiceImpl.java
@@ -143,28 +143,32 @@
productionProductMain.setDeviceId(dto.getDeviceId());
productionProductMainMapper.insert(productionProductMain);
/* 鏂板鎶ュ伐鎶曞叆琛� */
+ ProductWorkOrder WorkOrder = productWorkOrderMapper.selectById(dto.getWorkOrderId());
+ if (WorkOrder == null) {
+ throw new RuntimeException("宸ュ崟涓嶅瓨鍦�");
+ }
+
+ ProductOrder order = productOrderMapper.selectById(WorkOrder.getProductOrderId());
+ if (order == null) {
+ throw new RuntimeException("浜у搧璁㈠崟涓嶅瓨鍦�");
+ }
List<DrawMaterialDto> drawMaterialList = dto.getDrawMaterialList();
if (!CollectionUtils.isEmpty(drawMaterialList)) {
- // 1. 鎵归噺鏌ヨ鏁版嵁
- ProductWorkOrder productWorkOrder = productWorkOrderMapper.selectById(dto.getWorkOrderId());
- if (productWorkOrder == null) {
- throw new RuntimeException("宸ュ崟涓嶅瓨鍦�");
- }
- ProductOrder productOrder = productOrderMapper.selectById(productWorkOrder.getProductOrderId());
- if (productOrder == null) {
- throw new RuntimeException("浜у搧璁㈠崟涓嶅瓨鍦�");
- }
-
- // 2. 瑙f瀽骞舵瀯寤虹墿鏂橫ap
- List<DrawMaterialDto> existingMaterialList = JSON.parseArray(productOrder.getDrawMaterials(), DrawMaterialDto.class);
+ // 鐗╂枡Map
+ List<DrawMaterialDto> existingMaterialList = JSON.parseArray(order.getDrawMaterials(), DrawMaterialDto.class);
if (CollectionUtils.isEmpty(existingMaterialList)) {
throw new RuntimeException("鍙鐢ㄧ墿鏂欏垪琛ㄤ负绌�");
}
- Map<Long, DrawMaterialDto> materialMap = existingMaterialList.stream()
- .collect(Collectors.toMap(DrawMaterialDto::getProductModelId,
- Function.identity()));
+ Map<String, DrawMaterialDto> materialMap = existingMaterialList.stream()
+ .collect(Collectors.toMap(
+ materialDto -> materialDto.getProductModelId() + "_" +
+ (materialDto.getBatchNo() == null ? "" : materialDto.getBatchNo()) + "_" +
+ (materialDto.getCustomer() == null ? "" : materialDto.getCustomer()),
+ Function.identity(),
+ (existing, replacement) -> existing
+ ));
// 澶勭悊鎶ュ伐鐗╂枡
List<ProductionProductInput> inputList = new ArrayList<>();
@@ -173,9 +177,15 @@
Long modelId = drawMaterial.getProductModelId();
BigDecimal reportQty = drawMaterial.getReportQty();
- DrawMaterialDto material = materialMap.get(modelId);
+ String key = drawMaterial.getProductModelId() + "_" +
+ (drawMaterial.getBatchNo() == null ? "" : drawMaterial.getBatchNo()) + "_" +
+ (drawMaterial.getCustomer() == null ? "" : drawMaterial.getCustomer());
+
+ DrawMaterialDto material = materialMap.get(key);
if (material == null) {
- throw new RuntimeException("鐗╂枡涓嶅瓨鍦�: " + modelId);
+ throw new RuntimeException("鐗╂枡涓嶅瓨鍦�: 浜у搧鍨嬪彿ID=" + modelId +
+ ", 鎵规鍙�=" + drawMaterial.getBatchNo() +
+ ", 瀹㈡埛=" + drawMaterial.getCustomer());
}
// 楠岃瘉搴撳瓨
@@ -194,6 +204,8 @@
input.setQuantity(reportQty);
input.setProductMainId(productionProductMain.getId());
input.setRemark(drawMaterial.getRemark());
+ input.setBatchNo(drawMaterial.getBatchNo());
+ input.setCustomer(drawMaterial.getCustomer());
inputList.add(input);
}
@@ -201,8 +213,8 @@
for (ProductionProductInput productionProductInput : inputList) {
productionProductInputMapper.insert(productionProductInput);
}
- productOrder.setDrawMaterials(JSON.toJSONString(existingMaterialList));
- productOrderMapper.updateById(productOrder);
+ order.setDrawMaterials(JSON.toJSONString(existingMaterialList));
+ productOrderMapper.updateById(order);
}
}
/*鏂板鎶ュ伐浜у嚭琛�*/
@@ -233,7 +245,6 @@
if (productOrder == null) {
throw new RuntimeException("鐢熶骇璁㈠崟涓嶅瓨鍦�");
}
-
Product product = productMapper.selectById(productModel.getProductId());
QualityInspect qualityInspect = new QualityInspect();
@@ -266,7 +277,10 @@
}
} else {
//鐩存帴鍏ュ簱
- stockUtils.addStock(productProcessRouteItem.getProductModelId(), productionProductOutput.getQuantity().subtract(productionProductOutput.getScrapQty()), StockInQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_IN.getCode(), productionProductMain.getId());
+ String customer = "闀挎不甯傝酱鎵垮埗閫犳湁闄愬叕鍙�";
+ stockUtils.addStock(productProcessRouteItem.getProductModelId(), productionProductOutput.getQuantity().subtract(productionProductOutput.getScrapQty()),
+ StockInQualifiedRecordTypeEnum.PRODUCTION_REPORT_STOCK_IN.getCode(), productionProductMain.getId(),order.getBatchNo(),customer
+ );
}
/*鏇存柊宸ュ崟鍜岀敓浜ц鍗�*/
ProductWorkOrder productWorkOrder = productWorkOrderMapper.selectById(dto.getWorkOrderId());
--
Gitblit v1.9.3