|
|
@@ -7,8 +7,8 @@ import cn.iselab.mooctest.site.dao.WorkerDao;
|
|
|
import cn.iselab.mooctest.site.data.ContestStatistics;
|
|
|
import cn.iselab.mooctest.site.models.Contest;
|
|
|
import cn.iselab.mooctest.site.models.ContestMentor;
|
|
|
-import cn.iselab.mooctest.site.models.Worker;
|
|
|
import cn.iselab.mooctest.site.models.SignRecord;
|
|
|
+import cn.iselab.mooctest.site.models.Worker;
|
|
|
import cn.iselab.mooctest.site.service.ContestService;
|
|
|
import cn.iselab.mooctest.site.web.data.ContestMentorVO;
|
|
|
import org.apache.commons.collections.IteratorUtils;
|
|
|
@@ -55,6 +55,90 @@ public class ContestServiceImpl implements ContestService {
|
|
|
return contestDao.findByWorkerId(workerId);
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ * 2017秋季赛统计数据
|
|
|
+ * */
|
|
|
+ @Override
|
|
|
+ @Cacheable(value = "getContestStatisticsOfFall")
|
|
|
+ public ContestStatistics getContestStatisticsOfFall(Long groupId) {
|
|
|
+ ContestStatistics contestStatistics = new ContestStatistics();
|
|
|
+
|
|
|
+ List<Object[]> locationResult;
|
|
|
+ Map<String, Long> locationMap;
|
|
|
+ List<Object[]> schoolResult;
|
|
|
+ Map<String, Long> schoolMap;
|
|
|
+
|
|
|
+ if (groupId == 0) {
|
|
|
+ locationResult = contestDao.CountAllByLocationOfFall();
|
|
|
+ locationMap = new HashMap<>();
|
|
|
+ for (Object[] result : locationResult) {
|
|
|
+ if (StringUtils.isEmpty((String) result[0])) {
|
|
|
+ long count = locationMap.getOrDefault("未知", 0L);
|
|
|
+ locationMap.put("未知", count + (Long) result[1]);
|
|
|
+ } else {
|
|
|
+ locationMap.put((String) result[0], (Long) result[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ schoolResult = contestDao.CountAllBySchoolOfFall();
|
|
|
+ schoolMap = new HashMap<>();
|
|
|
+ for (Object[] result : schoolResult) {
|
|
|
+ if (StringUtils.isEmpty((String) result[0])) {
|
|
|
+ long count = schoolMap.getOrDefault("未知", 0L);
|
|
|
+ schoolMap.put("未知", count + (Long) result[1]);
|
|
|
+ } else {
|
|
|
+ schoolMap.put((String) result[0], (Long) result[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ contestStatistics.setSchoolData(schoolMap);
|
|
|
+ contestStatistics.setLocationData(locationMap);
|
|
|
+ } else {
|
|
|
+ locationResult = contestDao.CountByLocationOfFall(groupId);
|
|
|
+ locationMap = new HashMap<>();
|
|
|
+ for (Object[] result : locationResult) {
|
|
|
+ if (StringUtils.isEmpty((String) result[0])) {
|
|
|
+ long count = locationMap.getOrDefault("未知", 0L);
|
|
|
+ locationMap.put("未知", count + (Long) result[1]);
|
|
|
+ } else {
|
|
|
+ locationMap.put((String) result[0], (Long) result[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ schoolResult = contestDao.CountBySchoolOfFall(groupId);
|
|
|
+ schoolMap = new HashMap<>(schoolResult.size());
|
|
|
+ for (Object[] result : schoolResult) {
|
|
|
+ if (StringUtils.isEmpty((String) result[0])) {
|
|
|
+ long count = schoolMap.getOrDefault("未知", 0L);
|
|
|
+ schoolMap.put("未知", count + (Long) result[1]);
|
|
|
+ } else {
|
|
|
+ schoolMap.put((String) result[0], (Long) result[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ contestStatistics.setSchoolData(schoolMap);
|
|
|
+ contestStatistics.setLocationData(locationMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Object[]> activeResult = contestDao.CountByActiveofFall();
|
|
|
+ Map<String, Long> activeMap = new HashMap<>();
|
|
|
+
|
|
|
+ for (Object[] result : activeResult) {
|
|
|
+ if (StringUtils.isEmpty((String) result[0])) {
|
|
|
+ long count = activeMap.getOrDefault("未知", 0L);
|
|
|
+ activeMap.put("未知", count + (Long) result[1]);
|
|
|
+ continue;
|
|
|
+ } else {
|
|
|
+ activeMap.put((String) result[0], (Long) result[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ contestStatistics.setActiveData(activeMap);
|
|
|
+
|
|
|
+ return contestStatistics;
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ * 2017夏季赛统计数据
|
|
|
+ * */
|
|
|
@Override
|
|
|
@Cacheable(value = "getContestStatistics")
|
|
|
public ContestStatistics getContestStatistics(Long contestId) {
|
|
|
@@ -143,20 +227,20 @@ public class ContestServiceImpl implements ContestService {
|
|
|
System.out.println("sign record size: " + signRecords.size());
|
|
|
|
|
|
int count = 0;
|
|
|
- for (int i = 0; i < workers.size(); i ++) {
|
|
|
+ for (int i = 0; i < workers.size(); i++) {
|
|
|
Worker worker = workers.get(i);
|
|
|
if (worker.getInformation() != null) {
|
|
|
continue;
|
|
|
}
|
|
|
String mobile = worker.getMobile();
|
|
|
String email = worker.getEmail();
|
|
|
- for (int j = 0; j < signRecords.size(); j ++) {
|
|
|
+ for (int j = 0; j < signRecords.size(); j++) {
|
|
|
SignRecord record = signRecords.get(j);
|
|
|
if (email == null) {
|
|
|
if (mobile != null) {
|
|
|
if (mobile.equals(record.getStuTel())) {
|
|
|
worker.setInformation(record.getStuSchool());
|
|
|
- count ++;
|
|
|
+ count++;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -164,14 +248,14 @@ public class ContestServiceImpl implements ContestService {
|
|
|
if (email != null) {
|
|
|
if (email.equals(record.getStuEmail())) {
|
|
|
worker.setInformation(record.getStuSchool());
|
|
|
- count ++;
|
|
|
+ count++;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
} else if (email != null && mobile != null) {
|
|
|
if (email.equals(record.getStuEmail()) || mobile.equals(record.getStuTel())) {
|
|
|
worker.setInformation(record.getStuSchool());
|
|
|
- count ++;
|
|
|
+ count++;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
@@ -186,7 +270,7 @@ public class ContestServiceImpl implements ContestService {
|
|
|
List<Worker> workers = workerDao.getContestWorkerList();
|
|
|
System.out.println(workers.size());
|
|
|
|
|
|
- for (int i = 0; i < workers.size(); i ++) {
|
|
|
+ for (int i = 0; i < workers.size(); i++) {
|
|
|
Worker worker = workers.get(i);
|
|
|
if (worker.getLocation() == null && worker.getInformation() != null) {
|
|
|
String area = contestDao.findAreaByUniversity(worker.getInformation());
|
|
|
@@ -202,7 +286,7 @@ public class ContestServiceImpl implements ContestService {
|
|
|
|
|
|
@Override
|
|
|
public List<ContestMentor> addContestMentor(Long examId, Long userId, List<ContestMentorVO> contestMentorVOS, Byte role) {
|
|
|
- contestMentorDao.delete(contestMentorDao.findByExamIdAndParticipantIdAndRole(examId,userId,role));
|
|
|
+ contestMentorDao.delete(contestMentorDao.findByExamIdAndParticipantIdAndRole(examId, userId, role));
|
|
|
List<ContestMentor> contestMentors = new ArrayList<>();
|
|
|
contestMentorVOS.stream().forEach(enterContestVO -> {
|
|
|
ContestMentor contestMentor = new ContestMentor();
|
|
|
@@ -218,7 +302,7 @@ public class ContestServiceImpl implements ContestService {
|
|
|
|
|
|
@Override
|
|
|
public List<ContestMentor> getContestMnetor(Long contestId, Long userId, Byte role) {
|
|
|
- return contestMentorDao.findByExamIdAndParticipantIdAndRole(contestId,userId,role);
|
|
|
+ return contestMentorDao.findByExamIdAndParticipantIdAndRole(contestId, userId, role);
|
|
|
}
|
|
|
|
|
|
}
|