feat: fix
This commit is contained in:
@@ -2,7 +2,10 @@ package com.kamco.cd.kamcoback.code;
|
||||
|
||||
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
|
||||
import com.kamco.cd.kamcoback.code.service.CommonCodeService;
|
||||
import com.kamco.cd.kamcoback.common.enums.DetectionClassification;
|
||||
import com.kamco.cd.kamcoback.config.api.ApiResponseDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Clazzes;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
@@ -10,6 +13,8 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
@@ -206,4 +211,16 @@ public class CommonCodeApiController {
|
||||
String code) {
|
||||
return ApiResponseDto.ok(commonCodeService.findByCode(code));
|
||||
}
|
||||
|
||||
@GetMapping("/clazz")
|
||||
public ApiResponseDto<List<InferenceResultDto.Clazzes>> getClasses() {
|
||||
|
||||
List<Clazzes> list =
|
||||
Arrays.stream(DetectionClassification.values())
|
||||
.sorted(Comparator.comparingInt(DetectionClassification::getOrder))
|
||||
.map(Clazzes::new)
|
||||
.toList();
|
||||
|
||||
return ApiResponseDto.ok(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,24 +6,25 @@ import lombok.Getter;
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum DetectionClassification {
|
||||
BUILDING("building", "건물"),
|
||||
CONTAINER("container", "컨테이너"),
|
||||
FIELD("field", "경작지"),
|
||||
FOREST("forest", "숲"),
|
||||
GRASS("grass", "초지"),
|
||||
GREENHOUSE("greenhouse", "비닐하우스"),
|
||||
LAND("land", "일반토지"),
|
||||
ORCHARD("orchard", "과수원"),
|
||||
ROAD("road", "도로"),
|
||||
STONE("stone", "모래/자갈"),
|
||||
TANK("tank", "물탱크"),
|
||||
TUMULUS("tumulus", "토분(무덤)"),
|
||||
WASTE("waste", "폐기물"),
|
||||
WATER("water", "물"),
|
||||
ETC("ETC", "기타"); // For 'etc' (miscellaneous/other)
|
||||
BUILDING("building", "건물", 10),
|
||||
CONTAINER("container", "컨테이너", 20),
|
||||
FIELD("field", "경작지", 30),
|
||||
FOREST("forest", "숲", 40),
|
||||
GRASS("grass", "초지", 50),
|
||||
GREENHOUSE("greenhouse", "비닐하우스", 60),
|
||||
LAND("land", "일반토지", 70),
|
||||
ORCHARD("orchard", "과수원", 80),
|
||||
ROAD("road", "도로", 90),
|
||||
STONE("stone", "모래/자갈", 100),
|
||||
TANK("tank", "물탱크", 110),
|
||||
TUMULUS("tumulus", "토분(무덤)", 120),
|
||||
WASTE("waste", "폐기물", 130),
|
||||
WATER("water", "물", 140),
|
||||
ETC("ETC", "기타", 200); // For 'etc' (miscellaneous/other)
|
||||
|
||||
private final String id;
|
||||
private final String desc;
|
||||
private final int order;
|
||||
|
||||
/**
|
||||
* Optional: Helper method to get the enum from a String, case-insensitive, or return ETC if not
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package com.kamco.cd.kamcoback.inference.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.kamco.cd.kamcoback.common.enums.DetectionClassification;
|
||||
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -178,12 +180,45 @@ public class InferenceResultDto {
|
||||
@AllArgsConstructor
|
||||
public static class DetailListEntity {
|
||||
|
||||
private Uid code;
|
||||
private Double detectionScore;
|
||||
private Clazz compare;
|
||||
private Clazz target;
|
||||
private Clazzes compare;
|
||||
private Clazzes target;
|
||||
private MapSheet mapSheet;
|
||||
private Coordinate center;
|
||||
@JsonFormatDttm private ZonedDateTime updatedDttm;
|
||||
|
||||
public DetailListEntity(
|
||||
UUID uuid,
|
||||
Double detectionScore,
|
||||
Clazzes compare,
|
||||
Clazzes target,
|
||||
MapSheet mapSheet,
|
||||
Coordinate center,
|
||||
ZonedDateTime updatedDttm) {
|
||||
this.code = new Uid(uuid);
|
||||
this.detectionScore = detectionScore;
|
||||
this.compare = compare;
|
||||
this.target = target;
|
||||
this.mapSheet = mapSheet;
|
||||
this.center = center;
|
||||
this.updatedDttm = updatedDttm;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public static class Uid {
|
||||
|
||||
private String shortCode;
|
||||
private String code;
|
||||
|
||||
public Uid(UUID uuid) {
|
||||
if (uuid != null) {
|
||||
this.shortCode = uuid.toString().substring(0, 8).toUpperCase();
|
||||
this.code = uuid.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MAP NO
|
||||
@@ -201,13 +236,41 @@ public class InferenceResultDto {
|
||||
|
||||
private String code;
|
||||
private String name;
|
||||
private Double score;
|
||||
@JsonIgnore private Double score;
|
||||
|
||||
public Clazz(String code, Double score) {
|
||||
this.code = code;
|
||||
this.score = score;
|
||||
this.name = DetectionClassification.fromString(code).getDesc();
|
||||
}
|
||||
|
||||
public Clazz(String code) {
|
||||
this.code = code;
|
||||
this.name = DetectionClassification.fromString(code).getDesc();
|
||||
}
|
||||
}
|
||||
|
||||
// classification info
|
||||
@Getter
|
||||
public static class Clazzes {
|
||||
|
||||
private DetectionClassification code;
|
||||
private String name;
|
||||
@JsonIgnore private Double score;
|
||||
private Integer order;
|
||||
|
||||
public Clazzes(DetectionClassification classification, Double score) {
|
||||
this.code = classification;
|
||||
this.name = classification.getDesc();
|
||||
this.order = classification.getOrder();
|
||||
this.score = score;
|
||||
}
|
||||
|
||||
public Clazzes(DetectionClassification classification) {
|
||||
this.code = classification;
|
||||
this.name = classification.getDesc();
|
||||
this.order = classification.getOrder();
|
||||
}
|
||||
}
|
||||
|
||||
// 좌표 정보 point
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package com.kamco.cd.kamcoback.postgres.entity;
|
||||
|
||||
import com.kamco.cd.kamcoback.common.enums.DetectionClassification;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Clazz;
|
||||
import com.kamco.cd.kamcoback.inference.dto.InferenceResultDto.Clazzes;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.FetchType;
|
||||
@@ -14,6 +15,7 @@ import jakarta.persistence.SequenceGenerator;
|
||||
import jakarta.persistence.Table;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.hibernate.annotations.ColumnDefault;
|
||||
@@ -36,6 +38,9 @@ public class MapSheetAnalDataGeomEntity {
|
||||
@Column(name = "geo_uid", nullable = false)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "uuid")
|
||||
private UUID uuid;
|
||||
|
||||
@Column(name = "cd_prob")
|
||||
private Double cdProb;
|
||||
|
||||
@@ -144,8 +149,10 @@ public class MapSheetAnalDataGeomEntity {
|
||||
private Geometry geomCenter;
|
||||
|
||||
public InferenceResultDto.DetailListEntity toEntity() {
|
||||
Clazz comparedClazz = new Clazz(classBeforeCd, classBeforeProb);
|
||||
Clazz targetClazz = new Clazz(classAfterCd, classAfterProb);
|
||||
DetectionClassification classification = DetectionClassification.fromString(classBeforeCd);
|
||||
Clazzes comparedClazz = new Clazzes(classification, classBeforeProb);
|
||||
DetectionClassification classification1 = DetectionClassification.fromString(classAfterCd);
|
||||
Clazzes targetClazz = new Clazzes(classification1, classAfterProb);
|
||||
InferenceResultDto.MapSheet mapSheet = map5k != null ? map5k.toEntity() : null;
|
||||
|
||||
InferenceResultDto.Coordinate coordinate = null;
|
||||
@@ -155,6 +162,6 @@ public class MapSheetAnalDataGeomEntity {
|
||||
}
|
||||
|
||||
return new InferenceResultDto.DetailListEntity(
|
||||
cdProb, comparedClazz, targetClazz, mapSheet, coordinate, createdDttm);
|
||||
uuid, cdProb, comparedClazz, targetClazz, mapSheet, coordinate, createdDttm);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user