[bomList배치] Reader 단 statCd='D' 우선 전역 정렬 — 청크 경계 A+D 분리 시 A 가 이김 보장 #504
@ -6,6 +6,7 @@ import com.interplug.qcast.biz.displayItem.dto.BomSyncResponse;
|
|||||||
import com.interplug.qcast.util.InterfaceQsp;
|
import com.interplug.qcast.util.InterfaceQsp;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.springframework.batch.core.Job;
|
import org.springframework.batch.core.Job;
|
||||||
import org.springframework.batch.core.JobExecutionListener;
|
import org.springframework.batch.core.JobExecutionListener;
|
||||||
@ -62,9 +63,16 @@ public class BomConfiguration implements JobExecutionListener {
|
|||||||
this.bomSyncList =
|
this.bomSyncList =
|
||||||
interfaceQsp.callApiData(
|
interfaceQsp.callApiData(
|
||||||
HttpMethod.GET, qspInterfaceUrl, null, new TypeReference<List<BomSyncResponse>>() {});
|
HttpMethod.GET, qspInterfaceUrl, null, new TypeReference<List<BomSyncResponse>>() {});
|
||||||
return (bomSyncList != null)
|
if (bomSyncList == null) {
|
||||||
? new ListItemReader<>(bomSyncList)
|
return new ListItemReader<>(Collections.emptyList());
|
||||||
: new ListItemReader<>(Collections.emptyList());
|
}
|
||||||
|
// 2026-05-20 청크 경계에서 같은 키 A/D 가 분리되어 A 가 먼저 MERGE 된 뒤
|
||||||
|
// 다음 청크의 D 가 그것을 삭제해버리는 리스크를 차단하기 위해,
|
||||||
|
// 전체 리스트를 statCd='D' 우선으로 정렬한다. (Spring Batch 는 청크를 순차 처리하므로
|
||||||
|
// 모든 D 청크가 끝난 뒤에 A/U 청크가 시작되어 전역적으로 'A 가 이김' 이 보장됨)
|
||||||
|
bomSyncList.sort(
|
||||||
|
Comparator.comparingInt((BomSyncResponse b) -> "D".equals(b.getStatCd()) ? 0 : 1));
|
||||||
|
return new ListItemReader<>(bomSyncList);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user