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. 110
      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 {
private Integer planAreaSno;
private Integer bufferZone;
private double lat;
private double lon;
private String areaType;
private String idntfNum;
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) {
List<BasFlightPlanModel> effectivePlanList = fltPlanQueryRepository.CoordCheck(rq);
List<BasFlightPlanAreaCoordRq> effectivePlanCount = fltPlanQueryRepository.CoordCount(rq);
int accuCnt = 0;
if(effectivePlanList != null && !effectivePlanList.isEmpty()) {
for(BasFlightPlanModel plan : effectivePlanList) {
// 1. 구역 조회
@ -121,30 +122,70 @@ public class BasFlightService {
// 2. 좌표 조회 -> 영역 포함 여부 확인
for(FltPlanArea area : areaList) {
List<FltPlanAreaCoord> coordList = fltPlanAreaCoordRepository.findByPlanAreaSnoOrderByPlanAreaCoordSnoAsc(area.getPlanAreaSno());
List<FltPlanAreaCoord> coordLists = fltPlanAreaCoordRepository.findByPlanAreaSnoOrderByPlanAreaCoordSnoAsc(area.getPlanAreaSno());
if(coordList != null && !coordList.isEmpty()) {
List<BasFlightPlanAreaCoordModel> coordListMapping = BasFlightMapper.mapper.entityToModelCoordList(coordList);
if(coordLists != null && !coordLists.isEmpty()) {
List<BasFlightPlanAreaCoordModel> coordListMapping = BasFlightMapper.mapper.entityToModelCoordList(coordLists);
// 2-1 영역 좌표 -> jts model로 mapping
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()) {
boolean checking = false;
if("LINE".equals(rqArea.getAreaType()) || "POLYGON".equals(rqArea.getAreaType())) {
for(BasFlightPlanAreaCoordModel coord : rqArea.getCoordList()) {
Coordinate targetCoord = new Coordinate(coord.getLon(), coord.getLat());
checking = areaUtils.contains(effectiveCoordList, targetCoord);
boolean checkContains = false;
boolean checkOverlaps = false;
for(BasFlightPlanAreaCoordModel coord : rqArea.getCoordList()) {
Coordinate coords = new Coordinate(coord.getLon(), coord.getLat());
coordList.add(coords);
}
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())) {
checking = areaUtils.overlaps(areaUtils.convertCoordinates(rqArea.getCoordList()), effectiveCoordList);
bufferCoordList = areaUtils.createCircle(coordList.get(0), rqArea.getBufferZone());
}
if(checking) {
bufferCoordList.add(bufferCoordList.get(0));
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);
}
}
@ -152,7 +193,13 @@ public class BasFlightService {
}
// 3. 중복 기체 확인
for(BasFlightPlanAreaCoordRq idntfNum : effectivePlanCount) {
for(BasFlightPlanArcrftModel rqArcrft : rq.getArcrftList()) {
if(rqArcrft.getIdntfNum().equals(idntfNum.getIdntfNum())) {
throw new CustomException(ErrorCode.ARCRFT_DATA_DUPLICATE);
}
}
}
}
}
}

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

Loading…
Cancel
Save