병렬스트림 사용 시 키정보를 한번만 초기화하도록 수정

master
minkyu1128 3 years ago
parent 01a2a82c42
commit 96327fd687

@ -14,7 +14,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
@Slf4j
@ -33,13 +32,35 @@ public class NiceCiService {
* -. .
* -. .
* -. -> -> CI (88 byte)
*
* @param siteCode
* @param sitePw
* @param jids
* @return
*/
public ResponseVO findAllBySiteCodeAndSitePwAndJidIn(String siteCode, String sitePw, List<String> jids) {
AtomicInteger i = new AtomicInteger();
/* ========================
* (rest API CI )
* -. .
======================== */
if ("rest".equals(type))
if (!SymmetricKey.isValidStat()) {
ResponseVO responseVO = niceCiGenerator.initialKey();
if (!ErrCd.OK.equals(responseVO.getErrCode()))
return ResponseVO.builder()
.errCode(ErrCd.OK)
.errMsg(ErrCd.OK.getCodeNm())
.resultInfo(jids.stream()
.map(jid -> {
Map<String, Object> m = new HashMap<>();
m.put("key", jid);
m.put("value", responseVO);
return m;
})
.collect(Collectors.toMap(m -> String.valueOf(m.get("key")), m -> m.get("value"), (k1, k2) -> k1)))
.build();
}
return ResponseVO.builder()
.errCode(ErrCd.OK)
.errMsg(ErrCd.OK.getCodeNm())
@ -52,15 +73,15 @@ public class NiceCiService {
/* ========================
* validate
======================== */
if(!Optional.ofNullable(siteCode).isPresent()){
if (!Optional.ofNullable(siteCode).isPresent()) {
responseVO = ResponseVO.builder().errCode(ErrCd.ERR401).errMsg("사이트코드(은)는 필수조건 입니다.").build();
throw new RuntimeException(responseVO.getErrMsg());
}
if(!Optional.ofNullable(sitePw).isPresent()){
if (!Optional.ofNullable(sitePw).isPresent()) {
responseVO = ResponseVO.builder().errCode(ErrCd.ERR401).errMsg("사이트 패스워드(은)는 필수조건 입니다.").build();
throw new RuntimeException(responseVO.getErrMsg());
}
if(!Optional.ofNullable(jid).isPresent()){
if (!Optional.ofNullable(jid).isPresent()) {
responseVO = ResponseVO.builder().errCode(ErrCd.ERR401).errMsg("서비스 구분값(주민번호:JID)(은)는 필수조건 입니다.").build();
throw new RuntimeException(responseVO.getErrMsg());
}
@ -68,16 +89,13 @@ public class NiceCiService {
/* ========================
* api call
======================== */
if("socket".equals(type)) {
if ("socket".equals(type)) {
responseVO = Interop.getCI(siteCode, sitePw, jid);
}else if("rest".equals(type)){
if(0 == i.getAndIncrement())
if(!SymmetricKey.isValidStat())
niceCiGenerator.initialKey();
} else if ("rest".equals(type)) {
responseVO = niceCiGenerator.getCI(jid, null);
}
} catch (Exception e){
} catch (Exception e) {
log.error(e.getMessage());
} finally {
/* ========================
@ -90,7 +108,7 @@ public class NiceCiService {
}
})
.collect(Collectors.toMap(m -> String.valueOf(m.get("key")), m -> m.get("value"), (k1, k2)->k1)))
.collect(Collectors.toMap(m -> String.valueOf(m.get("key")), m -> m.get("value"), (k1, k2) -> k1)))
.build();
}

Loading…
Cancel
Save