diff --git a/build.gradle b/build.gradle index 0ba9998..21fba1f 100644 --- a/build.gradle +++ b/build.gradle @@ -86,14 +86,7 @@ sonarqube { property "sonar.login", "admin" property "sonar.password", "0520" property "sonar.sources", "src" - property "sonar.language", "java" // 분석을 Java로 제한 + property "sonar.language", "java" property "sonar.sourceEncoding", "UTF-8" -// property "sonar.exclusions", "**/*Test*.*, **/Q*.JAVA" -// property "sonar.test.inclusions", "**/*Test.groovy, **/*Test.java" -// property "sonar.coverage.exclusions", "**/*Test*.*, **/Q*.java" -// property "sonar.java.junit.reportPaths", "${buildDir}/test-results" -// property "sonar.jacoco.reportPaths", "${buildDir}/jacoco/jacoco.exec" -// property "sonar.coverage.jacoco.xmlReportPaths", "build/reports/coverageReport/coverageReport.xml" // Test Coverage Report 생성한 경우 사용 -// property 'sonar.exclusions', 'com/xxx/**/*_.java,com/**/QMyEntity.java,....' } -} \ No newline at end of file +} diff --git a/ml/main.py b/ml/main.py index 15c492b..c1baca1 100644 --- a/ml/main.py +++ b/ml/main.py @@ -18,14 +18,14 @@ def __init__(self, input_size, hidden_size, num_layers, output_size): super(LSTMModel, self).__init__() self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=True) self.fc = nn.Linear(hidden_size, output_size) - + def forward(self, x): out, _ = self.lstm(x) out = self.fc(out) - + return out -input_size = 13 +input_size = 12 hidden_size = 64 num_layers = 2 output_size = 4 @@ -46,21 +46,26 @@ async def predict(input_data: str = Form(...),type_num: int = Form(...)): # 모델에 대한 타입 지정을 num 에 해줘야함 - # 모델의 타입은 직렬 정보에 따라서 1 = 2 = 3 = 4 = 5 = 6 = - - - - + # 모델의 타입은 직렬 정보에 따라서 1 = 2 = 3 = 4 = 5 = 6 = model.load_state_dict(torch.load('lstm_model_'+str(type_num)+'.pth')) model.eval() input_data = ast.literal_eval(input_data) - filtered_values = [value for value in input_data if value != -1] - mean_value = np.mean(filtered_values) - - input_data = [mean_value if value == -1 else value for value in input_data] - input_data.append(sum(input_data)) - + # 모두 0이면 리스트에 0 추가 + if all(value == 0 for value in input_data): + input_data.append(0) + else: + # 0 값을 제외한 리스트 생성 + filtered_values = [value for value in input_data if value != 0] + + # 0이 없을 때만 평균값 계산 및 처리 + if filtered_values: + mean_value = np.mean(filtered_values) + input_data = [mean_value if value == 0 else value for value in input_data] + input_data.append(sum(input_data)) + else: + input_data.append(sum(input_data)) + print(f"model input data is {input_data}") result = predict_single_input(input_data) diff --git a/ml/train.py b/ml/train.py index 3c788a7..61f06e7 100644 --- a/ml/train.py +++ b/ml/train.py @@ -35,13 +35,12 @@ def data_preprocess(df): df=data_preprocess(df) - -type_1_df=df[df['applicationType']=='경찰직공무원(여)'] -type_2_df=df[df['applicationType']=='경찰직공무원(남)'] +type_1_df=df[df['applicationType']=='경찰직공무원(남)'] +type_2_df=df[df['applicationType']=='경찰직공무원(여)'] type_3_df=df[df['applicationType']=='소방직공무원(남)'] -type_4_df=df[df['applicationType']=='교정직공무원(남)'] -type_5_df=df[df['applicationType']=='소방직공무원(여)'] -type_6_df=df[df['applicationType']=='교정직공무원(여)'] +type_4_df=df[df['applicationType']=='소방직공무원(여)'] +type_5_df=df[df['applicationType']=='경호직공무원(남)'] +type_6_df=df[df['applicationType']=='경호직공무원(여)'] type_1_df=type_1_df.drop('applicationType',axis=1) type_2_df=type_2_df.drop('applicationType',axis=1) @@ -50,7 +49,7 @@ def data_preprocess(df): type_5_df=type_5_df.drop('applicationType',axis=1) type_6_df=type_6_df.drop('applicationType',axis=1) - +print(type_3_df) def convert(df): data = { @@ -62,15 +61,15 @@ def convert(df): # 피벗 테이블 생성 pivot_table = df.groupby(['member_id', 'month'])['score'].sum().unstack() - + return pivot_table -type_1_df=convert(type_1_df) -type_2_df=convert(type_2_df) -type_3_df=convert(type_3_df) -type_4_df=convert(type_4_df) -type_5_df=convert(type_5_df) -type_6_df=convert(type_6_df) +type_1_df=convert(type_1_df) +type_2_df=convert(type_2_df) +type_3_df=convert(type_3_df) +type_4_df=convert(type_4_df) +type_5_df=convert(type_5_df) +type_6_df=convert(type_6_df) type_1_df=type_1_df.fillna(type_1_df.mean()) @@ -106,6 +105,14 @@ def set_label(df): type_6_df = set_label(type_6_df) +type_1_df=type_1_df.drop("total_score",axis=1) +type_2_df=type_2_df.drop("total_score",axis=1) +type_3_df=type_3_df.drop("total_score",axis=1) +type_4_df=type_4_df.drop("total_score",axis=1) +type_5_df=type_5_df.drop("total_score",axis=1) +type_6_df=type_6_df.drop("total_score",axis=1) + + class LSTMModel(nn.Module): @@ -113,17 +120,17 @@ def __init__(self, input_size, hidden_size, num_layers, output_size): super(LSTMModel, self).__init__() self.lstm = nn.LSTM(input_size, hidden_size, num_layers, batch_first=True) self.fc = nn.Linear(hidden_size, output_size) - + def forward(self, x): - out, _ = self.lstm(x) + out,_= self.lstm(x) out = self.fc(out) # Remove this line - + return out - + df_list=[type_1_df,type_2_df,type_3_df,type_4_df,type_5_df,type_6_df] num=1 for i in df_list: - + # Convert the DataFrame to PyTorch tensors data_tensor = torch.tensor(i.drop(columns=['label']).values, dtype=torch.float32) label_tensor = torch.tensor(i['label'].values, dtype=torch.long) # Change dtype to long @@ -138,7 +145,7 @@ def forward(self, x): test_labels = label_tensor[train_size:] # Create an instance of the LSTMModel - input_size = 13 + input_size = 12 hidden_size = 64 num_layers = 2 output_size = 4 @@ -153,13 +160,13 @@ def forward(self, x): for epoch in range(num_epochs): model.train() optimizer.zero_grad() - + outputs = model(train_data) loss = criterion(outputs.squeeze(), train_labels) # Remove the dimension from outputs - + loss.backward() optimizer.step() - + if (epoch + 1) % 10 == 0: print(f'Epoch [{epoch+1}/{num_epochs}], Loss: {loss.item():.4f}') diff --git a/redis/data/dump.rdb b/redis/data/dump.rdb index 83ed7c7..517732c 100644 Binary files a/redis/data/dump.rdb and b/redis/data/dump.rdb differ diff --git a/src/main/java/se/ton/t210/configuration/RestConfig.java b/src/main/java/se/ton/t210/configuration/RestConfig.java new file mode 100644 index 0000000..e6303a2 --- /dev/null +++ b/src/main/java/se/ton/t210/configuration/RestConfig.java @@ -0,0 +1,29 @@ +package se.ton.t210.configuration; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class RestConfig { + + @Bean + public HttpHeaders headers() { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.MULTIPART_FORM_DATA); + return headers; + } + + @Bean + public ObjectMapper objectMapper() { + return new ObjectMapper(); + } + + @Bean + public RestTemplate restTemplate() { + return new RestTemplate(); + } +} diff --git a/src/main/java/se/ton/t210/configuration/TokenFilterConfig.java b/src/main/java/se/ton/t210/configuration/TokenFilterConfig.java index 8323db6..365c072 100644 --- a/src/main/java/se/ton/t210/configuration/TokenFilterConfig.java +++ b/src/main/java/se/ton/t210/configuration/TokenFilterConfig.java @@ -32,10 +32,15 @@ public FilterRegistrationBean addAccessTokenFilter() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>(); filterRegistrationBean.setFilter(new TokenFilter(tokenSecret, accessTokenCookieKey)); filterRegistrationBean.addUrlPatterns( - "/api/reissue/token", "/html/dashboard.html", "/html/personal-information.html", "/html/record.html", + "/html/application-information1.html", + "/html/application-information2.html", + "/html/application-information3.html", + "/html/application-information4.html", + "/html/application-information5.html", + "/html/application-information6.html", "/html/setting-account.html" ); return filterRegistrationBean; @@ -45,7 +50,9 @@ public FilterRegistrationBean addAccessTokenFilter() { public FilterRegistrationBean addRefreshTokenFilter() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>(); filterRegistrationBean.setFilter(new TokenFilter(tokenSecret, refreshTokenCookieKey)); - filterRegistrationBean.addUrlPatterns("/api/reissue/token"); + filterRegistrationBean.addUrlPatterns( + "/api/reissue/token" + ); return filterRegistrationBean; } @@ -53,7 +60,9 @@ public FilterRegistrationBean addRefreshTokenFilter() { public FilterRegistrationBean addEmailTokenFilter() { FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean<>(); filterRegistrationBean.setFilter(new TokenFilter(tokenSecret, emailAuthTokenCookieKey)); - filterRegistrationBean.addUrlPatterns("/api/member/signUp"); + filterRegistrationBean.addUrlPatterns( + "/api/member/signUp" + ); return filterRegistrationBean; } } diff --git a/src/main/java/se/ton/t210/configuration/filter/TokenFilter.java b/src/main/java/se/ton/t210/configuration/filter/TokenFilter.java index af4dd73..141fe9d 100644 --- a/src/main/java/se/ton/t210/configuration/filter/TokenFilter.java +++ b/src/main/java/se/ton/t210/configuration/filter/TokenFilter.java @@ -32,7 +32,7 @@ protected void doFilterInternal(HttpServletRequest request, HttpServletResponse secret.validateToken(refreshToken); } catch (AuthException e) { response.setStatus(HttpStatus.UNAUTHORIZED.value()); - response.sendRedirect("/html/error-401.html"); + response.sendRedirect("/html/sign-in.html"); response.getOutputStream().write(e.getMessage().getBytes()); return; } diff --git a/src/main/java/se/ton/t210/controller/PageController.java b/src/main/java/se/ton/t210/controller/PageController.java new file mode 100644 index 0000000..2cf63bf --- /dev/null +++ b/src/main/java/se/ton/t210/controller/PageController.java @@ -0,0 +1,34 @@ +package se.ton.t210.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import se.ton.t210.configuration.annotation.LoginMember; +import se.ton.t210.domain.type.ApplicationType; +import se.ton.t210.dto.LoginMemberInfo; + +@Controller +public class PageController { + + @GetMapping("/html/application-information") + public String information(@LoginMember LoginMemberInfo memberInfo) { + if(memberInfo.getApplicationType() == ApplicationType.PoliceOfficerMale) { + return "redirect:/html/application-information1.html"; + } + if(memberInfo.getApplicationType() == ApplicationType.PoliceOfficerFemale) { + return "redirect:/html/application-information2.html"; + } + if(memberInfo.getApplicationType() == ApplicationType.FireOfficerMale) { + return "redirect:/html/application-information3.html"; + } + if(memberInfo.getApplicationType() == ApplicationType.FireOfficerFemale) { + return "redirect:/html/application-information4.html"; + } + if(memberInfo.getApplicationType() == ApplicationType.CorrectionalOfficerFemale) { + return "redirect:/html/application-information5.html"; + } + if(memberInfo.getApplicationType() == ApplicationType.CorrectionalOfficerMale) { + return "redirect:/html/application-information6.html"; + } + return "/html/application-information1.html"; + } +} diff --git a/src/main/java/se/ton/t210/controller/ScoreController.java b/src/main/java/se/ton/t210/controller/ScoreController.java index f8c65ff..7d2e557 100644 --- a/src/main/java/se/ton/t210/controller/ScoreController.java +++ b/src/main/java/se/ton/t210/controller/ScoreController.java @@ -1,11 +1,13 @@ package se.ton.t210.controller; +import com.fasterxml.jackson.core.JsonProcessingException; import org.springframework.http.ResponseEntity; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; import se.ton.t210.configuration.annotation.LoginMember; -import se.ton.t210.domain.Member; -import se.ton.t210.domain.type.ApplicationType; import se.ton.t210.dto.*; import se.ton.t210.service.ScoreService; @@ -32,8 +34,8 @@ public ResponseEntity scoreCount(@LoginMember LoginMemberInf @GetMapping("/api/score/evaluate") public ResponseEntity evaluationScore( - @Valid @NotNull Long evaluationItemId, - @Valid @NotNull Float score) { + @Valid @NotNull Long evaluationItemId, + @Valid @NotNull Float score) { final int evaluationScore = scoreService.evaluate(evaluationItemId, score); return ResponseEntity.ok(new CalculateEvaluationScoreResponse(evaluationScore)); } @@ -45,8 +47,8 @@ public ResponseEntity> scores(@LoginMember LoginMembe } @GetMapping("/api/score/expect") - public ResponseEntity expect(@LoginMember LoginMemberInfo member) { - final ExpectScoreResponse scoreResponse = scoreService.expect(member.getId(), member.getApplicationType(), LocalDate.now()); + public ResponseEntity expect(@LoginMember LoginMemberInfo member) throws JsonProcessingException { + final ExpectScoreResponse scoreResponse = scoreService.expect(member, LocalDate.now()); return ResponseEntity.ok(scoreResponse); } diff --git a/src/main/java/se/ton/t210/domain/type/ApplicationType.java b/src/main/java/se/ton/t210/domain/type/ApplicationType.java index 5ec95ab..55de937 100644 --- a/src/main/java/se/ton/t210/domain/type/ApplicationType.java +++ b/src/main/java/se/ton/t210/domain/type/ApplicationType.java @@ -1,22 +1,24 @@ package se.ton.t210.domain.type; public enum ApplicationType { - PoliceOfficerMale("/static/default.jpg", "경찰직공무원(남)"), - PoliceOfficerFemale("/static/default.jpg", "경찰직공무원(여)"), - FireOfficerMale("/static/default.jpg", "소방직공무원(남)"), - FireOfficerFemale("/static/default.jpg", "소방직공무원(여)"), - CorrectionalOfficerMale("/static/default.jpg", "경호직공무원(남)"), - CorrectionalOfficerFemale("/static/default.jpg", "경호직공무원(여)"); + PoliceOfficerMale("/static/default.jpg", "경찰직공무원(남)", 1), + PoliceOfficerFemale("/static/default.jpg", "경찰직공무원(여)", 2), + FireOfficerMale("/static/default.jpg", "소방직공무원(남)", 3), + FireOfficerFemale("/static/default.jpg", "소방직공무원(여)", 4), + CorrectionalOfficerMale("/static/default.jpg", "경호직공무원(남)", 5), + CorrectionalOfficerFemale("/static/default.jpg", "경호직공무원(여)", 6); private final String iconImageUrl; private final String standardName; + private final int mlServerIndex; - ApplicationType(String iconImageUrl, String standardName) { + ApplicationType(String iconImageUrl, String standardName, int mlServerIndex) { this.iconImageUrl = iconImageUrl; this.standardName = standardName; + this.mlServerIndex = mlServerIndex; } - public String getStandardName() { + public String standardName() { return standardName; } @@ -24,12 +26,7 @@ public String iconImageUrl() { return iconImageUrl; } - public static String getKeyByName(String name) { - for (ApplicationType ApplicationType : values()) { - if (ApplicationType.standardName.equals(name)) { - return ApplicationType.toString(); - } - } - return null; + public int mlServerIndex() { + return mlServerIndex; } } diff --git a/src/main/java/se/ton/t210/dto/ApplicationTypeInfoResponse.java b/src/main/java/se/ton/t210/dto/ApplicationTypeInfoResponse.java index bac02cc..032598f 100644 --- a/src/main/java/se/ton/t210/dto/ApplicationTypeInfoResponse.java +++ b/src/main/java/se/ton/t210/dto/ApplicationTypeInfoResponse.java @@ -11,12 +11,11 @@ public class ApplicationTypeInfoResponse { private final ApplicationType applicationType; - private final String applicationTypeStandardName; public ApplicationTypeInfoResponse(ApplicationType applicationType) { this.applicationType = applicationType; - this.applicationTypeStandardName = applicationType.getStandardName(); + this.applicationTypeStandardName = applicationType.standardName(); } public static List listOf() { diff --git a/src/main/java/se/ton/t210/dto/ExpectScoreResponse.java b/src/main/java/se/ton/t210/dto/ExpectScoreResponse.java index fdb6735..331dc8d 100644 --- a/src/main/java/se/ton/t210/dto/ExpectScoreResponse.java +++ b/src/main/java/se/ton/t210/dto/ExpectScoreResponse.java @@ -7,9 +7,9 @@ public class ExpectScoreResponse { private final int currentScore; private final float currentPercentile; - private final float expectedPassPercent; + private final int expectedPassPercent; - public ExpectScoreResponse(int currentScore, float currentPercentile, float expectedPassPercent) { + public ExpectScoreResponse(int currentScore, float currentPercentile, int expectedPassPercent) { this.currentScore = currentScore; this.currentPercentile = currentPercentile; this.expectedPassPercent = expectedPassPercent; diff --git a/src/main/java/se/ton/t210/dto/MemberPersonalInfoResponse.java b/src/main/java/se/ton/t210/dto/MemberPersonalInfoResponse.java index f1cc513..7b3d68b 100644 --- a/src/main/java/se/ton/t210/dto/MemberPersonalInfoResponse.java +++ b/src/main/java/se/ton/t210/dto/MemberPersonalInfoResponse.java @@ -13,6 +13,6 @@ public class MemberPersonalInfoResponse { public MemberPersonalInfoResponse(String name, String email, ApplicationType applicationType) { this.name = name; this.email = email; - this.applicationTypeStandardName = applicationType.getStandardName(); + this.applicationTypeStandardName = applicationType.standardName(); } } diff --git a/src/main/java/se/ton/t210/dto/ml/ExpectPassPointResponse.java b/src/main/java/se/ton/t210/dto/ml/ExpectPassPointResponse.java new file mode 100644 index 0000000..22926e4 --- /dev/null +++ b/src/main/java/se/ton/t210/dto/ml/ExpectPassPointResponse.java @@ -0,0 +1,16 @@ +package se.ton.t210.dto.ml; + +import lombok.Getter; + +@Getter +public class ExpectPassPointResponse { + + private int prediction; + + public ExpectPassPointResponse() { + } + + public ExpectPassPointResponse(int prediction) { + this.prediction = prediction; + } +} diff --git a/src/main/java/se/ton/t210/service/ScoreService.java b/src/main/java/se/ton/t210/service/ScoreService.java index 990cafc..7b3e19b 100644 --- a/src/main/java/se/ton/t210/service/ScoreService.java +++ b/src/main/java/se/ton/t210/service/ScoreService.java @@ -1,13 +1,22 @@ package se.ton.t210.service; -import org.springframework.beans.factory.annotation.Autowired; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Sort; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; import se.ton.t210.domain.*; import se.ton.t210.domain.type.ApplicationType; import se.ton.t210.dto.*; +import se.ton.t210.dto.ml.ExpectPassPointResponse; import se.ton.t210.utils.date.LocalDateUtils; import java.time.LocalDate; @@ -21,22 +30,26 @@ @Service public class ScoreService { + private static final String ML_URL = "http://localhost:8000/predict"; + private final MemberRepository memberRepository; private final EvaluationItemRepository evaluationItemRepository; private final EvaluationItemScoreItemRepository evaluationItemScoreItemRepository; private final MonthlyScoreRepository monthlyScoreRepository; private final EvaluationScoreSectionRepository evaluationScoreSectionRepository; + private final RestTemplate restTemplate; + private final HttpHeaders httpHeaders; + private final ObjectMapper objectMapper; - public ScoreService(MemberRepository memberRepository, - EvaluationItemRepository evaluationItemRepository, - EvaluationItemScoreItemRepository evaluationItemScoreItemRepository, - MonthlyScoreRepository monthlyScoreRepository, - EvaluationScoreSectionRepository evaluationScoreSectionRepository) { + public ScoreService(MemberRepository memberRepository, EvaluationItemRepository evaluationItemRepository, EvaluationItemScoreItemRepository evaluationItemScoreItemRepository, MonthlyScoreRepository monthlyScoreRepository, EvaluationScoreSectionRepository evaluationScoreSectionRepository, RestTemplate restTemplate, HttpHeaders httpHeaders, ObjectMapper objectMapper) { this.memberRepository = memberRepository; this.evaluationItemRepository = evaluationItemRepository; this.evaluationItemScoreItemRepository = evaluationItemScoreItemRepository; this.monthlyScoreRepository = monthlyScoreRepository; this.evaluationScoreSectionRepository = evaluationScoreSectionRepository; + this.restTemplate = restTemplate; + this.httpHeaders = httpHeaders; + this.objectMapper = objectMapper; } public ScoreCountResponse count(ApplicationType applicationType) { @@ -44,17 +57,39 @@ public ScoreCountResponse count(ApplicationType applicationType) { return new ScoreCountResponse(recordCnt); } - public ExpectScoreResponse expect(Long memberId, ApplicationType applicationType, LocalDate yearMonth) { + public ExpectScoreResponse expect(LoginMemberInfo member, LocalDate yearMonth) throws JsonProcessingException { + Long memberId = member.getId(); + ApplicationType applicationType = member.getApplicationType(); final MonthlyScore monthlyScore = monthlyScoreRepository.findByMemberIdAndYearMonth(memberId, yearMonth) - .orElse(MonthlyScore.empty(applicationType)); + .orElse(MonthlyScore.empty(applicationType)); final int currentScore = monthlyScore.getScore(); final int greaterThanMine = monthlyScoreRepository.countByApplicationTypeAndYearMonthAndScoreGreaterThan(applicationType, yearMonth, currentScore); final int totalCount = monthlyScoreRepository.countByApplicationTypeAndYearMonth(applicationType, yearMonth); final float currentPercentile = (float) (Math.floor(((float) greaterThanMine / totalCount * 100) * 100) / 100.0); - final float expectedPassPercent = 0; // TODO :: expectedGrade - return new ExpectScoreResponse(currentScore, currentPercentile, expectedPassPercent); + final List monthlyScoreResponses = scoresYear(member, LocalDate.now()); + + final int expectedPassPoint = getExpectedPassPoint(monthlyScoreResponses, applicationType.mlServerIndex()); + return new ExpectScoreResponse(currentScore, currentPercentile, expectedPassPoint); + } + + private int getExpectedPassPoint(List monthlyScoreResponses, int mlServerIndex) throws JsonProcessingException { + final List scores = monthlyScoreResponses.stream() + .map(MonthlyScoreResponse::getScore) + .collect(Collectors.toList()); + + final MultiValueMap formData = new LinkedMultiValueMap<>(); + formData.add("input_data", scores); + formData.add("type_num", mlServerIndex); + final ResponseEntity response = restTemplate.exchange( + ML_URL, + HttpMethod.POST, + new HttpEntity<>(formData, httpHeaders), + String.class + ); + ExpectPassPointResponse expectedPassPointResponse = objectMapper.readValue(response.getBody(), ExpectPassPointResponse.class); + return expectedPassPointResponse.getPrediction(); } public MyScoreResponse myScores(Long memberId) { @@ -64,17 +99,17 @@ public MyScoreResponse myScores(Long memberId) { public List evaluationScores(Long memberId, ApplicationType applicationType, LocalDate yearMonth) { return evaluationItemRepository.findAllByApplicationType(applicationType).stream() - .map(item -> { - final float evaluationItemScore = evaluationItemScore(memberId, item, yearMonth); - final int evaluationScore = evaluate(item.getId(), evaluationItemScore); - return new EvaluationScoreByItemResponse(item.getId(), item.getName(), evaluationScore); - }).collect(Collectors.toList()); + .map(item -> { + final float evaluationItemScore = evaluationItemScore(memberId, item, yearMonth); + final int evaluationScore = evaluate(item.getId(), evaluationItemScore); + return new EvaluationScoreByItemResponse(item.getId(), item.getName(), evaluationScore); + }).collect(Collectors.toList()); } private float evaluationItemScore(Long memberId, EvaluationItem item, LocalDate yearMonth) { return evaluationItemScoreItemRepository.findByEvaluationItemIdAndMemberIdAndYearMonth(item.getId(), memberId, yearMonth) - .orElse(new EvaluationItemScore(memberId, item.getId(), 0)) - .getScore(); + .orElse(new EvaluationItemScore(memberId, item.getId(), 0)) + .getScore(); } @Transactional @@ -103,10 +138,10 @@ private void updateMonthlyScore(Member member, int evaluationScoreSum, LocalDate public int evaluate(Long evaluationItemId, float score) { return evaluationScoreSectionRepository.findAllByEvaluationItemId(evaluationItemId).stream() - .filter(it -> it.getSectionBaseScore() <= score) - .max(Comparator.comparingInt(EvaluationScoreSection::getEvaluationScore)) - .map(EvaluationScoreSection::getEvaluationScore) - .orElseThrow(() -> new IllegalArgumentException("Invalid evaluationItemId or score")); + .filter(it -> it.getSectionBaseScore() <= score) + .max(Comparator.comparingInt(EvaluationScoreSection::getEvaluationScore)) + .map(EvaluationScoreSection::getEvaluationScore) + .orElseThrow(() -> new IllegalArgumentException("Invalid evaluationItemId or score")); } public List rank(ApplicationType applicationType, int rankCnt, LocalDate date) { @@ -133,9 +168,11 @@ public List rank(ApplicationType applicationType, int rankCnt, Loc public List scoresYear(LoginMemberInfo member, LocalDate year) { final ApplicationType applicationType = member.getApplicationType(); return LocalDateUtils.monthsOfYear(year).stream() - .map(yearMonth -> MonthlyScoreResponse.of(monthlyScoreRepository.findByMemberIdAndYearMonth(member.getId(), yearMonth) - .orElse(MonthlyScore.empty(applicationType))) - ).collect(Collectors.toList()); + .map(yearMonth -> MonthlyScoreResponse.of( + monthlyScoreRepository.findByMemberIdAndYearMonth(member.getId(), yearMonth) + .orElse(MonthlyScore.empty(applicationType)) + ) + ).collect(Collectors.toList()); } // avg evaluation scores of each evaluation item per monthly rankers @@ -145,9 +182,9 @@ public List avgEvaluationItemScoresTopOf(Applicat for (Long itemId : rankersScoresByItem.keySet()) { final String itemName = evaluationItemRepository.findById(itemId).orElseThrow().getName(); final double avgEvaluationScore = rankersScoresByItem.get(itemId).stream() - .mapToInt(score -> evaluate(itemId, score.getScore())) - .average() - .orElseThrow(); + .mapToInt(score -> evaluate(itemId, score.getScore())) + .average() + .orElseThrow(); responses.add(new EvaluationScoreByItemResponse(itemId, itemName, (int) avgEvaluationScore)); } return responses; @@ -156,7 +193,7 @@ public List avgEvaluationItemScoresTopOf(Applicat private Map> rankerScoresByItem(ApplicationType applicationType, int top, LocalDate yearMonth) { final List rankerIds = rankersByMonthlyScore(applicationType, top, yearMonth); return evaluationItemScoreItemRepository.findAllByMemberIdInAndYearMonth(rankerIds, yearMonth).stream() - .collect(Collectors.groupingBy(EvaluationItemScore::getEvaluationItemId)); + .collect(Collectors.groupingBy(EvaluationItemScore::getEvaluationItemId)); } private List rankersByMonthlyScore(ApplicationType applicationType, int top, LocalDate yearMonth) { @@ -164,7 +201,7 @@ private List rankersByMonthlyScore(ApplicationType applicationType, int to final int fetchCount = (int) (scoreCnt * ((float) top / 100)); final PageRequest page = PageRequest.of(0, fetchCount, Sort.by(Sort.Order.desc("score"), Sort.Order.asc("id"))); return monthlyScoreRepository.findAllByApplicationTypeAndYearMonth(applicationType, yearMonth, page).stream() - .map(MonthlyScore::getMemberId) - .collect(Collectors.toList()); + .map(MonthlyScore::getMemberId) + .collect(Collectors.toList()); } } diff --git a/src/main/java/se/ton/t210/utils/encript/SeedUtils.java b/src/main/java/se/ton/t210/utils/encript/SeedUtils.java index 8ed0be5..ddd131f 100644 --- a/src/main/java/se/ton/t210/utils/encript/SeedUtils.java +++ b/src/main/java/se/ton/t210/utils/encript/SeedUtils.java @@ -39,5 +39,4 @@ public static String decode(String encodedSeedKey, String encodedText) { throw new InnerServiceException("fail seed cbc decrypt."); } } - } diff --git a/src/main/resources/static/js/dashboard.js b/src/main/resources/static/js/dashboard.js index 7051ae3..cb9b2ec 100644 --- a/src/main/resources/static/js/dashboard.js +++ b/src/main/resources/static/js/dashboard.js @@ -1,3 +1,6 @@ +const currentDomain = window.location.origin +// const currentDomain = "http://localhost:8080" + const settingContainer = document.getElementById("settingContainer"); settingContainer.addEventListener("click", function (e) { window.location.href = "../html/setting-account.html"; @@ -15,12 +18,10 @@ menu03Container.addEventListener("click", function (e) { const menu04Container = document.getElementById("menu04Container") menu04Container.addEventListener("click", function (e) { - window.location.href = "../html/application-information1.html"; + window.location.href = "../html/application-information"; }); -// const currentDomain = window.location.origin -const currentDomain = "http://localhost:8080" // 사용자의 applicationTypeName값 let applicationTypeName; diff --git a/src/main/resources/static/js/personal-information.js b/src/main/resources/static/js/personal-information.js index a96d845..6d00fa1 100644 --- a/src/main/resources/static/js/personal-information.js +++ b/src/main/resources/static/js/personal-information.js @@ -1,4 +1,5 @@ -const currentDomain = "http://localhost:8080" +const currentDomain = window.location.origin +// const currentDomain = "http://localhost:8080" var imgElement = document.querySelector('.frame-icon59'); async function fetchMyInfo() { diff --git a/src/main/resources/static/js/record.js b/src/main/resources/static/js/record.js index b63059c..bbd14f7 100644 --- a/src/main/resources/static/js/record.js +++ b/src/main/resources/static/js/record.js @@ -1,5 +1,5 @@ -//const currentDomain = window.location.origin -const currentDomain = "http://localhost:8080" +const currentDomain = window.location.origin +// const currentDomain = "http://localhost:8080" const scorePattern = /^(?!-)(?!.*[a-zA-Z])(?!.*[!@#$%^&*()])(?!.*\d{5,})(?=.*\d)[^\s]+$/; async function fetchEvaluationItem() { diff --git a/src/main/resources/static/js/reset-password-auth.js b/src/main/resources/static/js/reset-password-auth.js index c895894..7f15cbb 100644 --- a/src/main/resources/static/js/reset-password-auth.js +++ b/src/main/resources/static/js/reset-password-auth.js @@ -1,5 +1,5 @@ -// const currentDomain = window.location.origin -const currentDomain = "http://localhost:8080" +const currentDomain = window.location.origin +// const currentDomain = "http://localhost:8080" // reset-password-auth.html 페이지의 JavaScript 부분 document.addEventListener("DOMContentLoaded", function () { diff --git a/src/main/resources/static/js/reset-password.js b/src/main/resources/static/js/reset-password.js index 16bc47b..f8cccdd 100644 --- a/src/main/resources/static/js/reset-password.js +++ b/src/main/resources/static/js/reset-password.js @@ -1,12 +1,12 @@ +const currentDomain = window.location.origin +// const currentDomain = "http://localhost:8080" + const emailInput = document.getElementById("email"); // 변경된 이메일 입력 요소 가져오기 const mergedEmailResult = document.getElementById("mergedEmail"); const sendEmail = document.getElementById("sendEmail"); emailInput.addEventListener("input", updateMergedEmail); -// const currentDomain = window.location.origin -const currentDomain = "http://localhost:8080" - let mail_result = 0 // 정규식 diff --git a/src/main/resources/static/js/setting-account.js b/src/main/resources/static/js/setting-account.js index 56464b9..c6bd15e 100644 --- a/src/main/resources/static/js/setting-account.js +++ b/src/main/resources/static/js/setting-account.js @@ -1,3 +1,6 @@ +const currentDomain = window.location.origin +// const currentDomain = "http://localhost:8080" + // dropdown const dropdown = document.querySelector(".dropdown"); const dropdownText = dropdown.querySelector(".text704"); @@ -6,11 +9,6 @@ const nameInput = document.getElementById("full-name") const emailInput = document.getElementById("email") var imgElement = document.querySelector('.frame-icon69'); - -// const currentDomain = window.location.origin -const currentDomain = "http://localhost:8080" - - document.addEventListener("DOMContentLoaded", function () { // application type 드롭 다운 데이터 처리 diff --git a/src/main/resources/static/js/sign-in.js b/src/main/resources/static/js/sign-in.js index b17d898..496853b 100644 --- a/src/main/resources/static/js/sign-in.js +++ b/src/main/resources/static/js/sign-in.js @@ -1,5 +1,5 @@ -// const currentDomain = window.location.origin -const currentDomain = "http://localhost:8080" +const currentDomain = window.location.origin +// const currentDomain = "http://localhost:8080" const emailInput = document.getElementById("email"); // 변경된 이메일 입력 요소 가져오기 const passwordInput = document.getElementById("password1"); diff --git a/src/main/resources/static/js/sign-up-email-auth.js b/src/main/resources/static/js/sign-up-email-auth.js index bc5b192..f0aca05 100644 --- a/src/main/resources/static/js/sign-up-email-auth.js +++ b/src/main/resources/static/js/sign-up-email-auth.js @@ -1,6 +1,5 @@ -// const currentDomain = window.location.origin -const currentDomain = "http://localhost:8080" - +const currentDomain = window.location.origin +// const currentDomain = "http://localhost:8080" const codeInput = document.getElementById("code"); const timerSpan = document.getElementById("timer"); diff --git a/src/main/resources/static/js/sign-up.js b/src/main/resources/static/js/sign-up.js index 7671162..d5eff09 100644 --- a/src/main/resources/static/js/sign-up.js +++ b/src/main/resources/static/js/sign-up.js @@ -1,3 +1,6 @@ +const currentDomain = window.location.origin +// const currentDomain = "http://localhost:8080" + const emailInput = document.getElementById("email"); // 변경된 이메일 입력 요소 가져오기 const passwordInput = document.getElementById("password1"); const passwordInput2 = document.getElementById("password2"); @@ -13,9 +16,6 @@ const dropdown = document.querySelector(".dropdown"); const dropdownText = dropdown.querySelector(".text704"); const dropdownContent = dropdown.querySelector(".dropdown-content"); -// const currentDomain = window.location.origin -const currentDomain = "http://localhost:8080" - let mail_result = 0 let passwordMachResult = false;