demand: 漏组批次相关需求

committer: heyu
This commit is contained in:
aike 2025-11-27 10:58:43 +08:00
parent cb31dd1901
commit 0ddf1b729d
3 changed files with 43 additions and 11 deletions

View File

@ -981,14 +981,28 @@ public class EmisCommonController extends EmisBaseController
log.info("Found {} unique line codes, starting batch processing", lineCodeSet.size()); log.info("Found {} unique line codes, starting batch processing", lineCodeSet.size());
// 循环调用 // 循环调用,最后一个才清除状态
int index = 0;
int totalSize = lineCodeSet.size();
for (String code : lineCodeSet) { for (String code : lineCodeSet) {
try { try {
emisTmsSiteBatchMissService.autoScanSiteBatch(code); index++;
log.info("autoScanSiteBatch processed for lineCode: {}", code); // 最后一个lineCode才清除状态
boolean clearStatus = (index == totalSize);
emisTmsSiteBatchMissService.autoScanSiteBatch(code, clearStatus);
log.info("autoScanSiteBatch processed for lineCode: {} ({}/{})", code, index, totalSize);
} catch (Exception e) { } catch (Exception e) {
log.error("autoScanSiteBatch failed for lineCode: {}, error: {}", code, e.getMessage()); log.error("autoScanSiteBatch failed for lineCode: {}, error: {}", code, e.getMessage());
// 继续处理下一个,不中断整个流程 // 继续处理下一个,不中断整个流程
// 如果最后一个失败,需要清除状态
if (index == totalSize) {
try {
redissonService.setStr(statusKey, "", 0);
log.info("autoScanSiteBatch status cleared after last task failed");
} catch (Exception ex) {
log.error("Failed to clear status after last task failed", ex);
}
}
} }
} }

View File

@ -73,6 +73,14 @@ public interface IEmisTmsSiteBatchMissService {
*/ */
void autoScanSiteBatch(String lineCode); void autoScanSiteBatch(String lineCode);
/**
* 定时扫描运单货物组批次是否正确录入
*
* @param lineCode 线路代码
* @param clearStatus 是否清除状态,true-清除,false-不清除
*/
void autoScanSiteBatch(String lineCode, boolean clearStatus);
/** /**
* 根据bill_code出现次数查询TMS漏组批次信息 * 根据bill_code出现次数查询TMS漏组批次信息
* *

View File

@ -303,6 +303,12 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
@Async @Async
@Override @Override
public void autoScanSiteBatch(String lineCode) { public void autoScanSiteBatch(String lineCode) {
autoScanSiteBatch(lineCode, true);
}
@Async
@Override
public void autoScanSiteBatch(String lineCode, boolean clearStatus) {
ExecutorService executorService = null; ExecutorService executorService = null;
try { try {
emisTmsSiteBatchMissMapper.deleteReally(lineCode); emisTmsSiteBatchMissMapper.deleteReally(lineCode);
@ -382,7 +388,7 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
log.info("Processing {} batches with batch size: {}, total waybills: {}", log.info("Processing {} batches with batch size: {}, total waybills: {}",
batches.size(), batchSize, allWaybills.size()); batches.size(), batchSize, allWaybills.size());
// 复用现有线程池(老版逻辑使用 EmisBaseService.ProcessResult) // 复用现有线程池
List<Future<EmisBaseService.ProcessResult>> processFutures = new ArrayList<>(); List<Future<EmisBaseService.ProcessResult>> processFutures = new ArrayList<>();
for (List<EmisWaybill> batch : batches) { for (List<EmisWaybill> batch : batches) {
@ -480,13 +486,17 @@ public class EmisTmsSiteBatchMissServiceImpl extends EmisBaseService implements
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }
// 清除任务状态 // 清除任务状态(根据参数决定是否清除)
try { if (clearStatus) {
String statusKey = "autoScanSiteBatch_status"; try {
redissonService.setStr(statusKey, "", 0); String statusKey = "autoScanSiteBatch_status";
log.info("autoScanSiteBatch task status cleared"); redissonService.setStr(statusKey, "", 0);
} catch (Exception e) { log.info("autoScanSiteBatch task status cleared");
log.error("Failed to clear autoScanSiteBatch status", e); } catch (Exception e) {
log.error("Failed to clear autoScanSiteBatch status", e);
}
} else {
log.info("autoScanSiteBatch task completed, status not cleared (will be cleared after all tasks)");
} }
} }
} }