eCams 연동시 로그 저장

This commit is contained in:
eastargh
2026-08-28 13:57:41 +09:00
parent a2cda26909
commit 258bb70a93
8 changed files with 214 additions and 113 deletions
@@ -31,6 +31,12 @@ public class LayoutSyncHistoryService extends AbstractDataService<LayoutSyncHist
if (StringUtils.isNotBlank(search.getSearchLoutName())) {
query.where(q.loutname.containsIgnoreCase(search.getSearchLoutName()));
}
if (StringUtils.isNotBlank(search.getSearchServiceName())) {
query.where(q.servicename.containsIgnoreCase(search.getSearchServiceName()));
}
if (StringUtils.isNotBlank(search.getSearchCommand())) {
query.where(q.command.containsIgnoreCase(search.getSearchCommand()));
}
if (StringUtils.isNotBlank(search.getSearchStartDate())) {
query.where(q.recvamndhms.goe(parseYYYYMMDD(search.getSearchStartDate()).atStartOfDay()));
}
@@ -1,10 +1,10 @@
package com.eactive.eai.rms.onl.loader.controller;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
@@ -1451,77 +1451,92 @@ public class LoaderController implements InterceptorSkipController {
*/
@SuppressWarnings("rawtypes")
@RequestMapping( params ={"cmd=interface","control=downloadfull"})
public ModelAndView interfaceDownLoadFully(String serviceType, String interfaceId) throws Exception {
public ModelAndView interfaceDownLoadFully(String serviceType, String interfaceId) {
DataSourceType dt = DataSourceTypeManager.getDataSourceType(serviceType);
DataSourceContextHolder.setDataSourceType(dt);
// 1. interface 데이터 다운로드
InterfaceDeployPack interfaceDeployPack = new InterfaceDeployPack();
String json = "";
try {
// 1. interface 데이터 다운로드
InterfaceDeployPack interfaceDeployPack = new InterfaceDeployPack();
EAIMessageDeploy eaiMessageDeploy = interfaceDeployService.selectDeploy(interfaceId);
eaiMessageDeploy.setEailastamndyms(null);
EAIMessageDeploy eaiMessageDeploy = interfaceDeployService.selectDeploy(interfaceId);
eaiMessageDeploy.setEailastamndyms(null);
interfaceDeployPack.setEaiMessageDeploy(eaiMessageDeploy);
interfaceDeployPack.setEaiMessageDeploy(eaiMessageDeploy);
for(StandardMessageInfoDeploy standardMessageInfoDeploy : eaiMessageDeploy.getStandardMessageInfoDeploys()){
standardMessageInfoDeploy.setEailastamndyms(null);
}
for(StandardMessageInfoDeploy standardMessageInfoDeploy : eaiMessageDeploy.getStandardMessageInfoDeploys()){
standardMessageInfoDeploy.setEailastamndyms(null);
}
for (ServiceMessageDeploy serviceMessageDeploy : eaiMessageDeploy.getServiceMessages()){
String[] transformNames = {serviceMessageDeploy.getChngmsgidname(), serviceMessageDeploy.getBascrspnschngmsgidname()};
// 2. Layout 데이터 생성
for(String transformName: transformNames){
if(StringUtils.isBlank(transformName)){
continue;
}
for(TransformSourceResultUI transformSourceResultUI : transform2Service.selectTransformSourceResult(transformName)){
String loutName = transformSourceResultUI.getLoutName();
if(StringUtils.isBlank(loutName)){
for (ServiceMessageDeploy serviceMessageDeploy : eaiMessageDeploy.getServiceMessages()){
String[] transformNames = {serviceMessageDeploy.getChngmsgidname(), serviceMessageDeploy.getBascrspnschngmsgidname()};
// 2. Layout 데이터 생성
for(String transformName: transformNames){
if(StringUtils.isBlank(transformName)){
continue;
}
LayoutDeploy layoutDeploy = layoutDeployService.selectDeploy(loutName);
layoutDeploy.setLastamndhms(null);
interfaceDeployPack.getLayoutDeployList().add(layoutDeploy);
for(TransformSourceResultUI transformSourceResultUI : transform2Service.selectTransformSourceResult(transformName)){
String loutName = transformSourceResultUI.getLoutName();
if(StringUtils.isBlank(loutName)){
continue;
}
LayoutDeploy layoutDeploy = layoutDeployService.selectDeploy(loutName);
layoutDeploy.setLastamndhms(null);
interfaceDeployPack.getLayoutDeployList().add(layoutDeploy);
}
// 3. Transform 데이터 생성
TransformDeploy transformDeploy = transformDeployService.selectDeploy(transformName);
transformDeploy.setLastamndhms(null);
interfaceDeployPack.getTransformDeployList().add(transformDeploy);
}
// 3. Transform 데이터 생성
TransformDeploy transformDeploy = transformDeployService.selectDeploy(transformName);
transformDeploy.setLastamndhms(null);
interfaceDeployPack.getTransformDeployList().add(transformDeploy);
}
// 4. API 스펙 정보(ptl_api_spec_info) 추가 (감사(audit) 컬럼은 제외)
Optional<ApiSpecInfo> optSpecInfo = apiSpecInfoService.findById(interfaceId);
if (optSpecInfo.isPresent()) {
ApiSpecInfoUI specInfo = apiSpecUIMapper.mapToUI(optSpecInfo.get());
specInfo.setCreatedBy(null);
specInfo.setCreatedDate(null);
specInfo.setLastModifiedBy(null);
specInfo.setLastModifiedDate(null);
interfaceDeployPack.setSpecInfo(specInfo);
}
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
String bizCode = eaiMessageDeploy.getEaibzwkdstcd();
String ioMapPath = monitoringContext.getStringProperty(MonitoringContext.IOMAP_DOWNLOAD_PATH);
String fileDir = FilenameUtils.concat(ioMapPath, bizCode);
String fileFullPath = FilenameUtils.concat(fileDir, interfaceId+".json");
FileWriteUtil.makeDirWithGroupPermission(fileDir);
File file = new File(fileFullPath);
json = writer.writeValueAsString(interfaceDeployPack);
FileUtils.writeStringToFile(file, json, StandardCharsets.UTF_8);
// TSEAITR10 배포 이력 저장 (SERVICENAME=eCams, COMMAND=downloadfull, LOUTNAME=interfaceId, RECVDATA=json)
loaderService.insertDeploySyncLog(dt, "downloadfull", interfaceId, json);
Map<String,String> result = new HashMap<>();
result.put("status", "success");
result.put("message", fileFullPath+" write done.");
return new ModelAndView(resultView, "result", result);
} catch (Exception e) {
logger.error("interface downloadfull error - interfaceId=" + interfaceId, e);
loaderService.insertDeployFailLog(dt, "downloadfull", interfaceId, json, e.toString());
Map<String,String> result = new HashMap<>();
result.put("status", "fail");
result.put("message", e.toString());
return new ModelAndView(resultView, "result", result);
}
// 4. API 스펙 정보(ptl_api_spec_info) 추가 (감사(audit) 컬럼은 제외)
Optional<ApiSpecInfo> optSpecInfo = apiSpecInfoService.findById(interfaceId);
if (optSpecInfo.isPresent()) {
ApiSpecInfoUI specInfo = apiSpecUIMapper.mapToUI(optSpecInfo.get());
specInfo.setCreatedBy(null);
specInfo.setCreatedDate(null);
specInfo.setLastModifiedBy(null);
specInfo.setLastModifiedDate(null);
interfaceDeployPack.setSpecInfo(specInfo);
}
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
ObjectWriter writer = objectMapper.writerWithDefaultPrettyPrinter();
String bizCode = eaiMessageDeploy.getEaibzwkdstcd();
String ioMapPath = monitoringContext.getStringProperty(MonitoringContext.IOMAP_DOWNLOAD_PATH);
String fileDir = FilenameUtils.concat(ioMapPath, bizCode);
String fileFullPath = FilenameUtils.concat(fileDir, interfaceId+".json");
FileWriteUtil.makeDirWithGroupPermission(fileDir);
File file = new File(fileFullPath);
writer.writeValue(file, interfaceDeployPack);
Map<String,String> result = new HashMap<>();
String status = "success";
result.put("status", status);
result.put("message", fileFullPath+" write done.");
return new ModelAndView(resultView, "result", result);
}
/**
@@ -1533,57 +1548,73 @@ public class LoaderController implements InterceptorSkipController {
* @throws Exception
*/
@RequestMapping( params ={"cmd=interface","control=uploadfull"})
public ModelAndView interfaceLoadFully(String serviceType, String filePath) throws Exception {
public ModelAndView interfaceLoadFully(String serviceType, String filePath) {
DataSourceType dt = DataSourceTypeManager.getDataSourceType(serviceType);
DataSourceContextHolder.setDataSourceType(dt);
String ioMapPath = monitoringContext.getStringProperty(MonitoringContext.IOMAP_UPLOAD_PATH);
String fileFullPath ;
if(StringUtils.isBlank(ioMapPath)) {
fileFullPath = filePath;
} else {
fileFullPath = FilenameUtils.concat(ioMapPath, filePath);
}
File file = new File(fileFullPath);
InputStream inputStream = new FileInputStream(file);
// ObjectMapper 생성 및 설정
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
InterfaceDeployPack interfaceDeployPack = objectMapper.readValue(inputStream, InterfaceDeployPack.class);
EAIMessageDeploy eaiMessageDeploy = interfaceDeployPack.getEaiMessageDeploy();
interfaceDeployService.saveDeploy(eaiMessageDeploy);
agentUtilService.broadcast(new CommonCommand("com.ext.eai.agent.stdmessage.ReloadSTDMessageCommand", "ALL"));
agentUtilService.broadcast(new CommonCommand("com.eactive.eai.agent.eaimessage.ReloadEAIMessageCommand", eaiMessageDeploy.getEaisvcname()));
for(LayoutDeploy layoutDeploy: interfaceDeployPack.getLayoutDeployList()){
layoutDeployService.saveDeploy(layoutDeploy);
agentUtilService.broadcast(new CommonCommand( "com.eactive.eai.agent.transformer.ReloadLayoutCommand", layoutDeploy.getLoutname()));
}
for(TransformDeploy transformDeploy : interfaceDeployPack.getTransformDeployList()){
transformDeployService.saveDeploy(transformDeploy);
agentUtilService.broadcast(new CommonCommand( "com.eactive.eai.agent.transformer.ReloadTransformCommand", transformDeploy.getCnvsnname()));
}
ApiSpecInfoUI specInfoUI = interfaceDeployPack.getSpecInfo();
if (specInfoUI != null && StringUtils.isNotBlank(specInfoUI.getApiId())) {
ApiSpecInfo specInfo = apiSpecUIMapper.mapToEntity(specInfoUI);
if (apiSpecInfoService.findById(specInfo.getApiId()).isPresent()) {
apiSpecInfoService.updateById(specInfo.getApiId(), specInfo);
String json = "";
String loutName = filePath;
try {
String ioMapPath = monitoringContext.getStringProperty(MonitoringContext.IOMAP_UPLOAD_PATH);
String fileFullPath ;
if(StringUtils.isBlank(ioMapPath)) {
fileFullPath = filePath;
} else {
apiSpecInfoService.create(specInfo);
fileFullPath = FilenameUtils.concat(ioMapPath, filePath);
}
File file = new File(fileFullPath);
json = FileUtils.readFileToString(file, StandardCharsets.UTF_8);
// ObjectMapper 생성 및 설정
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new JavaTimeModule());
InterfaceDeployPack interfaceDeployPack = objectMapper.readValue(json, InterfaceDeployPack.class);
EAIMessageDeploy eaiMessageDeploy = interfaceDeployPack.getEaiMessageDeploy();
loutName = eaiMessageDeploy.getEaisvcname();
interfaceDeployService.saveDeploy(eaiMessageDeploy);
agentUtilService.broadcast(new CommonCommand("com.ext.eai.agent.stdmessage.ReloadSTDMessageCommand", "ALL"));
agentUtilService.broadcast(new CommonCommand("com.eactive.eai.agent.eaimessage.ReloadEAIMessageCommand", eaiMessageDeploy.getEaisvcname()));
for(LayoutDeploy layoutDeploy: interfaceDeployPack.getLayoutDeployList()){
layoutDeployService.saveDeploy(layoutDeploy);
agentUtilService.broadcast(new CommonCommand( "com.eactive.eai.agent.transformer.ReloadLayoutCommand", layoutDeploy.getLoutname()));
}
for(TransformDeploy transformDeploy : interfaceDeployPack.getTransformDeployList()){
transformDeployService.saveDeploy(transformDeploy);
agentUtilService.broadcast(new CommonCommand( "com.eactive.eai.agent.transformer.ReloadTransformCommand", transformDeploy.getCnvsnname()));
}
ApiSpecInfoUI specInfoUI = interfaceDeployPack.getSpecInfo();
if (specInfoUI != null && StringUtils.isNotBlank(specInfoUI.getApiId())) {
ApiSpecInfo specInfo = apiSpecUIMapper.mapToEntity(specInfoUI);
if (apiSpecInfoService.findById(specInfo.getApiId()).isPresent()) {
apiSpecInfoService.updateById(specInfo.getApiId(), specInfo);
} else {
apiSpecInfoService.create(specInfo);
}
}
// TSEAITR10 배포 이력 저장 (SERVICENAME=eCams, COMMAND=uploadfull, LOUTNAME=eaisvcname, RECVDATA=json)
loaderService.insertDeploySyncLog(dt, "uploadfull", loutName, json);
Map<String,String> result = new HashMap<String,String>();
result.put("status", "success");
result.put("message", fileFullPath+" deploy done.");
return new ModelAndView(resultView, "result", result);
} catch (Exception e) {
logger.error("interface uploadfull error - filePath=" + filePath, e);
loaderService.insertDeployFailLog(dt, "uploadfull", loutName, json, e.toString());
Map<String,String> result = new HashMap<String,String>();
result.put("status", "fail");
result.put("message", e.toString());
return new ModelAndView(resultView, "result", result);
}
Map<String,String> result = new HashMap<String,String>();
String status = "success";
result.put("status", status);
result.put("message", fileFullPath+" deploy done.");
return new ModelAndView(resultView, "result", result);
}
}
@@ -41,4 +41,9 @@ public interface LoaderDao {
public List<LinkedHashMap> selectTableDataForListValue( DataSourceType dataSourceType, String tableName, String key1, List<String> param1 ) ;
public List<LinkedHashMap> selectSnaAdpApList( DataSourceType dataSourceType, String param1 ) ;
/**
* TSEAITR10(배포/동기화 이력)에 로그 1건을 저장한다.
*/
public int insertSyncLog( DataSourceType dt, HashMap<String, String> param ) ;
}
@@ -189,10 +189,15 @@ public class LoaderDaoImpl extends SqlMapClientTemplateDao implements LoaderDao
// }
// }.execute();
}
public int insertSyncLog( DataSourceType dt, HashMap<String, String> param ) {
param.put("schemaId", dt.getSchema());
return this.template.update("Layout.insertLayoutSyncLog", param);
}
public List<LinkedHashMap> selectSnaAdpApList( DataSourceType dataSourceType, String param1 ) {
final HashMap param = new HashMap();
param.put("param1", param1);
param.put("param1", param1);
return template.queryForList("Loader.selectSnaAdpApList", param);
// return new SpecifiedDataSourceExecutor<List<LinkedHashMap>>(
@@ -157,5 +157,15 @@ public interface TransactionLoaderService{
public HashMap syncResult(Command command ,String fileName ) throws Exception;
public void appendToListfile(String bizCode, String interfaceId) throws Exception ;
public void appendToListfile(String bizCode, String interfaceId) throws Exception ;
/**
* downloadfull / uploadfull 성공 시 TSEAITR10 에 배포 이력을 저장한다. (PRCSSRSLT=S)
*/
public void insertDeploySyncLog(DataSourceType dt, String command, String interfaceId, String recvData) ;
/**
* downloadfull / uploadfull 실패 시 TSEAITR10 에 실패 이력을 저장한다. (PRCSSRSLT=F, PRCSSRSLTCMNT=errMsg)
*/
public void insertDeployFailLog(DataSourceType dt, String command, String interfaceId, String recvData, String errMsg) ;
}
@@ -2,6 +2,7 @@ package com.eactive.eai.rms.onl.loader.service;
import com.eactive.eai.agent.command.Command;
import com.eactive.eai.agent.command.CommonCommand;
import com.eactive.eai.common.util.UUIDGenerator;
import com.eactive.eai.rms.common.base.BaseService;
import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.common.converter.ElinkObjectMapper;
@@ -1483,4 +1484,33 @@ public class TransactionLoaderServiceImpl extends BaseService implements Transac
String targetLine = bizCode+"|"+interfaceId+System.lineSeparator();
org.apache.commons.io.FileUtils.writeStringToFile(listFile, targetLine, Charset.defaultCharset(), true);
}
@Override
public void insertDeploySyncLog(DataSourceType dt, String command, String interfaceId, String recvData) {
insertDeployLog(dt, command, interfaceId, recvData, "S", "");
}
@Override
public void insertDeployFailLog(DataSourceType dt, String command, String interfaceId, String recvData, String errMsg) {
insertDeployLog(dt, command, interfaceId, recvData, "F", errMsg);
}
private void insertDeployLog(DataSourceType dt, String command, String interfaceId, String recvData,
String prcssRslt, String prcssRsltCmnt) {
try {
HashMap<String, String> param = new HashMap<String, String>();
param.put("logPrcssSeqno", UUIDGenerator.getUUID());
param.put("serviceName", "InterfaceDeploy");
param.put("command", command);
param.put("loutName", interfaceId);
param.put("recvData", recvData == null ? "" : recvData);
param.put("recvAmndHMS", DateUtil.getDateTime("yyyyMMddHHmmssSS").substring(0, 16));
param.put("prcssRslt", prcssRslt);
param.put("prcssRsltCmnt", StringUtils.left(prcssRsltCmnt, 4000)); // PRCSSRSLTCMNT 길이 보호
dao.insertSyncLog(dt, param);
} catch (Exception e) {
// 이력 저장 실패가 download/upload 본기능을 중단시키지 않도록 한다.
logger.error("insertDeployLog error (command=" + command + ", interfaceId=" + interfaceId + ")", e);
}
}
}
@@ -7,6 +7,12 @@ public class LayoutSyncHistoryUISearch {
private String searchLoutName;
/* 서비스명 (부분일치) */
private String searchServiceName;
/* 커맨드 (부분일치) */
private String searchCommand;
/* 연동시간 기간 검색 (yyyyMMdd, 8자리) */
private String searchStartDate;
private String searchEndDate;