ums 관련 수정
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package com.eactive.eai.rms.ext.djb.ums.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.eactive.apim.portal.template.entity.MessageCode;
|
||||
import com.eactive.apim.portal.template.service.MessageEventHandler;
|
||||
import com.eactive.apim.portal.template.service.MessageRecipient;
|
||||
import com.eactive.apim.portal.template.service.MessageSendEvent;
|
||||
|
||||
@Component
|
||||
public class ApiStatusChangedEventHandler implements MessageEventHandler {
|
||||
|
||||
@Override
|
||||
public MessageCode getKey() {
|
||||
return MessageCode.API_STATUS_CHANGED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowAdditionalRecipients() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "API 상태 변화";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "<div>사용 가능 변수: </div><br/>"
|
||||
+ "<div> - message 알림 메시지 </div><br/>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageSendEvent createEvent(Object source, MessageRecipient recipient, Map<String, Object> params) {
|
||||
Map<String, String> eventParams = new HashMap<>();
|
||||
eventParams.put("message", (String) params.get("message"));
|
||||
return new MessageSendEvent(source, MessageCode.API_STATUS_CHANGED, recipient, eventParams);
|
||||
}
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
package com.eactive.eai.rms.ext.djb.ums.event;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.eactive.apim.portal.template.entity.MessageCode;
|
||||
import com.eactive.apim.portal.template.service.MessageEventHandler;
|
||||
import com.eactive.apim.portal.template.service.MessageRecipient;
|
||||
import com.eactive.apim.portal.template.service.MessageSendEvent;
|
||||
|
||||
@Component
|
||||
public class InflowTokenFailedEventHandler implements MessageEventHandler {
|
||||
|
||||
@Override
|
||||
public MessageCode getKey() {
|
||||
return MessageCode.INFLOW_TOKEN_FAILED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowAdditionalRecipients() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "유량제어 토큰 획득 실패";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "<div>사용 가능 변수: </div><br/>"
|
||||
+ "<div> - message 알림 메시지 </div><br/>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public MessageSendEvent createEvent(Object source, MessageRecipient recipient, Map<String, Object> params) {
|
||||
Map<String, String> eventParams = new HashMap<>();
|
||||
eventParams.put("message", (String) params.get("message"));
|
||||
return new MessageSendEvent(source, MessageCode.INFLOW_TOKEN_FAILED, recipient, eventParams);
|
||||
}
|
||||
}
|
||||
@@ -11,70 +11,42 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.eactive.apim.portal.portalproperty.service.PortalPropertyService;
|
||||
import com.eactive.apim.portal.template.entity.MessageRequest;
|
||||
import com.eactive.eai.common.util.SystemUtil;
|
||||
import com.eactive.eai.rms.data.entity.man.monitoringProperty.service.MonitoringPropertyService;
|
||||
import com.eactive.eai.rms.ext.djb.ums.vo.EmailDataVO;
|
||||
import com.eactive.eai.rms.ext.djb.ums.vo.SmsDataVO;
|
||||
import com.eactive.eai.rms.ext.djb.ums.vo.StdHeadVO;
|
||||
import com.eactive.eai.rms.ext.djb.ums.vo.SwingCommonVO;
|
||||
import com.eactive.eai.rms.ext.djb.ums.vo.SwingDataVO;
|
||||
import com.eactive.eai.rms.ext.djb.ums.vo.SwingReceiverDataVO;
|
||||
import com.eactive.ext.kjb.common.KjbProperty;
|
||||
import com.eactive.ext.kjb.common.KjbPropertyHolder;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class UmsService {
|
||||
//public final static int[] ALLOW_CHANNELS = { MessageCode.Channels.SWING.getValue() };
|
||||
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
private static volatile UmsService instance;
|
||||
|
||||
|
||||
private static final String SYS_DVCD = "OPA";
|
||||
|
||||
private UmsService() {
|
||||
// 싱글톤
|
||||
private final MonitoringPropertyService propertyService;
|
||||
|
||||
public UmsService(MonitoringPropertyService propertyService) {
|
||||
this.propertyService = propertyService;
|
||||
}
|
||||
|
||||
public static UmsService getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (UmsService.class) {
|
||||
if (instance == null) {
|
||||
instance = new UmsService();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private KjbProperty getProperty() {
|
||||
return KjbPropertyHolder.get();
|
||||
}
|
||||
|
||||
// public static boolean isAllowChannel(MessageRequest message) {
|
||||
// for (int channel : ALLOW_CHANNELS) {
|
||||
// if ((message.getMessageCode().getChannels() & channel) == channel) {
|
||||
// return true;
|
||||
// }
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
|
||||
|
||||
public boolean send(MessageRequest messageRequest) throws Exception {
|
||||
if (messageRequest == null) {
|
||||
throw new IllegalArgumentException("messageRequest is null");
|
||||
}
|
||||
|
||||
// if (MessageCode.Channels.SWING.getValue() != (messageRequest.getMessageCode().getChannels() & MessageCode.Channels.SWING.getValue())) {
|
||||
// log.error("지원하지 않는 발송 채널 - {}", messageRequest.getMessageCode().toString());
|
||||
// throw new IllegalArgumentException("지원하지 않는 발송 채널 - " + messageRequest.getMessageCode().toString());
|
||||
// }
|
||||
|
||||
this.httpConnection(messageRequest);
|
||||
|
||||
return true;
|
||||
@@ -84,9 +56,11 @@ public class UmsService {
|
||||
private void httpConnection(MessageRequest messageRequest) throws Exception {
|
||||
HttpURLConnection conn = null;
|
||||
BufferedReader br = null;
|
||||
|
||||
log.debug("<<<HTTP Connection>>>:" + messageRequest.toString());
|
||||
try {
|
||||
URL url = new URL(this.getHostUrl(messageRequest));
|
||||
String host = propertyService.getPropertyValue("Monitoring", "djb.ums."+messageRequest.getMessageType().toLowerCase()+".url", "");
|
||||
|
||||
URL url = new URL(host);
|
||||
int timeoutValue = 5 * 1000; // 타임아웃 설정을 위한 값 (단위: ms)
|
||||
// Charset charset = Charset.forName("UTF-8");
|
||||
Charset charset = Charset.forName("MS949");
|
||||
@@ -144,23 +118,8 @@ public class UmsService {
|
||||
}
|
||||
|
||||
|
||||
private String getHostUrl(MessageRequest messageRequest) {
|
||||
KjbProperty prop = getProperty();
|
||||
String hostUrl = "";
|
||||
if ("SWING".equals(messageRequest.getMessageType()) ) {
|
||||
hostUrl = prop.getUmsSwingUrl();
|
||||
} else if ("SMS".equals(messageRequest.getMessageType()) || "KAKAO".equals(messageRequest.getMessageType())) {
|
||||
hostUrl = prop.getUmsSmsUrl();
|
||||
} else if ("EMAIL".equals(messageRequest.getMessageType())) {
|
||||
hostUrl = prop.getUmsEmailUrl();
|
||||
}
|
||||
return hostUrl;
|
||||
}
|
||||
|
||||
private String makeBodyData(MessageRequest messageRequest) {
|
||||
|
||||
KjbProperty prop = getProperty();
|
||||
|
||||
// 리턴값
|
||||
String rtnVal = "";
|
||||
|
||||
@@ -175,9 +134,9 @@ public class UmsService {
|
||||
stdHeadVO.setStnd_mesg_ver("R10");
|
||||
stdHeadVO.setOrtr_guid(jsonData[2]);
|
||||
stdHeadVO.setSect_ecrpt_yn("N");
|
||||
stdHeadVO.setFrst_trnm_ipad(prop.getUmsWasIpAddress());
|
||||
stdHeadVO.setFrst_trnm_ipv4_addr(prop.getUmsWasIpAddress());
|
||||
stdHeadVO.setFrst_trnm_mac(prop.getUmsWasMacAddress());
|
||||
stdHeadVO.setFrst_trnm_ipad(propertyService.getPropertyValue("Monitoring", "djb.ums.was_ip_address", ""));
|
||||
stdHeadVO.setFrst_trnm_ipv4_addr(propertyService.getPropertyValue("Monitoring", "djb.ums.was_ip_address", ""));
|
||||
stdHeadVO.setFrst_trnm_mac(propertyService.getPropertyValue("Monitoring", "djb.ums.was_mac_address", ""));
|
||||
stdHeadVO.setFrst_mesg_dman_dt(jsonData[0]);
|
||||
stdHeadVO.setFrst_mesg_dman_time(jsonData[1]);
|
||||
stdHeadVO.setFrst_trnm_sys_dvcd(SYS_DVCD);
|
||||
@@ -186,18 +145,17 @@ public class UmsService {
|
||||
stdHeadVO.setSys_env_dvcd(SystemUtil.getSysOperEvirnDstcd()); // D:개발 T:테스트 P:운영
|
||||
stdHeadVO.setTx_tycd("O"); // O:온라인 B:배치
|
||||
stdHeadVO.setSynz_dvcd("S"); // S:동기 A:비동기
|
||||
stdHeadVO.setChnl_tycd(""); // 채널유형코드 TODO: 값 채울것!!
|
||||
stdHeadVO.setChnl_tycd(""); // 채널유형코드
|
||||
stdHeadVO.setHmab_dvcd("1"); // 내외구분코드 1:내부 2:외부(타발)
|
||||
stdHeadVO.setIf_id(messageRequest.getEaiInterfaceId()); // 인터페이스ID
|
||||
stdHeadVO.setTx_id(messageRequest.getServiceId()); // 거래ID
|
||||
|
||||
if ("SWING".equals(messageRequest.getMessageType()) ) {
|
||||
// 표준 헤더
|
||||
stdHeadVO.setTx_id(prop.getUmsSwingTxId()); // 거래ID
|
||||
stdHeadVO.setIf_id(prop.getUmsSwingIfId()); // 인터페이스ID
|
||||
if ("MESSENGER".equals(messageRequest.getMessageType()) ) {
|
||||
|
||||
// 스윙챗 알림 공용
|
||||
SwingCommonVO swiComVO = new SwingCommonVO();
|
||||
swiComVO.setClientld(prop.getUmsSwingClientId());
|
||||
swiComVO.setClientSecret(prop.getUmsSwingClientSecret());
|
||||
swiComVO.setClientld(propertyService.getPropertyValue("Monitoring", "djb.ums.messenger.client_id", ""));
|
||||
swiComVO.setClientSecret(propertyService.getPropertyValue("Monitoring", "djb.ums.messenger.client_secret", ""));
|
||||
swiComVO.setCompanyCode("CB");
|
||||
swiComVO.setRequestUniqueKey(this.genrateRandomStringNumber26());
|
||||
|
||||
@@ -225,11 +183,9 @@ public class UmsService {
|
||||
+ " \"common\":\r\n" + common + ",\r\n" + " \"data\":" + data
|
||||
+ " }\r\n" + " }\r\n" + " ]\r\n" + "}";
|
||||
|
||||
} else if ("SMS".equals(messageRequest.getMessageType())
|
||||
}
|
||||
else if ("SMS".equals(messageRequest.getMessageType())
|
||||
|| "KAKAO".equals(messageRequest.getMessageType())) {
|
||||
// 표준 헤더
|
||||
stdHeadVO.setTx_id(prop.getUmsSmsTxId()); // 거래ID
|
||||
stdHeadVO.setIf_id(prop.getUmsSmsIfId()); // 인터페이스ID
|
||||
|
||||
// Sms 데이터
|
||||
SmsDataVO dataVO = new SmsDataVO();
|
||||
@@ -240,8 +196,8 @@ public class UmsService {
|
||||
dataVO.setMsg_ctnt(messageRequest.getMessage());
|
||||
dataVO.setRecvr_no(messageRequest.getPhone());
|
||||
dataVO.setSndn_no("15880079"); //발신번호
|
||||
dataVO.setSnd_empno("999999"); //요청자
|
||||
dataVO.setSnd_emp_dprm_cd("157"); //요청부서코드
|
||||
dataVO.setSnd_empno(""); //요청자
|
||||
dataVO.setSnd_emp_dprm_cd(""); //요청부서코드
|
||||
if ("SMS".equals(messageRequest.getMessageType())) {
|
||||
dataVO.setLtrs_snd_tycd("1"); // 1:SMS 2:LMS/MMS
|
||||
dataVO.setMsg_snd_tycd("0000"); // 알림톡 메세지 종류 0000:SMS, 1000:LMS, 1008:알림톡, ....
|
||||
@@ -272,10 +228,8 @@ public class UmsService {
|
||||
+ " \"ums_if_data\":" + data
|
||||
+ " }\r\n" + " }\r\n" + " ]\r\n" + "}";
|
||||
|
||||
} else if ("EMAIL".equals(messageRequest.getMessageType())) {
|
||||
// 표준 헤더
|
||||
stdHeadVO.setTx_id(prop.getUmsEmailTxId()); // 거래ID
|
||||
stdHeadVO.setIf_id(prop.getUmsEmailIfId()); // 인터페이스ID
|
||||
}
|
||||
else if ("EMAIL".equals(messageRequest.getMessageType())) {
|
||||
|
||||
// 이메일 데이터
|
||||
EmailDataVO dataVO = new EmailDataVO();
|
||||
|
||||
@@ -19,6 +19,8 @@ import org.springframework.transaction.support.TransactionTemplate;
|
||||
|
||||
import com.eactive.apim.portal.template.entity.MessageRequest;
|
||||
import com.eactive.apim.portal.template.repository.MessageRequestRepository;
|
||||
import com.eactive.eai.rms.common.datasource.DataSourceContextHolder;
|
||||
import com.eactive.eai.rms.common.datasource.DataSourceTypeManager;
|
||||
import com.eactive.eai.rms.ext.djb.ums.service.UmsService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -47,9 +49,11 @@ public class UmsDispatchService {
|
||||
@Autowired
|
||||
public UmsDispatchService(
|
||||
@Qualifier("transactionManagerForEMS") PlatformTransactionManager transactionManager,
|
||||
MessageRequestRepository messageRequestRepository
|
||||
MessageRequestRepository messageRequestRepository,
|
||||
UmsService umsService
|
||||
) {
|
||||
this.messageRequestRepository = messageRequestRepository;
|
||||
this.umsService = umsService;
|
||||
|
||||
this.executorService = new ThreadPoolExecutor(
|
||||
CORE_POOL_SIZE,
|
||||
@@ -60,7 +64,6 @@ public class UmsDispatchService {
|
||||
new ThreadPoolExecutor.CallerRunsPolicy()
|
||||
);
|
||||
this.transactionTemplate = new TransactionTemplate(transactionManager);
|
||||
this.umsService = UmsService.getInstance();
|
||||
log.debug("UmsDispatchService initialized with thread pool - core: {}, max: {}, queue: {}",
|
||||
CORE_POOL_SIZE, MAX_POOL_SIZE, QUEUE_CAPACITY);
|
||||
}
|
||||
@@ -156,5 +159,6 @@ public class UmsDispatchService {
|
||||
message.setRequestStatus(status);
|
||||
message.setSentDate(LocalDateTime.now());
|
||||
entityManager.merge(message);
|
||||
entityManager.flush();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user