- 업무 데이터 XML Pretty Print 기능 호출

- 업무 데이터 보여줄 때 trim 하지않도록 수정
This commit is contained in:
daekuk
2026-02-10 10:41:01 +09:00
parent e32fa67b6d
commit 73848d14ca
2 changed files with 110 additions and 3 deletions
@@ -4,6 +4,7 @@ import com.eactive.eai.common.EAITable;
import com.eactive.eai.common.logger.HttpAdapterExtraLogVo; import com.eactive.eai.common.logger.HttpAdapterExtraLogVo;
import com.eactive.eai.common.util.MessageUtil; import com.eactive.eai.common.util.MessageUtil;
import com.eactive.eai.data.entity.onl.adapter.AdapterGroup; import com.eactive.eai.data.entity.onl.adapter.AdapterGroup;
import com.eactive.eai.data.entity.onl.server.EAIServer;
import com.eactive.eai.rms.common.combo.ComboVo; import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.context.MonitoringContext; import com.eactive.eai.rms.common.context.MonitoringContext;
import com.eactive.eai.rms.common.logging.UserAccessLogger; import com.eactive.eai.rms.common.logging.UserAccessLogger;
@@ -12,10 +13,12 @@ import com.eactive.eai.rms.common.vo.GridResponse;
import com.eactive.eai.rms.data.entity.onl.adapter.AdapterGroupService; import com.eactive.eai.rms.data.entity.onl.adapter.AdapterGroupService;
import com.eactive.eai.rms.data.entity.onl.logger.EAILogDetailSearch; import com.eactive.eai.rms.data.entity.onl.logger.EAILogDetailSearch;
import com.eactive.eai.rms.data.entity.onl.logger.EAILogSearch; import com.eactive.eai.rms.data.entity.onl.logger.EAILogSearch;
import com.eactive.eai.rms.data.entity.onl.server.EAIServerService;
import com.eactive.eai.transformer.message.ISO8583MessageFactory; import com.eactive.eai.transformer.message.ISO8583MessageFactory;
import com.eactive.eai.transformer.util.CommonLib; import com.eactive.eai.transformer.util.CommonLib;
import com.eactive.eai.transformer.util.IConv; import com.eactive.eai.transformer.util.IConv;
import com.eactive.eai.transformer.util.ISO8583DumpUtil; import com.eactive.eai.transformer.util.ISO8583DumpUtil;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.solab.iso8583.IsoMessage; import com.solab.iso8583.IsoMessage;
import org.apache.commons.io.HexDump; import org.apache.commons.io.HexDump;
@@ -24,11 +27,20 @@ import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@@ -44,15 +56,20 @@ public class DbTrackingController {
private final DbTrackingService service; private final DbTrackingService service;
private final MonitoringContext monitoringContext; private final MonitoringContext monitoringContext;
private final AdapterGroupService adapterGroupService; private final AdapterGroupService adapterGroupService;
private final EAIServerService eaiServerService;
private RestTemplate restTemplate = new RestTemplate();
private final ObjectMapper objectMapper = new ObjectMapper();
@Autowired @Autowired
public DbTrackingController(DbTrackingService service, public DbTrackingController(DbTrackingService service,
MonitoringContext monitoringContext, MonitoringContext monitoringContext,
AdapterGroupService adapterGroupService) { AdapterGroupService adapterGroupService,
EAIServerService eaiServerService) {
this.service = service; this.service = service;
this.monitoringContext = monitoringContext; this.monitoringContext = monitoringContext;
this.adapterGroupService = adapterGroupService; this.adapterGroupService = adapterGroupService;
this.eaiServerService = eaiServerService;
} }
@GetMapping(value = "/onl/transaction/tracking/trackingMan.view") @GetMapping(value = "/onl/transaction/tracking/trackingMan.view")
@@ -538,5 +555,95 @@ public class DbTrackingController {
return new String(byteArrayOutputStream.toByteArray()); return new String(byteArrayOutputStream.toByteArray());
} }
@RequestMapping(value = "/onl/transaction/tracking/trackingMan.json", params = "cmd=DETAIL_PRETTY_VIEW")
public ResponseEntity<?> selectList(@RequestParam Map<String, Object> paramMap) {
List<EAIServer> serverList = eaiServerService.selectEaiServerIpList();
if (serverList == null || serverList.isEmpty()) {
return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE)
.body(Collections.singletonMap("error", "접속 가능한 서버 목록이 없습니다."));
}
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(2000);
factory.setReadTimeout(5000);
RestTemplate restTemplate = new RestTemplate(factory);
Map<String, Object> requestBody = new HashMap<>();
requestBody.put("intrefaceId", paramMap.get("intrefaceId"));
requestBody.put("logProcessNo", paramMap.get("logProcessNo"));
requestBody.put("bizData", paramMap.get("bizData"));
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Map<String, Object>> entity = new HttpEntity<>(requestBody, headers);
Map<String, Object> resultResponse = null;
boolean isSuccess = false;
String lastErrorMsg = "";
for(EAIServer server : serverList) {
String ip = server.getEaisevrip();
String port = server.getSevrlsnportname();
if(ip == null || port == null) continue;
String targetUrl = "http://" + ip + ":" + port + "/PrettyPrint";
try {
ResponseEntity<Map> response = restTemplate.exchange(
targetUrl,
HttpMethod.POST,
entity,
Map.class
);
if(response.getStatusCode() == HttpStatus.OK && response.getBody() != null) {
resultResponse = response.getBody();
isSuccess = true;
break;
}
} catch (ResourceAccessException e) {
lastErrorMsg = "Network Error: " + e.getMessage();
logger.debug("서버 접속 실패 : " + lastErrorMsg);
continue;
} catch (HttpStatusCodeException e) {
String errorBodyString = e.getResponseBodyAsString();
logger.debug("서버 내부 에러 [" + targetUrl + "] : " + errorBodyString);
try {
// 에러 문자열을 Map(JSON 객체)으로 변환 시도
Map<String, Object> errorMap = objectMapper.readValue(errorBodyString, Map.class);
return ResponseEntity.status(e.getStatusCode()).body(errorMap);
} catch (Exception parseError) {
// 일반 텍스트를 보냈다면 수동으로 Map 생성
Map<String, Object> manualErrorMap = new HashMap<>();
manualErrorMap.put("error", true);
manualErrorMap.put("result", errorBodyString);
return ResponseEntity.status(e.getStatusCode()).body(manualErrorMap);
}
}
}
if (isSuccess && resultResponse != null) {
return ResponseEntity.ok(resultResponse);
} else {
// 모든 서버 실패
Map<String, Object> errorMap = new HashMap<>();
errorMap.put("error", true);
errorMap.put("result", "서버 연결 실패");
// errorMap.put("result", "서버 연결 실패 (Last Error: " + lastErrorMsg + ")");
logger.debug("서버 POST 요청 에러 : " + lastErrorMsg);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(errorMap);
}
}
} }
@@ -308,7 +308,7 @@ public class DbTrackingService extends BaseService {
Matcher matcher = pattern.matcher(input); Matcher matcher = pattern.matcher(input);
if (matcher.find()) { if (matcher.find()) {
return matcher.group(1).trim(); return matcher.group(1);
} }
return null; return null;