ums 연동 작성중
This commit is contained in:
@@ -64,3 +64,11 @@ gradle build -x test -Pprofile=weblogic
|
||||
## 광주은행 참고 사항
|
||||
### PORTAL Parameter
|
||||
- deploy.prod_use_proxy = N (개발/운영 망 간 연동 없음)
|
||||
- kjb.ums.eai_batch.url : EAI 배치 서버 URL (이메일 발송 용도)
|
||||
- 개발 : http://172.31.32.111:10230/BATAppWeb/EaiBatCall
|
||||
- QA : http://172.31.33.111:10430/BATAppWeb/EaiBatCall
|
||||
- 운영 : http://172.21.1.40:10860/BATAppWeb/EaiBatCall
|
||||
- 입력하지 않을 경우 EAI 배치 호출을 하지 않고 내부적으로 통신하지 않고 정상 처리(log 내 warning 로그)
|
||||
- kjb.ums.eai_batch.send_dir : EAI 배치 서버 파일 송신 디렉토리
|
||||
- Default : /Data/eapim/portal/sendmail
|
||||
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.eactive.eai.custom.kjb.ums;
|
||||
|
||||
import com.eactive.apim.portal.template.entity.MessageRequest;
|
||||
import com.eactive.eai.rms.common.base.BaseService;
|
||||
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@Service
|
||||
@Transactional(transactionManager = "transactionManagerForEMS")
|
||||
@Slf4j
|
||||
public class KjbUmsService extends BaseService {
|
||||
public static final String PROP_GORUP_ID = "Monitoring";
|
||||
public static final String PROP_EAI_BATCH_URL = "kjb.ums.eai_batch.url";
|
||||
public static final String PROP_EAI_BATCH_SEND_DIR = "kjb.ums.eai_batch.send_dir";
|
||||
|
||||
private final MonitoringPropertyService monitoringPropertyService;
|
||||
|
||||
private final String EAI_BATCH_URL;
|
||||
private final String EAI_BATCH_SEND_DIR;
|
||||
|
||||
|
||||
private KjbUmsService(MonitoringPropertyService monitoringPropertyService) {
|
||||
this.monitoringPropertyService = monitoringPropertyService;
|
||||
|
||||
|
||||
// 파라미터 검사
|
||||
this.EAI_BATCH_URL = monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_URL, "");
|
||||
this.EAI_BATCH_SEND_DIR = monitoringPropertyService.getPropertyValue(PROP_GORUP_ID, PROP_EAI_BATCH_SEND_DIR, "/Data/eapim/portal/sendmail");
|
||||
|
||||
|
||||
if (EAI_BATCH_URL.isEmpty()) {
|
||||
log.warn("{} 가 설정되지 않음. 실제 EAI 배치 연동 없이 동작함", PROP_EAI_BATCH_URL);
|
||||
}
|
||||
|
||||
log.info("EAI Batch URL: {}", EAI_BATCH_URL);
|
||||
log.info("EAI Batch Send Dir: {}", EAI_BATCH_SEND_DIR);
|
||||
|
||||
|
||||
// 디렉토리 검사(쓰기 권한 포함)
|
||||
Path sendDirPath = Paths.get(EAI_BATCH_SEND_DIR);
|
||||
if (!sendDirPath.toFile().exists()) {
|
||||
// 생성 시도
|
||||
boolean created = sendDirPath.toFile().mkdirs();
|
||||
if (!created) {
|
||||
log.error("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: {}", EAI_BATCH_SEND_DIR);
|
||||
throw new IllegalStateException("EAI_BATCH_SEND_DIR 디렉토리를 생성할 수 없음: " + EAI_BATCH_SEND_DIR);
|
||||
}
|
||||
}
|
||||
|
||||
if (!sendDirPath.toFile().isDirectory()) {
|
||||
log.error("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: {}", EAI_BATCH_SEND_DIR);
|
||||
throw new IllegalStateException("EAI_BATCH_SEND_DIR 가 디렉토리가 아님: " + EAI_BATCH_SEND_DIR);
|
||||
}
|
||||
|
||||
if (!sendDirPath.toFile().canWrite()) {
|
||||
log.error("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: {}", EAI_BATCH_SEND_DIR);
|
||||
throw new IllegalStateException("EAI_BATCH_SEND_DIR 에 쓰기 권한이 없음: " + EAI_BATCH_SEND_DIR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void sendEmail(MessageRequest messageRequest) {
|
||||
log.debug("sendEmail() called - EAI_BATCH_URL: {}, EAI_BATCH_SEND_DIR: {}", EAI_BATCH_URL, EAI_BATCH_SEND_DIR);
|
||||
log.debug("MessageRequest ID: {}, Email: {}", messageRequest.getId(), messageRequest.getEmail());
|
||||
|
||||
|
||||
if (StringUtils.isEmpty(messageRequest.getId())) {
|
||||
log.warn("MessageRequest ID is empty");
|
||||
throw new IllegalArgumentException("MessageRequest ID is required");
|
||||
}
|
||||
|
||||
|
||||
String filename = "EMAIL_" + messageRequest.getId() + ".json";
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("to", messageRequest.getEmail());
|
||||
}
|
||||
}
|
||||
+14
@@ -35,6 +35,20 @@ public class MonitoringPropertyService
|
||||
return property.map(MonitoringProperty::getPrpty2Val).orElse(null);
|
||||
}
|
||||
|
||||
public String getPropertyValue(String prptyGroupName, String prptyName, String defaultValue) {
|
||||
MonitoringPropertyId id = new MonitoringPropertyId();
|
||||
id.setPrptyGroupName(prptyGroupName);
|
||||
id.setPrptyName(prptyName);
|
||||
|
||||
Optional<MonitoringProperty> property = repository.findById(id);
|
||||
if (property.isPresent() && !property.get().getPrpty2Val().isEmpty()) {
|
||||
return property.get().getPrpty2Val();
|
||||
} else {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Iterable<MonitoringProperty> findAllByIdPrptyName(String prptyName) {
|
||||
BooleanExpression predicate = QMonitoringProperty.monitoringProperty.id.prptyName.eq(prptyName);
|
||||
return repository.findAll(predicate);
|
||||
|
||||
Reference in New Issue
Block a user