|
|
@@ -1,16 +1,15 @@
|
|
|
-package com.utic.incident.utic.incident.molit.service;
|
|
|
+package com.utic.incident.molit.server.service;
|
|
|
|
|
|
import com.utic.incident.common.annotation.ProcessingElapsed;
|
|
|
-import com.utic.incident.common.service.AbstractProcessService;
|
|
|
import com.utic.incident.common.url.RequestUrlData;
|
|
|
import com.utic.incident.common.url.RequestUrlDataError;
|
|
|
import com.utic.incident.common.url.RequestUrlDataResult;
|
|
|
import com.utic.incident.common.utils.TimeUtils;
|
|
|
-import com.utic.incident.utic.incident.molit.config.IncidentMolitConfig;
|
|
|
-import com.utic.incident.utic.incident.molit.dao.repository.IncidentMolitMapperImpl;
|
|
|
-import com.utic.incident.utic.incident.molit.dto.molit.IncidentMoctDto;
|
|
|
-import com.utic.incident.utic.incident.molit.dto.molit.MolitEventResponseDto;
|
|
|
-import com.utic.incident.utic.incident.molit.dto.molit.MolitIncidentResponseDto;
|
|
|
+import com.utic.incident.molit.server.config.MolitRequestConfig;
|
|
|
+import com.utic.incident.molit.server.dao.repository.IncidentMolitMapperImpl;
|
|
|
+import com.utic.incident.molit.server.dto.IncidentMoctDto;
|
|
|
+import com.utic.incident.molit.server.dto.MolitEventResponseDto;
|
|
|
+import com.utic.incident.molit.server.dto.MolitIncidentResponseDto;
|
|
|
import lombok.Getter;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -25,16 +24,17 @@ import java.util.List;
|
|
|
@Getter
|
|
|
@RequiredArgsConstructor
|
|
|
@Service
|
|
|
-public class IncidentMolitService implements AbstractProcessService {
|
|
|
+public class IncidentMolitService {
|
|
|
|
|
|
- private final IncidentMolitConfig config;
|
|
|
+ private final MolitRequestConfig config;
|
|
|
private final IncidentMolitMapperImpl mapper;
|
|
|
|
|
|
private final HashMap<String, IncidentMoctDto> incidentMoctMap = new HashMap<>();
|
|
|
private int incidentCnt = 0;
|
|
|
+ private String incidentErrorMsg = "";
|
|
|
private int eventCnt = 0;
|
|
|
+ private String eventErrorMsg = "";
|
|
|
|
|
|
- @Override
|
|
|
public boolean initialize() {
|
|
|
this.incidentMoctMap.clear();
|
|
|
this.incidentCnt = 0;
|
|
|
@@ -43,15 +43,15 @@ public class IncidentMolitService implements AbstractProcessService {
|
|
|
}
|
|
|
|
|
|
@ProcessingElapsed(type="MOLIT", name="Molit Incident Request")
|
|
|
- @Override
|
|
|
- public int processing() {
|
|
|
+ public int incidentProcessing() {
|
|
|
int result = 0;
|
|
|
+ this.incidentErrorMsg = "";
|
|
|
RequestUrlDataResult<MolitIncidentResponseDto> response = RequestUrlData.fetchXmlDataFromUrl(
|
|
|
- this.config.getIncidentUrl(),
|
|
|
- this.config.getConnectTimeout(),
|
|
|
- this.config.getReadTimeout(),
|
|
|
- this.config.getRetryCount(),
|
|
|
- this.config.getRetryDelay(),
|
|
|
+ this.config.getIncident().getUrl(),
|
|
|
+ this.config.getIncident().getConnectTimeout(),
|
|
|
+ this.config.getIncident().getReadTimeout(),
|
|
|
+ this.config.getIncident().getRetryCount(),
|
|
|
+ this.config.getIncident().getRetryDelay(),
|
|
|
MolitIncidentResponseDto.class);
|
|
|
|
|
|
if (response.getErrorCode() == RequestUrlDataError.SUCCESS) {
|
|
|
@@ -66,26 +66,28 @@ public class IncidentMolitService implements AbstractProcessService {
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- log.info("MOLIT INCIDENT 응답 데이터가 없습니다.");
|
|
|
+ log.info("There is no response data for MOLIT INCIDENT.");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
result = -1;
|
|
|
- log.info("MOLIT INCIDENT 요청 실패 (코드:{}, 메시지:{})", response.getErrorCode().getCode(), response.getErrorCode().getMessage());
|
|
|
+ this.incidentErrorMsg = response.getErrorCode().getMessage();
|
|
|
+ log.info("MOLIT INCIDENT Request failed. (Code:{}, Message:{})", response.getErrorCode().getCode(), this.incidentErrorMsg);
|
|
|
}
|
|
|
this.incidentCnt = result;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@ProcessingElapsed(type="MOLIT", name="Molit Event Request")
|
|
|
- public int processingEvent() {
|
|
|
+ public int eventProcessing() {
|
|
|
int result = 0;
|
|
|
+ this.eventErrorMsg = "";
|
|
|
RequestUrlDataResult<MolitEventResponseDto> response = RequestUrlData.fetchXmlDataFromUrl(
|
|
|
- this.config.getEventUrl(),
|
|
|
- this.config.getConnectTimeout(),
|
|
|
- this.config.getReadTimeout(),
|
|
|
- this.config.getRetryCount(),
|
|
|
- this.config.getRetryDelay(),
|
|
|
+ this.config.getEvent().getUrl(),
|
|
|
+ this.config.getEvent().getConnectTimeout(),
|
|
|
+ this.config.getEvent().getReadTimeout(),
|
|
|
+ this.config.getEvent().getRetryCount(),
|
|
|
+ this.config.getEvent().getRetryDelay(),
|
|
|
MolitEventResponseDto.class);
|
|
|
|
|
|
if (response.getErrorCode() == RequestUrlDataError.SUCCESS) {
|
|
|
@@ -100,12 +102,13 @@ public class IncidentMolitService implements AbstractProcessService {
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- log.info("MOLIT EVENT 응답 데이터가 없습니다.");
|
|
|
+ log.info("There is no response data for MOLIT EVENT.");
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
result = -1;
|
|
|
- log.info("MOLIT EVENT 요청 실패 (코드:{}, 메시지:{})", response.getErrorCode().getCode(), response.getErrorCode().getMessage());
|
|
|
+ this.eventErrorMsg = response.getErrorCode().getMessage();
|
|
|
+ log.info("MOLIT EVENT Request failed. (Code:{}, Message:{})", response.getErrorCode().getCode(), this.eventErrorMsg);
|
|
|
}
|
|
|
this.eventCnt = result;
|
|
|
return result;
|
|
|
@@ -131,6 +134,7 @@ public class IncidentMolitService implements AbstractProcessService {
|
|
|
.count();
|
|
|
this.eventCnt = this.incidentMoctMap.size() - this.incidentCnt;
|
|
|
|
|
|
+ log.info("MOLIT Data Save: (Incident: {}, Event: {})", this.incidentCnt, this.eventCnt);
|
|
|
this.mapper.insertLogRcvIncidentMoct(this.incidentCnt, this.eventCnt);
|
|
|
}
|
|
|
|