클라이언트 유량제어 테이블 수정

This commit is contained in:
eastargh
2026-05-27 16:54:19 +09:00
parent 7677e3b26e
commit 350297aaa2
@@ -1,9 +1,6 @@
package com.eactive.eai.rms.data.entity.onl.inflow; package com.eactive.eai.rms.data.entity.onl.inflow;
import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
@@ -18,6 +15,7 @@ import org.springframework.stereotype.Service;
import com.eactive.apim.portal.app.entity.QCredential; import com.eactive.apim.portal.app.entity.QCredential;
import com.eactive.eai.data.entity.onl.adapter.QAdapterGroup; import com.eactive.eai.data.entity.onl.adapter.QAdapterGroup;
import com.eactive.eai.data.entity.onl.authserver.QClientEntity;
import com.eactive.eai.data.entity.onl.inflow.InflowControl; import com.eactive.eai.data.entity.onl.inflow.InflowControl;
import com.eactive.eai.data.entity.onl.inflow.InflowControlId; import com.eactive.eai.data.entity.onl.inflow.InflowControlId;
import com.eactive.eai.data.entity.onl.inflow.QInflowControl; import com.eactive.eai.data.entity.onl.inflow.QInflowControl;
@@ -29,7 +27,6 @@ import com.eactive.eai.rms.onl.manage.inflow.history.InflowControlHistoryManUISe
import com.eactive.eai.rms.onl.manage.inflow.inflow.InflowControlManMapper; import com.eactive.eai.rms.onl.manage.inflow.inflow.InflowControlManMapper;
import com.querydsl.core.BooleanBuilder; import com.querydsl.core.BooleanBuilder;
import com.querydsl.core.Tuple; import com.querydsl.core.Tuple;
import com.querydsl.core.types.OrderSpecifier;
import com.querydsl.jpa.impl.JPAQuery; import com.querydsl.jpa.impl.JPAQuery;
import com.querydsl.jpa.impl.JPAQueryFactory; import com.querydsl.jpa.impl.JPAQueryFactory;
@@ -186,99 +183,65 @@ public class InflowControlService extends AbstractDataService<InflowControl, Inf
} }
public InflowControlServiceDto findByIdForClient(String clientId) { public InflowControlServiceDto findByIdForClient(String clientId) {
QCredential qCredential = QCredential.credential; JPAQueryFactory jpaQueryFactory = new JPAQueryFactory(entityManager);
QInflowControl qInflowControl = QInflowControl.inflowControl; QInflowControl qInflowControl = QInflowControl.inflowControl;
QClientEntity qClientEntity = QClientEntity.clientEntity;
// EMSADM: Credential 조회 Tuple tuple = jpaQueryFactory
Tuple credTuple = new JPAQueryFactory(entityManagerForEMS) .select(qInflowControl, qClientEntity.clientid, qClientEntity.clientname)
.select(qCredential.clientid, qCredential.clientname) .from(qClientEntity)
.from(qCredential) .leftJoin(qInflowControl)
.where(qCredential.clientid.eq(clientId)) .on(qInflowControl.id.type.eq(CLIENT_TYPE_INFLOW)
.and(qInflowControl.id.name.eq(qClientEntity.clientid)))
.where(qClientEntity.clientid.eq(clientId))
.fetchOne(); .fetchOne();
// AGWADM: InflowControl 조회 return toDto(qClientEntity, qInflowControl, tuple);
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) { public Page<InflowControlServiceDto> findAllForClient(Pageable pageable, String searchName) {
QCredential qCredential = QCredential.credential;
JPAQueryFactory jpaQueryFactory = new JPAQueryFactory(entityManager);
QInflowControl qInflowControl = QInflowControl.inflowControl; QInflowControl qInflowControl = QInflowControl.inflowControl;
QClientEntity qClientEntity = QClientEntity.clientEntity;
// EMSADM: Credential 목록 및 건수 조회 List<Tuple> tupleList = jpaQueryFactory
JPAQueryFactory emsFactory = new JPAQueryFactory(entityManagerForEMS); .select(qInflowControl, qClientEntity.clientid, qClientEntity.clientname)
BooleanBuilder credPredicate = new BooleanBuilder(); .from(qClientEntity)
if (!StringUtils.isEmpty(searchName)) { .leftJoin(qInflowControl)
credPredicate.and(qCredential.clientname.contains(searchName)); .on(qInflowControl.id.type.eq(CLIENT_TYPE_INFLOW)
} .and(qInflowControl.id.name.eq(qClientEntity.clientid)))
.where(qClientEntity.clientname.contains(searchName))
long totalCount = emsFactory .orderBy(qClientEntity.clientname.asc())
.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()) .offset(pageable.getOffset())
.limit(pageable.getPageSize()) .limit(pageable.getPageSize())
.fetch(); .fetch();
if (credList.isEmpty()) { List<InflowControlServiceDto> dtoList = tupleList
return new PageImpl<>(Collections.emptyList(), pageable, totalCount); .stream()
} .map(tuple -> toDto(qClientEntity, qInflowControl, tuple))
// AGWADM: 해당 clientId의 InflowControl 일괄 조회
List<String> clientIds = credList.stream()
.map(t -> t.get(qCredential.clientid))
.collect(Collectors.toList()); .collect(Collectors.toList());
Map<String, InflowControl> inflowMap = new JPAQueryFactory(entityManager) long totalCount = jpaQueryFactory
.selectFrom(qInflowControl) .select(qClientEntity.clientname.count())
.where(qInflowControl.id.type.eq(CLIENT_TYPE_INFLOW) .from(qClientEntity)
.and(qInflowControl.id.name.in(clientIds))) .where(qClientEntity.clientname.contains(searchName))
.fetch() .fetchOne();
.stream() return new PageImpl<>(dtoList, pageable, totalCount);
.collect(Collectors.toMap(ic -> ic.getId().getName(), ic -> ic)); }
// Java에서 병합 private InflowControlServiceDto toDto(QClientEntity qClientEntity, QInflowControl qInflowControl,
List<InflowControlServiceDto> dtoList = credList.stream() Tuple tuple) {
.map(tuple -> { InflowControlServiceDto dto = null;
String clientId = tuple.get(qCredential.clientid); if (tuple.get(qInflowControl) != null)
InflowControl inflowControl = inflowMap.get(clientId); dto = mapper.toDto(tuple.get(qInflowControl));
InflowControlServiceDto dto; else {
if (inflowControl != null) {
dto = mapper.toDto(inflowControl);
} else {
dto = new InflowControlServiceDto(); dto = new InflowControlServiceDto();
dto.setName(clientId); dto.setName(tuple.get(qClientEntity.clientid));
dto.setType(CLIENT_TYPE_INFLOW); dto.setType(CLIENT_TYPE_INFLOW);
} }
dto.setDesc(tuple.get(qCredential.clientname)); dto.setDesc(tuple.get(qClientEntity.clientname));
return dto; return dto;
})
.collect(Collectors.toList());
return new PageImpl<>(dtoList, pageable, totalCount);
} }
public Page<Tuple> selectLogList(Pageable pageable, InflowControlHistoryManUISearch uiSearch) { public Page<Tuple> selectLogList(Pageable pageable, InflowControlHistoryManUISearch uiSearch) {