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

master
minkyu1128 3 years ago
parent 01a2a82c42
commit 96327fd687

@ -14,7 +14,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
@ -33,13 +32,35 @@ public class NiceCiService {
* -. . * -. .
* -. . * -. .
* -. -> -> CI (88 byte) * -. -> -> CI (88 byte)
*
* @param siteCode * @param siteCode
* @param sitePw * @param sitePw
* @param jids * @param jids
* @return * @return
*/ */
public ResponseVO findAllBySiteCodeAndSitePwAndJidIn(String siteCode, String sitePw, List<String> jids) { 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() return ResponseVO.builder()
.errCode(ErrCd.OK) .errCode(ErrCd.OK)
.errMsg(ErrCd.OK.getCodeNm()) .errMsg(ErrCd.OK.getCodeNm())
@ -71,9 +92,6 @@ public class NiceCiService {
if ("socket".equals(type)) { if ("socket".equals(type)) {
responseVO = Interop.getCI(siteCode, sitePw, jid); responseVO = Interop.getCI(siteCode, sitePw, jid);
} else if ("rest".equals(type)) { } else if ("rest".equals(type)) {
if(0 == i.getAndIncrement())
if(!SymmetricKey.isValidStat())
niceCiGenerator.initialKey();
responseVO = niceCiGenerator.getCI(jid, null); responseVO = niceCiGenerator.getCI(jid, null);
} }

Loading…
Cancel
Save