diff --git a/docker-test-server/src/main/java/com/example/server/controller/ToothController.java b/docker-test-server/src/main/java/com/example/server/controller/ToothController.java index 7a06dab..beac356 100644 --- a/docker-test-server/src/main/java/com/example/server/controller/ToothController.java +++ b/docker-test-server/src/main/java/com/example/server/controller/ToothController.java @@ -3,6 +3,7 @@ import java.time.LocalDate; import java.time.ZoneId; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -64,6 +65,20 @@ public class ToothController { // 3. Count Frequency Map frequency = new HashMap<>(); + frequency.put("UNDER_FRONT", 0); + frequency.put("UP_FRONT", 0); + frequency.put("UNDER_RIGHT_CANINE", 0); + frequency.put("UP_RIGHT_CANINE", 0); + frequency.put("UNDER_RIGHT_MOLAR_OUTSIDE", 0); + frequency.put("UP_RIGHT_MOLAR_OUTSIDE", 0); + frequency.put("UP_LEFT_MOLAR_CHEWING_SIDE", 0); + frequency.put("UP_RIGHT_MOLAR_CHEWING_SIDE", 0); + frequency.put("DOWN_RIGHT_MOLAR_CHEWING_SIDE", 0); + frequency.put("DOWN_LEFT_MOLAR_CHEWING_SIDE", 0); + frequency.put("UP_LEFT_MOLAR_OUTSIDE", 0); + frequency.put("UNDER_LEFT_MOLAR_OUTSIDE", 0); + frequency.put("UNDER_LEFT_CANINE", 0); + frequency.put("UP_LEFT_CANINE", 0); for (String instruction : Instructions) { frequency.put(instruction, frequency.getOrDefault(instruction, 0) + 1); @@ -87,6 +102,8 @@ public class ToothController { toothReports.add(toothReport); } + Collections.sort(toothReports); + // 4. Get Sequence Data User user = null; try { diff --git a/docker-test-server/src/main/java/com/example/server/model/ToothDataAnalyzer.java b/docker-test-server/src/main/java/com/example/server/model/ToothDataAnalyzer.java index 96966f4..b16b147 100644 --- a/docker-test-server/src/main/java/com/example/server/model/ToothDataAnalyzer.java +++ b/docker-test-server/src/main/java/com/example/server/model/ToothDataAnalyzer.java @@ -13,9 +13,26 @@ public class ToothDataAnalyzer { @Getter @Setter - public static class ToothReport { + public static class ToothReport implements Comparable{ private String name; private String percent; private String description; + + @Override + public int compareTo(ToothReport other) { + // null 체크 + if (this.name == null && other.name == null) { + return 0; + } + if (this.name == null) { + return -1; + } + if (other.name == null) { + return 1; + } + + // name을 기준으로 오름차순 정렬 + return this.name.compareTo(other.name); + } } }