This commit is contained in:
Rinjae
2025-09-05 19:06:22 +09:00
commit a1d74cf004
333 changed files with 47708 additions and 0 deletions
@@ -0,0 +1,46 @@
package com.eactive.eai.custom.stderrorcode;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eactive.eai.common.dao.BaseDAO;
import com.eactive.eai.common.dao.DAOException;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.util.Logger;
import com.eactive.eai.custom.stderrorcode.loader.ChannelErrorCodeLoader;
import com.eactive.eai.custom.stderrorcode.mapper.ChannelErrorCodeMapper;
import com.eactive.eai.data.entity.custom.stderrorcode.ChannelErrorCode;
@Service
@Transactional
public class ChannelErrorCodeDAO extends BaseDAO {
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
@Autowired
private ChannelErrorCodeLoader channelErrorCodeEntityService;
@Autowired
private ChannelErrorCodeMapper channelErrorCodeMapper;
public HashMap getAllChannelErrorCode() throws DAOException {
try {
HashMap groups = new HashMap();
List<ChannelErrorCode> services = channelErrorCodeEntityService.findAllByNow();
logger.info("[ @@ Load Channel Error Code Configuration - starting >>>>>>>>>>>>>>>>> ]");
for (ChannelErrorCode channelErr : services) {
ChannelErrorCodeVO vo = channelErrorCodeMapper.toVo(channelErr);
String key = vo.getErrCd() + "_" + vo.getType();
groups.put(key, vo);
logger.info("[>>Load Channel Error Code vo(" + key + ") =" + vo + " ]");
}
logger.info("[>>Load Channel Error Code Configuration - ended ]");
return groups;
} catch (Exception e) {
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICPM101"));
}
}
}
@@ -0,0 +1,105 @@
package com.eactive.eai.custom.stderrorcode;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.eactive.eai.common.dao.DAOException;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.lifecycle.Lifecycle;
import com.eactive.eai.common.lifecycle.LifecycleException;
import com.eactive.eai.common.lifecycle.LifecycleListener;
import com.eactive.eai.common.lifecycle.LifecycleSupport;
import com.eactive.eai.common.util.ApplicationContextProvider;
import com.eactive.eai.common.util.Logger;
@Component
public class ChannelErrorCodeManager implements Lifecycle {
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
private LifecycleSupport lifecycle = new LifecycleSupport(this);
private Map<String, ChannelErrorCodeVO> channelErrorCodes = new HashMap();
private boolean started;
@Autowired
private ChannelErrorCodeDAO dao;
public static ChannelErrorCodeManager getInstance() {
return ApplicationContextProvider.getContext().getBean(ChannelErrorCodeManager.class);
}
public boolean isStarted() {
return this.started;
}
public synchronized void reload() throws LifecycleException {
logger.warn("reload ChannelErrorCodeManager ...");
try {
init();
} catch (Exception e) {
e.printStackTrace();
}
logger.warn("reload ChannelErrorCodeManager finish...");
}
private void init() throws LifecycleException, Exception {
try {
this.channelErrorCodes = dao.getAllChannelErrorCode();
} catch (DAOException e) {
// throw new LifecycleException("RECEAICPM201");
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICPM201"));
}
}
public void start() throws LifecycleException {
if (started)
throw new LifecycleException("RECEAICCM201");
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
try {
init();
} catch (Exception e) {
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICCM202"));
}
started = true;
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
}
public void stop() throws LifecycleException {
if (!started)
throw new LifecycleException("RECEAICCM203");
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
started = false;
logger.info("ChannelErrorCodeManager] It is stopped.");
lifecycle.fireLifecycleEvent(STOPPED_EVENT, this);
}
public void addLifecycleListener(LifecycleListener listener) {
lifecycle.addLifecycleListener(listener);
}
public LifecycleListener[] findLifecycleListeners() {
return lifecycle.findLifecycleListeners();
}
public void removeLifecycleListener(LifecycleListener listener) {
lifecycle.removeLifecycleListener(listener);
}
public ChannelErrorCodeVO getChannelErrorCode(String code) {
return channelErrorCodes.get(code);
}
public String[] getAllKeyNames() {
String[] names = this.channelErrorCodes.keySet().toArray(new String[0]);
Arrays.sort(names);
return names;
}
}
@@ -0,0 +1,58 @@
package com.eactive.eai.custom.stderrorcode;
import java.io.Serializable;
public class ChannelErrorCodeVO implements Serializable {
private static final long serialVersionUID = 1L;
private String errCd; // 오류코드[TSEAIMX06.STD_ERR_CD]
private String errMsg; // 오류메시지내용[TSEAIMX06.CHNL_ERR_MSG_CTS]
private String type; // 채널세부코드[TSEAIMX06.CHNL_DTLS_CLCD]
private String channelErrCd; // 채널세부코드[TSEAIMX06.CHNL_ERR_CD]
public ChannelErrorCodeVO() {
this("", "", "", "");
}
public ChannelErrorCodeVO(String errCd, String errMsg, String type, String channelErrCd) {
super();
this.errCd = errCd;
this.errMsg = errMsg;
this.type = type;
this.channelErrCd = channelErrCd;
}
public String getErrCd() {
return errCd;
}
public void setErrCd(String errCd) {
this.errCd = errCd;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getChannelErrCd() {
return channelErrCd;
}
public void setChannelErrCd(String channelErrCd) {
this.channelErrCd = channelErrCd;
}
}
@@ -0,0 +1,62 @@
package com.eactive.eai.custom.stderrorcode;
import com.eactive.eai.agent.AgentUtil;
import com.eactive.eai.agent.command.Command;
import com.eactive.eai.agent.command.CommandException;
import com.eactive.eai.common.util.Logger;
/**
* 1. 기능 : Running중인 EAI Server의 메모리에 로딩된 ChannelErrorCodeManager의 정보 변경
* 2. 처리 개요 : 메모리 전체 정보를 manager에서 reload
* 3. 주의사항
*
* @author
* @version v 1.0.0
* @see 관련 기능을 참조
* @since
*
*/
public class ReloadChannelErrorCodeCommand extends Command {
/**
* 1. 기능 : ReloadAdapterGroupCommand 생성자
* 2. 처리 개요 :
* 3. 주의사항
*
**/
public ReloadChannelErrorCodeCommand() {
super("ReloadChannelErrorCodeCommand");
}
/**
* 1. 기능 : ChannelErrorCodeManager에 errorCode를 reload
* 2. 처리 개요 :
* 3. 주의사항 :
*
* @exception CommandException Argument Type이 다르거나 Command 수행중 Excpetion이 발생할 경우
**/
public Object execute() throws CommandException {
Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
if (logger.isInfo())
logger.info(this.name + " is executed");
ChannelErrorCodeManager manager = ChannelErrorCodeManager.getInstance();
try {
manager.reload();
} catch (Exception e) {
String rspErrorCode = "RECEAIMCM002";
String msg = makeException(rspErrorCode, e);
if (logger.isError())
logger.error(msg, e);
throw new CommandException(msg);
}
if (logger.isInfo())
logger.info(this.name + " is finished");
return "success";
}
public static void main(String[] args) throws Exception {
Command command = new ReloadChannelErrorCodeCommand();
AgentUtil.broadcast(command);
}
}
@@ -0,0 +1,62 @@
package com.eactive.eai.custom.stderrorcode;
import com.eactive.eai.agent.AgentUtil;
import com.eactive.eai.agent.command.Command;
import com.eactive.eai.agent.command.CommandException;
import com.eactive.eai.common.util.Logger;
/**
* 1. 기능 : Running중인 EAI Server의 메모리에 로딩된 StdErrorCodeManager의 정보 변경
* 2. 처리 개요 : 메모리 전체 정보를 manager에서 reload
* 3. 주의사항
*
* @author
* @version v 1.0.0
* @see 관련 기능을 참조
* @since
*
*/
public class ReloadStdErrorCodeCommand extends Command {
/**
* 1. 기능 : ReloadAdapterGroupCommand 생성자
* 2. 처리 개요 :
* 3. 주의사항
*
**/
public ReloadStdErrorCodeCommand() {
super("ReloadStdErrorCodeCommand");
}
/**
* 1. 기능 : StdErrorCodeManager에 errorCode를 reload
* 2. 처리 개요 :
* 3. 주의사항 :
*
* @exception CommandException Argument Type이 다르거나 Command 수행중 Excpetion이 발생할 경우
**/
public Object execute() throws CommandException {
Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
if (logger.isInfo())
logger.info(this.name + " is executed");
StdErrorCodeManager manager = StdErrorCodeManager.getInstance();
try {
manager.reload();
} catch (Exception e) {
String rspErrorCode = "RECEAIMCM002";
String msg = makeException(rspErrorCode, e);
if (logger.isError())
logger.error(msg, e);
throw new CommandException(msg);
}
if (logger.isInfo())
logger.info(this.name + " is finished");
return "success";
}
public static void main(String[] args) throws Exception {
Command command = new ReloadChannelErrorCodeCommand();
AgentUtil.broadcast(command);
}
}
@@ -0,0 +1,45 @@
package com.eactive.eai.custom.stderrorcode;
import java.util.HashMap;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eactive.eai.common.dao.BaseDAO;
import com.eactive.eai.common.dao.DAOException;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.util.Logger;
import com.eactive.eai.custom.stderrorcode.loader.StdErrorCodeLoader;
import com.eactive.eai.custom.stderrorcode.mapper.StdErrorCodeMapper;
import com.eactive.eai.data.entity.custom.stderrorcode.StdErrorCode;
@Service
@Transactional
public class StdErrorCodeDAO extends BaseDAO {
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
@Autowired
private StdErrorCodeLoader stdErrorCodeEntityService;
@Autowired
private StdErrorCodeMapper stdErrorCodeMapper;
public HashMap getAllSTDErrorCode() throws DAOException {
try {
HashMap groups = new HashMap();
List<StdErrorCode> services = stdErrorCodeEntityService.findAllByNow();
logger.info("[ @@ Load STD Error Code Configuration - starting >>>>>>>>>>>>>>>>> ]");
for (StdErrorCode stdErr : services) {
StdErrorCodeVO vo = stdErrorCodeMapper.toVo(stdErr);
groups.put(vo.getErrCd(), vo);
logger.info("[>>Load STD Error Code vo(" + vo.getErrCd() + ") =" + vo + " ]");
}
logger.info("[>>Load STD Error Code Configuration - ended ]");
return groups;
} catch (Exception e) {
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICPM101"));
}
}
}
@@ -0,0 +1,105 @@
package com.eactive.eai.custom.stderrorcode;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.eactive.eai.common.dao.DAOException;
import com.eactive.eai.common.exception.ExceptionUtil;
import com.eactive.eai.common.lifecycle.Lifecycle;
import com.eactive.eai.common.lifecycle.LifecycleException;
import com.eactive.eai.common.lifecycle.LifecycleListener;
import com.eactive.eai.common.lifecycle.LifecycleSupport;
import com.eactive.eai.common.util.ApplicationContextProvider;
import com.eactive.eai.common.util.Logger;
@Component
public class StdErrorCodeManager implements Lifecycle {
static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
private LifecycleSupport lifecycle = new LifecycleSupport(this);
private Map<String, StdErrorCodeVO> stdErrorCodes = new HashMap();
private boolean started;
@Autowired
private StdErrorCodeDAO dao;
public static StdErrorCodeManager getInstance() {
return ApplicationContextProvider.getContext().getBean(StdErrorCodeManager.class);
}
public boolean isStarted() {
return this.started;
}
public synchronized void reload() throws LifecycleException {
logger.warn("reload StdErrorCodeManager ...");
try {
init();
} catch (Exception e) {
e.printStackTrace();
}
logger.warn("reload StdErrorCodeManager finish...");
}
private void init() throws LifecycleException, Exception {
try {
this.stdErrorCodes = dao.getAllSTDErrorCode();
} catch (DAOException e) {
// throw new LifecycleException("RECEAICPM201");
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICPM201"));
}
}
public void start() throws LifecycleException {
if (started)
throw new LifecycleException("RECEAICCM201");
lifecycle.fireLifecycleEvent(STARTING_EVENT, this);
try {
init();
} catch (Exception e) {
throw new LifecycleException(ExceptionUtil.getErrorCode(e, "RECEAICCM202"));
}
started = true;
lifecycle.fireLifecycleEvent(STARTED_EVENT, this);
}
public void stop() throws LifecycleException {
if (!started)
throw new LifecycleException("RECEAICCM203");
lifecycle.fireLifecycleEvent(STOPING_EVENT, this);
started = false;
logger.info("StdErrorCodeManager] It is stopped.");
lifecycle.fireLifecycleEvent(STOPPED_EVENT, this);
}
public void addLifecycleListener(LifecycleListener listener) {
lifecycle.addLifecycleListener(listener);
}
public LifecycleListener[] findLifecycleListeners() {
return lifecycle.findLifecycleListeners();
}
public void removeLifecycleListener(LifecycleListener listener) {
lifecycle.removeLifecycleListener(listener);
}
public StdErrorCodeVO getSTDErrorCode(String code) {
return stdErrorCodes.get(code);
}
public String[] getAllKeyNames() {
String[] names = this.stdErrorCodes.keySet().toArray(new String[0]);
Arrays.sort(names);
return names;
}
}
@@ -0,0 +1,38 @@
package com.eactive.eai.custom.stderrorcode;
import java.io.Serializable;
public class StdErrorCodeVO implements Serializable {
private static final long serialVersionUID = 1L;
private String errCd; // 오류코드[TSEAIMX03.ERR_CD]
private String errMsg; // 오류메시지내용[TSEAIMX03.ISD_ERR_CAS_CTS]
public StdErrorCodeVO() {
this("", "");
}
public StdErrorCodeVO(String errCd, String errMsg) {
super();
this.errCd = errCd;
this.errMsg = errMsg;
}
public String getErrCd() {
return errCd;
}
public void setErrCd(String errCd) {
this.errCd = errCd;
}
public String getErrMsg() {
return errMsg;
}
public void setErrMsg(String errMsg) {
this.errMsg = errMsg;
}
}
@@ -0,0 +1,21 @@
package com.eactive.eai.custom.stderrorcode.loader;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eactive.eai.common.util.DatetimeUtil;
import com.eactive.eai.data.entity.custom.stderrorcode.ChannelErrorCode;
import com.eactive.eai.data.jpa.AbstractDataService;
@Service
@Transactional
public class ChannelErrorCodeLoader extends AbstractDataService<ChannelErrorCode, String, ChannelErrorCodeLoaderRepository> {
@Transactional(readOnly = true)
public List<ChannelErrorCode> findAllByNow() {
return repository.selectAll(DatetimeUtil.getFormattedDate("yyyy-MM-dd"));
}
}
@@ -0,0 +1,15 @@
package com.eactive.eai.custom.stderrorcode.loader;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import com.eactive.eai.data.entity.custom.stderrorcode.ChannelErrorCode;
import com.eactive.eai.data.jpa.BaseRepository;
public interface ChannelErrorCodeLoaderRepository extends BaseRepository<ChannelErrorCode, String> {
@Query("from ChannelErrorCode where err_tlg_lan_dscd ='KOR' and err_cd_us_yn ='Y' and err_cd_apl_dt <= :pNow and del_yn = 'N' order by std_err_cd ")
List<ChannelErrorCode> selectAll(@Param("pNow")String now);
}
@@ -0,0 +1,21 @@
package com.eactive.eai.custom.stderrorcode.loader;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eactive.eai.common.util.DatetimeUtil;
import com.eactive.eai.data.entity.custom.stderrorcode.StdErrorCode;
import com.eactive.eai.data.jpa.AbstractDataService;
@Service
@Transactional
public class StdErrorCodeLoader extends AbstractDataService<StdErrorCode, String, StdErrorCodeLoaderRepository> {
@Transactional(readOnly = true)
public List<StdErrorCode> findAllByNow() {
return repository.selectAll(DatetimeUtil.getFormattedDate("yyyy-MM-dd"));
}
}
@@ -0,0 +1,15 @@
package com.eactive.eai.custom.stderrorcode.loader;
import java.util.List;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import com.eactive.eai.data.entity.custom.stderrorcode.StdErrorCode;
import com.eactive.eai.data.jpa.BaseRepository;
public interface StdErrorCodeLoaderRepository extends BaseRepository<StdErrorCode, String> {
@Query("from StdErrorCode where std_err_cd_yn ='Y' and err_tlg_lan_dscd ='KOR' and err_cd_us_yn ='Y' and err_cd_apl_dt <= :pNow and del_yn = 'N' order by err_cd ")
List<StdErrorCode> selectAll(@Param("pNow")String now);
}
@@ -0,0 +1,20 @@
package com.eactive.eai.custom.stderrorcode.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import com.eactive.eai.custom.stderrorcode.ChannelErrorCodeVO;
import com.eactive.eai.data.entity.custom.stderrorcode.ChannelErrorCode;
import com.eactive.eai.data.mapper.GenericMapper;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface ChannelErrorCodeMapper extends GenericMapper<ChannelErrorCodeVO, ChannelErrorCode> {
@Mapping(source = "STD_ERR_CD", target = "errCd") //표준오류코드
@Mapping(source = "CHNL_ERR_CD", target = "channelErrCd") //채널오류코드
@Mapping(source = "CHNL_DTLS_CLCD", target = "type") //채널세부코드
@Mapping(source = "CHNL_ERR_MSG_CTS", target = "errMsg") //채널오류메시니내용
@Override
ChannelErrorCodeVO toVo(ChannelErrorCode entity);
}
@@ -0,0 +1,18 @@
package com.eactive.eai.custom.stderrorcode.mapper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import com.eactive.eai.custom.stderrorcode.StdErrorCodeVO;
import com.eactive.eai.data.entity.custom.stderrorcode.StdErrorCode;
import com.eactive.eai.data.mapper.GenericMapper;
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
public interface StdErrorCodeMapper extends GenericMapper<StdErrorCodeVO, StdErrorCode> {
@Mapping(source = "ERR_CD", target = "errCd")
@Mapping(source = "ISD_ERR_CAS_CTS", target = "errMsg")
@Override
StdErrorCodeVO toVo(StdErrorCode entity);
}