Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ public ResponseEntity<String> createAndStoreServiceList() {
/**
* κ³΅κ³΅μ„œλΉ„μŠ€ 상세정보 전체 동기화 (νŽ˜μ΄μ§• 처리)
*/
@PostMapping("/serviceDetailList")
@PostMapping("/serviceDetail")
public ResponseEntity<String> createAndStoreServiceDetailList() {
validator.validateAndHandleException(() -> {
// 전체 상세정보 동기화 (νŽ˜μ΄μ§• 처리)
publicServiceDataService.syncPublicServiceDetailData(SERVICE_DETAIL_LIST);
publicServiceDataService.syncPublicServiceDetailData(SERVICE_DETAIL);
return null;
}, SERVICE_DETAIL_LIST);
}, SERVICE_DETAIL);

return ResponseEntity.status(HttpStatus.OK).body("κ³΅κ³΅μ„œλΉ„μŠ€ 상세정보 데이터 동기화 μ™„λ£Œ");
}

/**
* κ³΅κ³΅μ„œλΉ„μŠ€ 지원쑰건 전체 동기화 (νŽ˜μ΄μ§• 처리)
*/
@PostMapping("/supportConditionsList")
@PostMapping("/supportConditions")
public ResponseEntity<String> createAndStoreSupportConditionsList() {
validator.validateAndHandleException(() -> {
// 전체 지원쑰건 동기화 (νŽ˜μ΄μ§• 처리)
publicServiceDataService.syncPublicServiceConditionsData(SERVICE_CONDITIONS_LIST);
publicServiceDataService.syncPublicServiceConditionsData(SERVICE_CONDITIONS);
return null;
}, SERVICE_CONDITIONS_LIST);
}, SERVICE_CONDITIONS);

return ResponseEntity.status(HttpStatus.OK).body("κ³΅κ³΅μ„œλΉ„μŠ€ 지원쑰건 데이터 동기화 μ™„λ£Œ");
}
Expand All @@ -85,4 +85,18 @@ public ResponseEntity<List<PublicServiceDataDto.Data>> getServiceListByPage(

return ResponseEntity.status(HttpStatus.OK).body(result);
}

