diff --git a/pav-server/src/main/java/com/palnet/biz/api/bas/laanc/service/BasLaancService.java b/pav-server/src/main/java/com/palnet/biz/api/bas/laanc/service/BasLaancService.java index 73ec6216..3a642b7e 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/bas/laanc/service/BasLaancService.java +++ b/pav-server/src/main/java/com/palnet/biz/api/bas/laanc/service/BasLaancService.java @@ -216,7 +216,7 @@ public class BasLaancService { corpRegYn = isCorpReg ? "Y" : "N"; } fltPlanBas.setCorpRegYn(corpRegYn); // 사업자유무 - fltPlanBas.setServiceType("PAV-KAC"); + fltPlanBas.setServiceType("F0002"); FltPlanBas rBasEntity = fltPlanBasRepository.save(fltPlanBas); Integer planSno = rBasEntity.getPlanSno(); diff --git a/pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java b/pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java index dfe6bae3..36d6b462 100644 --- a/pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java +++ b/pav-server/src/main/java/com/palnet/biz/api/main/dash/service/MainDashService.java @@ -23,6 +23,7 @@ import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import java.time.Instant; +import java.time.ZoneId; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.util.HashMap; @@ -399,38 +400,39 @@ public class MainDashService { return result; } - public List dailyFlightNumOfStcs(){ - - // SUPER 권한일 경우와 KAC의 기관코드일 경우 전체적으로 모니터링 가능해야한다. 그외는 자신의 기관에 해당하는 데이터 볼 수 있어야 한다. - String userAuthByToken = token.getUserAuthByToken(); - String cptAuthCodeByToken = token.getCptAuthCodeByToken(); - String serviceType = ""; - if(!"SUPER".equals(userAuthByToken) && !"KAC".equals(cptAuthCodeByToken)){ - serviceType = cptAuthCodeByToken; - } - - // 1. 전일 , 금일, 명일(내일) - Instant yesterdayStart = Instant.now().minus(1, ChronoUnit.DAYS).truncatedTo(ChronoUnit.DAYS); - Instant yesterdayEnd = Instant.now().truncatedTo(ChronoUnit.DAYS); - Instant todayStart = Instant.now().truncatedTo(ChronoUnit.DAYS); - Instant todayEnd = Instant.now().plus(1, ChronoUnit.DAYS).truncatedTo(ChronoUnit.DAYS); - Instant tomorrowStart = Instant.now().plus(1, ChronoUnit.DAYS).truncatedTo(ChronoUnit.DAYS); - Instant tomorrowEnd = Instant.now().plus(2, ChronoUnit.DAYS).truncatedTo(ChronoUnit.DAYS); - Instant tomorrowEnd2 = Instant.now().plus(2, ChronoUnit.DAYS).minus(1, ChronoUnit.SECONDS); - - // 2. 비행계획서 승인 항목 : 비행계획서 제출기준(승인된 건수로봐도 동일) - int yesterdayCount = 0; - int todayCount = 0; - int tomorrowCount = 0; - if(serviceType != null && !serviceType.isEmpty()){ - yesterdayCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqualAndServiceType("Y", yesterdayEnd, yesterdayStart, serviceType); - todayCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqualAndServiceType("Y", todayEnd, todayStart, serviceType); - tomorrowCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqualAndServiceType("Y", tomorrowEnd, tomorrowStart, serviceType); - } else { - yesterdayCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqual("Y", yesterdayEnd, yesterdayStart); - todayCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqual("Y", todayEnd, todayStart); - tomorrowCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqual("Y", tomorrowEnd, tomorrowStart); - } + public List dailyFlightNumOfStcs() { + + // SUPER 권한일 경우와 KAC의 기관코드일 경우 전체적으로 모니터링 가능해야한다. 그외는 자신의 기관에 해당하는 데이터 볼 수 있어야 한다. + String userAuthByToken = token.getUserAuthByToken(); + String cptAuthCodeByToken = token.getCptAuthCodeByToken(); + String serviceType = ""; + if (!"SUPER".equals(userAuthByToken) && !"KAC".equals(cptAuthCodeByToken)) { + serviceType = cptAuthCodeByToken; + } + + // 1. 전일 , 금일, 명일(내일) +// ZoneId zoneId = ZoneId.systemDefault(); + ZoneId zoneId = ZoneId.of("Asia/Seoul"); + Instant yesterdayStart = Instant.now().atZone(zoneId).minusDays(1).truncatedTo(ChronoUnit.DAYS).toInstant(); + Instant yesterdayEnd = Instant.now().atZone(zoneId).truncatedTo(ChronoUnit.DAYS).toInstant(); + Instant todayStart = Instant.now().atZone(zoneId).truncatedTo(ChronoUnit.DAYS).toInstant(); + Instant todayEnd = Instant.now().atZone(zoneId).plusDays(1).truncatedTo(ChronoUnit.DAYS).toInstant(); + Instant tomorrowStart = Instant.now().atZone(zoneId).plusDays(1).truncatedTo(ChronoUnit.DAYS).toInstant(); + Instant tomorrowEnd = Instant.now().atZone(zoneId).plusDays(2).truncatedTo(ChronoUnit.DAYS).toInstant(); + + // 2. 비행계획서 승인 항목 : 비행계획서 제출기준(승인된 건수로봐도 동일) + int yesterdayCount = 0; + int todayCount = 0; + int tomorrowCount = 0; + if (serviceType != null && !serviceType.isEmpty()) { + yesterdayCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqualAndServiceType("Y", yesterdayEnd, yesterdayStart, serviceType); + todayCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqualAndServiceType("Y", todayEnd, todayStart, serviceType); + tomorrowCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqualAndServiceType("Y", tomorrowEnd, tomorrowStart, serviceType); + } else { + yesterdayCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqual("Y", yesterdayEnd, yesterdayStart); + todayCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqual("Y", todayEnd, todayStart); + tomorrowCount = fltPlanBasRepository.countByAprvlYnAndSchFltStDtLessThanAndSchFltEndDtGreaterThanEqual("Y", tomorrowEnd, tomorrowStart); + } // int yesterdayCount = serviceType != null && !serviceType.isEmpty() // ? fltPlanBasRepository.countByAprvlYnAndAprvlDtBetweenAndServiceType("Y", yesterdayStart, yesterdayEnd, serviceType); // : fltPlanBasRepository.countByAprvlYnAndAprvlDtBetween("Y", yesterdayStart, yesterdayEnd) @@ -441,32 +443,32 @@ public class MainDashService { // ? fltPlanBasRepository.countByAprvlYnAndAprvlDtBetweenAndServiceType("Y", tomorrowStart, tomorrowEnd, serviceType); // : fltPlanBasRepository.countByAprvlYnAndAprvlDtBetween("Y", tomorrowStart, tomorrowEnd) - // 3. 비행 완료 항목 : 실제 비행이 완료된 건수 - int yesterdayCompleteCount = query.completeFlight(yesterdayStart,yesterdayEnd,serviceType).size(); - int todayCompleteCount = query.completeFlight(todayStart,todayEnd,serviceType).size(); - int tomorrowCompleteCount = query.completeFlight(tomorrowStart,tomorrowEnd,serviceType).size(); - - // 4. 미 비행 항목 : 비행계획서는 제출했으나,실제 비행안한 건수 - int yesterdayNotFlight = query.notFlight(yesterdayStart,yesterdayEnd, serviceType).size(); - int todayNotFlight = query.notFlight(todayStart, todayEnd, serviceType).size(); - int tomorrowNotFlight = query.notFlight(tomorrowStart,tomorrowEnd, serviceType).size(); - - // 5. 비고 : 비행 완료 건수를 기준으로 상승 또는 하락폭 적용 - // ex) 오늘 기준 오늘은 어제의 비행 완료 건수를 비교해서 적용 - // 전일(어제)은 2일전 비행 완료 건수를 비교해서 적용 - // 명일(내일)은 오늘 비행 완료 건수를 비교해서 적용 - int yesterdayNote = yesterdayCompleteCount - query.completeFlight(yesterdayStart.minus(1, ChronoUnit.DAYS), yesterdayEnd.minus(1, ChronoUnit.DAYS), serviceType).size(); - double yesterdayNotePercent = yesterdayCompleteCount != 0 ? ((double) yesterdayNote / yesterdayCompleteCount) * 100.0 : 0.0; - double todayNotePercent = yesterdayCompleteCount != 0 ? ((double)(todayCompleteCount - yesterdayCompleteCount) / yesterdayCompleteCount) * 100.0 : 0.0; - double tomorrowNotePercent = todayCompleteCount != 0 ? ((double) (tomorrowCompleteCount - todayCompleteCount) / todayCompleteCount) * 100.0 : 0.0; - - List result = new ArrayList<>(); - result.add(createModel("yesterday", yesterdayCount,yesterdayCompleteCount,yesterdayNotFlight,yesterdayNotePercent)); - result.add(createModel("today", todayCount,todayCompleteCount,todayNotFlight,todayNotePercent)); - result.add(createModel("tomorrow", tomorrowCount,tomorrowCompleteCount,tomorrowNotFlight,tomorrowNotePercent)); - - return result; - } + // 3. 비행 완료 항목 : 실제 비행이 완료된 건수 + int yesterdayCompleteCount = query.completeFlight(yesterdayStart, yesterdayEnd, serviceType).size(); + int todayCompleteCount = query.completeFlight(todayStart, todayEnd, serviceType).size(); + int tomorrowCompleteCount = query.completeFlight(tomorrowStart, tomorrowEnd, serviceType).size(); + + // 4. 미 비행 항목 : 비행계획서는 제출했으나,실제 비행안한 건수 + int yesterdayNotFlight = query.notFlight(yesterdayStart, yesterdayEnd, serviceType).size(); + int todayNotFlight = query.notFlight(todayStart, todayEnd, serviceType).size(); + int tomorrowNotFlight = query.notFlight(tomorrowStart, tomorrowEnd, serviceType).size(); + + // 5. 비고 : 비행 완료 건수를 기준으로 상승 또는 하락폭 적용 + // ex) 오늘 기준 오늘은 어제의 비행 완료 건수를 비교해서 적용 + // 전일(어제)은 2일전 비행 완료 건수를 비교해서 적용 + // 명일(내일)은 오늘 비행 완료 건수를 비교해서 적용 + int yesterdayNote = yesterdayCompleteCount - query.completeFlight(yesterdayStart.minus(1, ChronoUnit.DAYS), yesterdayEnd.minus(1, ChronoUnit.DAYS), serviceType).size(); + double yesterdayNotePercent = yesterdayCompleteCount != 0 ? ((double) yesterdayNote / yesterdayCompleteCount) * 100.0 : 0.0; + double todayNotePercent = yesterdayCompleteCount != 0 ? ((double) (todayCompleteCount - yesterdayCompleteCount) / yesterdayCompleteCount) * 100.0 : 0.0; + double tomorrowNotePercent = todayCompleteCount != 0 ? ((double) (tomorrowCompleteCount - todayCompleteCount) / todayCompleteCount) * 100.0 : 0.0; + + List result = new ArrayList<>(); + result.add(createModel("yesterday", yesterdayCount, yesterdayCompleteCount, yesterdayNotFlight, yesterdayNotePercent)); + result.add(createModel("today", todayCount, todayCompleteCount, todayNotFlight, todayNotePercent)); + result.add(createModel("tomorrow", tomorrowCount, tomorrowCompleteCount, tomorrowNotFlight, tomorrowNotePercent)); + + return result; + } private MainDashFlightNumStcsModel createModel(String dateType, int flightPlanCount, int completeCount, int notFlight, double note) { MainDashFlightNumStcsModel model = new MainDashFlightNumStcsModel();