|
|
@ -2,8 +2,6 @@ package com.palnet.biz.api.anls.hstry.service; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Calendar; |
|
|
|
import java.util.Collections; |
|
|
|
|
|
|
|
import java.util.Comparator; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.Optional; |
|
|
@ -30,16 +28,12 @@ import com.palnet.biz.jpa.entity.ComArcrftBas; |
|
|
|
import com.palnet.biz.jpa.entity.ComIdntfBas; |
|
|
|
import com.palnet.biz.jpa.entity.ComIdntfBas; |
|
|
|
import com.palnet.biz.jpa.entity.CtrCntrlBas; |
|
|
|
import com.palnet.biz.jpa.entity.CtrCntrlBas; |
|
|
|
import com.palnet.biz.jpa.entity.CtrCntrlHstryArea; |
|
|
|
import com.palnet.biz.jpa.entity.CtrCntrlHstryArea; |
|
|
|
import com.palnet.biz.jpa.entity.FltPlanBas; |
|
|
|
|
|
|
|
import com.palnet.biz.jpa.entity.FltPlanPilot; |
|
|
|
|
|
|
|
import com.palnet.biz.jpa.entity.PtyCstmrGroup; |
|
|
|
import com.palnet.biz.jpa.entity.PtyCstmrGroup; |
|
|
|
import com.palnet.biz.jpa.repository.com.ComArcrftBasRepository; |
|
|
|
import com.palnet.biz.jpa.repository.com.ComArcrftBasRepository; |
|
|
|
import com.palnet.biz.jpa.repository.com.ComIdntBasRepository; |
|
|
|
import com.palnet.biz.jpa.repository.com.ComIdntBasRepository; |
|
|
|
import com.palnet.biz.jpa.repository.ctr.CtrCntrlBasRepository; |
|
|
|
import com.palnet.biz.jpa.repository.ctr.CtrCntrlBasRepository; |
|
|
|
import com.palnet.biz.jpa.repository.ctr.CtrCntrlHstryAreaRepository; |
|
|
|
import com.palnet.biz.jpa.repository.ctr.CtrCntrlHstryAreaRepository; |
|
|
|
import com.palnet.biz.jpa.repository.ctr.CtrCntrlQueryRepository; |
|
|
|
import com.palnet.biz.jpa.repository.ctr.CtrCntrlQueryRepository; |
|
|
|
import com.palnet.biz.jpa.repository.flt.FltPlanBasRepository; |
|
|
|
|
|
|
|
import com.palnet.biz.jpa.repository.flt.FltPlanPilotRepository; |
|
|
|
|
|
|
|
import com.palnet.biz.jpa.repository.pty.PtyCstmrGroupRepository; |
|
|
|
import com.palnet.biz.jpa.repository.pty.PtyCstmrGroupRepository; |
|
|
|
import com.palnet.comn.code.ErrorCode; |
|
|
|
import com.palnet.comn.code.ErrorCode; |
|
|
|
import com.palnet.comn.exception.CustomException; |
|
|
|
import com.palnet.comn.exception.CustomException; |
|
|
@ -65,12 +59,6 @@ public class AnlsHstryService { |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private CtrCntrlHstryAreaRepository ctrCntrlHstryAreaRepository; |
|
|
|
private CtrCntrlHstryAreaRepository ctrCntrlHstryAreaRepository; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private FltPlanBasRepository fltPlanBasRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private FltPlanPilotRepository fltPlanPilotRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private CtrCntrlQueryRepository query; |
|
|
|
private CtrCntrlQueryRepository query; |
|
|
|
|
|
|
|
|
|
|
@ -78,58 +66,30 @@ public class AnlsHstryService { |
|
|
|
private JwtTokenUtil jwtTokenUtil; |
|
|
|
private JwtTokenUtil jwtTokenUtil; |
|
|
|
|
|
|
|
|
|
|
|
//비행이력현황 list
|
|
|
|
//비행이력현황 list
|
|
|
|
public ComnPagingRs<AnlsHstryModel> list(AnlsHstryGroupModel rq){ |
|
|
|
public ComnPagingRs<AnlsHstryRsModel> list(AnlsHstryGroupModel rq){ |
|
|
|
Integer cstmrSno = jwtTokenUtil.getCstmrSnoByToken(); |
|
|
|
Integer cstmrSno = jwtTokenUtil.getCstmrSnoByToken(); |
|
|
|
|
|
|
|
List<JwtGroupModel> groupAuth = jwtTokenUtil.getGroupAuthByToken(); |
|
|
|
String appAuth = jwtTokenUtil.getUserAuthByToken(); |
|
|
|
String appAuth = jwtTokenUtil.getUserAuthByToken(); |
|
|
|
List<AnlsHstryModel>resultList = new ArrayList<>(); |
|
|
|
ComnPagingRs<AnlsHstryRsModel> response = new ComnPagingRs<>(); |
|
|
|
|
|
|
|
|
|
|
|
ComnPagingRs<AnlsHstryModel> response = new ComnPagingRs<>(); |
|
|
|
|
|
|
|
Pageable pageable = PageRequest.of(rq.getPage()-1, rq.getRecord()); |
|
|
|
Pageable pageable = PageRequest.of(rq.getPage()-1, rq.getRecord()); |
|
|
|
|
|
|
|
|
|
|
|
if("USER".equals(appAuth) || "ROLE_USER".equals(appAuth)) { |
|
|
|
if("USER".equals(appAuth) || "ROLE_USER".equals(appAuth)) { |
|
|
|
if("NORMAL".equals(rq.getGroupId())) { |
|
|
|
|
|
|
|
List<ComIdntfBas> idntfList = comIdntBasRepository.findIdntfNumber(cstmrSno); /* App 권한이 유저이면서 group 권한도 모두 NORMAL인 ID인 경우 본인이 생성한 기체만 조회 */ |
|
|
|
|
|
|
|
if (idntfList.size() > 0) { |
|
|
|
|
|
|
|
for (ComIdntfBas list : idntfList) { |
|
|
|
|
|
|
|
List<AnlsHstryModel> results = query.cntrlBasNormalHstryList(rq, list.getIdntfNum()); |
|
|
|
|
|
|
|
if (results.size() > 0) { |
|
|
|
|
|
|
|
resultList.addAll(results); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<FltPlanBas> basResult = fltPlanBasRepository.findByPlanSno(cstmrSno); /* App 권한이 유저이면서 group 권한도 모두 |
|
|
|
|
|
|
|
NORMAL인 ID인 경우 cstmrSno로 비행계획서 조회 */ |
|
|
|
|
|
|
|
for (FltPlanBas list : basResult) { |
|
|
|
|
|
|
|
resultList.addAll(query.cntrlBasNormalPlanHstryList(rq, list.getPlanSno())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
List<FltPlanPilot> pilotResult = fltPlanPilotRepository.findByPlanSno(cstmrSno); /* App 권한이 유저이면서 group 권한도 |
|
|
|
|
|
|
|
모두 NORMAL인 ID인 경우 cstmrSno로 조종사 조회 */ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (FltPlanPilot list : pilotResult) { |
|
|
|
|
|
|
|
resultList.addAll(query.cntrlBasNormalPlanHstryList(rq, list.getPlanSno())); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Comparator<AnlsHstryModel> comparator = (o1, o2) -> { |
|
|
|
|
|
|
|
if (DateUtils.diffSecond(o1.getCntrlStDt(), o2.getCntrlStDt()) < 0) { |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} else if(DateUtils.diffSecond(o1.getCntrlStDt(), o2.getCntrlStDt()) > 0) { |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
Collections.sort(resultList, comparator); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
PageImpl<AnlsHstryRsModel> result = query.listCntrlBasRs(rq, pageable); |
|
|
|
PageImpl<AnlsHstryModel> result = query.listCntrlBasRs(rq, pageable); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
long total = query.countCntrlBasRs(rq, cstmrSno); |
|
|
|
long total = query.countCntrlBasRs(rq, cstmrSno); |
|
|
|
long totalPage = total % rq.getRecord() > 0 ? (total/rq.getRecord()) + 1 : total/rq.getRecord(); |
|
|
|
long totalPage = total % rq.getRecord() > 0 ? (total/rq.getRecord()) + 1 : total/rq.getRecord(); |
|
|
|
response.setItems(result.getContent()); |
|
|
|
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; |
|
|
|
} |
|
|
|
} |
|
|
|