|
|
@ -67,6 +67,7 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
try { |
|
|
try { |
|
|
// 4.1 从key中提取类型 |
|
|
// 4.1 从key中提取类型 |
|
|
String type = extractTypeFromKey(key); |
|
|
String type = extractTypeFromKey(key); |
|
|
|
|
|
log.info("🔑 从分组 key [{}] 提取类型: {}", key, type); |
|
|
|
|
|
|
|
|
// 4.2 先生成SQC检验任务,获取检验单信息 |
|
|
// 4.2 先生成SQC检验任务,获取检验单信息 |
|
|
InspectionInfo inspectionInfo = generateSqcInspectionTask(labels, type); |
|
|
InspectionInfo inspectionInfo = generateSqcInspectionTask(labels, type); |
|
|
@ -99,11 +100,6 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 按 site + part_no + type 分组(不包含 batch_no) |
|
|
|
|
|
* <p> |
|
|
|
|
|
* 注意:呆滞品和临期品分开处理,不混合在同一组 |
|
|
|
|
|
*/ |
|
|
|
|
|
private Map<String, List<PrintLabelRecord>> groupLabelsBySitePartBatch( |
|
|
private Map<String, List<PrintLabelRecord>> groupLabelsBySitePartBatch( |
|
|
List<PrintLabelRecord> stagnationLabels, |
|
|
List<PrintLabelRecord> stagnationLabels, |
|
|
List<PrintLabelRecord> expiredLabels) { |
|
|
List<PrintLabelRecord> expiredLabels) { |
|
|
@ -111,16 +107,31 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
Map<String, List<PrintLabelRecord>> groupedMap = new HashMap<>(); |
|
|
Map<String, List<PrintLabelRecord>> groupedMap = new HashMap<>(); |
|
|
Set<Long> processedIds = new HashSet<>(); |
|
|
Set<Long> processedIds = new HashSet<>(); |
|
|
|
|
|
|
|
|
// 处理呆滞品(标记为呆滞品类型) |
|
|
|
|
|
|
|
|
// 1. 先找出所有临期品的 site+partNo 组合 |
|
|
|
|
|
Set<String> expiredPartKeys = new HashSet<>(); |
|
|
|
|
|
for (PrintLabelRecord label : expiredLabels) { |
|
|
|
|
|
String key = label.getSite() + "_" + label.getPartNo(); |
|
|
|
|
|
expiredPartKeys.add(key); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 2. 处理呆滞品:排除掉同时也是临期品的物料 |
|
|
for (PrintLabelRecord label : stagnationLabels) { |
|
|
for (PrintLabelRecord label : stagnationLabels) { |
|
|
if (!processedIds.contains(label.getId())) { |
|
|
if (!processedIds.contains(label.getId())) { |
|
|
|
|
|
String partKey = label.getSite() + "_" + label.getPartNo(); |
|
|
|
|
|
|
|
|
|
|
|
// 如果这个物料也是临期品,跳过,后面会优先生成临期品任务 |
|
|
|
|
|
if (expiredPartKeys.contains(partKey)) { |
|
|
|
|
|
log.debug("⚠️ 物料 [{}] 既是呆滞品又是临期品,跳过呆滞品处理,优先生成临期品任务", partKey); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
String key = buildGroupKey(label.getSite(), label.getPartNo(), "呆滞品"); |
|
|
String key = buildGroupKey(label.getSite(), label.getPartNo(), "呆滞品"); |
|
|
groupedMap.computeIfAbsent(key, k -> new ArrayList<>()).add(label); |
|
|
groupedMap.computeIfAbsent(key, k -> new ArrayList<>()).add(label); |
|
|
processedIds.add(label.getId()); |
|
|
processedIds.add(label.getId()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 处理临期品(标记为过期类型,即使同一批号也单独分组) |
|
|
|
|
|
|
|
|
// 3. 处理临期品(优先处理,包括那些既是呆滞品又是临期品的物料) |
|
|
for (PrintLabelRecord label : expiredLabels) { |
|
|
for (PrintLabelRecord label : expiredLabels) { |
|
|
if (!processedIds.contains(label.getId())) { |
|
|
if (!processedIds.contains(label.getId())) { |
|
|
String key = buildGroupKey(label.getSite(), label.getPartNo(), "临期品"); |
|
|
String key = buildGroupKey(label.getSite(), label.getPartNo(), "临期品"); |
|
|
@ -372,6 +383,7 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
String partNo, String batchNo, BigDecimal totalQty, String type) { |
|
|
String partNo, String batchNo, BigDecimal totalQty, String type) { |
|
|
try { |
|
|
try { |
|
|
// 插入单据头 |
|
|
// 插入单据头 |
|
|
|
|
|
log.info("🔍 准备插入 SOOpsTransferHeader - transNo: {}, type: {}", transNo, type); |
|
|
stagnationDetailMapper.insertSOOpsTransferHeader(transNo, site, "SYSTEM", batchNo, type); |
|
|
stagnationDetailMapper.insertSOOpsTransferHeader(transNo, site, "SYSTEM", batchNo, type); |
|
|
log.debug("插入 SOOpsTransferHeader 成功: {}, type: {}", transNo, type); |
|
|
log.debug("插入 SOOpsTransferHeader 成功: {}, type: {}", transNo, type); |
|
|
|
|
|
|
|
|
|