Browse Source

control-id 발급로직 caching 데이터 활용 롤백

feature/auth
노승철 2 years ago
parent
commit
db6eb9ea47
  1. 82
      src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java

82
src/main/java/com/palnet/biz/api/ctr/cntrl/service/CtrCntrlService.java

@ -383,63 +383,45 @@ public class CtrCntrlService {
public Map<String, String> getId(String id, Double lat, Double lon) {
Map<String, String> result = new HashMap<>();
/**
* Caching 되어 있는 식별 번호 확인
*/
String cacheControlId = shareContext.getIndtfKey(id);
if(cacheControlId == null) {
/* 식별번호의 가장 최근 이력 불러오기 */
CtrCntrlBas latestControl = cntrlBasRepository.findFirstByIdntfNumOrderByCreateDtDesc(id).orElse(null);
boolean isControl = false;
if(latestControl != null) {
CtrCntrlHstry latestHistory = cntrlHstryRepository.findFirstByCntrlIdOrderBySrvrRcvDtDesc(latestControl.getCntrlId()).orElse(null);
if(latestHistory != null) {
long diffMinute = DateUtils.diffMinute(latestHistory.getSrvrRcvDt(), new Date());
log.info("DIFF MINUTE : {}", diffMinute);
if("01".equals(latestControl.getEndTypeCd()) || diffMinute > 5) {
isControl = false;
}
if(!"01".equals(latestControl.getEndTypeCd()) && diffMinute < 5) {
isControl = true;
}
} else {
isControl = false;
}
} else {
isControl = false;
}
if(isControl) {
result.put("controlId", latestControl.getCntrlId());
result.put("typeCd", "02");
result.put("areaTrnsYn", "E");
} else {
String controlID = UUID.randomUUID().toString();
result.put("controlId", controlID);
result.put("typeCd", "01");
result.put("areaTrnsYn", "N");
// 기체 식별번호의 관제 ID 저장
// 기체 식별번호의 관제 ID 저장 (single ton)
shareContext.putIdntfKey(id, controlID);
/* 식별번호의 가장 최근 이력 불러오기 */
// CtrCntrlBas latestControl = cntrlBasRepository.findFirstByIdntfNumOrderByCreateDtDesc(id).orElse(null);
//
// boolean isControl = false;
//
// if(latestControl != null) {
// CtrCntrlHstry latestHistory = cntrlHstryRepository.findFirstByCntrlIdOrderBySrvrRcvDtDesc(latestControl.getCntrlId()).orElse(null);
//
// if(latestHistory != null) {
// long diffMinute = DateUtils.diffMinute(latestHistory.getSrvrRcvDt(), new Date());
// log.info("DIFF MINUTE : {}", diffMinute);
//
// if("01".equals(latestControl.getEndTypeCd()) || diffMinute > 5) {
// isControl = false;
// }
// if(!"01".equals(latestControl.getEndTypeCd()) && diffMinute < 5) {
// isControl = true;
// }
// } else {
// isControl = false;
// }
//
// } else {
// isControl = false;
// }
//
// if(isControl) {
// result.put("controlId", latestControl.getCntrlId());
// result.put("typeCd", "02");
// result.put("areaTrnsYn", "E");
// } else {
// String controlID = UUID.randomUUID().toString();
// result.put("controlId", controlID);
// result.put("typeCd", "01");
// result.put("areaTrnsYn", "N");
//
// // 기체 식별번호의 관제 ID 저장 (single ton)
// shareContext.putIdntfKey(id, controlID);
// }
} else {
result.put("controlId", cacheControlId);
result.put("typeCd", "02");
result.put("areaTrnsYn", "E");
}
List<BasFlightPlanModel> planList = this.getFlightPlan(id);

Loading…
Cancel
Save