Skip to content
Merged
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 @@ -21,12 +21,13 @@ public class SelectSecondPassUseCase {

private final FormRepository formRepository;
private final CalculateFormScoreService calculateFormScoreService;
private final AtomicInteger otherRegionCount = new AtomicInteger((int) Math.ceil(FixedNumber.TOTAL * FixedNumber.OTHER_REGION_RATE));

@Transactional
public void execute() {
validate();

AtomicInteger otherRegionCount = new AtomicInteger((int) Math.ceil(FixedNumber.TOTAL * FixedNumber.OTHER_REGION_RATE));

int regularCount = FixedNumber.REGULAR;
int meisterTalentCount = FixedNumber.MEISTER_TALENT;
int socialIntegrationCount = FixedNumber.SOCIAL_INTEGRATION;
Expand Down Expand Up @@ -54,25 +55,25 @@ public void execute() {
int equalOpportunityCount = (int) Math.round(socialIntegrationCount * 0.5);
int societyDiversityCount = equalOpportunityCount;

processForms(equalOpportunityFormList, equalOpportunityCount, this::changeToRegularAndCalculateScoreAgain);
processForms(societyDiversityFormList, societyDiversityCount, this::changeToRegularAndCalculateScoreAgain);
processForms(meisterTalentFormList, meisterTalentCount, this::changeToRegularAndCalculateScoreAgain);
processForms(equalOpportunityFormList, equalOpportunityCount, this::changeToRegularAndCalculateScoreAgain, otherRegionCount);
processForms(societyDiversityFormList, societyDiversityCount, this::changeToRegularAndCalculateScoreAgain, otherRegionCount);
processForms(meisterTalentFormList, meisterTalentCount, this::changeToRegularAndCalculateScoreAgain,otherRegionCount);

formRepository.flush();
List<Form> regularFormList = formRepository.findFirstPassedRegularForm();

processForms(regularFormList, regularCount, Form::fail);
processForms(regularFormList, regularCount, Form::fail, otherRegionCount);

formRepository.flush();
List<Form> supernumeraryFormList = formRepository.findFirstPassedSupernumeraryForm();
List<Form> nationalVeteransEducationFormList = classifyFormsByType(supernumeraryFormList, FormType::isNationalVeteransEducation);
List<Form> specialAdmissionFormList = classifyFormsByType(supernumeraryFormList, FormType::isSpecialAdmission);

processForms(nationalVeteransEducationFormList, nationalVeteransEducationCount, Form::fail);
processForms(specialAdmissionFormList, specialAdmissionCount, Form::fail);
processForms(nationalVeteransEducationFormList, nationalVeteransEducationCount, Form::fail, otherRegionCount);
processForms(specialAdmissionFormList, specialAdmissionCount, Form::fail, otherRegionCount);
}

private void processForms(List<Form> formList, int count, Consumer<Form> action) {
private void processForms(List<Form> formList, int count, Consumer<Form> action, AtomicInteger otherRegionCount) {
for (Form form : formList) {
if (count > 0) {
if (form.getEducation().getSchool().isBusan()) {
Expand Down
Loading