// 톡합 동기화
@PostMapping("/sync-all")
public ResponseEntity<String> syncAllPublicServiceData() {
// 순차적으둜 μ‹€ν–‰
createAndStoreServiceList();
createAndStoreServiceDetailList();
createAndStoreSupportConditionsList();

// λ―Έμ‚¬μš© 데이터 정리
publicServiceDataService.cleanupObsoleteServices();

return ResponseEntity.status(HttpStatus.OK).body("λͺ¨λ“  κ³΅κ³΅μ„œλΉ„μŠ€ 데이터 동기화 μ™„λ£Œ");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;

import java.util.List;

Expand All @@ -23,6 +20,7 @@ public class PublicServiceConditionsDataDto {
private long perPage;

@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Builder
Expand Down Expand Up @@ -54,46 +52,79 @@ public static class Data {
private String incomeLevelVeryHigh; // μ€‘μœ„μ†Œλ“ 200% 초과

// Special Group
@JsonProperty("JA0401")
private String JA0401; // λ‹€λ¬Έν™”κ°€μ‘±
@JsonProperty("JA0402")
private String JA0402; // λΆν•œμ΄νƒˆμ£Όλ―Ό
@JsonProperty("JA0403")
private String JA0403; // ν•œλΆ€λͺ¨κ°€μ •/쑰손가정
@JsonProperty("JA0404")
private String JA0404; // 1인가ꡬ
@JsonProperty("JA0328")
private String JA0328; // μž₯애인
@JsonProperty("JA0329")
private String JA0329; // κ΅­κ°€λ³΄ν›ˆλŒ€μƒμž
@JsonProperty("JA0330")
private String JA0330; // μ§ˆλ³‘/μ§ˆν™˜μž

// Family Type
// private String JA0410; // 해당사항 μ—†μŒ
@JsonProperty("JA0411")
private String JA0411; // λ‹€μžλ…€κ°€κ΅¬
@JsonProperty("JA0412")
private String JA0412; // λ¬΄μ£Όνƒμ„ΈλŒ€
@JsonProperty("JA0413")
private String JA0413; // μ‹ κ·œμ „μž…
@JsonProperty("JA0414")
private String JA0414; // ν™•λŒ€κ°€μ‘±

// Occupation
@JsonProperty("JA0313")
private String JA0313; // 농업인
@JsonProperty("JA0314")
private String JA0314; // 어업인
@JsonProperty("JA0315")
private String JA0315; // 좕산업인
@JsonProperty("JA0316")
private String JA0316; // μž„μ—…μΈ
@JsonProperty("JA0317")
private String JA0317; // μ΄ˆλ“±ν•™μƒ
@JsonProperty("JA0318")
private String JA0318; // 쀑학생
@JsonProperty("JA0319")
private String JA0319; // 고등학생
@JsonProperty("JA0320")
private String JA0320; // λŒ€ν•™μƒ/λŒ€ν•™μ›μƒ
@JsonProperty("JA0326")
private String JA0326; // 근둜자/직μž₯인
@JsonProperty("JA0327")
private String JA0327; // ꡬ직자/μ‹€μ—…μž

// Business Type
@JsonProperty("JA1101")
private String JA1101; // μ˜ˆλΉ„ μ°½μ—…μž
@JsonProperty("JA1102")
private String JA1102; // μ˜μ—…μ€‘
@JsonProperty("JA1103")
private String JA1103; // μƒκ³„κ³€λž€/νμ—…μ˜ˆμ •μž
@JsonProperty("JA1201")
private String JA1201; // μŒμ‹μ—…
@JsonProperty("JA1202")
private String JA1202; // μ œμ‘°μ—…
@JsonProperty("JA1299")
private String JA1299; // 기타업쒅
@JsonProperty("JA2101")
private String JA2101; // μ€‘μ†ŒκΈ°μ—…
@JsonProperty("JA2102")
private String JA2102; // μ‚¬νšŒλ³΅μ§€μ‹œμ„€
@JsonProperty("JA2103")
private String JA2103; // κΈ°κ΄€/단체
@JsonProperty("JA2201")
private String JA2201; // μ œμ‘°μ—…
@JsonProperty("JA2202")
private String JA2202; // 농업, μž„μ—… 및 μ–΄μ—…
@JsonProperty("JA2203")
private String JA2203; // 정보톡신업
@JsonProperty("JA2299")
private String JA2299; // 기타업쒅

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.*;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public interface PublicServiceDataMapper {
PublicService updateFromDetailData(@MappingTarget PublicService publicService, PublicServiceDetailDataDto.Data data);

// κ³΅κ³΅μ„œλΉ„μŠ€ 지원쑰건 데이터 λ§€ν•‘
@Mapping(target = "targetGenderMale", source = "targetGenderMale")
@Mapping(target = "targetGenderFemale", source = "targetGenderFemale")
@Mapping(target = "incomeLevel", expression = "java(mapIncomeLevel(data))")
PublicService updateFromConditionsData(@MappingTarget PublicService publicService, PublicServiceConditionsDataDto.Data data);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public void syncAllPublicServiceData() {

// 2. κ³΅κ³΅μ„œλΉ„μŠ€ 상세정보 동기화
log.info("2. κ³΅κ³΅μ„œλΉ„μŠ€ 상세정보 동기화 μ‹œμž‘");
publicServiceDataService.syncPublicServiceDetailData(PublicDataPath.SERVICE_DETAIL_LIST);
publicServiceDataService.syncPublicServiceDetailData(PublicDataPath.SERVICE_DETAIL);

// 3. κ³΅κ³΅μ„œλΉ„μŠ€ 지원쑰건 동기화
log.info("3. κ³΅κ³΅μ„œλΉ„μŠ€ 지원쑰건 동기화 μ‹œμž‘");
publicServiceDataService.syncPublicServiceConditionsData(PublicDataPath.SERVICE_CONDITIONS_LIST);
publicServiceDataService.syncPublicServiceConditionsData(PublicDataPath.SERVICE_CONDITIONS);

// 4. λ―Έμ‚¬μš© 데이터 정리
log.info("λ―Έμ‚¬μš© κ³΅κ³΅μ„œλΉ„μŠ€ 데이터 정리 μ‹œμž‘");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,31 @@ void updateSpecialGroups(PublicService publicService, PublicServiceConditionsDat
List<SpecialGroup> specialGroups = new ArrayList<>();

if ("Y".equals(data.getJA0401())) {
log.debug("λ‹€λ¬Έν™”κ°€μ‘± 특수 κ·Έλ£Ή μΆ”κ°€");
specialGroups.add(createSpecialGroup(publicService, SpecialGroupEnum.IS_MULTI_CULTURAL));
}
if ("Y".equals(data.getJA0402())) {
log.debug("λΆν•œμ΄νƒˆμ£Όλ―Ό 특수 κ·Έλ£Ή μΆ”κ°€");
specialGroups.add(createSpecialGroup(publicService, SpecialGroupEnum.IS_NORTH_KOREAN_DEFECTOR));
}
if ("Y".equals(data.getJA0403())) {
log.debug("ν•œλΆ€λͺ¨κ°€μ •/쑰손가정 특수 κ·Έλ£Ή μΆ”κ°€");
specialGroups.add(createSpecialGroup(publicService, SpecialGroupEnum.IS_SINGLE_PARENT_FAMILY));
}
if ("Y".equals(data.getJA0404())) {
log.debug("1인가ꡬ 특수 κ·Έλ£Ή μΆ”κ°€");
specialGroups.add(createSpecialGroup(publicService, SpecialGroupEnum.IS_SINGLE_MEMBER_HOUSEHOLD));
}
if ("Y".equals(data.getJA0328())) {
log.debug("μž₯애인 특수 κ·Έλ£Ή μΆ”κ°€");
specialGroups.add(createSpecialGroup(publicService, SpecialGroupEnum.IS_DISABLED));
}
if ("Y".equals(data.getJA0329())) {
log.debug("κ΅­κ°€λ³΄ν›ˆλŒ€μƒμž 특수 κ·Έλ£Ή μΆ”κ°€");
specialGroups.add(createSpecialGroup(publicService, SpecialGroupEnum.IS_NATIONAL_MERIT_RECIPIENT));
}
if ("Y".equals(data.getJA0330())) {
log.debug("μ§ˆλ³‘/μ§ˆν™˜μž 특수 κ·Έλ£Ή μΆ”κ°€");
specialGroups.add(createSpecialGroup(publicService, SpecialGroupEnum.IS_CHRONIC_ILLNESS));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
import com.hyetaekon.hyetaekon.common.publicdata.util.PublicServiceDataValidate;
import com.hyetaekon.hyetaekon.publicservice.entity.*;
import com.hyetaekon.hyetaekon.publicservice.repository.PublicServiceRepository;
import jakarta.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.annotation.Propagation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.web.client.RestTemplate;


Expand Down Expand Up @@ -305,7 +307,7 @@ public List<PublicServiceDetailDataDto.Data> upsertServiceDetailData(List<Public
/**
* κ³΅κ³΅μ„œλΉ„μŠ€ 지원쑰건 데이터 μ €μž₯ (배치 처리)
*/
@Transactional
@Transactional(propagation = Propagation.REQUIRES_NEW)
public List<PublicServiceConditionsDataDto.Data> upsertSupportConditionsData(List<PublicServiceConditionsDataDto.Data> dataList) {
List<PublicServiceConditionsDataDto.Data> validatedData = new ArrayList<>();
List<PublicService> entitiesToSave = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
@Getter
public enum PublicDataPath {
SERVICE_LIST("/serviceList"),
SERVICE_DETAIL_LIST("/serviceDetailList"),
SERVICE_CONDITIONS_LIST("/supportConditionsList");
SERVICE_DETAIL("/serviceDetail"),
SERVICE_CONDITIONS("/supportConditions");

private final String path;
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,36 +75,35 @@ public boolean validatePublicServiceDetailData(PublicServiceDetailDataDto.Data d
}

public boolean validatePublicServiceConditionsData(PublicServiceConditionsDataDto.Data data) {
// 성별 쑰건 확인 (ν•„μˆ˜)
// 성별 쑰건 확인
boolean hasGenderCondition = "Y".equals(data.getTargetGenderMale()) || "Y".equals(data.getTargetGenderFemale());

// 성별 정보가 μ—†μœΌλ©΄ μœ νš¨ν•˜μ§€ μ•Šμ€ λ°μ΄ν„°λ‘œ κ°„μ£Ό
// 성별 쑰건이 μ—†λŠ” 경우, κΈ°λ³Έκ°’μœΌλ‘œ λͺ¨λ‘ Y μ„€μ •
if (!hasGenderCondition) {
log.warn("⚠️ 곡곡 μ„œλΉ„μŠ€ 지원쑰건 ID {}에 성별 지원 쑰건이 μ—†μŠ΅λ‹ˆλ‹€.", data.getServiceId());
return false;
log.info("ℹ️ 곡곡 μ„œλΉ„μŠ€ 지원쑰건 ID {}에 성별 지원 쑰건이 μ—†μŠ΅λ‹ˆλ‹€. κΈ°λ³Έκ°’μœΌλ‘œ 남성/μ—¬μ„± λͺ¨λ‘ Y둜 μ„€μ •ν•©λ‹ˆλ‹€.", data.getServiceId());
data.setTargetGenderMale("Y");
data.setTargetGenderFemale("Y");
// hasGenderCondition = true;
}

// 특수 κ·Έλ£Ή 쑰건 확인
// λ‹€λ₯Έ 쑰건듀 검사 (경고만 λ‘œκΉ…ν•˜κ³  μ‹€μ œλ‘œλŠ” λͺ¨λ“  데이터 ν—ˆμš©)
boolean hasSpecialGroupCondition =
"Y".equals(data.getJA0401()) || "Y".equals(data.getJA0402()) ||
"Y".equals(data.getJA0403()) || "Y".equals(data.getJA0404()) ||
"Y".equals(data.getJA0328()) || "Y".equals(data.getJA0329()) ||
"Y".equals(data.getJA0330());

// κ°€μ‘± μœ ν˜• 쑰건 확인
boolean hasFamilyTypeCondition =
"Y".equals(data.getJA0411()) || "Y".equals(data.getJA0412()) ||
"Y".equals(data.getJA0413()) || "Y".equals(data.getJA0414());

// 직업 μœ ν˜• 쑰건 확인
boolean hasOccupationCondition =
"Y".equals(data.getJA0313()) || "Y".equals(data.getJA0314()) ||
"Y".equals(data.getJA0315()) || "Y".equals(data.getJA0316()) ||
"Y".equals(data.getJA0317()) || "Y".equals(data.getJA0318()) ||
"Y".equals(data.getJA0319()) || "Y".equals(data.getJA0320()) ||
"Y".equals(data.getJA0326()) || "Y".equals(data.getJA0327());

// 사업체 μœ ν˜• 쑰건 확인
boolean hasBusinessTypeCondition =
"Y".equals(data.getJA1101()) || "Y".equals(data.getJA1102()) ||
"Y".equals(data.getJA1103()) || "Y".equals(data.getJA1201()) ||
Expand All @@ -114,13 +113,13 @@ public boolean validatePublicServiceConditionsData(PublicServiceConditionsDataDt
"Y".equals(data.getJA2202()) || "Y".equals(data.getJA2203()) ||
"Y".equals(data.getJA2299());

// 성별 외에 λ‹€λ₯Έ 지원 쑰건이 ν•˜λ‚˜λΌλ„ μžˆμ–΄μ•Ό 함
if (!(hasSpecialGroupCondition || hasFamilyTypeCondition ||
hasOccupationCondition || hasBusinessTypeCondition)) {
log.warn("⚠️ 곡곡 μ„œλΉ„μŠ€ 지원쑰건 ID {}에 성별 μ™Έ λ‹€λ₯Έ 지원 쑰건이 μ—†μŠ΅λ‹ˆλ‹€.", data.getServiceId());
return false;
// 경고만 λ‘œκΉ…ν•˜κ³  λ°μ΄ν„°λŠ” ν—ˆμš©
}

// 항상 true λ°˜ν™˜ν•˜μ—¬ λͺ¨λ“  데이터 ν—ˆμš©
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.hyetaekon.hyetaekon.publicservice.dto.PublicServiceDetailResponseDto;
import com.hyetaekon.hyetaekon.publicservice.dto.PublicServiceListResponseDto;
import com.hyetaekon.hyetaekon.publicservice.entity.ServiceCategory;
import com.hyetaekon.hyetaekon.publicservice.service.PublicServiceHandler;
import com.hyetaekon.hyetaekon.common.util.AuthenticateUser;
import jakarta.validation.constraints.Max;
Expand Down Expand Up @@ -34,7 +33,7 @@ public ResponseEntity<Page<PublicServiceListResponseDto>> getAllServices(
@RequestParam(required = false) List<String> familyTypes,
@RequestParam(required = false) List<String> categories,
@RequestParam(name = "page", defaultValue = "0") @Min(0) int page,
@RequestParam(name = "size", defaultValue = "9") @Positive @Max(30) int size) {
@RequestParam(name = "size", defaultValue = "9") @Positive @Max(50) int size) {

Long userId = authenticateUser.authenticateUserId();

Expand All @@ -43,7 +42,7 @@ public ResponseEntity<Page<PublicServiceListResponseDto>> getAllServices(
}

// μ„œλΉ„μŠ€ 뢄야별 κ³΅κ³΅μ„œλΉ„μŠ€ λͺ©λ‘ 쑰회
@GetMapping("/category/{category}")
/*@GetMapping("/category/{category}")
public ResponseEntity<Page<PublicServiceListResponseDto>> getServicesByCategory (
@PathVariable("category") String categoryName,
@RequestParam(name = "page", defaultValue = "0") @Min(0) int page,
Expand All @@ -52,7 +51,7 @@ public ResponseEntity<Page<PublicServiceListResponseDto>> getServicesByCategory
ServiceCategory category = publicServiceHandler.getServiceCategory(categoryName);
return ResponseEntity.ok(publicServiceHandler.getServicesByCategory(category, PageRequest.of(page, size), userId));

}
}*/

// κ³΅κ³΅μ„œλΉ„μŠ€ 상세 쑰회
@GetMapping("/detail/{serviceId}")
Expand Down
Loading