From 47806d9e390ee00e1d29ad1da8c1aa908882a758 Mon Sep 17 00:00:00 2001
From: yuan <123@>
Date: 星期二, 11 八月 2026 14:43:59 +0800
Subject: [PATCH] 用河南鹤壁代码覆盖山西长治
---
src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java | 140 +++++++++++++++++++++++++++++++++-------------
1 files changed, 99 insertions(+), 41 deletions(-)
diff --git a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
index 5c103b8..caff402 100644
--- a/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
+++ b/src/main/java/com/ruoyi/production/service/impl/ProductionOrderServiceImpl.java
@@ -22,6 +22,8 @@
import com.ruoyi.production.bean.vo.ProductionOrderVo;
import com.ruoyi.production.bean.vo.ProductionPlanVo;
import com.ruoyi.production.bean.vo.ProductionOrderWorkOrderDetailVo;
+import com.ruoyi.production.bean.vo.ProcessRouteStatusVo;
+import com.ruoyi.production.bean.vo.ProductionOrderProcessTaskVo;
import com.ruoyi.production.enums.ProductOrderStatusEnum;
import com.ruoyi.production.mapper.*;
import com.ruoyi.production.pojo.*;
@@ -44,7 +46,6 @@
import java.math.BigDecimal;
import java.time.LocalDate;
-import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
@@ -87,6 +88,7 @@
// 鍒嗛〉鏌ヨ鐢熶骇璁㈠崟
Page<ProductionOrderVo> result = (Page<ProductionOrderVo>) baseMapper.pageProductionOrder(page, dto);
fillProductImages(result.getRecords());
+ fillProcessRouteStatus(result.getRecords());
return result;
}
@@ -95,6 +97,7 @@
// 鏌ヨ鐢熶骇璁㈠崟鍒楄〃
List<ProductionOrderVo> records = baseMapper.listProductionOrder(dto);
fillProductImages(records);
+ fillProcessRouteStatus(records);
return records;
}
@@ -116,7 +119,7 @@
// 涓嬪崟鍏ュ彛缁熶竴琛ラ綈鏉ユ簮鍗曟嵁銆佽鍒掑拰宸ヨ壓淇℃伅锛岄伩鍏嶅墠绔垎鍒紶澶氬瀛楁銆�
validateAndFillOrder(productionOrder, oldOrder);
if (productionOrder.getNpsNo() == null || productionOrder.getNpsNo().trim().isEmpty()) {
- productionOrder.setNpsNo(generateNextOrderNo(productionOrder.getCreateTime() != null ? productionOrder.getCreateTime() : LocalDateTime.now()));
+ productionOrder.setNpsNo(generateNextOrderNo());
}
if (productionOrder.getCompleteQuantity() == null) {
productionOrder.setCompleteQuantity(BigDecimal.ZERO);
@@ -134,7 +137,7 @@
|| !Objects.equals(oldOrder.getProductModelId(), productionOrder.getProductModelId())
|| compareDecimal(oldOrder.getQuantity(), productionOrder.getQuantity()) != 0
|| productionOrderRoutingMapper.selectCount(Wrappers.<ProductionOrderRouting>lambdaQuery()
- .eq(ProductionOrderRouting::getProductionOrderId, productionOrder.getId())) == 0);
+ .eq(ProductionOrderRouting::getProductionOrderId, productionOrder.getId())) == 0);
if (needSync) {
syncProductionOrderSnapshot(productionOrder.getId());
}
@@ -260,7 +263,7 @@
Map<String, BigDecimal> operationDemandedQuantityMap =
buildOperationDemandedQuantityMap(orderBomStructureList, rootProductModelId);
Map<Long, String> operationNameMap = technologyOperationMapper.selectBatchIds(
- // 閬嶅巻澶勭悊鏁版嵁骞剁粍瑁呯粨鏋�
+ // 閬嶅巻澶勭悊鏁版嵁骞剁粍瑁呯粨鏋�
routingOperations.stream()
.map(TechnologyRoutingOperation::getTechnologyOperationId)
.filter(Objects::nonNull)
@@ -461,7 +464,7 @@
private void clearProductionSnapshot(Long productionOrderId) {
// 娓呯悊璁㈠崟宸茬敓鎴愮殑宸ヨ壓涓嶣OM蹇収鏁版嵁
boolean hasPickRecord = productionOrderPickRecordMapper.selectCount(
- // 鏌ヨ骞跺噯澶囦笟鍔℃暟鎹�
+ // 鏌ヨ骞跺噯澶囦笟鍔℃暟鎹�
Wrappers.<ProductionOrderPickRecord>lambdaQuery()
.eq(ProductionOrderPickRecord::getProductionOrderId, productionOrderId)) > 0;
// 鍙傛暟涓庡墠缃潯浠舵牎楠�
@@ -471,7 +474,7 @@
List<Long> taskIds = productionOperationTaskMapper.selectList(
Wrappers.<ProductionOperationTask>lambdaQuery()
.eq(ProductionOperationTask::getProductionOrderId, productionOrderId))
- // 閬嶅巻澶勭悊鏁版嵁骞剁粍瑁呯粨鏋�
+ // 閬嶅巻澶勭悊鏁版嵁骞剁粍瑁呯粨鏋�
.stream().map(ProductionOperationTask::getId).collect(Collectors.toList());
if (!taskIds.isEmpty()) {
// 宸叉湁鎶ュ伐璁板綍璇存槑璁㈠崟宸插紑宸ワ紝姝ゆ椂涓嶅厑璁稿啀閲嶅缓蹇収銆�
@@ -509,10 +512,9 @@
.orderByDesc(ProductionOrder::getId);
}
- private String generateNextOrderNo(LocalDateTime createTime) {
+ private String generateNextOrderNo() {
// 鐢熸垚涓嬩竴涓敓浜ц鍗曞彿
- LocalDate localDate = createTime.toLocalDate();
- String datePrefix = localDate.format(DateTimeFormatter.ofPattern("yyyyMMdd"));
+ String datePrefix = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
String prefix = "SC" + datePrefix;
ProductionOrder latestOrder = this.getOne(Wrappers.<ProductionOrder>lambdaQuery()
.likeRight(ProductionOrder::getNpsNo, prefix)
@@ -814,6 +816,46 @@
}
}
+ private void fillProcessRouteStatus(List<ProductionOrderVo> records) {
+ if (records == null || records.isEmpty()) {
+ return;
+ }
+ List<Long> orderIds = records.stream()
+ .map(ProductionOrderVo::getId)
+ .filter(Objects::nonNull)
+ .distinct()
+ .collect(Collectors.toList());
+ if (orderIds.isEmpty()) {
+ return;
+ }
+
+ List<ProductionOrderProcessTaskVo> tasks = productionOperationTaskMapper.listProcessStatusByOrderIds(orderIds);
+ Map<Long, List<ProcessRouteStatusVo>> statusMap = new LinkedHashMap<>();
+ if (tasks != null) {
+ for (ProductionOrderProcessTaskVo task : tasks) {
+ if (task == null || task.getProductionOrderId() == null) {
+ continue;
+ }
+ ProcessRouteStatusVo status = new ProcessRouteStatusVo();
+ status.setName(task.getOperationName() != null && !task.getOperationName().isBlank()
+ ? task.getOperationName()
+ : "鏈煡宸ュ簭");
+ BigDecimal percentage = task.getCompletionStatus() == null
+ ? BigDecimal.ZERO
+ : task.getCompletionStatus();
+ if (percentage.compareTo(new BigDecimal("100")) > 0) {
+ percentage = new BigDecimal("100");
+ }
+ status.setPercentage(percentage);
+ statusMap.computeIfAbsent(task.getProductionOrderId(), key -> new ArrayList<>()).add(status);
+ }
+ }
+
+ for (ProductionOrderVo record : records) {
+ record.setProcessRouteStatus(statusMap.getOrDefault(record.getId(), Collections.emptyList()));
+ }
+ }
+
private StorageBlobVO toStorageBlobVO(StorageBlob blob) {
// 灏嗗瓨鍌ㄦ枃浠跺璞¤浆鎹负VO
StorageBlobVO vo = BeanUtil.copyProperties(blob, StorageBlobVO.class);
@@ -841,7 +883,7 @@
new Page<ProductionOperationTaskVo>(1, -1), taskQuery);
List<ProductionOperationTaskVo> workOrderList = workOrderPage == null || workOrderPage.getRecords() == null
? Collections.emptyList()
- // 閬嶅巻澶勭悊鏁版嵁骞剁粍瑁呯粨鏋�
+ // 閬嶅巻澶勭悊鏁版嵁骞剁粍瑁呯粨鏋�
: workOrderPage.getRecords().stream()
.filter(Objects::nonNull)
.sorted(Comparator.comparing(ProductionOperationTaskVo::getId, Comparator.nullsLast(Comparator.naturalOrder())))
@@ -857,7 +899,7 @@
.collect(Collectors.toList());
List<ProductionProductMain> reportMainList = workOrderIdList.isEmpty()
? Collections.emptyList()
- // 鏌ヨ骞跺噯澶囦笟鍔℃暟鎹�
+ // 鏌ヨ骞跺噯澶囦笟鍔℃暟鎹�
: productionProductMainMapper.selectList(
Wrappers.<ProductionProductMain>lambdaQuery()
.in(ProductionProductMain::getProductionOperationTaskId, workOrderIdList)
@@ -1065,20 +1107,30 @@
}
}
- // 杩囨护鍑洪潪鏍硅妭鐐癸紙瀹為檯棰嗘枡椤癸級
- // 鎺掗櫎鎶曞叆鍝佷笌浜у嚭鍝佺浉鍚屼笖姣斾緥涓�1鐨勬儏鍐碉紙鑷韩鍔犲伐锛屼笉闇�瑕侀鏂欙級
+ // 鏀堕泦璁㈠崟鎴愬搧瑙勬牸ID锛氬寘鍚敓浜ц鍗曟垚鍝佽鏍间笌BOM鏍硅妭鐐硅鏍硷紝鐢ㄤ簬鎺掗櫎鈥滆嚜宸扁�濊繖涓�鐗╂枡
+ Set<Long> finishedProductModelIds = new HashSet<>();
+ if (productionOrder != null && productionOrder.getProductModelId() != null) {
+ finishedProductModelIds.add(productionOrder.getProductModelId());
+ }
+ bomStructureList.stream()
+ .filter(s -> s != null && (s.getParentId() == null || s.getParentId() == 0))
+ .map(ProductionBomStructureVo::getProductModelId)
+ .filter(Objects::nonNull)
+ .forEach(finishedProductModelIds::add);
+
+ // 鏀堕泦鎵�鏈夎寮曠敤涓虹埗绾х殑鑺傜偣ID锛欱OM浠庢渶鍚庝竴閬撳伐搴忓線閲岄厤缃墠涓�閬撳伐搴忥紝
+ // 涓棿鑺傜偣鏄笂涓�閬撳伐搴忕殑浜у嚭锛堣嚜鍒讹級锛屽彧鏈夋瘡鏉″垎鏀渶閲屽眰鐨勫彾瀛愯妭鐐规墠鏄湡姝i渶瑕侀鐢ㄧ殑鐗╂枡銆�
+ Set<Long> parentNodeIds = bomStructureList.stream()
+ .filter(s -> s != null && s.getParentId() != null && s.getParentId() != 0)
+ .map(ProductionBomStructureVo::getParentId)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toSet());
+
+ // 杩囨护鍑哄彾瀛愯妭鐐癸紙瀹為檯棰嗘枡椤癸級锛氶潪鏍硅妭鐐广�侀潪涓棿鑺傜偣锛屽苟鎺掗櫎涓庤鍗曟垚鍝佸悓瑙勬牸鐨勭墿鏂欙紙鑷埗鎴愬搧鏃犻渶棰嗘枡锛�
List<ProductionBomStructureVo> childStructureList = bomStructureList.stream()
.filter(s -> s != null && s.getParentId() != null && s.getParentId() != 0)
- .filter(s -> {
- ProductionBomStructureVo parent = structureByIdMap.get(s.getParentId());
- if (parent == null) {
- return true;
- }
- // 鎶曞叆鍝佷笌浜у嚭鍝佺浉鍚屼笖姣斾緥涓�1鏃讹紝涓嶉渶瑕侀鏂�
- boolean sameProduct = Objects.equals(s.getProductModelId(), parent.getProductModelId());
- boolean unitRatio = BigDecimal.ONE.compareTo(defaultDecimal(s.getUnitQuantity())) == 0;
- return !(sameProduct && unitRatio);
- })
+ .filter(s -> s.getId() == null || !parentNodeIds.contains(s.getId()))
+ .filter(s -> s.getProductModelId() == null || !finishedProductModelIds.contains(s.getProductModelId()))
.collect(Collectors.toList());
// 閬嶅巻澶勭悊鏁版嵁骞剁粍瑁呯粨鏋�
@@ -1092,7 +1144,8 @@
if (!productModelIds.isEmpty()) {
List<StockInventory> stockList = stockInventoryMapper.selectList(
Wrappers.<StockInventory>lambdaQuery()
- .in(StockInventory::getProductModelId, productModelIds));
+ .in(StockInventory::getProductModelId, productModelIds)
+ .gt(StockInventory::getQualitity, BigDecimal.ZERO));
for (StockInventory stockItem : stockList) {
if (stockItem == null || stockItem.getProductModelId() == null) {
continue;
@@ -1106,29 +1159,34 @@
}
}
- List<ProductionOrderPickVo> pickList = new ArrayList<>();
+ Map<String, ProductionOrderPickVo> mergedPickMap = new LinkedHashMap<>();
for (ProductionBomStructureVo structure : childStructureList) {
if (structure == null || structure.getProductModelId() == null) {
continue;
}
Long productModelId = structure.getProductModelId();
- ProductionOrderPickVo vo = new ProductionOrderPickVo();
- vo.setProductModelId(productModelId);
- vo.setOperationName(structure.getOperationName());
- vo.setTechnologyOperationId(structure.getTechnologyOperationId());
- vo.setProductName(structure.getProductName());
- vo.setModel(structure.getModel());
- vo.setDemandedQuantity(defaultDecimal(structure.getDemandedQuantity()));
- vo.setUnit(structure.getUnit());
- List<String> batchNoList = stockBatchNoMap.get(productModelId) == null
- ? Collections.emptyList()
- : new ArrayList<>(stockBatchNoMap.get(productModelId));
- vo.setBatchNoList(batchNoList);
- vo.setStockQuantity(stockQuantityMap.getOrDefault(productModelId, BigDecimal.ZERO));
- vo.setBom(true);
- pickList.add(vo);
+ String mergeKey = String.valueOf(structure.getTechnologyOperationId()) + "#" + productModelId;
+ ProductionOrderPickVo vo = mergedPickMap.get(mergeKey);
+ if (vo == null) {
+ vo = new ProductionOrderPickVo();
+ vo.setProductModelId(productModelId);
+ vo.setOperationName(structure.getOperationName());
+ vo.setTechnologyOperationId(structure.getTechnologyOperationId());
+ vo.setProductName(structure.getProductName());
+ vo.setModel(structure.getModel());
+ vo.setDemandedQuantity(BigDecimal.ZERO);
+ vo.setUnit(structure.getUnit());
+ List<String> batchNoList = stockBatchNoMap.get(productModelId) == null
+ ? Collections.emptyList()
+ : new ArrayList<>(stockBatchNoMap.get(productModelId));
+ vo.setBatchNoList(batchNoList);
+ vo.setStockQuantity(stockQuantityMap.getOrDefault(productModelId, BigDecimal.ZERO));
+ vo.setBom(true);
+ mergedPickMap.put(mergeKey, vo);
+ }
+ vo.setDemandedQuantity(defaultDecimal(vo.getDemandedQuantity()).add(defaultDecimal(structure.getDemandedQuantity())));
}
- return pickList;
+ return new ArrayList<>(mergedPickMap.values());
}
@Override
--
Gitblit v1.9.3