클라이언트 유량제어 테이블 수정
This commit is contained in:
+43
-80
@@ -1,9 +1,6 @@
|
||||
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;
|
||||
@@ -18,6 +15,7 @@ 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.authserver.QClientEntity;
|
||||
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.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.querydsl.core.BooleanBuilder;
|
||||
import com.querydsl.core.Tuple;
|
||||
import com.querydsl.core.types.OrderSpecifier;
|
||||
import com.querydsl.jpa.impl.JPAQuery;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
|
||||
@@ -186,101 +183,67 @@ public class InflowControlService extends AbstractDataService<InflowControl, Inf
|
||||
}
|
||||
|
||||
public InflowControlServiceDto findByIdForClient(String clientId) {
|
||||
QCredential qCredential = QCredential.credential;
|
||||
JPAQueryFactory jpaQueryFactory = new JPAQueryFactory(entityManager);
|
||||
QInflowControl qInflowControl = QInflowControl.inflowControl;
|
||||
QClientEntity qClientEntity = QClientEntity.clientEntity;
|
||||
|
||||
// EMSADM: Credential 조회
|
||||
Tuple credTuple = new JPAQueryFactory(entityManagerForEMS)
|
||||
.select(qCredential.clientid, qCredential.clientname)
|
||||
.from(qCredential)
|
||||
.where(qCredential.clientid.eq(clientId))
|
||||
Tuple tuple = jpaQueryFactory
|
||||
.select(qInflowControl, qClientEntity.clientid, qClientEntity.clientname)
|
||||
.from(qClientEntity)
|
||||
.leftJoin(qInflowControl)
|
||||
.on(qInflowControl.id.type.eq(CLIENT_TYPE_INFLOW)
|
||||
.and(qInflowControl.id.name.eq(qClientEntity.clientid)))
|
||||
.where(qClientEntity.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;
|
||||
return toDto(qClientEntity, qInflowControl, tuple);
|
||||
}
|
||||
|
||||
public Page<InflowControlServiceDto> findAllForClient(Pageable pageable, String searchName) {
|
||||
QCredential qCredential = QCredential.credential;
|
||||
|
||||
JPAQueryFactory jpaQueryFactory = new JPAQueryFactory(entityManager);
|
||||
QInflowControl qInflowControl = QInflowControl.inflowControl;
|
||||
QClientEntity qClientEntity = QClientEntity.clientEntity;
|
||||
|
||||
// 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())
|
||||
List<Tuple> tupleList = jpaQueryFactory
|
||||
.select(qInflowControl, qClientEntity.clientid, qClientEntity.clientname)
|
||||
.from(qClientEntity)
|
||||
.leftJoin(qInflowControl)
|
||||
.on(qInflowControl.id.type.eq(CLIENT_TYPE_INFLOW)
|
||||
.and(qInflowControl.id.name.eq(qClientEntity.clientid)))
|
||||
.where(qClientEntity.clientname.contains(searchName))
|
||||
.orderBy(qClientEntity.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()
|
||||
List<InflowControlServiceDto> dtoList = tupleList
|
||||
.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;
|
||||
})
|
||||
.map(tuple -> toDto(qClientEntity, qInflowControl, tuple))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
long totalCount = jpaQueryFactory
|
||||
.select(qClientEntity.clientname.count())
|
||||
.from(qClientEntity)
|
||||
.where(qClientEntity.clientname.contains(searchName))
|
||||
.fetchOne();
|
||||
return new PageImpl<>(dtoList, pageable, totalCount);
|
||||
}
|
||||
|
||||
private InflowControlServiceDto toDto(QClientEntity qClientEntity, QInflowControl qInflowControl,
|
||||
Tuple tuple) {
|
||||
InflowControlServiceDto dto = null;
|
||||
if (tuple.get(qInflowControl) != null)
|
||||
dto = mapper.toDto(tuple.get(qInflowControl));
|
||||
else {
|
||||
dto = new InflowControlServiceDto();
|
||||
dto.setName(tuple.get(qClientEntity.clientid));
|
||||
dto.setType(CLIENT_TYPE_INFLOW);
|
||||
}
|
||||
dto.setDesc(tuple.get(qClientEntity.clientname));
|
||||
return dto;
|
||||
}
|
||||
|
||||
public Page<Tuple> selectLogList(Pageable pageable, InflowControlHistoryManUISearch uiSearch) {
|
||||
QInflowControlLog qlog = QInflowControlLog.inflowControlLog;
|
||||
QInflowControlGroup qgroup = QInflowControlGroup.inflowControlGroup;
|
||||
|
||||
Reference in New Issue
Block a user