Browse Source

비행계획서 유효성검사 ( 필터에 조회된 데이터가 두개 이상일 시 작동하지 않는 오류 있음.)

feature/auth
박재우 2 years ago
parent
commit
b61a771f3a
  1. 3
      src/main/java/com/palnet/biz/api/bas/flight/model/BasFlightPlanAreaCoordRq.java
  2. 79
      src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java
  3. 116
      src/main/java/com/palnet/biz/jpa/repository/flt/FltPlanQueryRepository.java

3
src/main/java/com/palnet/biz/api/bas/flight/model/BasFlightPlanAreaCoordRq.java

@ -8,8 +8,7 @@ import lombok.Data;
public class BasFlightPlanAreaCoordRq { public class BasFlightPlanAreaCoordRq {
private Integer planAreaSno; private Integer planAreaSno;
private Integer bufferZone; private Integer bufferZone;
private double lat;
private double lon;
private String areaType; private String areaType;
private String idntfNum;
private Integer cnt; private Integer cnt;
} }

79
src/main/java/com/palnet/biz/api/bas/flight/service/BasFlightService.java

@ -113,7 +113,8 @@ public class BasFlightService {
public void planValid(BasFlightPlanModel rq) { public void planValid(BasFlightPlanModel rq) {
List<BasFlightPlanModel> effectivePlanList = fltPlanQueryRepository.CoordCheck(rq); List<BasFlightPlanModel> effectivePlanList = fltPlanQueryRepository.CoordCheck(rq);
List<BasFlightPlanAreaCoordRq> effectivePlanCount = fltPlanQueryRepository.CoordCount(rq);
int accuCnt = 0;
if(effectivePlanList != null && !effectivePlanList.isEmpty()) { if(effectivePlanList != null && !effectivePlanList.isEmpty()) {
for(BasFlightPlanModel plan : effectivePlanList) { for(BasFlightPlanModel plan : effectivePlanList) {
// 1. 구역 조회 // 1. 구역 조회
@ -121,30 +122,70 @@ public class BasFlightService {
// 2. 좌표 조회 -> 영역 포함 여부 확인 // 2. 좌표 조회 -> 영역 포함 여부 확인
for(FltPlanArea area : areaList) { for(FltPlanArea area : areaList) {
List<FltPlanAreaCoord> coordList = fltPlanAreaCoordRepository.findByPlanAreaSnoOrderByPlanAreaCoordSnoAsc(area.getPlanAreaSno()); List<FltPlanAreaCoord> coordLists = fltPlanAreaCoordRepository.findByPlanAreaSnoOrderByPlanAreaCoordSnoAsc(area.getPlanAreaSno());
if(coordList != null && !coordList.isEmpty()) { if(coordLists != null && !coordLists.isEmpty()) {
List<BasFlightPlanAreaCoordModel> coordListMapping = BasFlightMapper.mapper.entityToModelCoordList(coordList); List<BasFlightPlanAreaCoordModel> coordListMapping = BasFlightMapper.mapper.entityToModelCoordList(coordLists);
// 2-1 영역 좌표 -> jts model로 mapping // 2-1 영역 좌표 -> jts model로 mapping
List<Coordinate> effectiveCoordList = areaUtils.convertCoordinates(coordListMapping); List<Coordinate> effectiveCoordList = areaUtils.convertCoordinates(coordListMapping);
List<Coordinate> coordList = new ArrayList<>();
List<Coordinate> bufferCoordList = new ArrayList<>();
List<Coordinate> effectiveCntCoordList = new ArrayList<>();
// 유효한 비행구역 검증하기. // 유효한 비행구역 검증하기.
for(BasFlightPlanAreaModel rqArea : rq.getAreaList()) { for(BasFlightPlanAreaModel rqArea : rq.getAreaList()) {
boolean checking = false; boolean checkContains = false;
if("LINE".equals(rqArea.getAreaType()) || "POLYGON".equals(rqArea.getAreaType())) { boolean checkOverlaps = false;
for(BasFlightPlanAreaCoordModel coord : rqArea.getCoordList()) {
for(BasFlightPlanAreaCoordModel coord : rqArea.getCoordList()) { Coordinate coords = new Coordinate(coord.getLon(), coord.getLat());
Coordinate targetCoord = new Coordinate(coord.getLon(), coord.getLat()); coordList.add(coords);
checking = areaUtils.contains(effectiveCoordList, targetCoord); }
if("LINE".equals(rqArea.getAreaType())) {
List<Coordinate> transCoordList = areaUtils.transform(coordList, "EPSG:4326", "EPSG:5181");
List<Coordinate> bufferList = areaUtils.buffer(transCoordList, rqArea.getBufferZone()); // buffer 영역 생성
bufferCoordList = areaUtils.transform(bufferList, "EPSG:5181", "EPSG:4326"); // buffer 영역 좌표계 변환
bufferCoordList.add(bufferCoordList.get(0));
}
if("POLYGON".equals(rqArea.getAreaType())) {
for(Coordinate coord : coordList) {
Coordinate targetCoord = new Coordinate(coord.x, coord.y);
bufferCoordList.add(targetCoord);
} }
} }
if("CIRCLE".equals(rqArea.getAreaType())) { if("CIRCLE".equals(rqArea.getAreaType())) {
checking = areaUtils.overlaps(areaUtils.convertCoordinates(rqArea.getCoordList()), effectiveCoordList); bufferCoordList = areaUtils.createCircle(coordList.get(0), rqArea.getBufferZone());
} }
bufferCoordList.add(bufferCoordList.get(0));
if(checking) { for(int i = 0; i < areaList.size(); i++) {
System.out.println(areaList.size() + "," + coordLists.size());
List<Coordinate> effectiveBufferCoordList = new ArrayList<>();
for(int j = 0 ; j < coordLists.size(); j++) {
Double lon = effectiveCoordList.get(accuCnt).getX();
Double lat = effectiveCoordList.get(accuCnt).getY();
Coordinate coord = new Coordinate(lon , lat);
effectiveCntCoordList.add(coord);
accuCnt++;
}
if("LINE".equals(effectivePlanCount.get(i).getAreaType())){
List<Coordinate> transCoordList = areaUtils.transform(effectiveCntCoordList, "EPSG:4326", "EPSG:5181");
List<Coordinate> bufferList = areaUtils.buffer(transCoordList, effectivePlanCount.get(i).getBufferZone()); // buffer 영역 생성
effectiveCntCoordList = areaUtils.transform(bufferList, "EPSG:5181", "EPSG:4326"); // buffer 영역 좌표계 변환
effectiveBufferCoordList.addAll(effectiveCntCoordList);
}
if("POLYGON".equals(effectivePlanCount.get(i).getAreaType())) {
effectiveBufferCoordList.addAll(effectiveCntCoordList);
effectiveBufferCoordList.add(effectiveBufferCoordList.get(0));
}
if("CIRCLE".equals(effectivePlanCount.get(i).getAreaType())) {
effectiveBufferCoordList = areaUtils.createCircle(effectiveCntCoordList.get(0), effectivePlanCount.get(i).getBufferZone());
}
for(Coordinate coord : effectiveBufferCoordList) {
checkContains = areaUtils.contains(bufferCoordList, coord);
}
effectiveBufferCoordList.add(effectiveBufferCoordList.get(0));
checkOverlaps = FlightUtils.overlaps((bufferCoordList.toArray(new Coordinate[]{})),(effectiveBufferCoordList.toArray(new Coordinate[]{})));
}
if(checkContains || checkOverlaps) {
throw new CustomException(ErrorCode.PLAN_DATA_DUPLICATE); throw new CustomException(ErrorCode.PLAN_DATA_DUPLICATE);
} }
} }
@ -152,7 +193,13 @@ public class BasFlightService {
} }
// 3. 중복 기체 확인 // 3. 중복 기체 확인
for(BasFlightPlanAreaCoordRq idntfNum : effectivePlanCount) {
for(BasFlightPlanArcrftModel rqArcrft : rq.getArcrftList()) {
if(rqArcrft.getIdntfNum().equals(idntfNum.getIdntfNum())) {
throw new CustomException(ErrorCode.ARCRFT_DATA_DUPLICATE);
}
}
}
} }
} }
} }

116
src/main/java/com/palnet/biz/jpa/repository/flt/FltPlanQueryRepository.java

@ -102,12 +102,12 @@ public class FltPlanQueryRepository {
} }
//동일 기체 등록시 비행시간 중복여부 조회 //동일 기체 등록시 비행시간 중복여부 조회
public List<BasFlightPlanModel> arcrftCheck(BasFlightPlanModel rq, String idntfNum){ public List<BasFlightPlanModel> arcrftCheck(BasFlightPlanModel rq, String idntfNum){
QFltPlanArcrft arcrft = QFltPlanArcrft.fltPlanArcrft; QFltPlanArcrft arcrft = QFltPlanArcrft.fltPlanArcrft;
QFltPlanBas bas = QFltPlanBas.fltPlanBas; QFltPlanBas bas = QFltPlanBas.fltPlanBas;
List<BasFlightPlanModel> list = query List<BasFlightPlanModel> list = query
.select(Projections.bean( .select(Projections.bean(
BasFlightPlanModel.class, BasFlightPlanModel.class,
bas.schFltStDt, bas.schFltStDt,
bas.schFltEndDt, bas.schFltEndDt,
bas.delYn bas.delYn
@ -116,28 +116,27 @@ public class FltPlanQueryRepository {
.leftJoin(arcrft) .leftJoin(arcrft)
.on(bas.planSno.eq(arcrft.planSno)) .on(bas.planSno.eq(arcrft.planSno))
.where(arcrft.idntfNum.eq(idntfNum) .where(arcrft.idntfNum.eq(idntfNum)
.and(((bas.schFltStDt.loe(rq.getSchFltStDt())) .and(((bas.schFltStDt.loe(rq.getSchFltStDt()))
.and(bas.schFltEndDt.goe(rq.getSchFltEndDt()))) .and(bas.schFltEndDt.goe(rq.getSchFltEndDt())))
.or((bas.schFltStDt.goe(rq.getSchFltStDt())) .or((bas.schFltStDt.goe(rq.getSchFltStDt()))
.and((bas.schFltStDt.loe(rq.getSchFltEndDt())) .and((bas.schFltStDt.loe(rq.getSchFltEndDt()))
.and(bas.schFltEndDt.goe(rq.getSchFltEndDt())))) .and(bas.schFltEndDt.goe(rq.getSchFltEndDt()))))
.or(((bas.schFltStDt.loe(rq.getSchFltStDt())) .or(((bas.schFltStDt.loe(rq.getSchFltStDt()))
.and(bas.schFltEndDt.goe(rq.getSchFltStDt()))) .and(bas.schFltEndDt.goe(rq.getSchFltStDt())))
.and(bas.schFltEndDt.loe(rq.getSchFltEndDt()))) .and(bas.schFltEndDt.loe(rq.getSchFltEndDt())))
.or((bas.schFltStDt.goe(rq.getSchFltStDt())) .or((bas.schFltStDt.goe(rq.getSchFltStDt()))
.and(bas.schFltEndDt.loe(rq.getSchFltEndDt())))) .and(bas.schFltEndDt.loe(rq.getSchFltEndDt()))))
.and(bas.delYn.eq("N"))) .and(bas.delYn.eq("N")))
.fetch(); .fetch();
return list; return list;
} }
// 비행계획구역 설정시 같은 시간대에 구역이 중복되는지 조회 // 비행계획구역 설정시 같은 시간대에 구역이 중복되는지 조회
public List<BasFlightPlanModel> CoordCheck(BasFlightPlanModel rq){ public List<BasFlightPlanModel> CoordCheck(BasFlightPlanModel rq){
QFltPlanArea area = QFltPlanArea.fltPlanArea; QFltPlanArea area = QFltPlanArea.fltPlanArea;
QFltPlanAreaCoord coord = QFltPlanAreaCoord.fltPlanAreaCoord; QFltPlanAreaCoord coord = QFltPlanAreaCoord.fltPlanAreaCoord;
QFltPlanBas bas = QFltPlanBas.fltPlanBas; QFltPlanBas bas = QFltPlanBas.fltPlanBas;
List<BasFlightPlanModel> list = query
List<BasFlightPlanModel> list = query
.select(Projections.bean( .select(Projections.bean(
BasFlightPlanModel.class, BasFlightPlanModel.class,
bas.planSno, bas.planSno,
@ -159,58 +158,61 @@ public class FltPlanQueryRepository {
bas.createDt, bas.createDt,
bas.updateUserId, bas.updateUserId,
bas.updateDt bas.updateDt
)) ))
.from(bas) .from(bas)
.where((((bas.schFltStDt.loe(rq.getSchFltStDt())) .where((((bas.schFltStDt.loe(rq.getSchFltStDt()))
.and(bas.schFltEndDt.goe(rq.getSchFltEndDt()))) .and(bas.schFltEndDt.goe(rq.getSchFltEndDt())))
.or((bas.schFltStDt.goe(rq.getSchFltStDt())) .or((bas.schFltStDt.goe(rq.getSchFltStDt()))
.and((bas.schFltStDt.loe(rq.getSchFltEndDt())) .and((bas.schFltStDt.loe(rq.getSchFltEndDt()))
.and(bas.schFltEndDt.goe(rq.getSchFltEndDt())))) .and(bas.schFltEndDt.goe(rq.getSchFltEndDt()))))
.or(((bas.schFltStDt.loe(rq.getSchFltStDt())) .or(((bas.schFltStDt.loe(rq.getSchFltStDt()))
.and(bas.schFltEndDt.goe(rq.getSchFltStDt()))) .and(bas.schFltEndDt.goe(rq.getSchFltStDt())))
.and(bas.schFltEndDt.loe(rq.getSchFltEndDt()))) .and(bas.schFltEndDt.loe(rq.getSchFltEndDt())))
.or((bas.schFltStDt.goe(rq.getSchFltStDt())) .or((bas.schFltStDt.goe(rq.getSchFltStDt()))
.and(bas.schFltEndDt.loe(rq.getSchFltEndDt())))) .and(bas.schFltEndDt.loe(rq.getSchFltEndDt()))))
.and(bas.delYn.eq("N"))) .and(bas.delYn.eq("N")))
.fetch(); .fetch();
return list; return list;
} }
//CoordCheck에 들어갈 count //CoordCheck에 들어갈 count
public List<BasFlightPlanAreaCoordRq> CoordCount(BasFlightPlanModel rq){ public List<BasFlightPlanAreaCoordRq> CoordCount(BasFlightPlanModel rq){
QFltPlanArea area = QFltPlanArea.fltPlanArea; QFltPlanArea area = QFltPlanArea.fltPlanArea;
QFltPlanAreaCoord coord = QFltPlanAreaCoord.fltPlanAreaCoord; QFltPlanAreaCoord coord = QFltPlanAreaCoord.fltPlanAreaCoord;
QFltPlanBas bas = QFltPlanBas.fltPlanBas; QFltPlanBas bas = QFltPlanBas.fltPlanBas;
QFltPlanArcrft arcrft = QFltPlanArcrft.fltPlanArcrft;
List<BasFlightPlanAreaCoordRq> list = query List<BasFlightPlanAreaCoordRq> list = query
.select(Projections.bean( .select(Projections.bean(
BasFlightPlanAreaCoordRq.class, BasFlightPlanAreaCoordRq.class,
coord.lon,
coord.lat,
area.bufferZone, area.bufferZone,
area.areaType, area.areaType,
area.planAreaSno.count().intValue().as("cnt") area.planAreaSno.count().intValue().as("cnt"),
arcrft.idntfNum
)) ))
.from(bas) .from(bas)
.leftJoin(area) .leftJoin(area)
.on(bas.planSno.eq(area.planSno)) .on(bas.planSno.eq(area.planSno))
.leftJoin(arcrft)
.on(area.planSno.eq(arcrft.planSno))
.leftJoin(coord) .leftJoin(coord)
.on(area.planAreaSno.eq(coord.planAreaSno)) .on(area.planAreaSno.eq(coord.planAreaSno))
.where((((bas.schFltStDt.loe(rq.getSchFltStDt())) .where((((bas.schFltStDt.loe(rq.getSchFltStDt()))
.and(bas.schFltEndDt.goe(rq.getSchFltEndDt()))) .and(bas.schFltEndDt.goe(rq.getSchFltEndDt())))
.or((bas.schFltStDt.goe(rq.getSchFltStDt())) .or((bas.schFltStDt.goe(rq.getSchFltStDt()))
.and((bas.schFltStDt.loe(rq.getSchFltEndDt())) .and((bas.schFltStDt.loe(rq.getSchFltEndDt()))
.and(bas.schFltEndDt.goe(rq.getSchFltEndDt())))) .and(bas.schFltEndDt.goe(rq.getSchFltEndDt()))))
.or(((bas.schFltStDt.loe(rq.getSchFltStDt())) .or(((bas.schFltStDt.loe(rq.getSchFltStDt()))
.and(bas.schFltEndDt.goe(rq.getSchFltStDt()))) .and(bas.schFltEndDt.goe(rq.getSchFltStDt())))
.and(bas.schFltEndDt.loe(rq.getSchFltEndDt()))) .and(bas.schFltEndDt.loe(rq.getSchFltEndDt())))
.or((bas.schFltStDt.goe(rq.getSchFltStDt())) .or((bas.schFltStDt.goe(rq.getSchFltStDt()))
.and(bas.schFltEndDt.loe(rq.getSchFltEndDt())))) .and(bas.schFltEndDt.loe(rq.getSchFltEndDt()))))
.and(bas.delYn.eq("N")) .and(bas.delYn.eq("N"))
.and(((coord.lon.goe(0.1)) .and(((coord.lon.goe(0.1))
.and(coord.lat.goe(0.1))))) .and(coord.lat.goe(0.1)))))
.groupBy(area.planAreaSno) .groupBy(area.planAreaSno)
.fetch(); .fetch();
return list; return list;
} }
// 조종사 조회 // 조종사 조회
public List<BasFlightPlanPilotModel> listPilot(String groupId) { public List<BasFlightPlanPilotModel> listPilot(String groupId) {
@ -348,4 +350,4 @@ public class FltPlanQueryRepository {
return r; return r;
} }
} }
Loading…
Cancel
Save