init
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package com.eactive.eai.common.sessioninfo;
|
||||
|
||||
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.sessioninfo.loader.SessionHistoryLogger;
|
||||
import com.eactive.eai.common.sessioninfo.mapper.SessionHistoryMapper;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.sessioninfo.SessionHistory;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class SessionHistoryDAO extends BaseDAO {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private SessionHistoryLogger sessionHistoryLogger;
|
||||
|
||||
@Autowired
|
||||
private SessionHistoryMapper sessionHistoryMapper;
|
||||
|
||||
public void insertSessionHistory(SessionHistoryVO sessionHistoryVo) throws DAOException {
|
||||
try {
|
||||
SessionHistory entity = sessionHistoryMapper.toEntity(sessionHistoryVo);
|
||||
sessionHistoryLogger.save(entity);
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICKE118"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.eactive.eai.common.sessioninfo;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.JSONValue;
|
||||
|
||||
import com.eactive.eai.common.util.DatetimeUtil;
|
||||
import com.eactive.eai.common.util.UUIDGenerator;
|
||||
import com.eactive.eai.message.EncodingVar;
|
||||
import com.eactive.eai.message.StandardMessage;
|
||||
import com.eactive.eai.message.manager.StandardMessageManager;
|
||||
import com.eactive.eai.message.parser.ReaderType;
|
||||
import com.eactive.eai.message.parser.StandardReader;
|
||||
import com.eactive.eai.message.service.InterfaceMapper;
|
||||
|
||||
public class SessionHistoryDTO {
|
||||
private String historyId;
|
||||
private String requestData;
|
||||
private String historyDstcd;
|
||||
private String responseResultDvsn;
|
||||
private String uuid;
|
||||
private String remoteIp;
|
||||
private boolean isJson;
|
||||
|
||||
public SessionHistoryDTO(String requestData, String historyDstcd, String responseResultDvsn, String uuid, String remoteIp, boolean isJson) {
|
||||
|
||||
this.requestData = requestData;
|
||||
this.historyDstcd = historyDstcd;
|
||||
this.responseResultDvsn = responseResultDvsn;
|
||||
this.uuid = uuid;
|
||||
this.remoteIp = remoteIp;
|
||||
this.isJson = isJson;
|
||||
|
||||
}
|
||||
|
||||
public SessionHistoryVO toVo() {
|
||||
|
||||
if (isJson) {
|
||||
StandardMessage standardMessage = null;
|
||||
StandardMessageManager standardManager = StandardMessageManager.getInstance();
|
||||
StandardReader reader = null;
|
||||
InterfaceMapper mapper = standardManager.getMapper();
|
||||
standardMessage = standardManager.getStandardMessage();
|
||||
reader = standardManager.getReader(ReaderType.JSON);
|
||||
String historyId = null;
|
||||
String guid = null;
|
||||
String userId = null;
|
||||
String body = null;
|
||||
try {
|
||||
reader.parse(standardMessage, requestData);
|
||||
// 표준전문 파싱 후 어댑터의 charset을 설정한다.
|
||||
standardMessage.setBizDataCharset(EncodingVar.jsonEncoding);
|
||||
|
||||
historyId = "HISL" + UUIDGenerator.getUUID();
|
||||
guid = mapper.getGuid(standardMessage);
|
||||
userId = mapper.getUserId(standardMessage);
|
||||
|
||||
String bizData = standardMessage.getBizData();
|
||||
JSONObject bodyObject = (JSONObject) JSONValue.parse(bizData);
|
||||
// TODO 추후 제거해야될 값 확인
|
||||
// bodyObject.remove(ExtMessageKeys.FIELD_USER_PASSWORD);
|
||||
body = bodyObject.toJSONString();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
//
|
||||
// JSONObject reqJsonObject = (JSONObject) JSONValue.parse(requestData);
|
||||
// JSONObject headerObject = (JSONObject) reqJsonObject.get(ExtMessageKeys.GROUP_HEADER);
|
||||
// JSONObject systemHeader = (JSONObject) headerObject.get(ExtMessageKeys.GROUP_SYSTEM_HEADER);
|
||||
// JSONObject commonHeader = (JSONObject) headerObject.get(ExtMessageKeys.GROUP_COMMON_HEADER);
|
||||
//
|
||||
// String historyId = "HISL" + UUIDGenerator.getUUID();
|
||||
// String guid = (String) systemHeader.get(ExtMessageKeys.FIELD_GUID);
|
||||
// String userId = (String) commonHeader.get(ExtMessageKeys.FIELD_USERID);
|
||||
//
|
||||
// JSONObject bodyObject = (JSONObject)reqJsonObject.get(ExtMessageKeys.GROUP_BODY);
|
||||
// bodyObject.remove(ExtMessageKeys.FIELD_USER_PASSWORD);
|
||||
//
|
||||
// String body = bodyObject.toJSONString();
|
||||
// String tranTime = (String) systemHeader.get(ExtMessageKeys.FIELD_TLGR_DMND_DT);
|
||||
String tranTime = DatetimeUtil.getCurrentTimeMillis();
|
||||
|
||||
return new SessionHistoryVO(historyId, guid, userId, uuid, remoteIp, historyDstcd, responseResultDvsn, body,
|
||||
tranTime);
|
||||
} else {
|
||||
|
||||
// requestData : 57 bytes
|
||||
// ICON(4) + REQ/RES(3) + 정상여부(1) + 사용자 ID(9) + UUID(40)
|
||||
String historyId = "HISL" + UUIDGenerator.getUUID();
|
||||
String guid = "";
|
||||
String userId = StringUtils.trim(requestData.substring(8, 8 + 9));
|
||||
String tranTime = DatetimeUtil.getCurrentTimeMillis();
|
||||
|
||||
return new SessionHistoryVO(historyId, guid, userId, uuid, remoteIp, historyDstcd, responseResultDvsn, requestData, tranTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SessionHistoryDTO [requestData=" + requestData + ", historyDstcd=" + historyDstcd
|
||||
+ ", responseResultDvsn=" + responseResultDvsn + ", uuid=" + uuid + ", remoteIp=" + remoteIp
|
||||
+ ", isJson=" + isJson + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.eactive.eai.common.sessioninfo;
|
||||
|
||||
import com.eactive.eai.common.dao.Keys;
|
||||
|
||||
public class SessionHistoryQuery {
|
||||
|
||||
public static final String INSERT_SESSION_HISTORY = String.join(System.getProperty("line.separator"),
|
||||
" INSERT INTO",
|
||||
" " + Keys.TABLE_OWNER + "TSEAISM05 SM05",
|
||||
" (HISTORYID, GUID, USERID, UUID, HISTORYDSTCD, RSPNSRSLTDVSN, BODY, TRANTIME, REMOTEIP)",
|
||||
" VALUES",
|
||||
" (",
|
||||
" ?, ", //HISTORYID
|
||||
" ?, ", //GUID
|
||||
" ?, ", //USERID
|
||||
" ?, ", //UUID
|
||||
" ?, ", //HISTORYDSTCD
|
||||
" ?, ", //RSPNSRSLTDVSN
|
||||
" ?, ", //BODY
|
||||
" ?, ", //TRANTIME
|
||||
" ?) " //REMOTEIP
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.eactive.eai.common.sessioninfo;
|
||||
|
||||
import com.eactive.eai.common.session.ChannelSessionFacade.LogoutType;
|
||||
|
||||
public class SessionHistoryVO {
|
||||
|
||||
public static final String HISTORYDSTCD_LOGIN = "LOGIN";
|
||||
public static final String HISTORYDSTCD_LOGOUT = "LOGOUT";
|
||||
public static final String HISTORYDSTCD_DUPLOGIN = "DUPLOGIN";
|
||||
public static final String HISTORYDSTCD_AUTOLOGOUT = "AUTOLOGOUT";
|
||||
public static final String HISTORYDSTCD_WEBSOCKET = "WEBSOCKET";
|
||||
public static final String HISTORYDSTCD_FORCELOGOUT = "FORCELOUT";
|
||||
public static final String HISTORYDSTCD_WEBSOCKET_TIMEOUT = "WSTIMEOUT";
|
||||
public static final String HISTORYDSTCD_DATECHANGE = "DATECHANGE";
|
||||
public static final String HISTORYDSTCD_SERVERDOWN = "SERVERDOWN";
|
||||
|
||||
public static String convertLogoutType_EnumToString(LogoutType logoutType) {
|
||||
|
||||
switch(logoutType) {
|
||||
case AutoLogout:
|
||||
return SessionHistoryVO.HISTORYDSTCD_AUTOLOGOUT;
|
||||
case ForceLogout:
|
||||
return SessionHistoryVO.HISTORYDSTCD_FORCELOGOUT;
|
||||
case Logout:
|
||||
return SessionHistoryVO.HISTORYDSTCD_LOGOUT;
|
||||
case WebSocketTimeout:
|
||||
return SessionHistoryVO.HISTORYDSTCD_WEBSOCKET_TIMEOUT;
|
||||
case DateChange:
|
||||
return SessionHistoryVO.HISTORYDSTCD_DATECHANGE;
|
||||
case ServerDown:
|
||||
return SessionHistoryVO.HISTORYDSTCD_SERVERDOWN;
|
||||
default:
|
||||
throw new RuntimeException("Fail to convert LogoutTypeEnum : " + logoutType.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String historyId;
|
||||
private String guid;
|
||||
private String userId;
|
||||
private String uuid;
|
||||
private String historyDstcd;
|
||||
private String rspnsRsltDvsn;
|
||||
private String body;
|
||||
private String tranTime;
|
||||
private String remoteIp;
|
||||
|
||||
public SessionHistoryVO(String historyId, String guid, String userId, String uuid, String remoteIp, String historyDstcd, String rspnsRsltDvsn, String body, String tranTime) {
|
||||
this.historyId = historyId;
|
||||
this.guid = guid;
|
||||
this.userId = userId;
|
||||
this.uuid = uuid;
|
||||
this.historyDstcd = historyDstcd;
|
||||
this.rspnsRsltDvsn = rspnsRsltDvsn;
|
||||
this.body = body;
|
||||
this.tranTime = tranTime;
|
||||
this.remoteIp = remoteIp;
|
||||
}
|
||||
|
||||
public String getHistoryId() {
|
||||
return historyId;
|
||||
}
|
||||
|
||||
public void setHistoryId(String historyId) {
|
||||
this.historyId = historyId;
|
||||
}
|
||||
|
||||
public String getGuid() {
|
||||
return guid;
|
||||
}
|
||||
|
||||
public void setGuid(String guid) {
|
||||
this.guid = guid;
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public String getHistoryDstcd() {
|
||||
return historyDstcd;
|
||||
}
|
||||
|
||||
public void setHistoryDstcd(String historyDstcd) {
|
||||
this.historyDstcd = historyDstcd;
|
||||
}
|
||||
|
||||
public String getRspnsRsltDvsn() {
|
||||
return rspnsRsltDvsn;
|
||||
}
|
||||
|
||||
public void setRspnsRsltDvsn(String rspnsRsltDvsn) {
|
||||
this.rspnsRsltDvsn = rspnsRsltDvsn;
|
||||
}
|
||||
|
||||
public String getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public void setBody(String body) {
|
||||
this.body = body;
|
||||
}
|
||||
|
||||
public String getTranTime() {
|
||||
return tranTime;
|
||||
}
|
||||
|
||||
public void setTranTime(String tranTime) {
|
||||
this.tranTime = tranTime;
|
||||
}
|
||||
|
||||
public String getRemoteIp() {
|
||||
return remoteIp;
|
||||
}
|
||||
|
||||
public void setRemoteIp(String remoteIp) {
|
||||
this.remoteIp = remoteIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SessionHistoryVO [historyId=" + historyId + ", guid=" + guid + ", userId=" + userId + ", uuid=" + uuid
|
||||
+ ", historyDstcd=" + historyDstcd + ", rspnsRsltDvsn=" + rspnsRsltDvsn + ", body=" + body
|
||||
+ ", tranTime=" + tranTime + ", remote=" + remoteIp + "]";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.eactive.eai.common.sessioninfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
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.sessioninfo.loader.SessionInfoLoader;
|
||||
import com.eactive.eai.common.sessioninfo.mapper.SessionInfoMapper;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.common.util.ObjectUtil;
|
||||
import com.eactive.eai.data.entity.onl.sessioninfo.SessionInfo;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class SessionInfoDAO extends BaseDAO {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private SessionInfoLoader sessionInfoLoader;
|
||||
|
||||
@Autowired
|
||||
private SessionInfoMapper sessionInfoMapper;
|
||||
|
||||
|
||||
public void upsertSessionInfo(SessionInfoVO vo) throws DAOException {
|
||||
SessionInfoVO cloned = null;
|
||||
try {
|
||||
cloned = (SessionInfoVO) ObjectUtil.deepCopy(vo);
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
throw new DAOException(e);
|
||||
}
|
||||
cloned.setUserId(cloned.getUserId() + "_" + cloned.getSessionId());
|
||||
|
||||
try {
|
||||
SessionInfo sessionInfo = null;
|
||||
Optional<SessionInfo> optional = sessionInfoLoader.findById(cloned.getUserId());
|
||||
if(optional.isPresent()) {
|
||||
sessionInfo = optional.get();
|
||||
sessionInfo.setSessionStatus( vo.getSessionStatusInfo() );
|
||||
sessionInfo.setWsocSessionStatus( vo.getWsocSessionStatusInfo() );
|
||||
// sessionInfo.setUserid( vo.getUserId() );
|
||||
sessionInfo.setBrnCd( vo.getBrnCode() );
|
||||
sessionInfo.setBrnName( vo.getBrnName() );
|
||||
// sessionInfo.setCreateTime( vo.getCreateTime() );
|
||||
sessionInfo.setRofcCd( vo.getRofcCode() );
|
||||
// sessionInfo.setSessionId( vo.getSessionId() );
|
||||
sessionInfo.setTerminalId( vo.getTerminalId() );
|
||||
// sessionInfo.setUserName( vo.getUserName() );
|
||||
sessionInfo.setWsocInstance( vo.getWsocInstance() );
|
||||
sessionInfo.setWsocRemoteAddr( vo.getWsocRemoteAddr() );
|
||||
}
|
||||
else {
|
||||
sessionInfo = sessionInfoMapper.toEntity(cloned);
|
||||
sessionInfoLoader.save(sessionInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICKE118"));
|
||||
}
|
||||
}
|
||||
|
||||
public SessionInfoVO getSessionInfo(String userId) throws DAOException {
|
||||
try {
|
||||
SessionInfo sessionInfo = sessionInfoLoader.getById(userId);
|
||||
return sessionInfoMapper.toVo(sessionInfo);
|
||||
} catch (Exception e) {
|
||||
logger.error(e);
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICKE118"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.eactive.eai.common.sessioninfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class SessionInfoVO implements Serializable {
|
||||
public enum Status {
|
||||
active, inactive
|
||||
};
|
||||
|
||||
private String userId;
|
||||
private String sessionId;
|
||||
private String userName;
|
||||
private String rofcCode;
|
||||
private String brnName;
|
||||
private String brnCode;
|
||||
private Status sessionStatus;
|
||||
private String wsocInstance;
|
||||
private String wsocRemoteAddr;
|
||||
private Status wsocSessionStatus;
|
||||
private String terminalId;
|
||||
// YYYYMMDDHHMI24SS
|
||||
private String createTime;
|
||||
|
||||
public SessionInfoVO() {
|
||||
|
||||
}
|
||||
|
||||
public SessionInfoVO(String userId) {
|
||||
this.userId = userId;
|
||||
// this.createTime = DatetimeUtil.getCurrentDateTime();
|
||||
}
|
||||
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(String userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getSessionId() {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
public void setSessionId(String sessionId) {
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return userName;
|
||||
}
|
||||
|
||||
public void setUserName(String userName) {
|
||||
this.userName = userName;
|
||||
}
|
||||
|
||||
public String getRofcCode() {
|
||||
return rofcCode;
|
||||
}
|
||||
|
||||
public void setRofcCode(String rofcCode) {
|
||||
this.rofcCode = rofcCode;
|
||||
}
|
||||
|
||||
public String getBrnName() {
|
||||
return brnName;
|
||||
}
|
||||
|
||||
public void setBrnName(String brnName) {
|
||||
this.brnName = brnName;
|
||||
}
|
||||
|
||||
public String getBrnCode() {
|
||||
return brnCode;
|
||||
}
|
||||
|
||||
public void setBrnCode(String brnCode) {
|
||||
this.brnCode = brnCode;
|
||||
}
|
||||
|
||||
public Status getSessionStatus() {
|
||||
return sessionStatus;
|
||||
}
|
||||
|
||||
public String getSessionStatusInfo() {
|
||||
return sessionStatus == null ? "" : sessionStatus.toString();
|
||||
}
|
||||
public void setSessionStatusInfo(String status) {
|
||||
sessionStatus = Status.inactive.toString().equals(status) ? Status.inactive : Status.active;
|
||||
}
|
||||
|
||||
public void setSessionStatus(Status sessionStatus) {
|
||||
this.sessionStatus = sessionStatus;
|
||||
}
|
||||
|
||||
public String getWsocInstance() {
|
||||
return wsocInstance;
|
||||
}
|
||||
|
||||
public void setWsocInstance(String wsocInstance) {
|
||||
this.wsocInstance = wsocInstance;
|
||||
}
|
||||
|
||||
public String getWsocRemoteAddr() {
|
||||
return wsocRemoteAddr;
|
||||
}
|
||||
|
||||
public void setWsocRemoteAddr(String wsocRemoteAddr) {
|
||||
this.wsocRemoteAddr = wsocRemoteAddr;
|
||||
}
|
||||
|
||||
public Status getWsocSessionStatus() {
|
||||
return wsocSessionStatus;
|
||||
}
|
||||
|
||||
public String getWsocSessionStatusInfo() {
|
||||
return wsocSessionStatus == null ? "" : wsocSessionStatus.toString();
|
||||
}
|
||||
|
||||
public void setWsocSessionStatusInfo(String status) {
|
||||
wsocSessionStatus = Status.inactive.toString().equals(status) ? Status.inactive : Status.active;
|
||||
}
|
||||
|
||||
public void setWsocSessionStatus(Status wsocSessionStatus) {
|
||||
this.wsocSessionStatus = wsocSessionStatus;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public String getTerminalId() {
|
||||
return terminalId;
|
||||
}
|
||||
|
||||
public void setTerminalId(String terminalId) {
|
||||
this.terminalId = terminalId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SessionInfoVO [userId=" + userId + ", sessionId=" + sessionId + ", rofcCode=" + rofcCode + ", brnCode="
|
||||
+ brnCode + ", sessionStatus=" + sessionStatus + ", wsocInstance=" + wsocInstance + ", wsocRemoteAddr="
|
||||
+ wsocRemoteAddr + ", wsocSessionStatus=" + wsocSessionStatus + ", terminalId=" + terminalId
|
||||
+ ", createTime=" + createTime + "]";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.eactive.eai.common.sessioninfo;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
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.sessioninfo.loader.TerminalInfoLoader;
|
||||
import com.eactive.eai.common.sessioninfo.mapper.TerminalInfoMapper;
|
||||
import com.eactive.eai.common.util.Logger;
|
||||
import com.eactive.eai.data.entity.onl.sessioninfo.TerminalInfo;
|
||||
|
||||
@Service
|
||||
@Transactional
|
||||
public class TerminalInfoDAO extends BaseDAO {
|
||||
private static Logger logger = Logger.getLogger(Logger.LOGGER_DEFAULT);
|
||||
|
||||
@Autowired
|
||||
private TerminalInfoLoader terminalInfoLoader;
|
||||
|
||||
@Autowired
|
||||
private TerminalInfoMapper terminalInfoMapper;
|
||||
|
||||
public void upsertTerminalInfo(TerminalInfoVO vo) throws DAOException {
|
||||
try {
|
||||
TerminalInfo terminalInfo = null;
|
||||
Optional<TerminalInfo> optional = terminalInfoLoader.findById(vo.getTerminalNo());
|
||||
if(optional.isPresent()) {
|
||||
terminalInfo = optional.get();
|
||||
terminalInfo.setSocSessionStatus( vo.getSocSessionStatusInfo() );
|
||||
terminalInfo.setTerminalNo( vo.getTerminalNo() );
|
||||
terminalInfo.setBrnCd( vo.getBrnCode() );
|
||||
terminalInfo.setBrnName( vo.getBrnName() );
|
||||
terminalInfo.setCreateTime( vo.getCreateTime() );
|
||||
terminalInfo.setRofcCd( vo.getRofcCode() );
|
||||
terminalInfo.setSocInstance( vo.getSocInstance() );
|
||||
terminalInfo.setSocRemoteAddr( vo.getSocRemoteAddr() );
|
||||
}
|
||||
else {
|
||||
terminalInfo = terminalInfoMapper.toEntity(vo);
|
||||
terminalInfoLoader.save(terminalInfo);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new DAOException(ExceptionUtil.getErrorCode(e, "RECEAICKE118"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.eactive.eai.common.sessioninfo;
|
||||
|
||||
public class TerminalInfoVO {
|
||||
public enum Status {
|
||||
active, inactive
|
||||
};
|
||||
|
||||
private String terminalNo;
|
||||
private String rofcCode;
|
||||
private String brnName;
|
||||
private String brnCode;
|
||||
private String socInstance;
|
||||
private String socRemoteAddr;
|
||||
private Status socSessionStatus;
|
||||
// YYYYMMDDHHMI24SS
|
||||
private String createTime;
|
||||
|
||||
public TerminalInfoVO(String terminalNo) {
|
||||
this.terminalNo = terminalNo;
|
||||
// this.createTime = DatetimeUtil.getCurrentDateTime();
|
||||
}
|
||||
|
||||
public String getTerminalNo() {
|
||||
return terminalNo;
|
||||
}
|
||||
|
||||
public void setTerminalNo(String terminalNo) {
|
||||
this.terminalNo = terminalNo;
|
||||
}
|
||||
|
||||
public String getRofcCode() {
|
||||
return rofcCode;
|
||||
}
|
||||
|
||||
public void setRofcCode(String rofcCode) {
|
||||
this.rofcCode = rofcCode;
|
||||
}
|
||||
|
||||
public String getBrnName() {
|
||||
return brnName;
|
||||
}
|
||||
|
||||
public void setBrnName(String brnName) {
|
||||
this.brnName = brnName;
|
||||
}
|
||||
|
||||
public String getBrnCode() {
|
||||
return brnCode;
|
||||
}
|
||||
|
||||
public void setBrnCode(String brnCode) {
|
||||
this.brnCode = brnCode;
|
||||
}
|
||||
|
||||
public String getSocInstance() {
|
||||
return socInstance;
|
||||
}
|
||||
|
||||
public void setSocInstance(String socInstance) {
|
||||
this.socInstance = socInstance;
|
||||
}
|
||||
|
||||
public String getSocRemoteAddr() {
|
||||
return socRemoteAddr;
|
||||
}
|
||||
|
||||
public void setSocRemoteAddr(String socRemoteAddr) {
|
||||
this.socRemoteAddr = socRemoteAddr;
|
||||
}
|
||||
|
||||
public Status getSocSessionStatus() {
|
||||
return socSessionStatus;
|
||||
}
|
||||
|
||||
public String getSocSessionStatusInfo() {
|
||||
return socSessionStatus == null ? "" : socSessionStatus.toString();
|
||||
}
|
||||
|
||||
public void setSocSessionStatus(Status socSessionStatus) {
|
||||
this.socSessionStatus = socSessionStatus;
|
||||
}
|
||||
|
||||
public String getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(String createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TerminalInfoVO [terminalNo=" + terminalNo + ", rofcCode=" + rofcCode + ", brnName=" + brnName
|
||||
+ ", brnCode=" + brnCode + ", socInstance=" + socInstance + ", socRemoteAddr=" + socRemoteAddr
|
||||
+ ", socSessionStatus=" + socSessionStatus + ", createTime=" + createTime + "]";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.eactive.eai.common.sessioninfo.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import com.eactive.eai.common.sessioninfo.SessionHistoryVO;
|
||||
import com.eactive.eai.data.entity.onl.sessioninfo.SessionHistory;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface SessionHistoryMapper extends GenericMapper<SessionHistoryVO, SessionHistory> {
|
||||
@Mapping(source = "historyid", target = "historyId")
|
||||
@Mapping(source = "body", target = "body")
|
||||
@Mapping(source = "guid", target = "guid")
|
||||
@Mapping(source = "historydstcd", target = "historyDstcd")
|
||||
@Mapping(source = "rspnsrsltdvsn", target = "rspnsRsltDvsn")
|
||||
@Mapping(source = "trantime", target = "tranTime")
|
||||
@Mapping(source = "userid", target = "userId")
|
||||
@Mapping(source = "uuid", target = "uuid")
|
||||
@Override
|
||||
SessionHistoryVO toVo(SessionHistory entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
SessionHistory toEntity(SessionHistoryVO vo);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.eactive.eai.common.sessioninfo.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import com.eactive.eai.common.sessioninfo.SessionInfoVO;
|
||||
import com.eactive.eai.common.sessioninfo.SessionInfoVO.Status;
|
||||
import com.eactive.eai.data.entity.onl.sessioninfo.SessionInfo;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface SessionInfoMapper extends GenericMapper<SessionInfoVO, SessionInfo> {
|
||||
@Mapping(source = "userid", target = "userId")
|
||||
@Mapping(source = "brnCd", target = "brnCode")
|
||||
@Mapping(source = "brnName", target = "brnName")
|
||||
@Mapping(source = "createTime", target = "createTime")
|
||||
@Mapping(source = "rofcCd", target = "rofcCode")
|
||||
@Mapping(source = "sessionId", target = "sessionId")
|
||||
@Mapping(source = "sessionStatus", target = "sessionStatus")
|
||||
@Mapping(source = "terminalId", target = "terminalId")
|
||||
@Mapping(source = "userName", target = "userName")
|
||||
@Mapping(source = "wsocInstance", target = "wsocInstance")
|
||||
@Mapping(source = "wsocRemoteAddr", target = "wsocRemoteAddr")
|
||||
@Mapping(source = "wsocSessionStatus", target = "wsocSessionStatus")
|
||||
@Override
|
||||
SessionInfoVO toVo(SessionInfo entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Mapping(source = "sessionStatusInfo", target = "sessionStatus")
|
||||
@Mapping(source = "wsocSessionStatusInfo", target = "wsocSessionStatus")
|
||||
SessionInfo toEntity(SessionInfoVO vo);
|
||||
|
||||
default Status mapStatus(String status) {
|
||||
return Status.inactive.toString().equals(status) ? Status.inactive : Status.active;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.eactive.eai.common.sessioninfo.mapper;
|
||||
|
||||
import org.mapstruct.InheritInverseConfiguration;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
import com.eactive.eai.common.sessioninfo.TerminalInfoVO;
|
||||
import com.eactive.eai.common.sessioninfo.TerminalInfoVO.Status;
|
||||
import com.eactive.eai.data.entity.onl.sessioninfo.TerminalInfo;
|
||||
import com.eactive.eai.data.mapper.GenericMapper;
|
||||
|
||||
@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface TerminalInfoMapper extends GenericMapper<TerminalInfoVO, TerminalInfo> {
|
||||
@Mapping(source = "terminalNo", target = "terminalNo")
|
||||
@Mapping(source = "brnCd", target = "brnCode")
|
||||
@Mapping(source = "brnName", target = "brnName")
|
||||
@Mapping(source = "createTime", target = "createTime")
|
||||
@Mapping(source = "rofcCd", target = "rofcCode")
|
||||
@Mapping(source = "socInstance", target = "socInstance")
|
||||
@Mapping(source = "socRemoteAddr", target = "socRemoteAddr")
|
||||
@Mapping(source = "socSessionStatus", target = "socSessionStatus")
|
||||
@Override
|
||||
TerminalInfoVO toVo(TerminalInfo entity);
|
||||
|
||||
@InheritInverseConfiguration
|
||||
@Mapping(source = "socSessionStatusInfo", target = "socSessionStatus")
|
||||
TerminalInfo toEntity(TerminalInfoVO vo);
|
||||
|
||||
default Status mapStatus(String statusString) {
|
||||
return Status.inactive.toString().equals(statusString) ? Status.inactive : Status.active;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user