|
|
@@ -0,0 +1,119 @@
|
|
|
+package cn.iselab.mooctest.site.service.impl;
|
|
|
+
|
|
|
+import cn.iselab.mooctest.site.common.enums.ScoreRuleKey;
|
|
|
+import cn.iselab.mooctest.site.dao.GradeDao;
|
|
|
+import cn.iselab.mooctest.site.dao.ManagerDao;
|
|
|
+import cn.iselab.mooctest.site.dao.WeightDao;
|
|
|
+import cn.iselab.mooctest.site.dao.fromKibug.CaseTakeDao;
|
|
|
+import cn.iselab.mooctest.site.dao.fromKibug.ManagerScoreDao;
|
|
|
+import cn.iselab.mooctest.site.dao.fromKibug.ScriptAutoResultDao;
|
|
|
+import cn.iselab.mooctest.site.models.Grade;
|
|
|
+import cn.iselab.mooctest.site.models.Weight;
|
|
|
+import cn.iselab.mooctest.site.models.fromKibug.CaseTake;
|
|
|
+import cn.iselab.mooctest.site.models.fromKibug.ManagerScore;
|
|
|
+import cn.iselab.mooctest.site.models.fromKibug.ScoreRule;
|
|
|
+import cn.iselab.mooctest.site.models.fromKibug.ScriptAutoResult;
|
|
|
+import cn.iselab.mooctest.site.service.CalculateScoreService;
|
|
|
+import cn.iselab.mooctest.site.web.data.fromKibug.ScoreRuleItemVO;
|
|
|
+import cn.iselab.mooctest.site.web.data.fromKibug.ScoreRuleVO;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by HenryLee on 2017/7/10.
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CalculateScoreServiceImpl implements CalculateScoreService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CaseTakeDao caseTakeDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ScriptAutoResultDao scriptAutoResultDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ManagerScoreDao managerScoreDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WeightDao weightDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GradeDao gradeDao;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void calculateManual(long taskId, long caseId) {
|
|
|
+ List<CaseTake> caseTakeList=caseTakeDao.findByTaskIdAndCaseId(taskId, caseId);
|
|
|
+ for(CaseTake caseTake:caseTakeList){
|
|
|
+ List<ManagerScore> managerScoreList=managerScoreDao.findByCaseTakeId(caseTake.getId());
|
|
|
+ int sum=0;
|
|
|
+ int count=0;
|
|
|
+ for(ManagerScore managerScore:managerScoreList){
|
|
|
+ sum+=managerScore.getScore();
|
|
|
+ count+=1;
|
|
|
+ }
|
|
|
+ float avg=0.0f;
|
|
|
+ if(count!=0){
|
|
|
+ avg=sum/count;
|
|
|
+ }
|
|
|
+ caseTake.setManual(avg);
|
|
|
+ caseTakeDao.save(caseTake);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void calculateScript(long taskId, long caseId) {
|
|
|
+ List<CaseTake> caseTakeList=caseTakeDao.findByTaskIdAndCaseId(taskId, caseId);
|
|
|
+ for(CaseTake caseTake:caseTakeList){
|
|
|
+ List<ScriptAutoResult> scriptAutoResults=scriptAutoResultDao.findByCaseTakeId(caseTake.getId());
|
|
|
+ int max=0;
|
|
|
+ for(ScriptAutoResult scriptAutoResult:scriptAutoResults){
|
|
|
+ if(scriptAutoResult.getScore()>max)
|
|
|
+ max=scriptAutoResult.getScore();
|
|
|
+ }
|
|
|
+ caseTake.setScript(max);
|
|
|
+ System.out.println(max);
|
|
|
+ caseTakeDao.save(caseTake);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void calculateTotal(long taskId, long caseId,List<ScoreRuleItemVO> scoreRule) {
|
|
|
+ List<CaseTake> caseTakeList=caseTakeDao.findByTaskIdAndCaseId(taskId, caseId);
|
|
|
+ for(CaseTake caseTake:caseTakeList){
|
|
|
+ float manual=caseTake.getManual();
|
|
|
+ float script=caseTake.getScript();
|
|
|
+ int manualPercentage=0;
|
|
|
+ int scriptPercentage=0;
|
|
|
+ for(ScoreRuleItemVO sr:scoreRule){
|
|
|
+ if(sr.getName().equals(ScoreRuleKey.MANUAL.toString())){
|
|
|
+ manualPercentage=sr.getPercentage();
|
|
|
+ }else if(sr.getName().equals(ScoreRuleKey.SCRIPT.toString())){
|
|
|
+ scriptPercentage=sr.getPercentage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ caseTake.setTotal(manual*manualPercentage + script*scriptPercentage / 100);
|
|
|
+ caseTakeDao.save(caseTake);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void calculateDevScore(long taskId, long caseId) {
|
|
|
+ List<Grade> grades=gradeDao.findByTaskIdAndCaseId(taskId,caseId);
|
|
|
+ Weight weight=weightDao.findByTidAndCid(taskId, caseId);
|
|
|
+ for(Grade grade:grades){
|
|
|
+ double totle=0.0;
|
|
|
+ totle=grade.getSc()*weight.getSc()
|
|
|
+ +grade.getBc()*weight.getBc()
|
|
|
+ +grade.getPpc()*weight.getPpc()
|
|
|
+ +grade.getMc_dc()*weight.getMc_dc()
|
|
|
+ +grade.getAu()*weight.getAu()
|
|
|
+ +grade.getAd()*weight.getAd()
|
|
|
+ +grade.getAdu()*weight.getAdu()
|
|
|
+ +grade.getApfd()*weight.getApfd()
|
|
|
+ +grade.getMutation()*weight.getMutationcom();
|
|
|
+ grade.setScore(totle);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|