diff --git a/WebContent/jsp/onl/admin/inflow/inflowClientControlMan.jsp b/WebContent/jsp/onl/admin/inflow/inflowClientControlMan.jsp new file mode 100644 index 0000000..5d0275e --- /dev/null +++ b/WebContent/jsp/onl/admin/inflow/inflowClientControlMan.jsp @@ -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"); + +%> + + + + + + + + + +
+
+ +
+
+
+ +
+
클라이언트 유량제어클라이언트(API Key) 유량제어를 관리한다
+ + + + + + + + +
클라이언트명
+ +
+
+ +
+
+ + + diff --git a/WebContent/jsp/onl/admin/inflow/inflowClientControlManDetail.jsp b/WebContent/jsp/onl/admin/inflow/inflowClientControlManDetail.jsp new file mode 100644 index 0000000..2bac2cd --- /dev/null +++ b/WebContent/jsp/onl/admin/inflow/inflowClientControlManDetail.jsp @@ -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"); +%> + + + + + + + + + + + +
+
+ +
+
+
+ + + +
+
클라이언트 유량제어 클라이언트 유량제어
+ +
+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
클라이언트 ID
클라이언트명
<%= localeMessage.getString("infAdpConMan.thrPerSecond") %>
<%= localeMessage.getString("infAdpConMan.thr") %>
<%= localeMessage.getString("infAdpConMan.thrTimeUnit") %> +
+
<%= localeMessage.getString("infAdpConMan.useYn") %> +
+
+
+ +
+
+ + + diff --git a/src/main/java/com/eactive/eai/rms/data/entity/onl/inflow/InflowControlService.java b/src/main/java/com/eactive/eai/rms/data/entity/onl/inflow/InflowControlService.java index 15adc96..9c1284f 100644 --- a/src/main/java/com/eactive/eai/rms/data/entity/onl/inflow/InflowControlService.java +++ b/src/main/java/com/eactive/eai/rms/data/entity/onl/inflow/InflowControlService.java @@ -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 { 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(dtoList, pageable, totalCount); } + + private InflowControlServiceDto toDto(QEAIMessageEntity qEAIMessageEntity, QInflowControl qInflowControl, Tuple tuple) { @@ -167,13 +178,109 @@ public class InflowControlService extends AbstractDataService 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 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 clientIds = credList.stream() + .map(t -> t.get(qCredential.clientid)) + .collect(Collectors.toList()); + + Map 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 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 selectLogList(Pageable pageable, InflowControlHistoryManUISearch uiSearch) { QInflowControlLog qlog = QInflowControlLog.inflowControlLog; QInflowControlGroup qgroup = QInflowControlGroup.inflowControlGroup; diff --git a/src/main/java/com/eactive/eai/rms/onl/manage/inflow/inflow/InflowClientControlManController.java b/src/main/java/com/eactive/eai/rms/onl/manage/inflow/inflow/InflowClientControlManController.java new file mode 100644 index 0000000..a384d01 --- /dev/null +++ b/src/main/java/com/eactive/eai/rms/onl/manage/inflow/inflow/InflowClientControlManController.java @@ -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> selectList(HttpServletRequest request, Pageable pageVo, + String searchName) { + Page uiPage = service.selectClientList(pageVo, searchName); + return ResponseEntity.ok(new GridResponse<>(uiPage)); + } + + @RequestMapping(value = "/onl/admin/inflow/inflowClientControlMan.json", params = "cmd=DETAIL") + public ResponseEntity 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 useYnRows = comboService.getFromCode("USE_YN"); + List timeUnitRows = comboService.getFromCode("INFLOW_CTRL_TIME_UNIT"); + Map> resultMap = new HashMap<>(); + resultMap.put("useYnRows", useYnRows); + resultMap.put("timeUnitRows", timeUnitRows); + return new ModelAndView("jsonView", resultMap); + } + +} \ No newline at end of file diff --git a/src/main/java/com/eactive/eai/rms/onl/manage/inflow/inflow/InflowControlManService.java b/src/main/java/com/eactive/eai/rms/onl/manage/inflow/inflow/InflowControlManService.java index df23d5f..c5c6d19 100644 --- a/src/main/java/com/eactive/eai/rms/onl/manage/inflow/inflow/InflowControlManService.java +++ b/src/main/java/com/eactive/eai/rms/onl/manage/inflow/inflow/InflowControlManService.java @@ -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 selectClientList(Pageable pageable, String searchName) { + Page 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 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()); }