diff --git a/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java b/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java index 5481ee4..9ac33e1 100644 --- a/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java +++ b/src/main/java/cokr/xit/adds/biz/nims/service/bean/BizNimsServiceBean.java @@ -65,28 +65,46 @@ public class BizNimsServiceBean extends AbstractServiceBean implements BizNimsSe //------------------------------------------------------------------------------------------------------ @Override public List saveBsshInfoSt(BsshInfoRequest dto) { - NimsApiResult.Response result = infNimsService.getBsshInfoSt(dto); - List list = result.getResult(); + List list = new ArrayList<>(); + while(true) { + // 마약류취급자식별번호로 마약류취급자정보 조회 + NimsApiResult.Response rslt = infNimsService.getBsshInfoSt(dto); + List 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 saveProductInfoKd(NimsApiRequest.ProductInfoRequest dto) { - NimsApiResult.Response result = infNimsService.getProductInfoKd(dto); - List list = result.getResult(); + List list = new ArrayList<>(); + + while(true) { + // 제품코드로 제품정보 조회 + NimsApiResult.Response rslt = infNimsService.getProductInfoKd(dto); + List 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 saveDsuseRptInfo(NimsApiRequest.DsuseRptInfoRequest reqDto) { + List rsltList = new ArrayList<>(); + + while(true) { + NimsApiResult.Response rslt = infNimsService.getDsuseRptInfo(reqDto); + List curList = rslt.getResultOrThrow(); - NimsApiResult.Response result = infNimsService.getDsuseRptInfo(reqDto); - List 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 list = new ArrayList<>(); for (NimsApiDto.DsuseRptInfo dto : rsltList) { diff --git a/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiResult.java b/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiResult.java index d3dbbe7..674ea63 100644 --- a/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiResult.java +++ b/src/main/java/cokr/xit/adds/inf/nims/model/NimsApiResult.java @@ -91,6 +91,11 @@ public class NimsApiResult { } throw Objects.requireNonNull(ApiCustomException.of(header)); } + + @JsonIgnore + public boolean isEndYn() { + return "Y".equals(body.isEndYn); + } } @JsonInclude(JsonInclude.Include.NON_NULL)