NIMS API 호출시 페이징 처리 - isEndYn = 'Y' 일때 까지

dev
Jonguk. Lim 7 months ago
parent e9c12b7c8c
commit fbc2cf42d8

@ -65,28 +65,46 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
//------------------------------------------------------------------------------------------------------
@Override
public List<BsshInfoSt> saveBsshInfoSt(BsshInfoRequest dto) {
NimsApiResult.Response<BsshInfoSt> result = infNimsService.getBsshInfoSt(dto);
List<BsshInfoSt> list = result.getResult();
List<BsshInfoSt> list = new ArrayList<>();
while(true) {
// 마약류취급자식별번호로 마약류취급자정보 조회
NimsApiResult.Response<BsshInfoSt> rslt = infNimsService.getBsshInfoSt(dto);
List<BsshInfoSt> curList = rslt.getResult();
if(isEmpty(list)) return list;
if(isEmpty(curList)) break;
for (BsshInfoSt d : curList) {
d.setRgtr(Constants.NIMS_API_USER_ID);
bizNimsMapper.mergeBsshInfoSt(d);
}
list.addAll(curList);
if(rslt.isEndYn()) break;
dto.setPg(String.valueOf(Integer.parseInt(dto.getPg()) + 1));
for (BsshInfoSt d : list) {
d.setRgtr(Constants.NIMS_API_USER_ID);
bizNimsMapper.mergeBsshInfoSt(d);
}
return list;
}
@Override
public List<NimsApiDto.ProductInfoKd> saveProductInfoKd(NimsApiRequest.ProductInfoRequest dto) {
NimsApiResult.Response<NimsApiDto.ProductInfoKd> result = infNimsService.getProductInfoKd(dto);
List<NimsApiDto.ProductInfoKd> list = result.getResult();
List<NimsApiDto.ProductInfoKd> list = new ArrayList<>();
while(true) {
// 제품코드로 제품정보 조회
NimsApiResult.Response<NimsApiDto.ProductInfoKd> rslt = infNimsService.getProductInfoKd(dto);
List<NimsApiDto.ProductInfoKd> curList = rslt.getResult();
if(isEmpty(list)) return list;
if(isEmpty(curList)) break;
for (NimsApiDto.ProductInfoKd d : list) {
d.setRgtr(Constants.NIMS_API_USER_ID);
bizNimsMapper.mergeProductInfoKd(d);
for (NimsApiDto.ProductInfoKd d : curList) {
d.setRgtr(Constants.NIMS_API_USER_ID);
bizNimsMapper.mergeProductInfoKd(d);
}
list.addAll(curList);
if(rslt.isEndYn()) break;
dto.setPg(String.valueOf(Integer.parseInt(dto.getPg()) + 1));
}
return list;
}
@ -141,10 +159,19 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe
*/
@Override
public List<NimsApiDto.DsuseRptInfo> saveDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest reqDto) {
List<NimsApiDto.DsuseRptInfo> rsltList = new ArrayList<>();
while(true) {
NimsApiResult.Response<NimsApiDto.DsuseRptInfo> rslt = infNimsService.getDsuseRptInfo(reqDto);
List<NimsApiDto.DsuseRptInfo> curList = rslt.getResultOrThrow();
NimsApiResult.Response<NimsApiDto.DsuseRptInfo> result = infNimsService.getDsuseRptInfo(reqDto);
List<NimsApiDto.DsuseRptInfo> rsltList = result.getResultOrThrow();
if(isEmpty(curList)) break;
rsltList.addAll(curList);
if(rslt.isEndYn()) break;
reqDto.setPg(String.valueOf(Integer.parseInt(reqDto.getPg()) + 1));
}
// 0. 조회(저장)한 데이타 대상 에서 제외 (usrRptIdNo가 DB에 저장된 경우)
List<NimsApiDto.DsuseRptInfo> list = new ArrayList<>();
for (NimsApiDto.DsuseRptInfo dto : rsltList) {

@ -91,6 +91,11 @@ public class NimsApiResult<T> {
}
throw Objects.requireNonNull(ApiCustomException.of(header));
}
@JsonIgnore
public boolean isEndYn() {
return "Y".equals(body.isEndYn);
}
}
@JsonInclude(JsonInclude.Include.NON_NULL)

Loading…
Cancel
Save