|
|
@ -45,11 +45,9 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
List<PrintLabelRecord> stagnationLabels = printLabelRecordMapper.selectStagnationLabels(); |
|
|
List<PrintLabelRecord> stagnationLabels = printLabelRecordMapper.selectStagnationLabels(); |
|
|
log.info("查询到呆滞品标签数量: {}", stagnationLabels.size()); |
|
|
log.info("查询到呆滞品标签数量: {}", stagnationLabels.size()); |
|
|
|
|
|
|
|
|
// TODO: 过期品功能预留,后续启用 |
|
|
|
|
|
// 2. 查询过期品标签 |
|
|
// 2. 查询过期品标签 |
|
|
// List<PrintLabelRecord> expiredLabels = printLabelRecordMapper.selectExpiredLabels(); |
|
|
|
|
|
// log.info("查询到过期品标签数量: {}", expiredLabels.size()); |
|
|
|
|
|
List<PrintLabelRecord> expiredLabels = new ArrayList<>(); |
|
|
|
|
|
|
|
|
List<PrintLabelRecord> expiredLabels = printLabelRecordMapper.selectExpiredLabels(); |
|
|
|
|
|
log.info("查询到过期品标签数量: {}", expiredLabels.size()); |
|
|
|
|
|
|
|
|
// 3. 合并并按 site + part_no + batch_no + type 分组 |
|
|
// 3. 合并并按 site + part_no + batch_no + type 分组 |
|
|
Map<String, List<PrintLabelRecord>> groupedLabels = groupLabelsBySitePartBatch( |
|
|
Map<String, List<PrintLabelRecord>> groupedLabels = groupLabelsBySitePartBatch( |
|
|
@ -57,7 +55,7 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
|
|
|
|
|
|
log.info("分组后共 {} 组需要生成检验任务", groupedLabels.size()); |
|
|
log.info("分组后共 {} 组需要生成检验任务", groupedLabels.size()); |
|
|
|
|
|
|
|
|
// 4. 为每组生成SQC检验任务(事务性:全部成功或全部失败) |
|
|
|
|
|
|
|
|
// 4. 为每组生成SQC检验任务 |
|
|
int successCount = 0; |
|
|
int successCount = 0; |
|
|
int failCount = 0; |
|
|
int failCount = 0; |
|
|
List<String> failedKeys = new ArrayList<>(); |
|
|
List<String> failedKeys = new ArrayList<>(); |
|
|
@ -102,7 +100,7 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 按 site + part_no + batch_no + type 分组 |
|
|
|
|
|
|
|
|
* 按 site + part_no + type 分组(不包含 batch_no) |
|
|
* <p> |
|
|
* <p> |
|
|
* 注意:呆滞品和过期品分开处理,不混合在同一组 |
|
|
* 注意:呆滞品和过期品分开处理,不混合在同一组 |
|
|
*/ |
|
|
*/ |
|
|
@ -116,7 +114,7 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
// 处理呆滞品(标记为呆滞品类型) |
|
|
// 处理呆滞品(标记为呆滞品类型) |
|
|
for (PrintLabelRecord label : stagnationLabels) { |
|
|
for (PrintLabelRecord label : stagnationLabels) { |
|
|
if (!processedIds.contains(label.getId())) { |
|
|
if (!processedIds.contains(label.getId())) { |
|
|
String key = buildGroupKey(label.getSite(), label.getPartNo(), label.getBatchNo(), "呆滞品"); |
|
|
|
|
|
|
|
|
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()); |
|
|
} |
|
|
} |
|
|
@ -125,7 +123,7 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
// 处理过期品(标记为过期类型,即使同一批号也单独分组) |
|
|
// 处理过期品(标记为过期类型,即使同一批号也单独分组) |
|
|
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(), label.getBatchNo(), "过期"); |
|
|
|
|
|
|
|
|
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()); |
|
|
} |
|
|
} |
|
|
@ -135,10 +133,10 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 构建分组key(包含类型) |
|
|
|
|
|
|
|
|
* 构建分组key |
|
|
*/ |
|
|
*/ |
|
|
private String buildGroupKey(String site, String partNo, String batchNo, String type) { |
|
|
|
|
|
return site + "_" + partNo + "_" + batchNo + "_" + type; |
|
|
|
|
|
|
|
|
private String buildGroupKey(String site, String partNo, String type) { |
|
|
|
|
|
return site + "_" + partNo + "_" + type; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -149,9 +147,9 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
return "呆滞品"; |
|
|
return "呆滞品"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// key格式: site_partNo_batchNo_type |
|
|
|
|
|
|
|
|
// key格式: site_partNo_type |
|
|
String[] parts = key.split("_"); |
|
|
String[] parts = key.split("_"); |
|
|
if (parts.length >= 4) { |
|
|
|
|
|
|
|
|
if (parts.length >= 3) { |
|
|
// 最后一个部分是类型 |
|
|
// 最后一个部分是类型 |
|
|
return parts[parts.length - 1]; |
|
|
return parts[parts.length - 1]; |
|
|
} |
|
|
} |
|
|
@ -205,29 +203,6 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 插入呆滞明细表 |
|
|
|
|
|
*/ |
|
|
|
|
|
private void insertStagnationDetails(List<PrintLabelRecord> labels, String type) { |
|
|
|
|
|
List<StagnationDetail> details = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
for (PrintLabelRecord label : labels) { |
|
|
|
|
|
StagnationDetail detail = new StagnationDetail(); |
|
|
|
|
|
detail.setLabelRecordId(label.getId()); |
|
|
|
|
|
detail.setType(type); |
|
|
|
|
|
detail.setIsInspectionCompleted(0); // 未完成 |
|
|
|
|
|
// sqcInspectionNo、laboratoryOrderNo、laboratoryItemNo 后续回填 |
|
|
|
|
|
|
|
|
|
|
|
details.add(detail); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 批量插入 |
|
|
|
|
|
if (!details.isEmpty()) { |
|
|
|
|
|
stagnationDetailMapper.batchInsert(details); |
|
|
|
|
|
log.debug("批量插入呆滞明细 {} 条", details.size()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 生成SQC检验任务,返回检验单信息 |
|
|
* 生成SQC检验任务,返回检验单信息 |
|
|
*/ |
|
|
*/ |
|
|
@ -268,7 +243,7 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
String transNo = generateTransNo(site, partNo, batchNo); |
|
|
String transNo = generateTransNo(site, partNo, batchNo); |
|
|
|
|
|
|
|
|
// 2. 插入 SOOpsTransferHeader 和 SOOpsTransferDetail |
|
|
// 2. 插入 SOOpsTransferHeader 和 SOOpsTransferDetail |
|
|
insertLaboratoryTransferData(transNo, site, partNo, batchNo, totalQty); |
|
|
|
|
|
|
|
|
insertLaboratoryTransferData(transNo, site, partNo, batchNo, totalQty, type); |
|
|
|
|
|
|
|
|
// 3. 调用存储过程生成SQC任务(使用 transNo 作为 @order_no) |
|
|
// 3. 调用存储过程生成SQC任务(使用 transNo 作为 @order_no) |
|
|
List<Object> params = buildSqcParams(site, partNo, batchNo, seqNo, transNo, totalQty, type); |
|
|
List<Object> params = buildSqcParams(site, partNo, batchNo, seqNo, transNo, totalQty, type); |
|
|
@ -356,7 +331,9 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
params.add(""); // @document_type - 单据类型 |
|
|
params.add(""); // @document_type - 单据类型 |
|
|
params.add(""); // @document_no - 单据号 |
|
|
params.add(""); // @document_no - 单据号 |
|
|
params.add(partNo); // @part_no - 物料编号 |
|
|
params.add(partNo); // @part_no - 物料编号 |
|
|
params.add("呆滞品自动检验"); // @operation_desc - 操作描述 |
|
|
|
|
|
|
|
|
// 根据类型设置操作描述 |
|
|
|
|
|
String operationDesc = "过期品".equals(type) ? "过期品自动检验" : "呆滞品自动检验"; |
|
|
|
|
|
params.add(operationDesc); // @operation_desc - 操作描述 |
|
|
params.add(""); // @resource_id - 机台编码 |
|
|
params.add(""); // @resource_id - 机台编码 |
|
|
return params; |
|
|
return params; |
|
|
} |
|
|
} |
|
|
@ -381,19 +358,19 @@ public class StagnationInspectionServiceImpl implements StagnationInspectionServ |
|
|
* 插入实验室单据数据(SOOpsTransferHeader 和 SOOpsTransferDetail) |
|
|
* 插入实验室单据数据(SOOpsTransferHeader 和 SOOpsTransferDetail) |
|
|
*/ |
|
|
*/ |
|
|
private void insertLaboratoryTransferData(String transNo, String site, |
|
|
private void insertLaboratoryTransferData(String transNo, String site, |
|
|
String partNo, String batchNo, BigDecimal totalQty) { |
|
|
|
|
|
|
|
|
String partNo, String batchNo, BigDecimal totalQty, String type) { |
|
|
try { |
|
|
try { |
|
|
// 插入单据头 |
|
|
// 插入单据头 |
|
|
stagnationDetailMapper.insertSOOpsTransferHeader(transNo, site, "SYSTEM", batchNo); |
|
|
|
|
|
log.debug("插入 SOOpsTransferHeader 成功: {}", transNo); |
|
|
|
|
|
|
|
|
stagnationDetailMapper.insertSOOpsTransferHeader(transNo, site, "SYSTEM", batchNo, type); |
|
|
|
|
|
log.debug("插入 SOOpsTransferHeader 成功: {}, type: {}", transNo, type); |
|
|
|
|
|
|
|
|
// 插入单据明细 |
|
|
// 插入单据明细 |
|
|
stagnationDetailMapper.insertSOOpsTransferDetail(transNo, site, partNo); |
|
|
stagnationDetailMapper.insertSOOpsTransferDetail(transNo, site, partNo); |
|
|
log.debug("插入 SOOpsTransferDetail 成功: {}", transNo); |
|
|
log.debug("插入 SOOpsTransferDetail 成功: {}", transNo); |
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("插入实验室单据失败 - transNo: {}, site: {}, partNo: {}, batchNo: {}", |
|
|
|
|
|
transNo, site, partNo, batchNo, e); |
|
|
|
|
|
|
|
|
log.error("插入实验室单据失败 - transNo: {}, site: {}, partNo: {}, batchNo: {}, type: {}", |
|
|
|
|
|
transNo, site, partNo, batchNo, type, e); |
|
|
throw new RuntimeException("插入实验室单据失败: " + e.getMessage(), e); |
|
|
throw new RuntimeException("插入实验室单据失败: " + e.getMessage(), e); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|