feat: fix

This commit is contained in:
2025-12-02 17:04:10 +09:00
parent 199d3bcac7
commit 7def1e4e90
4 changed files with 110 additions and 22 deletions

View File

@@ -2,7 +2,10 @@ package com.kamco.cd.kamcoback.code;
import com.kamco.cd.kamcoback.code.dto.CommonCodeDto; import com.kamco.cd.kamcoback.code.dto.CommonCodeDto;
import com.kamco.cd.kamcoback.code.service.CommonCodeService; 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.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.Operation;
import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema; 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.responses.ApiResponses;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List; import java.util.List;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
@@ -206,4 +211,16 @@ public class CommonCodeApiController {
String code) { String code) {
return ApiResponseDto.ok(commonCodeService.findByCode(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);
}
} }

View File

@@ -6,24 +6,25 @@ import lombok.Getter;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum DetectionClassification { public enum DetectionClassification {
BUILDING("building", "건물"), BUILDING("building", "건물", 10),
CONTAINER("container", "컨테이너"), CONTAINER("container", "컨테이너", 20),
FIELD("field", "경작지"), FIELD("field", "경작지", 30),
FOREST("forest", ""), FOREST("forest", "", 40),
GRASS("grass", "초지"), GRASS("grass", "초지", 50),
GREENHOUSE("greenhouse", "비닐하우스"), GREENHOUSE("greenhouse", "비닐하우스", 60),
LAND("land", "일반토지"), LAND("land", "일반토지", 70),
ORCHARD("orchard", "과수원"), ORCHARD("orchard", "과수원", 80),
ROAD("road", "도로"), ROAD("road", "도로", 90),
STONE("stone", "모래/자갈"), STONE("stone", "모래/자갈", 100),
TANK("tank", "물탱크"), TANK("tank", "물탱크", 110),
TUMULUS("tumulus", "토분(무덤)"), TUMULUS("tumulus", "토분(무덤)", 120),
WASTE("waste", "폐기물"), WASTE("waste", "폐기물", 130),
WATER("water", ""), WATER("water", "", 140),
ETC("ETC", "기타"); // For 'etc' (miscellaneous/other) ETC("ETC", "기타", 200); // For 'etc' (miscellaneous/other)
private final String id; private final String id;
private final String desc; 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 * Optional: Helper method to get the enum from a String, case-insensitive, or return ETC if not

View File

@@ -1,10 +1,12 @@
package com.kamco.cd.kamcoback.inference.dto; 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.enums.DetectionClassification;
import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm; import com.kamco.cd.kamcoback.common.utils.interfaces.JsonFormatDttm;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.List; import java.util.List;
import java.util.UUID;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@@ -178,12 +180,45 @@ public class InferenceResultDto {
@AllArgsConstructor @AllArgsConstructor
public static class DetailListEntity { public static class DetailListEntity {
private Uid code;
private Double detectionScore; private Double detectionScore;
private Clazz compare; private Clazzes compare;
private Clazz target; private Clazzes target;
private MapSheet mapSheet; private MapSheet mapSheet;
private Coordinate center; private Coordinate center;
@JsonFormatDttm private ZonedDateTime updatedDttm; @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 // MAP NO
@@ -201,13 +236,41 @@ public class InferenceResultDto {
private String code; private String code;
private String name; private String name;
private Double score; @JsonIgnore private Double score;
public Clazz(String code, Double score) { public Clazz(String code, Double score) {
this.code = code; this.code = code;
this.score = score; this.score = score;
this.name = DetectionClassification.fromString(code).getDesc(); 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 // 좌표 정보 point

View File

@@ -1,7 +1,8 @@
package com.kamco.cd.kamcoback.postgres.entity; 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;
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.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.FetchType; import jakarta.persistence.FetchType;
@@ -14,6 +15,7 @@ import jakarta.persistence.SequenceGenerator;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import jakarta.validation.constraints.Size; import jakarta.validation.constraints.Size;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.UUID;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.hibernate.annotations.ColumnDefault; import org.hibernate.annotations.ColumnDefault;
@@ -36,6 +38,9 @@ public class MapSheetAnalDataGeomEntity {
@Column(name = "geo_uid", nullable = false) @Column(name = "geo_uid", nullable = false)
private Long id; private Long id;
@Column(name = "uuid")
private UUID uuid;
@Column(name = "cd_prob") @Column(name = "cd_prob")
private Double cdProb; private Double cdProb;
@@ -144,8 +149,10 @@ public class MapSheetAnalDataGeomEntity {
private Geometry geomCenter; private Geometry geomCenter;
public InferenceResultDto.DetailListEntity toEntity() { public InferenceResultDto.DetailListEntity toEntity() {
Clazz comparedClazz = new Clazz(classBeforeCd, classBeforeProb); DetectionClassification classification = DetectionClassification.fromString(classBeforeCd);
Clazz targetClazz = new Clazz(classAfterCd, classAfterProb); 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.MapSheet mapSheet = map5k != null ? map5k.toEntity() : null;
InferenceResultDto.Coordinate coordinate = null; InferenceResultDto.Coordinate coordinate = null;
@@ -155,6 +162,6 @@ public class MapSheetAnalDataGeomEntity {
} }
return new InferenceResultDto.DetailListEntity( return new InferenceResultDto.DetailListEntity(
cdProb, comparedClazz, targetClazz, mapSheet, coordinate, createdDttm); uuid, cdProb, comparedClazz, targetClazz, mapSheet, coordinate, createdDttm);
} }
} }