|
|
@ -2,8 +2,10 @@ package com.ccsens.mt.service; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
import cn.hutool.core.lang.Snowflake; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import cn.hutool.crypto.SecureUtil; |
|
|
|
import com.ccsens.cloudutil.bean.tall.vo.MemberVo; |
|
|
|
import com.ccsens.cloudutil.bean.tall.vo.TaskVo; |
|
|
|
import com.ccsens.cloudutil.feign.TallFeignClient; |
|
|
@ -16,23 +18,27 @@ import com.ccsens.mt.persist.dao.MtJudgeDao; |
|
|
|
import com.ccsens.mt.persist.dao.MtScoreDao; |
|
|
|
import com.ccsens.mt.persist.dao.MtScoreLogDao; |
|
|
|
import com.ccsens.util.CodeEnum; |
|
|
|
import com.ccsens.util.ExcelUtil; |
|
|
|
import com.ccsens.util.JsonResponse; |
|
|
|
import com.ccsens.util.WebConstant; |
|
|
|
import com.ccsens.util.exception.BaseException; |
|
|
|
import lombok.Data; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCell; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.core.io.DefaultResourceLoader; |
|
|
|
import org.springframework.core.io.ResourceLoader; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import static java.math.BigDecimal.ROUND_HALF_UP; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class ScoreService implements IScoreService{ |
|
|
|
public class ScoreService implements IScoreService { |
|
|
|
@Autowired |
|
|
|
private TallFeignClient tallFeignClient; |
|
|
|
@Autowired |
|
|
@ -48,6 +54,7 @@ public class ScoreService implements IScoreService{ |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取评分项 |
|
|
|
* |
|
|
|
* @param userId |
|
|
|
* @param playerId |
|
|
|
* @return |
|
|
@ -55,28 +62,28 @@ public class ScoreService implements IScoreService{ |
|
|
|
@Override |
|
|
|
public List<ScoreVo.ScoreInfo> getScoreLog(Long userId, Long playerId) { |
|
|
|
List<ScoreVo.ScoreInfo> scoreInfoList = new ArrayList<>(); |
|
|
|
if(ObjectUtil.isNull(userId)){ |
|
|
|
if (ObjectUtil.isNull(userId)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_LOGIN); |
|
|
|
} |
|
|
|
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(playerId); |
|
|
|
if(ObjectUtil.isNull(taskInfo)){ |
|
|
|
if (ObjectUtil.isNull(taskInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
JsonResponse<MemberVo.MemberInfo> jMemberInfo = tallFeignClient.getMemberByUserId(userId,taskInfo.getProjectId()); |
|
|
|
if(ObjectUtil.isNull(jMemberInfo)){ |
|
|
|
JsonResponse<MemberVo.MemberInfo> jMemberInfo = tallFeignClient.getMemberByUserId(userId, taskInfo.getProjectId()); |
|
|
|
if (ObjectUtil.isNull(jMemberInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
|
} |
|
|
|
MemberVo.MemberInfo memberInfo = jMemberInfo.getData(); |
|
|
|
if(ObjectUtil.isNull(memberInfo)){ |
|
|
|
if (ObjectUtil.isNull(memberInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
|
} |
|
|
|
|
|
|
|
MtScoreLogExample scoreLogExample = new MtScoreLogExample(); |
|
|
|
scoreLogExample.createCriteria().andProjectIdEqualTo(taskInfo.getProjectId()); |
|
|
|
List<MtScoreLog> scoreLogList = scoreLogDao.selectByExample(scoreLogExample); |
|
|
|
if(CollectionUtil.isNotEmpty(scoreLogList)){ |
|
|
|
if (CollectionUtil.isNotEmpty(scoreLogList)) { |
|
|
|
ScoreVo.ScoreInfo scoreInfo = null; |
|
|
|
for(MtScoreLog mtScoreLog : scoreLogList){ |
|
|
|
for (MtScoreLog mtScoreLog : scoreLogList) { |
|
|
|
scoreInfo = new ScoreVo.ScoreInfo(); |
|
|
|
scoreInfo.setId(mtScoreLog.getId()); |
|
|
|
scoreInfo.setMax(mtScoreLog.getMaxScore()); |
|
|
@ -101,24 +108,25 @@ public class ScoreService implements IScoreService{ |
|
|
|
|
|
|
|
/** |
|
|
|
* 提交评分 |
|
|
|
* |
|
|
|
* @param userId |
|
|
|
* @param submitScore |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void submitScore(Long userId, ScoreDto.SubmitScore submitScore) { |
|
|
|
if(ObjectUtil.isNull(userId)){ |
|
|
|
if (ObjectUtil.isNull(userId)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_LOGIN); |
|
|
|
} |
|
|
|
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(submitScore.getTaskId()); |
|
|
|
if(ObjectUtil.isNull(taskInfo)){ |
|
|
|
if (ObjectUtil.isNull(taskInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
JsonResponse<MemberVo.MemberInfo> jMemberInfo = tallFeignClient.getMemberByUserId(userId,taskInfo.getProjectId()); |
|
|
|
if(ObjectUtil.isNull(jMemberInfo)){ |
|
|
|
JsonResponse<MemberVo.MemberInfo> jMemberInfo = tallFeignClient.getMemberByUserId(userId, taskInfo.getProjectId()); |
|
|
|
if (ObjectUtil.isNull(jMemberInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
|
} |
|
|
|
MemberVo.MemberInfo memberInfo = jMemberInfo.getData(); |
|
|
|
if(ObjectUtil.isNull(memberInfo)){ |
|
|
|
if (ObjectUtil.isNull(memberInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
|
} |
|
|
|
//添加评委
|
|
|
@ -133,6 +141,7 @@ public class ScoreService implements IScoreService{ |
|
|
|
MtScore score = new MtScore(); |
|
|
|
score.setId(snowflake.nextId()); |
|
|
|
score.setJudgeUserId(memberInfo.getId()); |
|
|
|
score.setProjectId(taskInfo.getProjectId()); |
|
|
|
score.setTaskId(taskInfo.getId()); |
|
|
|
score.setTaskName(taskInfo.getName()); |
|
|
|
score.setScoreLogId(data.getId()); |
|
|
@ -146,35 +155,37 @@ public class ScoreService implements IScoreService{ |
|
|
|
throw new BaseException(CodeEnum.SCORE_REPEAT); |
|
|
|
} |
|
|
|
} |
|
|
|
private void addJudge(MemberVo.MemberInfo memberInfo){ |
|
|
|
|
|
|
|
private void addJudge(MemberVo.MemberInfo memberInfo) { |
|
|
|
MtJudge judge = judgeDao.selectByPrimaryKey(memberInfo.getId()); |
|
|
|
if(ObjectUtil.isNull(judge)){ |
|
|
|
if (ObjectUtil.isNull(judge)) { |
|
|
|
judge = new MtJudge(); |
|
|
|
BeanUtil.copyProperties(memberInfo,judge); |
|
|
|
BeanUtil.copyProperties(memberInfo, judge); |
|
|
|
judgeDao.insertSelective(judge); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 提交单项评分 |
|
|
|
* |
|
|
|
* @param userId |
|
|
|
* @param submitOnlyOneScore |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void submitOnlyOneScore(Long userId, ScoreDto.SubmitOnlyOneScore submitOnlyOneScore) { |
|
|
|
if(ObjectUtil.isNull(userId)){ |
|
|
|
if (ObjectUtil.isNull(userId)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_LOGIN); |
|
|
|
} |
|
|
|
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(submitOnlyOneScore.getTaskId()); |
|
|
|
if(ObjectUtil.isNull(taskInfo)){ |
|
|
|
if (ObjectUtil.isNull(taskInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
JsonResponse<MemberVo.MemberInfo> jMemberInfo = tallFeignClient.getMemberByUserId(userId,taskInfo.getProjectId()); |
|
|
|
if(ObjectUtil.isNull(jMemberInfo)){ |
|
|
|
JsonResponse<MemberVo.MemberInfo> jMemberInfo = tallFeignClient.getMemberByUserId(userId, taskInfo.getProjectId()); |
|
|
|
if (ObjectUtil.isNull(jMemberInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
|
} |
|
|
|
MemberVo.MemberInfo memberInfo = jMemberInfo.getData(); |
|
|
|
if(ObjectUtil.isNull(memberInfo)){ |
|
|
|
if (ObjectUtil.isNull(memberInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_MEMBER); |
|
|
|
} |
|
|
|
//添加评委
|
|
|
@ -187,6 +198,7 @@ public class ScoreService implements IScoreService{ |
|
|
|
MtScore score = new MtScore(); |
|
|
|
score.setId(snowflake.nextId()); |
|
|
|
score.setJudgeUserId(memberInfo.getId()); |
|
|
|
score.setProjectId(taskInfo.getProjectId()); |
|
|
|
score.setTaskId(taskInfo.getId()); |
|
|
|
score.setTaskName(taskInfo.getName()); |
|
|
|
score.setScore(submitOnlyOneScore.getScore()); |
|
|
@ -200,37 +212,46 @@ public class ScoreService implements IScoreService{ |
|
|
|
|
|
|
|
/** |
|
|
|
* 查看评分 |
|
|
|
* |
|
|
|
* @param userId |
|
|
|
* @param roleId |
|
|
|
* @param playerId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<ScoreVo.AdminScore> adminScore(Long userId, Long roleId, Long playerId) { |
|
|
|
List<ScoreVo.AdminScore> adminScoreList = new ArrayList<>(); |
|
|
|
ScoreVo.AdminScore adminScore = null; |
|
|
|
//
|
|
|
|
public ScoreVo.AdminScore adminScore(Long userId, Long roleId, Long playerId) { |
|
|
|
ScoreVo.AdminScore adminScore = new ScoreVo.AdminScore(); |
|
|
|
List<ScoreVo._adminScoreList> judgeScoreList = new ArrayList<>(); |
|
|
|
ScoreVo._adminScoreList judgeScore = new ScoreVo._adminScoreList(); |
|
|
|
// Score scoreMax = scoreDao.maxScore(playerId);//最高分
|
|
|
|
// Score scoreMin = scoreDao.minScore(playerId);//最低分
|
|
|
|
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(playerId); |
|
|
|
if(ObjectUtil.isNull(taskInfo)){ |
|
|
|
if (ObjectUtil.isNull(taskInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
//总分
|
|
|
|
BigDecimal totalScore = BigDecimal.valueOf(0); |
|
|
|
//获取项目下的所有评委
|
|
|
|
MtJudgeExample judgeExample = new MtJudgeExample(); |
|
|
|
judgeExample.createCriteria().andProjectIdEqualTo(taskInfo.getProjectId()); |
|
|
|
List<MtJudge> judgeList = judgeDao.selectByExample(judgeExample); |
|
|
|
if(CollectionUtil.isNotEmpty(judgeList)){ |
|
|
|
for(MtJudge mtJudge:judgeList){ |
|
|
|
BigDecimal score = scoreDao.sumScoreByJudgeId(mtJudge.getId(),taskInfo.getId()); |
|
|
|
adminScore = new ScoreVo.AdminScore(); |
|
|
|
|
|
|
|
adminScore.setJudge(mtJudge.getId()); |
|
|
|
adminScore.setScore(score); |
|
|
|
adminScore.setJudgeName(mtJudge.getNickname()); |
|
|
|
adminScoreList.add(adminScore); |
|
|
|
if (CollectionUtil.isNotEmpty(judgeList)) { |
|
|
|
for (MtJudge mtJudge : judgeList) { |
|
|
|
BigDecimal score = scoreDao.sumScoreByJudgeId(mtJudge.getId(), taskInfo.getId()); |
|
|
|
judgeScore = new ScoreVo._adminScoreList(); |
|
|
|
|
|
|
|
judgeScore.setJudge(mtJudge.getId()); |
|
|
|
judgeScore.setScore(score); |
|
|
|
judgeScore.setJudgeName(mtJudge.getNickname()); |
|
|
|
judgeScoreList.add(judgeScore); |
|
|
|
if (ObjectUtil.isNotNull(score)) { |
|
|
|
totalScore = totalScore.add(score); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return adminScoreList; |
|
|
|
adminScore.setTotalScore(totalScore); |
|
|
|
adminScore.setJudgeScore(judgeScoreList); |
|
|
|
return adminScore; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -240,47 +261,57 @@ public class ScoreService implements IScoreService{ |
|
|
|
public List<ScoreVo.RankingScore> getRanking(Long projectId) { |
|
|
|
//获取所有参赛任务
|
|
|
|
Set<Long> taskIdList = new HashSet<>(); |
|
|
|
|
|
|
|
MtScoreLogExample scoreLogExample = new MtScoreLogExample(); |
|
|
|
scoreLogExample.createCriteria().andProjectIdEqualTo(projectId); |
|
|
|
List<MtScoreLog> scoreLogList = scoreLogDao.selectByExample(scoreLogExample); |
|
|
|
if(CollectionUtil.isNotEmpty(scoreLogList)){ |
|
|
|
for(MtScoreLog scoreLog : scoreLogList){ |
|
|
|
if (CollectionUtil.isNotEmpty(scoreLogList)) { |
|
|
|
for (MtScoreLog scoreLog : scoreLogList) { |
|
|
|
MtScoreExample scoreExample = new MtScoreExample(); |
|
|
|
scoreExample.createCriteria().andScoreLogIdEqualTo(scoreLog.getId()); |
|
|
|
List<MtScore> scoreList = scoreDao.selectByExample(scoreExample); |
|
|
|
if(CollectionUtil.isNotEmpty(scoreList)){ |
|
|
|
for(MtScore score : scoreList){ |
|
|
|
if (CollectionUtil.isNotEmpty(scoreList)) { |
|
|
|
for (MtScore score : scoreList) { |
|
|
|
taskIdList.add(score.getTaskId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
MtScoreExample mtScoreExample = new MtScoreExample(); |
|
|
|
mtScoreExample.createCriteria().andProjectIdEqualTo(projectId); |
|
|
|
List<MtScore> scoreList = scoreDao.selectByExample(mtScoreExample); |
|
|
|
if (CollectionUtil.isNotEmpty(scoreList)) { |
|
|
|
for (MtScore score : scoreList) { |
|
|
|
taskIdList.add(score.getTaskId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//查找每个任务的分数
|
|
|
|
List<ScoreVo.RankingScore> rankingScoreList = new ArrayList<>(); |
|
|
|
ScoreVo.RankingScore rankingScore = null; |
|
|
|
if(CollectionUtil.isNotEmpty(taskIdList)){ |
|
|
|
for(Long taskId : taskIdList){ |
|
|
|
if (CollectionUtil.isNotEmpty(taskIdList)) { |
|
|
|
for (Long taskId : taskIdList) { |
|
|
|
rankingScore = new ScoreVo.RankingScore(); |
|
|
|
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(taskId); |
|
|
|
if(ObjectUtil.isNull(taskInfo)){ |
|
|
|
if (ObjectUtil.isNull(taskInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
rankingScore.setTaskId(taskInfo.getId()); |
|
|
|
rankingScore.setCompany(taskInfo.getName()); |
|
|
|
//获取每个评委对此任务的评分
|
|
|
|
List<ScoreVo.JudgeScore> judgeScoreList = findJudgeScore(projectId,taskInfo.getId()); |
|
|
|
List<ScoreVo.JudgeScore> judgeScoreList = findJudgeScore(projectId, taskInfo.getId()); |
|
|
|
// rankingScore.setJudgeScoreList(judgeScoreList);
|
|
|
|
|
|
|
|
//获取此任务的平均分
|
|
|
|
BigDecimal aveScore = BigDecimal.valueOf(0); |
|
|
|
if(CollectionUtil.isNotEmpty(judgeScoreList)){ |
|
|
|
for(ScoreVo.JudgeScore judgeScore : judgeScoreList){ |
|
|
|
if (CollectionUtil.isNotEmpty(judgeScoreList)) { |
|
|
|
for (ScoreVo.JudgeScore judgeScore : judgeScoreList) { |
|
|
|
aveScore = aveScore.add(judgeScore.getScore()); |
|
|
|
} |
|
|
|
aveScore = aveScore.divide(BigDecimal.valueOf(judgeScoreList.size()), 2, ROUND_HALF_UP); |
|
|
|
} |
|
|
|
rankingScore.setAveScore(aveScore); |
|
|
|
|
|
|
|
rankingScore.setJudgeScoreList(judgeScoreList); |
|
|
|
rankingScoreList.add(rankingScore); |
|
|
|
} |
|
|
|
} |
|
|
@ -314,7 +345,7 @@ public class ScoreService implements IScoreService{ |
|
|
|
if (CollectionUtil.isNotEmpty(judgeList)) { |
|
|
|
for (MtJudge judge : judgeList) { |
|
|
|
BigDecimal scoreSum = scoreDao.sumScoreByJudgeId(judge.getId(), taskId); |
|
|
|
if(ObjectUtil.isNotNull(scoreSum)) { |
|
|
|
if (ObjectUtil.isNotNull(scoreSum)) { |
|
|
|
judgeScore = new ScoreVo.JudgeScore(); |
|
|
|
judgeScore.setJudgeId(judge.getId()); |
|
|
|
judgeScore.setJudgeName(judge.getNickname()); |
|
|
@ -339,7 +370,7 @@ public class ScoreService implements IScoreService{ |
|
|
|
|
|
|
|
//项目
|
|
|
|
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(taskId); |
|
|
|
if(ObjectUtil.isNull(taskInfo)){ |
|
|
|
if (ObjectUtil.isNull(taskInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
data.setProjectId(taskInfo.getProjectId()); |
|
|
@ -347,10 +378,10 @@ public class ScoreService implements IScoreService{ |
|
|
|
data.setPlayerId(taskInfo.getId()); |
|
|
|
data.setPlayerName(taskInfo.getName()); |
|
|
|
//获取每个评委对此任务的评分
|
|
|
|
List<ScoreVo.JudgeScore> judgeScoreList = findJudgeScore(projectId,taskInfo.getId()); |
|
|
|
List<ScoreVo.JudgeScore> judgeScoreList = findJudgeScore(projectId, taskInfo.getId()); |
|
|
|
BigDecimal aveScore = BigDecimal.valueOf(0); |
|
|
|
if(CollectionUtil.isNotEmpty(judgeScoreList)){ |
|
|
|
for(ScoreVo.JudgeScore judgeScore : judgeScoreList){ |
|
|
|
if (CollectionUtil.isNotEmpty(judgeScoreList)) { |
|
|
|
for (ScoreVo.JudgeScore judgeScore : judgeScoreList) { |
|
|
|
MtJudge mtJudge = judgeDao.selectByPrimaryKey(judgeScore.getJudgeId()); |
|
|
|
|
|
|
|
judge = new SyncMessageWithShowDto.Data.Judge(); |
|
|
@ -359,7 +390,7 @@ public class ScoreService implements IScoreService{ |
|
|
|
judge.setScore(judgeScore.getScore()); |
|
|
|
judgeList.add(judge); |
|
|
|
//获取此任务的总分
|
|
|
|
if(ObjectUtil.isNotNull(judgeScore.getScore())){ |
|
|
|
if (ObjectUtil.isNotNull(judgeScore.getScore())) { |
|
|
|
aveScore = aveScore.add(judgeScore.getScore()); |
|
|
|
} |
|
|
|
} |
|
|
@ -390,14 +421,14 @@ public class ScoreService implements IScoreService{ |
|
|
|
@Override |
|
|
|
public void backScore(Long roleId, Long taskId) { |
|
|
|
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(taskId); |
|
|
|
if(ObjectUtil.isNull(taskInfo)){ |
|
|
|
if (ObjectUtil.isNull(taskInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
MtScoreExample mtScoreExample = new MtScoreExample(); |
|
|
|
mtScoreExample.createCriteria().andJudgeUserIdEqualTo(roleId).andTaskIdEqualTo(taskInfo.getId()); |
|
|
|
List<MtScore> mtScoreList = scoreDao.selectByExample(mtScoreExample); |
|
|
|
if(CollectionUtil.isNotEmpty(mtScoreList)){ |
|
|
|
for(MtScore score : mtScoreList){ |
|
|
|
if (CollectionUtil.isNotEmpty(mtScoreList)) { |
|
|
|
for (MtScore score : mtScoreList) { |
|
|
|
score.setRecStatus((byte) 2); |
|
|
|
scoreDao.updateByPrimaryKeySelective(score); |
|
|
|
} |
|
|
@ -410,43 +441,247 @@ public class ScoreService implements IScoreService{ |
|
|
|
@Override |
|
|
|
public void backScoreAll(Long taskId) { |
|
|
|
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(taskId); |
|
|
|
if(ObjectUtil.isNull(taskInfo)){ |
|
|
|
if (ObjectUtil.isNull(taskInfo)) { |
|
|
|
throw new BaseException(CodeEnum.NOT_TASK); |
|
|
|
} |
|
|
|
|
|
|
|
MtScoreExample mtScoreExample = new MtScoreExample(); |
|
|
|
mtScoreExample.createCriteria().andTaskIdEqualTo(taskInfo.getId()); |
|
|
|
List<MtScore> mtScoreList = scoreDao.selectByExample(mtScoreExample); |
|
|
|
if(CollectionUtil.isNotEmpty(mtScoreList)){ |
|
|
|
for(MtScore score : mtScoreList){ |
|
|
|
if (CollectionUtil.isNotEmpty(mtScoreList)) { |
|
|
|
for (MtScore score : mtScoreList) { |
|
|
|
score.setRecStatus((byte) 2); |
|
|
|
scoreDao.updateByPrimaryKeySelective(score); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导出签字表 |
|
|
|
* |
|
|
|
* @param projectId |
|
|
|
* @param taskId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String exportExcel(Long projectId, Long taskId) throws Exception { |
|
|
|
//返回excel地址
|
|
|
|
String excelPath = ""; |
|
|
|
//获取模板
|
|
|
|
ResourceLoader resourceLoader = new DefaultResourceLoader(); |
|
|
|
InputStream is = resourceLoader.getResource("classpath:template/judgeTemplate.xlsx").getInputStream(); |
|
|
|
XSSFWorkbook excel = new XSSFWorkbook(is); |
|
|
|
//获取任务和项目信息
|
|
|
|
TaskVo.TaskInfoWithFeign taskInfo = tallFeignClient.getProjectId(taskId); |
|
|
|
//查找项目下所有评委
|
|
|
|
MtJudgeExample judgeExample = new MtJudgeExample(); |
|
|
|
judgeExample.createCriteria().andProjectIdEqualTo(projectId); |
|
|
|
List<MtJudge> judgeList = judgeDao.selectByExample(judgeExample); |
|
|
|
if (CollectionUtil.isNotEmpty(judgeList)) { |
|
|
|
for (int i = 0; i < judgeList.size(); i++) { |
|
|
|
MtJudge judge = judgeList.get(i); |
|
|
|
writeExcel(taskInfo, judge, excel.getSheetAt(i)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//保存地址
|
|
|
|
String path = taskInfo.getName(); |
|
|
|
String dir = WebConstant.UPLOAD_PATH_BASE + File.separator + WebConstant.UPLOAD_PATH_BASE_MT_JUDGE; |
|
|
|
String extraPath = DateUtil.format(new Date(), "yyyyMMdd"); |
|
|
|
String ePath = dir + File.separator + extraPath + File.separator + path + ".xlsx"; |
|
|
|
//导出
|
|
|
|
File tmpFile = new File(dir + File.separator + extraPath); |
|
|
|
if (!tmpFile.exists()) { |
|
|
|
tmpFile.mkdirs(); |
|
|
|
} |
|
|
|
File file = new File(ePath); |
|
|
|
//将文件写入创建的file当中
|
|
|
|
OutputStream stream = new FileOutputStream(file); |
|
|
|
excel.write(stream); |
|
|
|
//关闭流
|
|
|
|
stream.close(); |
|
|
|
String rePath = WebConstant.TEST_URL_BASE_MT + WebConstant.UPLOAD_PATH_BASE_MT_JUDGE + File.separator + extraPath + File.separator + path + ".xlsx"; |
|
|
|
return rePath; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 写入excel |
|
|
|
* |
|
|
|
* @param taskInfo |
|
|
|
* @param judge |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
public void writeExcel(TaskVo.TaskInfoWithFeign taskInfo, MtJudge judge, XSSFSheet judgeSheet) throws Exception { |
|
|
|
XSSFCell industry = judgeSheet.getRow(5).getCell(3); |
|
|
|
//项目名
|
|
|
|
XSSFCell projectName = judgeSheet.getRow(5).getCell(5); |
|
|
|
projectName.setCellValue(taskInfo.getProjectName()); |
|
|
|
//任务名
|
|
|
|
XSSFCell company = judgeSheet.getRow(5).getCell(9); |
|
|
|
company.setCellValue(taskInfo.getName()); |
|
|
|
XSSFCell cell1 = judgeSheet.getRow(8).getCell(10); |
|
|
|
XSSFCell cell2 = judgeSheet.getRow(9).getCell(10); |
|
|
|
//评委名
|
|
|
|
XSSFCell judgeName = judgeSheet.getRow(10).getCell(6); |
|
|
|
judgeName.setCellValue(judge.getNickname()); |
|
|
|
|
|
|
|
MtScoreExample mtScoreExample = new MtScoreExample(); |
|
|
|
mtScoreExample.createCriteria().andJudgeUserIdEqualTo(judge.getId()).andTaskIdEqualTo(taskInfo.getId()); |
|
|
|
List<MtScore> scoreList = scoreDao.selectByExample(mtScoreExample); |
|
|
|
if (CollectionUtil.isNotEmpty(scoreList)) { |
|
|
|
for (int i = 0; i < scoreList.size(); i++) { |
|
|
|
cell1.setCellValue(scoreList.get(0).getScore().toString()); |
|
|
|
} |
|
|
|
|
|
|
|
BigDecimal score = new BigDecimal(0); |
|
|
|
for (MtScore score1 : scoreList) { |
|
|
|
score = score.add(score1.getScore()); |
|
|
|
} |
|
|
|
cell2.setCellValue(score.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 导出排名表 |
|
|
|
* @param projectId |
|
|
|
* @return |
|
|
|
* @throws Exception |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String rankingExcel(Long projectId) throws Exception { |
|
|
|
String path = ""; |
|
|
|
//获取模板
|
|
|
|
ResourceLoader resourceLoader = new DefaultResourceLoader(); |
|
|
|
InputStream is = resourceLoader.getResource("classpath:template/rankingTemplate.xlsx").getInputStream(); |
|
|
|
XSSFWorkbook excel = new XSSFWorkbook(is); |
|
|
|
XSSFSheet sheet = excel.getSheetAt(0); |
|
|
|
List<ScoreVo.RankingScore> rankingScoreList = getRanking(projectId); |
|
|
|
if(CollectionUtil.isNotEmpty(rankingScoreList)){ |
|
|
|
for(int i=0; i<rankingScoreList.size(); i++){ |
|
|
|
ScoreVo.RankingScore rankingScore = rankingScoreList.get(i); |
|
|
|
XSSFCell no = sheet.getRow(i+1).getCell(0); |
|
|
|
XSSFCell taskName = sheet.getRow(i+1).getCell(1); |
|
|
|
XSSFCell aveScore = sheet.getRow(i+1).getCell(2); |
|
|
|
no.setCellValue(i+1); |
|
|
|
taskName.setCellValue(rankingScore.getCompany()); |
|
|
|
aveScore.setCellValue(rankingScore.getAveScore().toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
//保存地址
|
|
|
|
String filePath = SecureUtil.simpleUUID(); |
|
|
|
String dir = WebConstant.UPLOAD_PATH_BASE + File.separator + WebConstant.UPLOAD_PATH_BASE_MT_JUDGE; |
|
|
|
String extraPath = DateUtil.format(new Date(), "yyyyMMdd"); |
|
|
|
String ePath = dir + File.separator + extraPath + File.separator + filePath + ".xlsx"; |
|
|
|
//导出
|
|
|
|
File tmpFile = new File(dir + File.separator + extraPath); |
|
|
|
if (!tmpFile.exists()) { |
|
|
|
tmpFile.mkdirs(); |
|
|
|
} |
|
|
|
File file = new File(ePath); |
|
|
|
//将文件写入创建的file当中
|
|
|
|
OutputStream stream = new FileOutputStream(file); |
|
|
|
excel.write(stream); |
|
|
|
//关闭流
|
|
|
|
stream.close(); |
|
|
|
path = WebConstant.TEST_URL_BASE_MT + WebConstant.UPLOAD_PATH_BASE_MT_JUDGE + File.separator + extraPath + File.separator + filePath + ".xlsx"; |
|
|
|
return path; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取总评分表 |
|
|
|
* @param projectId |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String rankingAllExcel(Long projectId) throws Exception{ |
|
|
|
//获取模板
|
|
|
|
ResourceLoader resourceLoader = new DefaultResourceLoader(); |
|
|
|
InputStream is = resourceLoader.getResource("classpath:template/gradeTemplate.xlsx").getInputStream(); |
|
|
|
XSSFWorkbook excel = new XSSFWorkbook(is); |
|
|
|
XSSFSheet sheet = excel.getSheetAt(0); |
|
|
|
//获取排名信息
|
|
|
|
List<ScoreVo.RankingScore> rankingScoreList = getRanking(projectId); |
|
|
|
//获取所有评委信息
|
|
|
|
//获取项目下的所有评委
|
|
|
|
int a = 2; |
|
|
|
MtJudgeExample judgeExample = new MtJudgeExample(); |
|
|
|
judgeExample.createCriteria().andProjectIdEqualTo(projectId); |
|
|
|
List<MtJudge> judgeList = judgeDao.selectByExample(judgeExample); |
|
|
|
if(CollectionUtil.isNotEmpty(judgeList)){ |
|
|
|
for(MtJudge judge:judgeList){ |
|
|
|
XSSFCell judgeName = sheet.getRow(0).getCell(a); |
|
|
|
judgeName.setCellValue(judge.getNickname()); |
|
|
|
a++; |
|
|
|
} |
|
|
|
XSSFCell aveScore = sheet.getRow(0).getCell(a); |
|
|
|
aveScore.setCellValue("平均分"); |
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtil.isNotEmpty(rankingScoreList)){ |
|
|
|
int index = 1; |
|
|
|
for(ScoreVo.RankingScore rankingScore : rankingScoreList){ |
|
|
|
XSSFCell taskName = sheet.getRow(index).getCell(1); |
|
|
|
taskName.setCellValue(rankingScore.getCompany()); |
|
|
|
if(CollectionUtil.isNotEmpty(rankingScore.getJudgeScoreList())){ |
|
|
|
for(int i = 2; i < a; i++){ |
|
|
|
String judgeName = ExcelUtil.getCellValue(sheet.getRow(0).getCell(i)); |
|
|
|
for(ScoreVo.JudgeScore judgeScore : rankingScore.getJudgeScoreList()){ |
|
|
|
if(judgeName.equalsIgnoreCase(judgeScore.getJudgeName())){ |
|
|
|
XSSFCell score = sheet.getRow(index).getCell(i); |
|
|
|
score.setCellValue(judgeScore.getScore().toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
XSSFCell aveScore = sheet.getRow(index).getCell(a); |
|
|
|
aveScore.setCellValue(rankingScore.getAveScore().toString()); |
|
|
|
index++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//保存地址
|
|
|
|
String filePath = SecureUtil.simpleUUID(); |
|
|
|
String dir = WebConstant.UPLOAD_PATH_BASE + File.separator + WebConstant.UPLOAD_PATH_BASE_MT_JUDGE; |
|
|
|
String extraPath = DateUtil.format(new Date(), "yyyyMMdd"); |
|
|
|
String ePath = dir + File.separator + extraPath + File.separator + filePath + ".xlsx"; |
|
|
|
//导出
|
|
|
|
File tmpFile = new File(dir + File.separator + extraPath); |
|
|
|
if (!tmpFile.exists()) { |
|
|
|
tmpFile.mkdirs(); |
|
|
|
} |
|
|
|
File file = new File(ePath); |
|
|
|
//将文件写入创建的file当中
|
|
|
|
OutputStream stream = new FileOutputStream(file); |
|
|
|
excel.write(stream); |
|
|
|
//关闭流
|
|
|
|
stream.close(); |
|
|
|
String path = WebConstant.TEST_URL_BASE_MT + WebConstant.UPLOAD_PATH_BASE_MT_JUDGE + File.separator + extraPath + File.separator + filePath + ".xlsx"; |
|
|
|
return path; |
|
|
|
} |
|
|
|
|
|
|
|
/*=====================================================*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
public BigDecimal getMemberScore(Long taskId, Long userId) { |
|
|
|
BigDecimal score = null; |
|
|
|
BigDecimal scoreSum = scoreDao.sumScoreByJudgeId(userId, taskId); |
|
|
|
if(ObjectUtil.isNotNull(scoreSum)){ |
|
|
|
if (ObjectUtil.isNotNull(scoreSum)) { |
|
|
|
score = scoreSum; |
|
|
|
} |
|
|
|
return score; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public BigDecimal getAdminScore(Long projectId,Long taskId) { |
|
|
|
public BigDecimal getAdminScore(Long projectId, Long taskId) { |
|
|
|
BigDecimal aveScore = null; |
|
|
|
//获取每个评委对此任务的评分
|
|
|
|
List<ScoreVo.JudgeScore> judgeScoreList = findJudgeScore(projectId,taskId); |
|
|
|
if(CollectionUtil.isNotEmpty(judgeScoreList)){ |
|
|
|
List<ScoreVo.JudgeScore> judgeScoreList = findJudgeScore(projectId, taskId); |
|
|
|
if (CollectionUtil.isNotEmpty(judgeScoreList)) { |
|
|
|
aveScore = BigDecimal.valueOf(0); |
|
|
|
for(ScoreVo.JudgeScore judgeScore : judgeScoreList){ |
|
|
|
for (ScoreVo.JudgeScore judgeScore : judgeScoreList) { |
|
|
|
//获取此任务的总分
|
|
|
|
if(ObjectUtil.isNotNull(judgeScore.getScore())){ |
|
|
|
if (ObjectUtil.isNotNull(judgeScore.getScore())) { |
|
|
|
aveScore = aveScore.add(judgeScore.getScore()); |
|
|
|
} |
|
|
|
} |
|
|
|