|
|
@@ -0,0 +1,70 @@
|
|
|
+package cn.seecoder.data.server.service.Impl;
|
|
|
+
|
|
|
+import cn.seecoder.data.server.service.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.atomic.AtomicReference;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class CompetencyServiceImpl implements CompetencyService {
|
|
|
+
|
|
|
+ SonarqubeService sonarqubeService;
|
|
|
+ HelperService helperService;
|
|
|
+ DevcloudService devcloudService;
|
|
|
+ KnowledgeService knowledgeService;
|
|
|
+ CoderService coderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ public CompetencyServiceImpl(SonarqubeService sonarqubeService,
|
|
|
+ HelperService helperService,
|
|
|
+ DevcloudService devcloudService,
|
|
|
+ KnowledgeService knowledgeService,
|
|
|
+ CoderService coderService) {
|
|
|
+ this.coderService = coderService;
|
|
|
+ this.knowledgeService = knowledgeService;
|
|
|
+ this.devcloudService = devcloudService;
|
|
|
+ this.helperService = helperService;
|
|
|
+ this.sonarqubeService = sonarqubeService;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public double getCompetencyScore(Map<String, Double> scores) {
|
|
|
+ double[] weight = new double[]{0.5,0.3,0.2}; // Knowledge, Dispositions, Skills
|
|
|
+ AtomicReference<Double> res = new AtomicReference<>(0.0);
|
|
|
+ scores.forEach((k,v) -> {
|
|
|
+ switch (k) {
|
|
|
+ case "Knowledge": res.updateAndGet(v1 -> (double) (v1 + v * weight[0]));
|
|
|
+ case "Dispositions": res.updateAndGet(v1 -> (double) (v1 + v * weight[1]));
|
|
|
+ case "Skills": res.updateAndGet(v1 -> (double) (v1 + v * weight[2]));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return res.get();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Double> getCompetencyScores(int userId) {
|
|
|
+ Map<String, Double> map = new HashMap<>();
|
|
|
+ map.put("Knowledge", getKnowledgeScore(userId));
|
|
|
+ map.put("Dispositions", getDispositionsScore(userId));
|
|
|
+ map.put("Skills", getSkillsScore(userId));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ private double getKnowledgeScore(int userId) { // Knwoledge Service
|
|
|
+ return 0.0;
|
|
|
+ }
|
|
|
+ private double getSkillsScore(int userId) { // Coder Service
|
|
|
+ double coderScore = coderService.getCoderGrade(userId);
|
|
|
+ return coderScore;
|
|
|
+ }
|
|
|
+ private double getDispositionsScore(int userId) { // Helper Service,Devcloud Service, SonarqubeService
|
|
|
+ double[] weight = new double[]{0.33, 0.33, 0.34};
|
|
|
+ double sonarScore = sonarqubeService.getSonarScoreOfUser(userId);
|
|
|
+ double helperScore = helperService.getHelperEventScoreById(userId);
|
|
|
+ double devcloudScore = devcloudService.commitScoreCompute(userId);
|
|
|
+ return sonarScore * weight[0] + helperScore * weight[1] + devcloudScore * weight[2];
|
|
|
+ }
|
|
|
+}
|