Merge pull request 'dev' (#373) from dev into dev-deploy

Reviewed-on: #373
This commit is contained in:
ysCha 2026-02-05 14:55:00 +09:00
commit 15deda383a
2 changed files with 138 additions and 72 deletions

View File

@ -4,8 +4,11 @@ import com.fasterxml.jackson.core.type.TypeReference;
import com.interplug.qcast.biz.displayItem.DisplayItemService;
import com.interplug.qcast.biz.displayItem.dto.ItemSyncResponse;
import com.interplug.qcast.util.InterfaceQsp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.Step;
@ -34,6 +37,9 @@ public class MaterialConfiguration implements JobExecutionListener {
@Value("${qsp.master-material-batch-url}")
private String qspInterfaceUrl;
@Value("${qsp.master-material-batch-page-size:1000}")
private int pageSize;
public MaterialConfiguration(DisplayItemService displayItemService, InterfaceQsp interfaceQsp) {
this.displayItemService = displayItemService;
this.interfaceQsp = interfaceQsp;
@ -58,12 +64,32 @@ public class MaterialConfiguration implements JobExecutionListener {
@Bean
@StepScope
public ListItemReader<ItemSyncResponse> materialReader() throws Exception {
this.itemSyncList =
List<ItemSyncResponse> aggregated = new ArrayList<>();
int page = 1;
while (true) {
Map<String, Object> params = new HashMap<>();
params.put("allYn", "N");
params.put("page", page);
params.put("size", pageSize);
List<ItemSyncResponse> pageItems =
interfaceQsp.callApiData(
HttpMethod.GET,
qspInterfaceUrl + "?allYn=N",
null,
qspInterfaceUrl,
params,
new TypeReference<List<ItemSyncResponse>>() {});
if (pageItems == null || pageItems.isEmpty()) {
break;
}
aggregated.addAll(pageItems);
if (pageItems.size() < pageSize) {
break;
}
page++;
}
this.itemSyncList = aggregated;
return (itemSyncList != null)
? new ListItemReader<>(itemSyncList)
: new ListItemReader<>(Collections.emptyList());

View File

@ -45,6 +45,8 @@ public class InterfaceQsp {
OutputStreamWriter osw = null;
BufferedReader br = null;
StringBuilder sb = null;
long startAt = System.currentTimeMillis();
String requestType = requestObject == null ? "none" : requestObject.getClass().getSimpleName();
try {
@ -60,6 +62,11 @@ public class InterfaceQsp {
apiPath += "?" + queryString; // 쿼리 스트링 추가
}
log.debug(
"QSP API call start: method={}, url={}, requestType={}",
httpMethod,
apiPath,
requestType);
url = new URL(apiPath);
con = (HttpURLConnection) url.openConnection();
con.setConnectTimeout(120000); // 서버에 연결되는 Timeout 시간 설정
@ -84,7 +91,8 @@ public class InterfaceQsp {
}
sb = new StringBuilder();
if (con.getResponseCode() == HttpURLConnection.HTTP_OK) {
int status = con.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"));
String line;
@ -92,7 +100,19 @@ public class InterfaceQsp {
sb.append(line);
}
}
log.debug(
"QSP API call end: method={}, url={}, status={}, durationMs={}",
httpMethod,
apiPath,
status,
System.currentTimeMillis() - startAt);
} catch (Exception e) {
log.error(
"QSP API call failed: method={}, url={}, durationMs={}",
httpMethod,
apiPath,
System.currentTimeMillis() - startAt,
e);
throw e;
} finally {
try {
@ -166,8 +186,15 @@ public class InterfaceQsp {
BufferedReader br = null;
byte[] bt = null;
long startAt = System.currentTimeMillis();
String requestType = requestObject == null ? "none" : requestObject.getClass().getSimpleName();
try {
log.debug(
"QSP API call start: method={}, url={}, requestType={}",
httpMethod,
apiPath,
requestType);
url = new URL(apiPath);
con = (HttpURLConnection) url.openConnection();
con.setConnectTimeout(30000); // 서버에 연결되는 Timeout 시간 설정
@ -190,7 +217,8 @@ public class InterfaceQsp {
osw.flush();
}
}
if (con.getResponseCode() == HttpURLConnection.HTTP_OK) {
int status = con.getResponseCode();
if (status == HttpURLConnection.HTTP_OK) {
// response 헤더 결과 셋팅
result.put("type", con.getHeaderField("Content-Type"));
result.put("disposition", con.getHeaderField("Content-Disposition"));
@ -205,7 +233,19 @@ public class InterfaceQsp {
}
bt = outputStream.toByteArray(); // 파일 데이터 반환
}
log.debug(
"QSP API call end: method={}, url={}, status={}, durationMs={}",
httpMethod,
apiPath,
status,
System.currentTimeMillis() - startAt);
} catch (Exception e) {
log.error(
"QSP API call failed: method={}, url={}, durationMs={}",
httpMethod,
apiPath,
System.currentTimeMillis() - startAt,
e);
throw e;
} finally {
try {