Browse Source

비행 시뮬레이션 페이징작업(super , admin만 가능)

Test
qkr7828(박재우) 2 years ago
parent
commit
214ef305a0
  1. 44
      src/main/java/com/palnet/biz/api/anls/smlt/service/AnlsSmltService.java
  2. 7
      src/main/java/com/palnet/biz/jpa/repository/ctr/CtrCntrlQueryRepository.java

44
src/main/java/com/palnet/biz/api/anls/smlt/service/AnlsSmltService.java

@ -69,20 +69,28 @@ public class AnlsSmltService {
String appAuth = jwtTokenUtil.getUserAuthByToken(); String appAuth = jwtTokenUtil.getUserAuthByToken();
List<JwtGroupModel> groupAuth = jwtTokenUtil.getGroupAuthByToken(); List<JwtGroupModel> groupAuth = jwtTokenUtil.getGroupAuthByToken();
Integer cstmrSno = jwtTokenUtil.getCstmrSnoByToken(); Integer cstmrSno = jwtTokenUtil.getCstmrSnoByToken();
ComnPagingRs<AnlsHstryModel> response = new ComnPagingRs<>();
Pageable pageable = PageRequest.of(rq.getPage()-1, rq.getRecord());
PageImpl<AnlsHstryModel> result;
List<AnlsHstryModel> resultList = new ArrayList<>(); List<AnlsHstryModel>resultList = new ArrayList<>();
long total = resultList.size();
long totalPage = total % rq.getRecord() > 0 ? (total/rq.getRecord()) + 1 : total/rq.getRecord();
if("SUPER".equals(appAuth)||"ADMIN".equals(appAuth)) { // App 권한이 수퍼 / 어드민일 경우 목록 전부 표출 if("SUPER".equals(appAuth)||"ADMIN".equals(appAuth)) { // App 권한이 수퍼 / 어드민일 경우 목록 전부 표출
resultList = query.listCntrlBas(rq); result = query.listCntrlBas(rq, pageable);
response.setItems(result.getContent());
response.setTotal(total);
response.setTotalPage(totalPage);
response.setPage(rq.getPage());
return response;
} }
if("USER".equals(appAuth) || "ROLE_USER".equals(appAuth)) { // App 권한은 user이지만 group 권한이 LEADER / MASTER인 그룹이 있는 경우 해당 그룹의 비행 이력 목록 표출 if("USER".equals(appAuth) || "ROLE_USER".equals(appAuth)) { // App 권한은 user이지만 group 권한이 LEADER / MASTER인 그룹이 있는 경우 해당 그룹의 비행 이력 목록 표출
for (JwtGroupModel list : groupAuth) { for (JwtGroupModel list : groupAuth) {
if("MASTER".equals(list.getGroupAuthCd()) || "LEADER".equals(list.getGroupAuthCd())) { if("MASTER".equals(list.getGroupAuthCd()) || "LEADER".equals(list.getGroupAuthCd())) {
List<AnlsHstryModel> result = query.cntrlBasAuthList(rq, list.getGroupId()); List<AnlsHstryModel> results = query.cntrlBasAuthList(rq, list.getGroupId());
if (result.size() > 0) { if (results.size() > 0) {
resultList.addAll(result); resultList.addAll(results);
} }
} }
} }
@ -91,9 +99,9 @@ public class AnlsSmltService {
List<ComIdntfBas> idntfList = comIdntBasRepository.findIdntfNumber(cstmrSno); List<ComIdntfBas> idntfList = comIdntBasRepository.findIdntfNumber(cstmrSno);
if (idntfList.size() > 0) { if (idntfList.size() > 0) {
for (ComIdntfBas list : idntfList) { for (ComIdntfBas list : idntfList) {
List<AnlsHstryModel> result = query.cntrlBasNormalList(rq, list.getIdntfNum()); List<AnlsHstryModel> results = query.cntrlBasNormalList(rq, list.getIdntfNum());
if (result.size() > 0) { if (results.size() > 0) {
resultList.addAll(result); resultList.addAll(results);
} }
} }
} }
@ -119,18 +127,16 @@ public class AnlsSmltService {
}; };
Collections.sort(resultList, comparator); Collections.sort(resultList, comparator);
PageImpl<AnlsHstryModel> res = new PageImpl<>(resultList, pageable, resultList.size());
} response.setItems(res.getContent());
ComnPagingRs<AnlsHstryModel> response = new ComnPagingRs<>();
Pageable pageable = PageRequest.of(rq.getPage()-1, 5);
PageImpl<AnlsHstryModel> result =new PageImpl<AnlsHstryModel>(resultList, pageable, resultList.size());
long total = resultList.size();
long totalPage = total % rq.getRecord() > 0 ? (total/rq.getRecord()) + 1 : total/rq.getRecord();
response.setItems(result.getContent());
response.setTotal(total); response.setTotal(total);
response.setTotalPage(totalPage); response.setTotalPage(totalPage);
response.setPage(rq.getPage()); response.setPage(rq.getPage());
}
return response; return response;
} }

7
src/main/java/com/palnet/biz/jpa/repository/ctr/CtrCntrlQueryRepository.java

@ -70,7 +70,7 @@ public class CtrCntrlQueryRepository{
* @param rq * @param rq
* @return * @return
*/ */
public List<AnlsHstryModel> listCntrlBas(AnlsHstryRqModel rq){ public PageImpl<AnlsHstryModel> listCntrlBas(AnlsHstryRqModel rq, Pageable pageable){
QCtrCntrlBas qCntrlBasEntity = QCtrCntrlBas.ctrCntrlBas; QCtrCntrlBas qCntrlBasEntity = QCtrCntrlBas.ctrCntrlBas;
QCtrCntrlHstryArea qCntrlHstryAreaEntity = QCtrCntrlHstryArea.ctrCntrlHstryArea; QCtrCntrlHstryArea qCntrlHstryAreaEntity = QCtrCntrlHstryArea.ctrCntrlHstryArea;
@ -78,7 +78,6 @@ public class CtrCntrlQueryRepository{
BooleanBuilder builder = new BooleanBuilder(); BooleanBuilder builder = new BooleanBuilder();
builder.and(qCntrlBasEntity.statusCd.eq("99")); builder.and(qCntrlBasEntity.statusCd.eq("99"));
log.debug("Params ===> " +rq.toString());
Calendar end = Calendar.getInstance(); Calendar end = Calendar.getInstance();
end.setTime(DateUtils.stringToDate(rq.getEndDate())); end.setTime(DateUtils.stringToDate(rq.getEndDate()));
end.add(Calendar.DATE, 1); end.add(Calendar.DATE, 1);
@ -128,6 +127,8 @@ public class CtrCntrlQueryRepository{
.on(qCntrlHstryAreaEntity.actnType.eq("01")) .on(qCntrlHstryAreaEntity.actnType.eq("01"))
.where(builder) .where(builder)
.orderBy(qCntrlBasEntity.cntrlStDt.asc()) .orderBy(qCntrlBasEntity.cntrlStDt.asc())
.offset(pageable.getOffset())
.limit(5)
.fetch(); .fetch();
for(AnlsHstryModel model: queryList) { for(AnlsHstryModel model: queryList) {
@ -158,7 +159,7 @@ public class CtrCntrlQueryRepository{
return result; return new PageImpl<>(result, pageable, result.size());
} }
public List<AnlsHstryModel> cntrlBasAuthList(AnlsHstryRqModel rq, String groupId){ public List<AnlsHstryModel> cntrlBasAuthList(AnlsHstryRqModel rq, String groupId){

Loading…
Cancel
Save