Merge branch 'jenkins_with_weblogic' into features/ui-improvements

This commit is contained in:
daekuk
2026-02-10 10:41:19 +09:00
15 changed files with 291 additions and 353 deletions
+2 -2
View File
@@ -6,9 +6,9 @@
<context-root>monitoring</context-root> <context-root>monitoring</context-root>
<session-descriptor> <session-descriptor>
<timeout-secs>3600</timeout-secs> <timeout-secs>1800</timeout-secs>
<cookie-name>JSESSIONID_EMS</cookie-name> <cookie-name>JSESSIONID_EMS</cookie-name>
<persistent-store-type>memory</persistent-store-type> <!-- <persistent-store-type>memory</persistent-store-type>-->
<persistent-store-type>replicated_if_clustered</persistent-store-type> <persistent-store-type>replicated_if_clustered</persistent-store-type>
</session-descriptor> </session-descriptor>
@@ -211,6 +211,22 @@
layoutInfo = json.standardHeader; layoutInfo = json.standardHeader;
bzwkdatatntInfo = json.BZWKDATACTNT; bzwkdatatntInfo = json.BZWKDATACTNT;
// bzwkdatatntInfoLength 파싱 및 패딩 처리
let bzwkdatatntInfoLength = 0;
try {
bzwkdatatntInfoLength = parseInt(layoutInfo[layoutInfo.length - 2].value, 10);
if (isNaN(bzwkdatatntInfoLength)) {
bzwkdatatntInfoLength = 0;
}
} catch (e) {
bzwkdatatntInfoLength = 0;
}
// bzwkdatatntInfo 패딩 적용
if (bzwkdatatntInfoLength > 0 && bzwkdatatntInfo) {
bzwkdatatntInfo = padByteString(bzwkdatatntInfo, bzwkdatatntInfoLength);
}
if((isInboundPart && isInboundWithoutNet) || (isOutboundPart && isOutboundWithoutNet)){ if((isInboundPart && isInboundWithoutNet) || (isOutboundPart && isOutboundWithoutNet)){
selectHttpLog(url, prcsDate, json.EAISVCSERNO.trim(), logPrcssSerno); selectHttpLog(url, prcsDate, json.EAISVCSERNO.trim(), logPrcssSerno);
}else{ }else{
@@ -900,6 +916,39 @@ $(document).ready(function() {
}); });
/**
* 문자열의 바이트 수 계산 (한글 2바이트, 영문/숫자 1바이트)
*/
function getByteLength(str) {
let byteCount = 0;
for (let i = 0; i < str.length; i++) {
const charCode = str.charCodeAt(i);
byteCount += (charCode >= 0xAC00 && charCode <= 0xD7A3) ? 2 : 1;
}
return byteCount;
}
/**
* 문자열을 주어진 바이트 수만큼 패딩
* @param {string} str - 원본 문자열
* @param {number} targetBytes - 목표 바이트 수
* @param {string} position - 'left' 또는 'right' (기본: 'right')
* @param {string} padChar - 패딩 문자 (기본: 공백)
* @returns {string} - 패딩된 문자열
*/
function padByteString(str, targetBytes, position = 'right', padChar = ' ') {
const currentBytes = getByteLength(str);
if (currentBytes >= targetBytes) {
return str; // 이미 목표 바이트 이상이면 그대로 반환
}
const paddingBytes = targetBytes - currentBytes;
const padding = padChar.repeat(paddingBytes);
return position === 'left' ? padding + str : str + padding;
}
</script> </script>
<style> <style>
.dialog_confirm{ .dialog_confirm{
+1 -1
View File
@@ -1,4 +1,4 @@
org.gradle.jvmargs=-Xmx2g org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
org.gradle.parallel=true org.gradle.parallel=true
org.gradle.caching=true org.gradle.caching=true
org.gradle.configureondemand=true org.gradle.configureondemand=true
@@ -2,6 +2,9 @@ package com.eactive.eai.rms.data.entity.onl.apim.obp;
import com.eactive.apim.portal.obp.entity.ObpGwMetric; import com.eactive.apim.portal.obp.entity.ObpGwMetric;
import com.eactive.apim.portal.obp.repository.ObpGwMetricRepository; import com.eactive.apim.portal.obp.repository.ObpGwMetricRepository;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -50,6 +53,24 @@ public class ObpGwMetricService {
return repository.findByTimesliceGreaterThanEqual(timeslice); return repository.findByTimesliceGreaterThanEqual(timeslice);
} }
/**
* 특정 시간대 이후의 GwMetric 데이터 조회 (row 수 제한)
*
* @param timeslice 조회 시작 시간대
* @param limit 최대 조회 건수 (0이면 무제한)
* @return 조회된 지표 목록 (timeslice ASC 정렬)
*/
public List<ObpGwMetric> findByTimesliceGreaterThanEqual(LocalDateTime timeslice, int limit) {
if (limit <= 0) {
// 무제한 조회 (기존 동작 유지)
return repository.findByTimesliceGreaterThanEqual(timeslice);
} else {
// 제한적 조회 (timeslice ASC 정렬 + limit)
Pageable pageable = PageRequest.of(0, limit, Sort.by(Sort.Order.asc("timeslice")));
return repository.findByTimesliceGreaterThanEqual(timeslice, pageable);
}
}
/** /**
* 엔티티 저장 (INSERT 또는 UPDATE) * 엔티티 저장 (INSERT 또는 UPDATE)
*/ */
@@ -7,8 +7,9 @@ import com.eactive.ext.kjb.common.KjbPropertyHolder;
import com.eactive.ext.kjb.common.KjbUmsException; import com.eactive.ext.kjb.common.KjbUmsException;
import com.eactive.ext.kjb.ums.KjbUmsService; import com.eactive.ext.kjb.ums.KjbUmsService;
import com.eactive.ext.kjb.ums.UmsBizWorkCode; import com.eactive.ext.kjb.ums.UmsBizWorkCode;
import com.eactive.ext.kjb.ums.gson.IUmsGsonObject; import com.eactive.ext.kjb.ums.gson.GsonUtil;
import com.eactive.ext.kjb.ums.gson.VerifyPhoneUmsTemplate; import com.eactive.ext.kjb.ums.gson.VerifyPhoneUmsTemplate;
import com.google.gson.JsonObject;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@@ -121,8 +122,7 @@ public class SmsAuthService {
String guid = String.format("EAPIM_EMS-%s", String guid = String.format("EAPIM_EMS-%s",
DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now())); DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS").format(LocalDateTime.now()));
IUmsGsonObject content = null; JsonObject content = GsonUtil.toJsonObject(VerifyPhoneUmsTemplate.builder().authNumber(authCode).build());
content = VerifyPhoneUmsTemplate.builder().authNumber(authCode).build();
getUmsService().sendKakaoAlimTalk(guid, UmsBizWorkCode.VERIFY_PHONE, cleanedPhone, content); getUmsService().sendKakaoAlimTalk(guid, UmsBizWorkCode.VERIFY_PHONE, cleanedPhone, content);
log.info("SMS 인증번호 발송 완료 - guid: {}, phone: {}****{}", log.info("SMS 인증번호 발송 완료 - guid: {}, phone: {}****{}",
@@ -1,131 +0,0 @@
package com.eactive.eai.rms.onl.apim.obp;
import com.eactive.apim.portal.obp.entity.ObpGwMetric;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/**
* ObpGwMetric JSON 응답 DTO (after-timeslice 엔드포인트용)
*
* <p>예시 출력 형식에 맞춤:</p>
* <pre>
* {
* "apiId": "1ba56b82-a9c9-41e2-b3ab-ff9377667d56",
* "apiName": "[해외송금] 가상계좌 입금실패 정보조회",
* "apiRoutingUri": "/api/obs/remittance/remittancefail*",
* "httpMethod": "POST",
* "orgId": "ORG001",
* "partnerCode": "000008-01",
* "appId": "APP001",
* "appKey": "l7xx2fd7efc523794be5a1b126873a5de613",
* "requestUri": "-1",
* "timeslice": "2025-12-02T03:00:00.000+0000",
* "attemptedCount": 3,
* "completedCount": 3
* }
* </pre>
*/
@Data
public class ObpGwMetricAfterDTO {
private static final DateTimeFormatter ISO8601_MILLIS_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'+0000'");
@SerializedName("apiId")
private String apiId;
@SerializedName("apiName")
private String apiName;
@SerializedName("apiRoutingUri")
private String apiRoutingUri;
@SerializedName("httpMethod")
private String httpMethod;
@SerializedName("orgId")
private String orgId;
@SerializedName("partnerCode")
private String partnerCode;
@SerializedName("appId")
private String appId;
@SerializedName("appKey")
private String appKey;
@SerializedName("requestUri")
private String requestUri;
@SerializedName("timeslice")
private String timeslice;
@SerializedName("attemptedCount")
private Long attemptedCount;
@SerializedName("completedCount")
private Long completedCount;
// AS-IS 호환을 위한 필드 (null 값으로 리턴)
@SerializedName("clusterHostname")
private String clusterHostname = null;
@SerializedName("apiDatabaseId")
private Integer apiDatabaseId = null;
@SerializedName("unauthorizedCount")
private Integer authorizedCount = null;
@SerializedName("backMinTime")
private Integer backMinTime = null;
@SerializedName("backMaxTime")
private Integer backMaxTime = null;
@SerializedName("backSumTime")
private Integer backSumTime = null;
@SerializedName("frontMinTime")
private Integer frontMinTime = null;
@SerializedName("frontMaxTime")
private Integer frontMaxTime = null;
@SerializedName("frontSumTime")
private Integer frontSumTime = null;
/**
* Entity → DTO 변환
*/
public static ObpGwMetricAfterDTO from(ObpGwMetric entity) {
ObpGwMetricAfterDTO dto = new ObpGwMetricAfterDTO();
dto.setApiId(entity.getApiId());
dto.setApiName(entity.getApiName());
dto.setApiRoutingUri(entity.getUri());
dto.setHttpMethod(entity.getMethod());
dto.setOrgId(entity.getOrgId());
dto.setPartnerCode(entity.getPartnerCode());
dto.setAppId(entity.getAppId());
dto.setAppKey(entity.getClientId());
dto.setRequestUri(entity.getRequestUri());
dto.setTimeslice(formatTimeslice(entity.getTimeslice()));
dto.setAttemptedCount(entity.getAttemptedCount());
dto.setCompletedCount(entity.getCompletedCount());
return dto;
}
/**
* timeslice를 ISO8601 형식 (밀리초 포함) + UTC 시간대로 변환
* 예: 2025-12-02T03:00:00.000+0000
*/
private static String formatTimeslice(LocalDateTime timeslice) {
if (timeslice == null) return null;
return timeslice.format(ISO8601_MILLIS_FORMATTER);
}
}
@@ -55,12 +55,12 @@ public class ObpGwMetricController extends BaseRestController {
produces = JSON_CONTENT_TYPE produces = JSON_CONTENT_TYPE
) )
@ResponseBody @ResponseBody
public String getGwMetricsAfterTimesliceV2( public String getGwMetricsAfterTimeslice(
@PathVariable("timeslice") String timeslice, @PathVariable("timeslice") String timeslice,
@PathVariable("providerCode") String providerCode, @PathVariable("providerCode") String providerCode,
@RequestParam(value = "pretty", required = false) Boolean pretty) { @RequestParam(value = "pretty", required = false) Boolean pretty) {
log.debug("GwMetric after-timeslice 조회 요청 (v2): timeslice={}, providerCode={}, pretty={}", log.debug("GwMetric after-timeslice 조회 요청: timeslice={}, providerCode={}, pretty={}",
timeslice, providerCode, pretty); timeslice, providerCode, pretty);
long startTime = System.currentTimeMillis(); long startTime = System.currentTimeMillis();
@@ -85,7 +85,7 @@ public class ObpGwMetricController extends BaseRestController {
DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.MONITORING)); DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.MONITORING));
// 5. 데이터 조회 // 5. 데이터 조회
List<ObpGwMetricAfterDTO> metrics = obpGwMetricManService.findByTimesliceAfter(timesliceHour); List<ObpGwMetricDTO> metrics = obpGwMetricManService.findByTimesliceAfter(timesliceHour);
// 6. JSON 변환 // 6. JSON 변환
String json = toJson(metrics, pretty); String json = toJson(metrics, pretty);
@@ -104,90 +104,4 @@ public class ObpGwMetricController extends BaseRestController {
throw new BizException("Failed to retrieve metrics: " + e.getMessage(), e); throw new BizException("Failed to retrieve metrics: " + e.getMessage(), e);
} }
} }
/**
* 특정 시간대의 GwMetric 데이터 조회
*
* @param datetime 조회 시간대 (형식: yyyy-MM-dd_HH:mm:ss)
* @param pretty true면 JSON 들여쓰기 적용
* @return JSON Array
*/
@RequestMapping(
value = "/kjb/gw-metrics/{datetime}.json",
produces = JSON_CONTENT_TYPE
)
@ResponseBody
public String getGwMetrics(
@PathVariable("datetime") String datetime,
@RequestParam(value = "pretty", required = false) Boolean pretty) {
log.debug("GwMetric 조회 요청: datetime={}, pretty={}", datetime, pretty);
long startTime = System.currentTimeMillis();
try {
// Path 파라미터 파싱
LocalDateTime targetTime = LocalDateTime.parse(datetime, PATH_FORMATTER);
LocalDateTime timeslice = targetTime.withMinute(0).withSecond(0).withNano(0);
// 조회
List<ObpGwMetricDTO> metrics = obpGwMetricManService.findByTimeslice(timeslice);
// JSON 변환 (GSON)
String json = toJson(metrics, pretty);
long elapsed = System.currentTimeMillis() - startTime;
log.info("GwMetric 조회 완료: datetime={}, count={}, size={}, elapsed={}ms",
datetime, metrics.size(), getFormattedJsonSize(json), elapsed);
return json;
} catch (Exception e) {
log.error("GwMetric 조회 실패: datetime={}", datetime, e);
throw e;
}
}
/**
* 특정 시간대 이후의 GwMetric 데이터 조회
*
* @param datetime 조회 시작 시간대 (형식: yyyy-MM-dd_HH:mm:ss)
* @param pretty true면 JSON 들여쓰기 적용
* @return JSON Array (해당 시간대 이후의 모든 지표)
* @deprecated Use {@link #getGwMetricsAfterTimesliceV2(String, String, Boolean)} instead.
* Migrate to /api/metrics/afterTimeslice/{timeslice}/{providerCode}
* Will be removed in next major version.
*/
@Deprecated
@RequestMapping(
value = "/kjb/gw-metrics/after-timeslice/{datetime}.json",
produces = JSON_CONTENT_TYPE
)
@ResponseBody
public String getGwMetricsAfterTimeslice(
@PathVariable("datetime") String datetime,
@RequestParam(value = "pretty", required = false) Boolean pretty) {
log.debug("GwMetric after-timeslice 조회 요청: datetime={}, pretty={}", datetime, pretty);
long startTime = System.currentTimeMillis();
try {
// Path 파라미터 파싱
LocalDateTime targetTime = LocalDateTime.parse(datetime, PATH_FORMATTER);
LocalDateTime timeslice = targetTime.withMinute(0).withSecond(0).withNano(0);
// 조회
List<ObpGwMetricAfterDTO> metrics = obpGwMetricManService.findByTimesliceAfter(timeslice);
// JSON 변환 (GSON)
String json = toJson(metrics, pretty);
long elapsed = System.currentTimeMillis() - startTime;
log.info("GwMetric after-timeslice 조회 완료: datetime={}, count={}, size={}, elapsed={}ms",
datetime, metrics.size(), getFormattedJsonSize(json), elapsed);
return json;
} catch (Exception e) {
log.error("GwMetric after-timeslice 조회 실패: datetime={}", datetime, e);
throw e;
}
}
} }
@@ -8,32 +8,61 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
/** /**
* ObpGwMetric JSON 응답 DTO * ObpGwMetric JSON 응답 DTO (after-timeslice 엔드포인트용)
* Entity 주석에 명시된 JSON Key 사용 *
* <p>예시 출력 형식에 맞춤:</p>
* <pre>
* {
* "apiId": "1ba56b82-a9c9-41e2-b3ab-ff9377667d56",
* "apiName": "[해외송금] 가상계좌 입금실패 정보조회",
* "apiRoutingUri": "/api/obs/remittance/remittancefail*",
* "httpMethod": "POST",
* "orgId": "ORG001",
* "partnerCode": "000008-01",
* "appId": "APP001",
* "appKey": "l7xx2fd7efc523794be5a1b126873a5de613",
* "requestUri": "-1",
* "timeslice": "2025-12-02T03:00:00.000+0000",
* "attemptedCount": 3,
* "completedCount": 3
* }
* </pre>
*/ */
@Data @Data
public class ObpGwMetricDTO { public class ObpGwMetricDTO {
private static final DateTimeFormatter ISO8601_FORMATTER = private static final DateTimeFormatter ISO8601_MILLIS_FORMATTER =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'+0000'"); DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'+0900'");
@SerializedName("appKey") @SerializedName("apiId")
private String clientId; private String apiId;
@SerializedName("clusterHostname")
private String hostname;
@SerializedName("timeslice")
private String timeslice;
@SerializedName("apiName") @SerializedName("apiName")
private String apiName; private String apiName;
@SerializedName("apiRoutingUri") @SerializedName("apiRoutingUri")
private String uri; private String apiRoutingUri;
@SerializedName("httpMethod") @SerializedName("httpMethod")
private String method; private String httpMethod;
@SerializedName("orgId")
private String orgId;
@SerializedName("partnerCode")
private String partnerCode;
@SerializedName("appId")
private String appId;
@SerializedName("appKey")
private String appKey;
@SerializedName("requestUri")
private String requestUri;
@SerializedName("timeslice")
private String timeslice;
@SerializedName("attemptedCount") @SerializedName("attemptedCount")
private Long attemptedCount; private Long attemptedCount;
@@ -41,62 +70,68 @@ public class ObpGwMetricDTO {
@SerializedName("completedCount") @SerializedName("completedCount")
private Long completedCount; private Long completedCount;
// EAPIM ID
@SerializedName("apiIdByEapim")
private String apiId;
@SerializedName("appIdByEapim") // AS-IS 호환을 위한 필드 (null 값으로 리턴)
private String appId; @SerializedName("clusterHostname")
private String clusterHostname = null;
@SerializedName("orgIdByEapim") @SerializedName("apiDatabaseId")
private String orgId; private Integer apiDatabaseId = null;
// AS-IS 호환용 필드 @SerializedName("unauthorizedCount")
@SerializedName("appId") private Integer authorizedCount = null;
private String appIdByCaPortal;
@SerializedName("portalOrgId") @SerializedName("backMinTime")
private String orgIdByCaPortal; private Integer backMinTime = null;
@SerializedName("portalApiId") @SerializedName("backMaxTime")
private String apiIdByCaPortal; private Integer backMaxTime = null;
@SerializedName("partnerCode") @SerializedName("backSumTime")
private String partnerCode; private Integer backSumTime = null;
@SerializedName("frontMinTime")
private Integer frontMinTime = null;
@SerializedName("frontMaxTime")
private Integer frontMaxTime = null;
@SerializedName("frontSumTime")
private Integer frontSumTime = null;
@SerializedName("apiId")
private String apiIdByCa;
/** /**
* Entity → DTO 변환 * Entity → DTO 변환
*/ */
public static ObpGwMetricDTO from(ObpGwMetric entity) { public static ObpGwMetricDTO from(ObpGwMetric entity) {
ObpGwMetricDTO dto = new ObpGwMetricDTO(); ObpGwMetricDTO dto = new ObpGwMetricDTO();
dto.setClientId(entity.getClientId()); dto.setApiId(entity.getApiId());
dto.setHostname(entity.getHostname());
dto.setTimeslice(formatTimeslice(entity.getTimeslice()));
dto.setApiName(entity.getApiName()); dto.setApiName(entity.getApiName());
dto.setUri(entity.getUri()); dto.setApiRoutingUri(entity.getUri());
dto.setMethod(entity.getMethod()); dto.setHttpMethod(entity.getMethod());
dto.setOrgId(entity.getOrgId());
dto.setPartnerCode(entity.getPartnerCode());
dto.setAppId(entity.getAppId());
dto.setAppKey(entity.getClientId());
dto.setRequestUri(entity.getRequestUri());
dto.setTimeslice(formatTimeslice(entity.getTimeslice()));
dto.setAttemptedCount(entity.getAttemptedCount()); dto.setAttemptedCount(entity.getAttemptedCount());
dto.setCompletedCount(entity.getCompletedCount()); dto.setCompletedCount(entity.getCompletedCount());
dto.setApiId(entity.getApiId());
dto.setAppId(entity.getAppId());
dto.setOrgId(entity.getOrgId()); // 260224 - AS-IS 개발자포탈에서 쓰이던 ID 필드 값 삭제(OBP 디비 필드 형식과 맞지 않음)
dto.setAppIdByCaPortal(entity.getAppIdByCaPortal()); dto.setOrgId(null);
dto.setOrgIdByCaPortal(entity.getOrgIdByCaPortal()); dto.setAppId(null);
dto.setApiIdByCaPortal(entity.getApiIdByCaPortal());
dto.setPartnerCode(entity.getPartnerCode());
dto.setApiIdByCa(entity.getApiIdByCa());
return dto; return dto;
} }
/** /**
* timeslice를 ISO8601 형식 + UTC 시간대로 변환 * timeslice를 ISO8601 형식 (밀리초 포함) + UTC 시간대로 변환
* 예: 2025-12-02T01:00:00+0000 * 예: 2025-12-02T03:00:00.000+0000
*/ */
private static String formatTimeslice(LocalDateTime timeslice) { private static String formatTimeslice(LocalDateTime timeslice) {
if (timeslice == null) return null; if (timeslice == null) return null;
return timeslice.format(ISO8601_FORMATTER); return timeslice.format(ISO8601_MILLIS_FORMATTER);
} }
} }
@@ -10,6 +10,7 @@ import com.eactive.eai.rms.common.util.CommonUtil;
import com.eactive.eai.rms.data.entity.onl.apim.obp.ObpGwMetricJpaDAO; import com.eactive.eai.rms.data.entity.onl.apim.obp.ObpGwMetricJpaDAO;
import com.eactive.eai.rms.data.entity.onl.apim.obp.ObpGwMetricService; import com.eactive.eai.rms.data.entity.onl.apim.obp.ObpGwMetricService;
import com.eactive.eai.rms.data.entity.onl.apim.obp.ObpGwMetricVO; import com.eactive.eai.rms.data.entity.onl.apim.obp.ObpGwMetricVO;
import com.eactive.ext.kjb.common.KjbPropertyHolder;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.dao.DataIntegrityViolationException; import org.springframework.dao.DataIntegrityViolationException;
@@ -311,30 +312,32 @@ public class ObpGwMetricManService extends BaseService {
return entity; return entity;
} }
/**
* 특정 시간대의 GwMetric 데이터 조회 (REST API용)
*/
public List<ObpGwMetricDTO> findByTimeslice(LocalDateTime timeslice) {
DataSourceContextHolder.setDataSourceType(
DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.MONITORING));
List<ObpGwMetric> entities = obpGwMetricService.findByTimeslice(timeslice);
return entities.stream()
.map(ObpGwMetricDTO::from)
.collect(Collectors.toList());
}
/** /**
* 특정 시간대 이후의 GwMetric 데이터 조회 (REST API용) * 특정 시간대 이후의 GwMetric 데이터 조회 (REST API용)
* after-timeslice 엔드포인트에서 사용 * after-timeslice 엔드포인트에서 사용
*
* <p>조회 범위 제한:</p>
* <ul>
* <li>pageSize 값을 KjbProperty.apiGwMetricPageSize에서 읽어옴 (기본값: 10000)</li>
* <li>0일 경우 무제한 조회</li>
* <li>정렬: timeslice ASC (오래된 데이터부터 반환)</li>
* </ul>
*/ */
public List<ObpGwMetricAfterDTO> findByTimesliceAfter(LocalDateTime timeslice) { public List<ObpGwMetricDTO> findByTimesliceAfter(LocalDateTime timeslice) {
DataSourceContextHolder.setDataSourceType( DataSourceContextHolder.setDataSourceType(
DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.MONITORING)); DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.MONITORING));
List<ObpGwMetric> entities = obpGwMetricService.findByTimesliceGreaterThanEqual(timeslice); // KjbProperty에서 pageSize 읽기
Integer pageSize = KjbPropertyHolder.get().getApiGwMetricPageSize();
if (pageSize == null) {
pageSize = 10000; // 기본값 (null 안전 처리)
}
// Service 호출 (limit 적용)
List<ObpGwMetric> entities = obpGwMetricService.findByTimesliceGreaterThanEqual(timeslice, pageSize);
return entities.stream() return entities.stream()
.map(ObpGwMetricAfterDTO::from) .map(ObpGwMetricDTO::from)
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@@ -404,7 +404,7 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
String resultS = null; String resultS = null;
ServletInputStream sis = null; ServletInputStream sis = null;
HashMap<String, String> param = new HashMap<String, String>(); HashMap<String, String> param = new HashMap<>();
String recvTime = DateUtil.getDateTime("yyyyMMddHHmmssSS").substring(0, 16); String recvTime = DateUtil.getDateTime("yyyyMMddHHmmssSS").substring(0, 16);
// 초기화 // 초기화
@@ -431,26 +431,33 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
byte[] arg = new byte[request.getContentLength()]; byte[] arg = new byte[request.getContentLength()];
int resultSet = 0; int resultSet = 0;
int total = 0; int total = 0;
String xmlContent = null;
try { try {
resultSet = sis.readLine(arg, 0, arg.length); resultSet = sis.readLine(arg, 0, arg.length);
while(resultSet != -1) { while (resultSet != -1) {
total += resultSet; total += resultSet;
resultSet = sis.readLine(arg, total, 1024); resultSet = sis.readLine(arg, total, 1024);
} }
param.put("recvData", new String(arg, "UTF-8")); xmlContent = new String(arg, "EUC-KR");
} catch(Exception e) { // ===== 인코딩 확인 로그 시작 =====
logger.error("MessageSync.err - don't read the XML File - " + new String(arg), e); logger.info("========== 인코딩 디버깅 정보 ==========");
// 다양한 인코딩으로 읽어보기
logger.info("request.getCharacterEncoding(): {}", request.getCharacterEncoding());
logger.info("request.getContentType(): {}", request.getContentType());
logger.info("Content Length: {} bytes", arg.length);
logger.info("EUC-KR 전체 내용:\n{}", xmlContent);
logger.info("========================================");
// ===== 인코딩 확인 로그 끝 =====
param.put("recvData", xmlContent);
} catch (Exception e) {
logger.error("MessageSync.err - don't read the XML File", e);
param.put("recvData", ""); param.put("recvData", "");
} }
// byte[]로부터 XML 파싱 (BOM 제거) // byte[]로부터 XML 파싱 - EUC-KR로 읽기
String xmlContent = new String(arg, "UTF-8").trim(); Document doc = builder.build(new StringReader(xmlContent));
// BOM 제거 (UTF-8 BOM: EF BB BF)
if (xmlContent.startsWith("\uFEFF")) {
xmlContent = xmlContent.substring(1);
}
Document doc = builder.build(new ByteArrayInputStream(xmlContent.getBytes("UTF-8")));
param.put("logPrcssSeqno", UUIDGenerator.getUUID()); param.put("logPrcssSeqno", UUIDGenerator.getUUID());
// xml 1.1 // xml 1.1
@@ -468,9 +475,9 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
param.put("recvAmndHMS", recvTime); param.put("recvAmndHMS", recvTime);
logger.info(layoutName + " command - [" + command +"]"); logger.info(layoutName + " command - [" + command +"]");
HashMap<String, Object> returnMap = new HashMap<String,Object>(); HashMap<String, Object> returnMap = new HashMap<>();
if( command.equals("delete") ) { if( command.equals("delete") ) {
HashMap<String,Object> vo = new HashMap<String,Object>(); HashMap<String,Object> vo = new HashMap<>();
vo.put("loutName",layoutName); vo.put("loutName",layoutName);
service.deleteLayout(vo); service.deleteLayout(vo);
@@ -496,10 +503,10 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
// } // }
String layout = body.getChild("data").getText(); String layout = body.getChild("data").getText();
logger.info(layoutName + " recv Data - [" + layout + "]"); logger.info("{} recv Data - [{}]]", layoutName, layout);
param.put("recvData", layout); param.put("recvData", layout);
Document doc2 = builder.build(new ByteArrayInputStream(layout.getBytes())); Document doc2 = builder.build(new StringReader(layout));
HashMap<String,Object> vo = new HashMap<String,Object>(); HashMap<String,Object> vo = new HashMap<String,Object>();
@@ -512,7 +519,7 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
if (!"EAI".equalsIgnoreCase(useSystem) && !"FEP".equalsIgnoreCase(useSystem)) { if (!"EAI".equalsIgnoreCase(useSystem) && !"FEP".equalsIgnoreCase(useSystem)) {
String errorMessage = "사용 시스템(" + useSystem + ")인 전문레이아웃은 EAI, FEP로 배포 안됨."; String errorMessage = "사용 시스템(" + useSystem + ")인 전문레이아웃은 EAI, FEP로 배포 안됨.";
logger.error(errorMessage); logger.error(errorMessage);
throw new Exception(errorMessage); throw new UseSystemException(errorMessage);
} }
if( "ASCII".equals(format.getAttributeValue("msgType")) ) { if( "ASCII".equals(format.getAttributeValue("msgType")) ) {
@@ -584,12 +591,17 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
} catch( Exception e ) { } catch( Exception e ) {
logger.error("",e); logger.error("",e);
logger.error("",e.getStackTrace()[0]);
try { try {
if( results != null ) { if( results != null ) {
if (e instanceof UseSystemException) {
results.getChild("Result").setText("True");
} else {
results.getChild("Result").setText("False"); results.getChild("Result").setText("False");
}
results.getChild("ResultMessage").setText( e.getMessage() ); results.getChild("ResultMessage").setText( e.getMessage() );
resultS = StringUtils.toXMLString(rDoc, true); resultS = StringUtils.toXMLString(rDoc, true);
} }
if( param.get("logPrcssSeqno") == null ) { if( param.get("logPrcssSeqno") == null ) {
@@ -607,8 +619,9 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
ServletOutputStream sos = null; ServletOutputStream sos = null;
try { try {
response.setContentType("application/xml; charset=EUC-KR");
sos = response.getOutputStream(); sos = response.getOutputStream();
sos.write(resultS.getBytes()); sos.write(resultS.getBytes("EUC-KR"));
} catch( Exception e ) { } catch( Exception e ) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
@@ -648,7 +661,7 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
// // 요청 전문 // // 요청 전문
sis = request.getInputStream(); sis = request.getInputStream();
JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(sis)); JSONObject json = (JSONObject) JSONValue.parse(new InputStreamReader(sis, "EUC-KR"));
// JJB 향후제거 shkim 2020-05-13 연계 테스트 체크 // JJB 향후제거 shkim 2020-05-13 연계 테스트 체크
logger.error("\n\n MMI SYNC Request : " + json.toString()); logger.error("\n\n MMI SYNC Request : " + json.toString());
@@ -664,9 +677,9 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
resultSet = sis.readLine(arg, total, 1024); resultSet = sis.readLine(arg, total, 1024);
} }
param.put("recvData", new String(arg)); param.put("recvData", new String(arg, "EUC-KR"));
} catch(Exception e) { } catch(Exception e) {
logger.error("MessageSync.err - don't read the JSON File - " + new String(arg), e); logger.error("MessageSync.err - don't read the JSON File - " + new String(arg, "EUC-KR"), e);
param.put("recvData", ""); param.put("recvData", "");
} }
@@ -707,8 +720,9 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
ServletOutputStream sos = null; ServletOutputStream sos = null;
try { try {
response.setContentType("application/json; charset=EUC-KR");
sos = response.getOutputStream(); sos = response.getOutputStream();
sos.write(resultS.toString().getBytes()); sos.write(resultS.toString().getBytes("EUC-KR"));
} catch( Exception e ) { } catch( Exception e ) {
e.printStackTrace(); e.printStackTrace();
} finally { } finally {
@@ -0,0 +1,11 @@
package com.eactive.eai.rms.onl.manage.rule.layoutsync;
import com.eactive.eai.rms.onl.common.exception.EMSRuntimeException;
public class UseSystemException extends EMSRuntimeException {
public UseSystemException(String message) {
super(message);
}
}
@@ -10,9 +10,11 @@ import java.util.List;
import org.quartz.Job; import org.quartz.Job;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -39,7 +41,6 @@ public class DailyToMonthlyAggregationJob implements Job {
private ApiStatsDayService apiStatsDayService; private ApiStatsDayService apiStatsDayService;
private ApiStatsMonthService apiStatsMonthService; private ApiStatsMonthService apiStatsMonthService;
private DailyToMonthlyAggregationJob self;
@Autowired @Autowired
public void setApiStatsDayService(ApiStatsDayService apiStatsDayService) { public void setApiStatsDayService(ApiStatsDayService apiStatsDayService) {
@@ -51,18 +52,24 @@ public class DailyToMonthlyAggregationJob implements Job {
this.apiStatsMonthService = apiStatsMonthService; this.apiStatsMonthService = apiStatsMonthService;
} }
@Autowired
public void setSelf(DailyToMonthlyAggregationJob self) {
this.self = self;
}
@Override @Override
public void execute(JobExecutionContext context) throws JobExecutionException { public void execute(JobExecutionContext context) throws JobExecutionException {
ApplicationContext appContext = null;
final DailyToMonthlyAggregationJob selfJob;
try {
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
selfJob = appContext.getBean(DailyToMonthlyAggregationJob.class);
} catch (SchedulerException e) {
log.error("applicationContext get module error",e);
return ;
}
DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW); DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
DataSourceContextHolder.setDataSourceType(dataType); DataSourceContextHolder.setDataSourceType(dataType);
try { try {
YearMonth targetMonth = YearMonth.now().minusMonths(1); YearMonth targetMonth = YearMonth.now().minusMonths(1);
self.executeManual(targetMonth); selfJob.executeManual(targetMonth);
} catch (Exception e) { } catch (Exception e) {
throw new JobExecutionException(e); throw new JobExecutionException(e);
} finally { } finally {
@@ -9,9 +9,11 @@ import java.util.List;
import org.quartz.Job; import org.quartz.Job;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -38,7 +40,6 @@ public class HourlyToDailyAggregationJob implements Job {
private ApiStatsHourService apiStatsHourService; private ApiStatsHourService apiStatsHourService;
private ApiStatsDayService apiStatsDayService; private ApiStatsDayService apiStatsDayService;
private HourlyToDailyAggregationJob self;
@Autowired @Autowired
public void setApiStatsHourService(ApiStatsHourService apiStatsHourService) { public void setApiStatsHourService(ApiStatsHourService apiStatsHourService) {
@@ -50,18 +51,23 @@ public class HourlyToDailyAggregationJob implements Job {
this.apiStatsDayService = apiStatsDayService; this.apiStatsDayService = apiStatsDayService;
} }
@Autowired
public void setSelf(HourlyToDailyAggregationJob self) {
this.self = self;
}
@Override @Override
public void execute(JobExecutionContext context) throws JobExecutionException { public void execute(JobExecutionContext context) throws JobExecutionException {
ApplicationContext appContext = null;
final HourlyToDailyAggregationJob selfJob;
try {
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
selfJob = appContext.getBean(HourlyToDailyAggregationJob.class);
} catch (SchedulerException e) {
log.error("applicationContext get module error",e);
return ;
}
DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW); DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
DataSourceContextHolder.setDataSourceType(dataType); DataSourceContextHolder.setDataSourceType(dataType);
try { try {
LocalDate targetDate = LocalDate.now().minusDays(1); LocalDate targetDate = LocalDate.now().minusDays(1);
self.executeManual(targetDate); selfJob.executeManual(targetDate);
} catch (Exception e) { } catch (Exception e) {
throw new JobExecutionException(e); throw new JobExecutionException(e);
} finally { } finally {
@@ -8,9 +8,11 @@ import java.util.List;
import org.quartz.Job; import org.quartz.Job;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException; import org.quartz.JobExecutionException;
import org.quartz.SchedulerException;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -37,7 +39,6 @@ public class MonthlyToYearlyAggregationJob implements Job {
private ApiStatsMonthService apiStatsMonthService; private ApiStatsMonthService apiStatsMonthService;
private ApiStatsYearService apiStatsYearService; private ApiStatsYearService apiStatsYearService;
private MonthlyToYearlyAggregationJob self;
@Autowired @Autowired
public void setApiStatsMonthService(ApiStatsMonthService apiStatsMonthService) { public void setApiStatsMonthService(ApiStatsMonthService apiStatsMonthService) {
@@ -49,18 +50,24 @@ public class MonthlyToYearlyAggregationJob implements Job {
this.apiStatsYearService = apiStatsYearService; this.apiStatsYearService = apiStatsYearService;
} }
@Autowired
public void setSelf(MonthlyToYearlyAggregationJob self) {
this.self = self;
}
@Override @Override
public void execute(JobExecutionContext context) throws JobExecutionException { public void execute(JobExecutionContext context) throws JobExecutionException {
ApplicationContext appContext = null;
final MonthlyToYearlyAggregationJob selfJob;
try {
appContext = (ApplicationContext) context.getScheduler().getContext().get("applicationContext");
selfJob = appContext.getBean(MonthlyToYearlyAggregationJob.class);
} catch (SchedulerException e) {
log.error("applicationContext get module error",e);
return ;
}
DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW); DataSourceType dataType = DataSourceTypeManager.getDataSourceType(DataSourceTypeManager.APIGW);
DataSourceContextHolder.setDataSourceType(dataType); DataSourceContextHolder.setDataSourceType(dataType);
try { try {
Year targetYear = Year.now().minusYears(1); Year targetYear = Year.now().minusYears(1);
self.executeManual(targetYear); selfJob.executeManual(targetYear);
} catch (Exception e) { } catch (Exception e) {
throw new JobExecutionException(e); throw new JobExecutionException(e);
} finally { } finally {
@@ -9,6 +9,8 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import java.nio.charset.Charset;
import static org.junit.jupiter.api.Assertions.*; import static org.junit.jupiter.api.Assertions.*;
/** /**
@@ -37,9 +39,9 @@ class LayoutSyncControllerTest {
String url = BASE_URL + "?cmd=Message&schema=APIGW"; String url = BASE_URL + "?cmd=Message&schema=APIGW";
// HTTP 헤더 설정 // HTTP 헤더 설정 (EUC-KR)
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_XML); headers.setContentType(new MediaType("application", "xml", Charset.forName("EUC-KR")));
// 요청 생성 // 요청 생성
HttpEntity<String> request = new HttpEntity<>(requestXml, headers); HttpEntity<String> request = new HttpEntity<>(requestXml, headers);