IIM 연동시 empty json 파일 직접생성하도록 변경
eapim-admin CI / build (push) Has been cancelled

This commit is contained in:
eastargh
2026-10-06 14:44:43 +09:00
parent 85fd2dcf10
commit a8bdc3fe89
2 changed files with 34 additions and 20 deletions
@@ -29,7 +29,10 @@ class KJBInterfaceService {
}
}
public void insertInterface(HashMap<String, Object> info) throws Exception {
/**
* @return 신규 등록했으면 true, 이미 존재해서 등록하지 않았으면 false
*/
public boolean insertInterface(HashMap<String, Object> info) throws Exception {
HashMap detail = dao.selectDetailAPI(info);
if (detail == null) {
dao.insertToHE01(info);
@@ -48,7 +51,9 @@ class KJBInterfaceService {
logParam.put("prcssRsltCmnt", "");
service.addLayoutSyncLog(logParam);
return true;
}
return false;
}
public boolean existsInterface(String interfaceId) throws Exception {
@@ -5,6 +5,7 @@ import java.io.File;
import java.io.InputStream;
import java.io.Reader;
import java.io.StringReader;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -23,6 +24,8 @@ import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
@@ -57,7 +60,7 @@ import com.eactive.eai.rms.common.util.CommonUtil;
import com.eactive.eai.rms.common.util.StringUtils;
import com.eactive.eai.rms.onl.common.exception.BizException;
import com.eactive.eai.rms.onl.common.util.DateUtil;
import com.eactive.eai.rms.onl.loader.controller.LoaderController;
import com.eactive.eai.rms.onl.common.util.FileWriteUtil;
import com.eactive.eai.transformer.layout.Item;
import com.eactive.eai.transformer.layout.Types;
@@ -85,9 +88,6 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
@Autowired
private MonitoringCodeService monitoringCodeService;
@Autowired
private LoaderController loaderController;
/**
* xml 형식으로 전달 된 레이아웃을 LayoutVo로 전환
@@ -1226,13 +1226,10 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
boolean isDevMake = this.isDevMake(interfaceId);
if (command.equals("insert")) {
String serviceType = DataSourceContextHolder.getDataSourceType().getName();
insertInterfaceDjb(interfaceId, body, param);
downloadFull(serviceType, interfaceId); //eCams 인터페이스 목록에 노출시키기 위해 빈 JSON파일을 생성한다
insertInterfaceDjb(interfaceId, body, param, true);
if (isDevMake) {
interfaceId = interfaceId.substring(0,8) + "D" + interfaceId.substring(8);
insertInterfaceDjb(interfaceId, body, param);
insertInterfaceDjb(interfaceId, body, param, false);
}
}
@@ -1276,7 +1273,7 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
return false;
}
//interfaceId 9번째 글자가 D이면 false
if ("D".equals(interfaceId.substring(7,8))) {
if ("D".equals(interfaceId.substring(8,9))) {
return false;
}
//신규 등록 true
@@ -1300,7 +1297,7 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
return isDevMake(interfaceId);
}
private void insertInterfaceDjb(String interfaceId, JSONObject body, HashMap<String, String> param) throws Exception
private void insertInterfaceDjb(String interfaceId, JSONObject body, HashMap<String, String> param, boolean isDownload) throws Exception
{
String bizCode = (String) body.get("bzSystemCode");
String interfaceDesc = (String) body.get("interfaceDesc");
@@ -1314,19 +1311,31 @@ public class LayoutSyncController extends OnlBaseAnnotationController implements
info.put("recvData", body.toJSONString());
info.put("recvAmndHMS", param.get("recvAmndHMS"));
interfaceService.insertInterface(info);
boolean inserted = interfaceService.insertInterface(info);
//기존에 interface가 있으면 다운로드 하지 않는다
if (isDownload && inserted) {
createEmptyJsonFile(bizCode, interfaceId); //eCams 인터페이스 목록에 노출시키기 위해 빈 JSON파일을 생성한다
}
}
/**
* LoaderController 의 downloadfull 호출 (인터페이스 전체 JSON 배포파일 생성)
* {iomap 다운로드 경로}/{bizCode}/{interfaceId}.json 파일을 "{}" 내용으로 생성 (이미 있으면 내용 유지)
* 실패해도 싱크 처리는 계속 진행한다.
*/
@SuppressWarnings("unchecked")
private void downloadFull(String serviceType, String interfaceId) {
ModelAndView mav = loaderController.interfaceDownLoadFully(serviceType, interfaceId);
Map<String, String> result = (Map<String, String>) mav.getModel().get("result");
if (result == null || !"success".equals(result.get("status"))) {
logger.warn("interface downloadfull fail - interfaceId={}, message={}", interfaceId, result == null ? null : result.get("message"));
private void createEmptyJsonFile(String bizCode, String interfaceId) {
try {
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);
if (!file.exists()) {
FileUtils.writeStringToFile(file, "{}", StandardCharsets.UTF_8);
}
} catch (Exception e) {
logger.warn("interface empty json file create fail - interfaceId=" + interfaceId, e);
}
}