Skip to content

Commit

Permalink
Fix(#78): 재난 유형 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
nohy6630 committed Nov 20, 2023
1 parent 0ac4bc5 commit b2d315f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ public void collectData() {
break;
String[] locations = disaster.getLocationName().split(",");
for (String loc : locations) {
if (disasterTypeMap.get(disasterNum).equals(DisasterType.OTHERS) && disaster.getMsg().contains("실종"))
disasterTypeMap.put(disasterNum, DisasterType.MISSING);
disasterService.save(SaveDisasterRequest.of(
disasterTypeMap.get(disasterNum),
loc.replace(" 전체", ""),//이 부분은 메시지 내부 파싱하여 더 정확한 주소를 저장하도록 수정해야함
Expand Down Expand Up @@ -128,7 +130,7 @@ public void collectData() {

private void crawlingDisasterTypeV2() {
disasterTypeMap.clear();
try (WebClient webClient = new WebClient()){
try (WebClient webClient = new WebClient()) {
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setCssEnabled(false);
HtmlPage htmlPage = webClient.getPage(disasterProperties.getCrawlingUrl());
Expand All @@ -142,7 +144,7 @@ private void crawlingDisasterTypeV2() {
DisasterType.kor2code(types.get(i).text())
);
}
} catch (IOException e){
} catch (IOException e) {
throw new NotFoundCrawlingException();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,51 @@
@Getter
@RequiredArgsConstructor
public enum DisasterType {
CIVIL_DEFENSE("민방공"),
TERROR("테러"),
//자연재난
DROUGHT("가뭄"),
STRONG_WIND("강풍"),
DRYNESS("건조"),
HEAVY_SNOWFALL("대설"),
TIDAL_WAVE("대조기"),
FINE_DUST("미세먼지"),
WILDFIRE("산불"),
LANDSLIDE("산사태"),
FOG("안개"),
EARTHQUAKE("지진"),
TSUNAMI("해일"),
FLOOD("홍수"),
TYPHOON("태풍"),
WILDFIRE("산불"),
NATURAL_DISASTER("자연재난"),
INFECTIOUS_DISEASE("감염병"),
HEATWAVE("폭염"),
ROUGH_SEA("풍랑"),
COLD_WAVE("한파"),
HEAVY_RAIN("호우"),
FLOOD("홍수"),

//사회재난
GAS("가스"),
TRAFFIC("교통"),
FINANCE("금융"),
COLLAPSE("붕괴"),
WATER_SUPPLY("수도"),
ENERGY("에너지"),
MEDICAL("의료"),
INFECTIOUS_DISEASE("전염병"),
POWER_OUTAGE("정전"),
COMMUNICATION("통신"),
EXPLOSION("폭발"),
FIRE("화재"),
OTHERS("기타");
ENVIRONMENTAL_POLLUTION("환경오염사고"),
AI("AI"),

//비상대비
EMERGENCY("비상사태"),
TERROR("테러"),
CHEMICAL("화생방사고"),

//기타
MISSING("실종"),
OTHERS("기타"),

//추후 삭제예정
NATURAL_DISASTER("자연재난");

private final String description;

Expand All @@ -27,42 +60,23 @@ public String getDescription() {
}

public static DisasterType kor2code(String kor) {
for (DisasterType type : values()) {
if (kor.equals(type.getDescription()))
return type;
}
//1대1 매핑이 되지 않는 카테고리들 처리
switch (kor) {
case "민방공" -> {
return CIVIL_DEFENSE;
}
case "테러" -> {
return TERROR;
}
case "산사태" -> {
return LANDSLIDE;
}
case "지진" -> {
return EARTHQUAKE;
}
case "지진해일" -> {
return TSUNAMI;
}
case "홍수" -> {
return FLOOD;
}
case "태풍" -> {
return TYPHOON;
}
case "산불" -> {
return WILDFIRE;
}
case "건조", "폭염", "미세먼지", "대조기", "가뭄", "대설", "한파", "황사", "강풍", "호우", "풍랑", "안개" -> {
return NATURAL_DISASTER;
return EARTHQUAKE;
}
case "전염병" -> {
return INFECTIOUS_DISEASE;
case "황사" -> {
return OTHERS;
}
case "화재" -> {
return FIRE;
case "교통통제", "교통사고" -> {
return TRAFFIC;
}
case "화생방사고", "폭동", "비상사태", "기타", "교통통제", "붕괴", "폭발", "교통사고", "환경오염사고", "에너지", "통신", "교통", "금융", "의료", "수도", "정전", "가스", "AI" -> {
return OTHERS;
case "폭동", "민방공" -> {
return EMERGENCY;
}
}
throw new InvalidDisasterTypeException();
Expand Down

0 comments on commit b2d315f

Please sign in to comment.