클라이언트 유량제어 신규생성

This commit is contained in:
eastargh
2026-05-07 09:39:59 +09:00
parent e9bff78cbf
commit 9a5d5e4815
5 changed files with 551 additions and 2 deletions
@@ -0,0 +1,138 @@
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/jsp/common/include/css.jsp"/>
<jsp:include page="/jsp/common/include/script.jsp"/>
<script language="javascript" >
var url ='<c:url value="/onl/admin/inflow/inflowClientControlMan.json" />';
var url_view ='<c:url value="/onl/admin/inflow/inflowClientControlMan.view" />';
$(document).ready(function() {
$('#grid').jqGrid({
datatype:"json",
mtype: 'POST',
url: url,
postData : { cmd : 'LIST', searchName: $('input[name=searchName]').val()},
colNames:['클라이언트 ID',
'클라이언트명',
'<%= localeMessage.getString("infAdpConMan.thrPerSecond") %>',
'<%= localeMessage.getString("infAdpConMan.thr") %>',
'<%= localeMessage.getString("infAdpConMan.thrTimeUnit") %>',
'<%= localeMessage.getString("infAdpConMan.useYn") %>'
],
colModel:[
{ name : 'NAME' , align:'left' , width:'100' , sortable:false },
{ name : 'DESC' , align:'left' , width:'200'},
{ name : 'THRESHOLDPERSECOND' , align:'right' , width:'60'},
{ name : 'THRESHOLD' , align:'right' , width:'60'},
{ name : 'THRESHOLDTIMEUNIT' , align:'center' , width:'80'},
{ name : 'USEYN' , align:'center' , width:'60' , editoptions:{value:"0:사용안함;1:사용함"}, formatter:"select" }
],
jsonReader: {
repeatitems:false
},
pager : $('#pager'),
page : '${param.page}',
rowNum : '${rmsDefaultRowNum}',
autoheight: true,
height: $("#container").height(),
autowidth: true,
viewrecords: true,
rowList : eval('[${rmsDefaultRowList}]'),
ondblClickRow: function(rowId) {
var rowData = $(this).getRowData(rowId);
var name = rowData['NAME'];
var url2 = url_view;
url2 += '?cmd=DETAIL';
url2 += '&page='+$(this).getGridParam("page");
url2 += '&returnUrl='+getReturnUrl();
url2 += '&menuId='+'${param.menuId}';
//검색값
url2 += '&searchName='+$("input[name=searchName]").val();
//key값
url2 += '&name='+name;
goNav(url2);
},
gridComplete:function (d){
var colModel = $(this).getGridParam("colModel");
for(var i = 0 ; i< colModel.length; i++){
$(this).setColProp(colModel[i].name, {sortable : false});
}
}
});
resizeJqGridWidth('grid','content_middle','1000');
$("#btn_search").click(function(){
$("#grid").setGridParam({ postData: { searchName: $('input[name=searchName]').val()}, page:1 }).trigger("reloadGrid");
});
$("#btn_new").click(function(){
var url2 = url_view;
url2 += '?cmd=DETAIL';
url2 += '&page='+$("#grid").getGridParam("page");
url2 += '&returnUrl='+getReturnUrl();
url2 += '&menuId='+'${param.menuId}';
//검색값
url2 += '&searchName=';
goNav(url2);
});
$("input[name^=search]").keydown(function(key){
if (key.keyCode == 13){
$("#btn_search").click();
}
});
buttonControl();
});
</script>
</head>
<body>
<div class="right_box">
<div class="content_top">
<ul class="path">
<li><a href="#">${rmsMenuPath}</a></li>
</ul>
</div><!-- end content_top -->
<div class="content_middle" id="content_middle">
<div class="search_wrap">
<button type="button" class="cssbtn" id="btn_search" level="R"><i class="material-icons">search</i> <%= localeMessage.getString("button.search") %></button>
</div>
<div class="title">클라이언트 유량제어<span class="tooltip">클라이언트(API Key) 유량제어를 관리한다</span></div>
<table class="search_condition" cellspacing=0;>
<tbody>
<tr>
<th style="width:180px;">클라이언트명</th>
<td><input type="text" name="searchName" value="${param.searchName}"></td>
</tr>
</tbody>
</table>
<table id="grid" ></table>
<div id="pager"></div>
</div><!-- end content_middle -->
</div><!-- end right_box -->
</body>
</html>
@@ -0,0 +1,185 @@
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ page import="java.io.*"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ include file="/jsp/common/include/localemessage.jsp" %>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Expires", "0");
%>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<jsp:include page="/jsp/common/include/css.jsp"/>
<jsp:include page="/jsp/common/include/script.jsp"/>
<script language="javascript" >
var url ='<c:url value="/onl/admin/inflow/inflowClientControlMan.json" />';
var url_view ='<c:url value="/onl/admin/inflow/inflowClientControlMan.view" />';
var isDetail = false;
function init(url,key,callback){
$.ajax({
type : "POST",
url:url,
dataType:"json",
data:{cmd: 'LIST_INIT_COMBO'},
success:function(json){
new makeOptions("CODE","NAME").setObj($("select[name=useYn]")).setData(json.useYnRows).setFormat(codeName3OptionFormat).rendering();
new makeOptions("CODE","NAME").setObj($("select[name=thresholdTimeUnit]")).setNoValueInclude(true).setData(json.timeUnitRows).setFormat(codeName3OptionFormat).rendering();
if(typeof callback === 'function') {
callback(url,key);
}
},
error:function(e){
alert(e.responseText);
}
});
}
function detail(url,key){
if (!isDetail)return;
$.ajax({
type : "POST",
url:url,
dataType:"json",
data:{cmd: 'DETAIL', name : key},
success:function(json){
var data = json;
$("input[name=name]").attr('readonly',true);
$("input[name=desc]").attr('readonly',true);
$("#ajaxForm input[type!=radio],#ajaxForm select,#ajaxForm textarea").each(function(){
var name = $(this).attr("name");
var tag = $(this).prop("tagName").toLowerCase();
$(tag+"[name="+name+"]").val(data[name.toUpperCase()]);
});
},
error:function(e){
alert(e.responseText);
}
});
}
$(document).ready(function() {
var returnUrl = getReturnUrlForReturn();
var key ="${param.name}";
if (key != "" && key !="null"){
isDetail = true;
}
init(url,key,detail);
$("#btn_modify").click(function(){
var postData = $('#ajaxForm').serializeArray();
if (isDetail){
postData.push({ name: "cmd" , value:"UPDATE"});
}else{
postData.push({ name: "cmd" , value:"INSERT"});
}
$.ajax({
type : "POST",
url:url,
data:postData,
success:function(args){
alert("<%= localeMessage.getString("common.saveMsg") %>");
goNav(returnUrl);//LIST로 이동
},
error:function(e){
alert(e.responseText);
}
});
});
$("#btn_delete").click(function(){
if ( confirm( '<%=localeMessage.getString("common.confirmMsg")%>' ) != true ) return;
var postData = $('#ajaxForm').serializeArray();
postData.push({ name: "cmd" , value:"DELETE"});
$.ajax({
type : "POST",
url:url,
data:postData,
success:function(args){
alert("<%= localeMessage.getString("common.deleteMsg") %>");
goNav(returnUrl);//LIST로 이동
},
error:function(e){
alert(e.responseText);
}
});
});
$("#btn_previous").click(function(){
goNav(returnUrl);//LIST로 이동
});
buttonControl(isDetail);
titleControl(isDetail);
});
</script>
</head>
<body>
<div class="right_box">
<div class="content_top">
<ul class="path">
<li><a href="#">${rmsMenuPath}</a></li>
</ul>
</div><!-- end content_top -->
<div class="content_middle">
<div class="search_wrap">
<button type="button" class="cssbtn" id="btn_delete" level="W" status="DETAIL"><i class="material-icons">delete</i> <%= localeMessage.getString("button.delete") %></button>
<button type="button" class="cssbtn" id="btn_modify" level="W" status="DETAIL,NEW"><i class="material-icons">save</i> <%= localeMessage.getString("button.modify") %></button>
<button type="button" class="cssbtn" id="btn_previous" level="R" status="DETAIL,NEW"><i class="material-icons">arrow_back</i> <%= localeMessage.getString("button.previous") %></button>
</div>
<div class="title">클라이언트 유량제어 <span class="tooltip" >클라이언트 유량제어 </span></div>
<table id="grid" ></table>
<div id="pager"></div>
<!-- detail -->
<form id="ajaxForm">
<table class="table_row" cellspacing="0">
<tr>
<th style="width:20%;">클라이언트 ID</th>
<td><input type="text" name="name" /></td>
</tr>
<tr>
<th style="width:20%;">클라이언트명</th>
<td><input type="text" name="desc" /></td>
</tr>
<tr>
<th style="width:20%;"><%= localeMessage.getString("infAdpConMan.thrPerSecond") %></th>
<td><input type="text" name="thresholdPerSecond" /></td>
</tr>
<tr>
<th style="width:20%;"><%= localeMessage.getString("infAdpConMan.thr") %></th>
<td><input type="text" name="threshold" /></td>
</tr>
<tr>
<th style="width:20%;"><%= localeMessage.getString("infAdpConMan.thrTimeUnit") %></th>
<td>
<div class="select-style">
<select name="thresholdTimeUnit" />
</div>
</td>
</tr>
<tr>
<th style="width:20%;"><%= localeMessage.getString("infAdpConMan.useYn") %></th>
<td>
<div class="select-style">
<select name="useYn" />
</div>
</td>
</tr>
</table>
</form>
</div><!-- end content_middle -->
</div><!-- end right_box -->
</body>
</html>
@@ -1,6 +1,9 @@
package com.eactive.eai.rms.data.entity.onl.inflow;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.persistence.EntityManager;
@@ -13,6 +16,7 @@ import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import com.eactive.apim.portal.app.entity.QCredential;
import com.eactive.eai.data.entity.onl.adapter.QAdapterGroup;
import com.eactive.eai.data.entity.onl.inflow.InflowControl;
import com.eactive.eai.data.entity.onl.inflow.InflowControlId;
@@ -33,10 +37,15 @@ import com.querydsl.jpa.impl.JPAQueryFactory;
public class InflowControlService extends AbstractDataService<InflowControl, InflowControlId, InflowControlRepository> {
private static final String ADAPTER_TYPE_INFLOW = "01";
private static final String INTERFACE_TYPE_INFLOW = "02";
private static final String CLIENT_TYPE_INFLOW = "03";
@PersistenceContext
EntityManager entityManager;
@PersistenceContext(unitName = "entityManagerFactoryForEMS")
EntityManager entityManagerForEMS;
@Autowired
InflowControlManMapper mapper;
@@ -124,7 +133,7 @@ public class InflowControlService extends AbstractDataService<InflowControl, Inf
.select(qInflowControl, qEAIMessageEntity.eaisvcname, qEAIMessageEntity.eaisvcdesc)
.from(qEAIMessageEntity)
.leftJoin(qInflowControl)
.on(qInflowControl.id.type.eq("02").and(qInflowControl.id.name.eq(qEAIMessageEntity.eaisvcname)))
.on(qInflowControl.id.type.eq(INTERFACE_TYPE_INFLOW).and(qInflowControl.id.name.eq(qEAIMessageEntity.eaisvcname)))
.where(qEAIMessageEntity.eaisvcname.contains(searchName))
.orderBy(qEAIMessageEntity.eaisvcname.asc())
.offset(pageable.getOffset())
@@ -143,6 +152,8 @@ public class InflowControlService extends AbstractDataService<InflowControl, Inf
.fetchOne();
return new PageImpl<>(dtoList, pageable, totalCount);
}
private InflowControlServiceDto toDto(QEAIMessageEntity qEAIMessageEntity, QInflowControl qInflowControl,
Tuple tuple) {
@@ -167,13 +178,109 @@ public class InflowControlService extends AbstractDataService<InflowControl, Inf
.select(qInflowControl, qEAIMessageEntity.eaisvcname, qEAIMessageEntity.eaisvcdesc)
.from(qEAIMessageEntity)
.leftJoin(qInflowControl)
.on(qInflowControl.id.type.eq("02").and(qInflowControl.id.name.eq(qEAIMessageEntity.eaisvcname)))
.on(qInflowControl.id.type.eq(INTERFACE_TYPE_INFLOW).and(qInflowControl.id.name.eq(qEAIMessageEntity.eaisvcname)))
.where(qEAIMessageEntity.eaisvcname.eq(eaisvcname))
.fetchOne();
return toDto(qEAIMessageEntity, qInflowControl, tuple);
}
public InflowControlServiceDto findByIdForClient(String clientId) {
QCredential qCredential = QCredential.credential;
QInflowControl qInflowControl = QInflowControl.inflowControl;
// EMSADM: Credential 조회
Tuple credTuple = new JPAQueryFactory(entityManagerForEMS)
.select(qCredential.clientid, qCredential.clientname)
.from(qCredential)
.where(qCredential.clientid.eq(clientId))
.fetchOne();
// AGWADM: InflowControl 조회
InflowControl inflowControl = new JPAQueryFactory(entityManager)
.selectFrom(qInflowControl)
.where(qInflowControl.id.type.eq(CLIENT_TYPE_INFLOW)
.and(qInflowControl.id.name.eq(clientId)))
.fetchOne();
InflowControlServiceDto dto;
if (inflowControl != null) {
dto = mapper.toDto(inflowControl);
} else {
dto = new InflowControlServiceDto();
dto.setName(clientId);
dto.setType(CLIENT_TYPE_INFLOW);
}
if (credTuple != null) {
dto.setDesc(credTuple.get(qCredential.clientname));
}
return dto;
}
public Page<InflowControlServiceDto> findAllForClient(Pageable pageable, String searchName) {
QCredential qCredential = QCredential.credential;
QInflowControl qInflowControl = QInflowControl.inflowControl;
// EMSADM: Credential 목록 및 건수 조회
JPAQueryFactory emsFactory = new JPAQueryFactory(entityManagerForEMS);
BooleanBuilder credPredicate = new BooleanBuilder();
if (!StringUtils.isEmpty(searchName)) {
credPredicate.and(qCredential.clientname.contains(searchName));
}
long totalCount = emsFactory
.select(qCredential.clientid.count())
.from(qCredential)
.where(credPredicate)
.fetchOne();
List<Tuple> credList = emsFactory
.select(qCredential.clientid, qCredential.clientname)
.from(qCredential)
.where(credPredicate)
.orderBy(qCredential.clientname.asc())
.offset(pageable.getOffset())
.limit(pageable.getPageSize())
.fetch();
if (credList.isEmpty()) {
return new PageImpl<>(Collections.emptyList(), pageable, totalCount);
}
// AGWADM: 해당 clientId의 InflowControl 일괄 조회
List<String> clientIds = credList.stream()
.map(t -> t.get(qCredential.clientid))
.collect(Collectors.toList());
Map<String, InflowControl> inflowMap = new JPAQueryFactory(entityManager)
.selectFrom(qInflowControl)
.where(qInflowControl.id.type.eq(CLIENT_TYPE_INFLOW)
.and(qInflowControl.id.name.in(clientIds)))
.fetch()
.stream()
.collect(Collectors.toMap(ic -> ic.getId().getName(), ic -> ic));
// Java에서 병합
List<InflowControlServiceDto> dtoList = credList.stream()
.map(tuple -> {
String clientId = tuple.get(qCredential.clientid);
InflowControl inflowControl = inflowMap.get(clientId);
InflowControlServiceDto dto;
if (inflowControl != null) {
dto = mapper.toDto(inflowControl);
} else {
dto = new InflowControlServiceDto();
dto.setName(clientId);
dto.setType(CLIENT_TYPE_INFLOW);
}
dto.setDesc(tuple.get(qCredential.clientname));
return dto;
})
.collect(Collectors.toList());
return new PageImpl<>(dtoList, pageable, totalCount);
}
public Page<Tuple> selectLogList(Pageable pageable, InflowControlHistoryManUISearch uiSearch) {
QInflowControlLog qlog = QInflowControlLog.inflowControlLog;
QInflowControlGroup qgroup = QInflowControlGroup.inflowControlGroup;
@@ -0,0 +1,86 @@
package com.eactive.eai.rms.onl.manage.inflow.inflow;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.eactive.eai.agent.command.CommonCommand;
import com.eactive.eai.rms.common.base.OnlBaseAnnotationController;
import com.eactive.eai.rms.common.combo.ComboService;
import com.eactive.eai.rms.common.combo.ComboVo;
import com.eactive.eai.rms.common.vo.GridResponse;
@Controller
public class InflowClientControlManController extends OnlBaseAnnotationController {
@Autowired
private InflowControlManService service;
@Autowired
private ComboService comboService;
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.view")
public String viewList() {
return "/onl/admin/inflow/inflowClientControlMan";
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.view", params = "cmd=DETAIL")
public String viewDetail() {
return "/onl/admin/inflow/inflowClientControlManDetail";
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=LIST")
public ResponseEntity<GridResponse<InflowControlManUI>> selectList(HttpServletRequest request, Pageable pageVo,
String searchName) {
Page<InflowControlManUI> uiPage = service.selectClientList(pageVo, searchName);
return ResponseEntity.ok(new GridResponse<>(uiPage));
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=DETAIL")
public ResponseEntity<InflowControlManUI> selectDetail(HttpServletRequest request, HttpServletResponse response,
String name) {
InflowControlManUI ui = service.selectClientDetail(name);
return ResponseEntity.ok(ui);
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=UPDATE")
public String save(HttpServletRequest request, HttpServletResponse response, InflowControlManUI ui)
throws Exception {
service.mergeClient(ui);
CommonCommand command = new CommonCommand("com.eactive.eai.agent.inflow.ReloadInflowClientControlCommand",
ui.getName());
agentUtilService.broadcast(command);
return null;
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=DELETE")
public String delete(HttpServletRequest request, HttpServletResponse response, String name) throws Exception {
service.deleteClient(name);
CommonCommand command = new CommonCommand("com.eactive.eai.agent.inflow.RemoveInflowClientControlCommand",
name);
agentUtilService.broadcast(command);
return null;
}
@RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=LIST_INIT_COMBO")
public ModelAndView initCombo(HttpServletRequest request, HttpServletResponse response) {
List<ComboVo> useYnRows = comboService.getFromCode("USE_YN");
List<ComboVo> timeUnitRows = comboService.getFromCode("INFLOW_CTRL_TIME_UNIT");
Map<String, List<ComboVo>> resultMap = new HashMap<>();
resultMap.put("useYnRows", useYnRows);
resultMap.put("timeUnitRows", timeUnitRows);
return new ModelAndView("jsonView", resultMap);
}
}
@@ -20,6 +20,7 @@ public class InflowControlManService extends BaseService {
private static final String ADAPTER_TYPE_INFLOW = "01";
private static final String INTERFACE_TYPE_INFLOW = "02";
private static final String CLIENT_TYPE_INFLOW = "03";
@Autowired
@Qualifier("comboService")
@@ -92,6 +93,38 @@ public class InflowControlManService extends BaseService {
service.deleteById(id);
}
// 클라이언트 유량제어
public Page<InflowControlManUI> selectClientList(Pageable pageable, String searchName) {
Page<InflowControlServiceDto> dtoList = service.findAllForClient(pageable, searchName);
return dtoList.map(mapper::toVo);
}
public InflowControlManUI selectClientDetail(String name) {
return mapper.toVo(service.findByIdForClient(name));
}
public void mergeClient(InflowControlManUI ui) {
ui.setType(CLIENT_TYPE_INFLOW);
InflowControlId id = toId(ui);
Optional<InflowControl> inflowControlOptional = service.findById(id);
InflowControl entity = null;
if (inflowControlOptional.isPresent()) {
entity = inflowControlOptional.get();
mapper.updateToEntity(ui, entity);
} else {
entity = mapper.toEntity(ui);
}
service.save(entity);
}
public void deleteClient(String name) {
InflowControlId id = toId(CLIENT_TYPE_INFLOW, name);
service.findById(id).ifPresent(service::delete);
}
private InflowControlId toId(InflowControlManUI ui) {
return toId(ui.getType(), ui.getName());
}