|
|
|
@ -19,6 +19,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
@ -44,11 +45,41 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
|
|
|
|
|
return trainingScores.get(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public SysTrainingScore checkStatusAndControlsName(Long userId, String controlsName) {
|
|
|
|
|
SysTrainingScoreExample example = new SysTrainingScoreExample();
|
|
|
|
|
SysTrainingScoreExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
criteria.andUseridEqualTo(userId);
|
|
|
|
|
List<SysTrainingScore> trainingScores = trainingScoreMapper.selectByExample(example);
|
|
|
|
|
SysTrainingScore sysTrainingScore = trainingScores.get(0);
|
|
|
|
|
if (sysTrainingScore.getStatus() == 1) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
if (sysTrainingScore.get(controlsName) == null || ("").equals(sysTrainingScore.get(controlsName))) {
|
|
|
|
|
Map<String, Integer> trainingScoreConstantsMap = TrainingScoreConstants.getTrainingScoreConstantsMap();
|
|
|
|
|
Integer score = trainingScoreConstantsMap.get(controlsName);
|
|
|
|
|
SysTrainingScore trainingScore = new SysTrainingScore();
|
|
|
|
|
trainingScore.setId(sysTrainingScore.getId());
|
|
|
|
|
trainingScore.set(controlsName, String.valueOf(score));
|
|
|
|
|
trainingScoreMapper.updateByPrimaryKeySelective(trainingScore);
|
|
|
|
|
sysTrainingScore.set(controlsName, String.valueOf(score));
|
|
|
|
|
return sysTrainingScore;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateByPrimaryKeySelective(SysTrainingScore trainingScore) {
|
|
|
|
|
trainingScoreMapper.updateByPrimaryKeySelective(trainingScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public PageInfo<ReportDto> teacherGetReport(Integer index, Integer size, Double reportWeight, Double operatorWeight, String keyWord, String stuClass) {
|
|
|
|
|
PageHelper.startPage(index, size);
|
|
|
|
|
List<ReportDto> reportDtoList = new ArrayList<>();
|
|
|
|
|
double total = 100;
|
|
|
|
|
SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample();
|
|
|
|
|
if (stuClass != null || keyWord != null) {
|
|
|
|
|
List<SysUser> users = sysUserMapper.selectByNameStuNum(stuClass, keyWord);
|
|
|
|
@ -57,7 +88,7 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
|
|
|
|
|
List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(trainingScoreExample);
|
|
|
|
|
if (!sysTrainingScores.isEmpty()) {
|
|
|
|
|
SysTrainingScore sysTrainingScore = sysTrainingScores.get(0);
|
|
|
|
|
ReportDto reportDto = createReportDto(sysTrainingScore, user, total);
|
|
|
|
|
ReportDto reportDto = createReportDto(sysTrainingScore, user, reportWeight, operatorWeight);
|
|
|
|
|
reportDtoList.add(reportDto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -69,7 +100,7 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
|
|
|
|
|
List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(trainingScoreExample);
|
|
|
|
|
if (!sysTrainingScores.isEmpty()) {
|
|
|
|
|
SysTrainingScore sysTrainingScore = sysTrainingScores.get(0);
|
|
|
|
|
ReportDto reportDto = createReportDto(sysTrainingScore, sysUser, total);
|
|
|
|
|
ReportDto reportDto = createReportDto(sysTrainingScore, sysUser, reportWeight, operatorWeight);
|
|
|
|
|
reportDtoList.add(reportDto);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -82,34 +113,51 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public SysTrainingScore checkStatusAndControlsName(Long userId, String controlsName) {
|
|
|
|
|
SysTrainingScoreExample example = new SysTrainingScoreExample();
|
|
|
|
|
SysTrainingScoreExample.Criteria criteria = example.createCriteria();
|
|
|
|
|
criteria.andUseridEqualTo(userId);
|
|
|
|
|
List<SysTrainingScore> trainingScores = trainingScoreMapper.selectByExample(example);
|
|
|
|
|
SysTrainingScore sysTrainingScore = trainingScores.get(0);
|
|
|
|
|
if (sysTrainingScore.getStatus() == 1) {
|
|
|
|
|
return null;
|
|
|
|
|
} else {
|
|
|
|
|
if (sysTrainingScore.get(controlsName) == null || ("").equals(sysTrainingScore.get(controlsName))) {
|
|
|
|
|
Map<String, Integer> trainingScoreConstantsMap = TrainingScoreConstants.getTrainingScoreConstantsMap();
|
|
|
|
|
Integer score = trainingScoreConstantsMap.get(controlsName);
|
|
|
|
|
SysTrainingScore trainingScore = new SysTrainingScore();
|
|
|
|
|
trainingScore.setId(sysTrainingScore.getId());
|
|
|
|
|
trainingScore.set(controlsName, String.valueOf(score));
|
|
|
|
|
trainingScoreMapper.updateByPrimaryKeySelective(trainingScore);
|
|
|
|
|
sysTrainingScore.set(controlsName, String.valueOf(score));
|
|
|
|
|
return sysTrainingScore;
|
|
|
|
|
// 算分
|
|
|
|
|
private ReportDto createReportDto(SysTrainingScore sysTrainingScore, SysUser user, Double reportWeight, Double operatorWeight) {
|
|
|
|
|
ReportDto reportDto = new ReportDto();
|
|
|
|
|
reportDto.setFileName(sysTrainingScore.getReportFilename());
|
|
|
|
|
Integer reportSubmissionScore = sysTrainingScore.getReportSubmissionScore(); // 报告成绩
|
|
|
|
|
reportDto.setReportSubmissionScore(reportSubmissionScore);
|
|
|
|
|
Integer trainingOperationScore = sysTrainingScore.getTrainingOperationScore(); // 操作成绩
|
|
|
|
|
reportDto.setTrainingOperationScore(trainingOperationScore);
|
|
|
|
|
reportDto.setName(user.getUserName());
|
|
|
|
|
reportDto.setStuClass(user.getStuClass());
|
|
|
|
|
reportDto.setStuNumber(user.getStudentNumber());
|
|
|
|
|
reportDto.setUserId(user.getUserId());
|
|
|
|
|
if (reportSubmissionScore != null && trainingOperationScore != null) {
|
|
|
|
|
SysGradeWeight sysGradeWeight = gradeWeightMapper.selectByPrimaryKey(1L);
|
|
|
|
|
Double oldReportWeight = sysGradeWeight.getReportWeight();
|
|
|
|
|
Double oldOperatorWeight = sysGradeWeight.getOperatorWeight();
|
|
|
|
|
if (reportWeight != null) {
|
|
|
|
|
sysGradeWeight.setReportWeight(reportWeight);
|
|
|
|
|
} else if (oldReportWeight != null) {
|
|
|
|
|
reportWeight = oldReportWeight;
|
|
|
|
|
} else {
|
|
|
|
|
reportWeight = 0.1; // 设置默认权重
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
|
|
if (operatorWeight != null) {
|
|
|
|
|
sysGradeWeight.setOperatorWeight(operatorWeight);
|
|
|
|
|
} else if (oldOperatorWeight != null) {
|
|
|
|
|
operatorWeight = oldOperatorWeight;
|
|
|
|
|
} else {
|
|
|
|
|
operatorWeight = 0.9; // 设置默认权重
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Double totalScore = (reportSubmissionScore * reportWeight) + (trainingOperationScore * operatorWeight);
|
|
|
|
|
reportDto.setScoreTotal(totalScore);
|
|
|
|
|
sysTrainingScore.setTotalscore(totalScore);
|
|
|
|
|
trainingScoreMapper.updateByPrimaryKeySelective(sysTrainingScore);
|
|
|
|
|
gradeWeightMapper.updateByPrimaryKeySelective(sysGradeWeight);
|
|
|
|
|
} else {
|
|
|
|
|
reportDto.setScoreTotal(null);
|
|
|
|
|
}
|
|
|
|
|
return reportDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void updateByPrimaryKeySelective(SysTrainingScore trainingScore) {
|
|
|
|
|
trainingScoreMapper.updateByPrimaryKeySelective(trainingScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//上传
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult uploadReport(MultipartFile file, String fileName, Long id) {
|
|
|
|
|
String filePath = fileUtil.upload(file);
|
|
|
|
@ -139,6 +187,8 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//提交
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult submitReport(String content, Long userId) {
|
|
|
|
|
SysTrainingScoreExample trainingScoreExample = new SysTrainingScoreExample();
|
|
|
|
@ -156,40 +206,31 @@ public class SysTrainingScoreServiceImpl implements ISysTrainingScoreService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private ReportDto createReportDto(SysTrainingScore sysTrainingScore, SysUser user, Double toatle) {
|
|
|
|
|
ReportDto reportDto = new ReportDto();
|
|
|
|
|
reportDto.setFileName(sysTrainingScore.getReportFilename());
|
|
|
|
|
Integer reportSubmissionScore = sysTrainingScore.getReportSubmissionScore(); // 报告成绩
|
|
|
|
|
reportDto.setReportSubmissionScore(reportSubmissionScore);
|
|
|
|
|
Integer trainingOperationScore = sysTrainingScore.getTrainingOperationScore(); // 操作成绩
|
|
|
|
|
reportDto.setTrainingOperationScore(trainingOperationScore);
|
|
|
|
|
SysGradeWeight sysGradeWeight = gradeWeightMapper.selectByPrimaryKey(1L);
|
|
|
|
|
Double reportWeight = sysGradeWeight.getReportWeight();
|
|
|
|
|
Double operatorWeight = sysGradeWeight.getOperatorWeight();
|
|
|
|
|
if (reportWeight == null) {
|
|
|
|
|
reportWeight = 0.1;
|
|
|
|
|
}
|
|
|
|
|
if (operatorWeight == null) {
|
|
|
|
|
operatorWeight = 0.9;
|
|
|
|
|
}
|
|
|
|
|
if (reportSubmissionScore != null && trainingOperationScore != null) {
|
|
|
|
|
Double totalScore = (reportSubmissionScore * reportWeight) + (trainingOperationScore * operatorWeight); // 总成绩=实训操作成绩*权重+实训报告成绩*权重
|
|
|
|
|
reportDto.setScoreTotal(totalScore);
|
|
|
|
|
// sysTrainingScore
|
|
|
|
|
} else {
|
|
|
|
|
reportDto.setScoreTotal(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reportDto.setName(user.getUserName());
|
|
|
|
|
reportDto.setStuClass(user.getStuClass());
|
|
|
|
|
reportDto.setStuNumber(user.getStudentNumber());
|
|
|
|
|
|
|
|
|
|
return reportDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<String> selectClass() {
|
|
|
|
|
return sysUserMapper.selectClass();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public AjaxResult downloadReport(HttpServletResponse response, Long id) {
|
|
|
|
|
// 根据id获取文件路径信息
|
|
|
|
|
SysTrainingScoreExample sysTrainingScoreExample = new SysTrainingScoreExample();
|
|
|
|
|
sysTrainingScoreExample.createCriteria().andUseridEqualTo(id);
|
|
|
|
|
List<SysTrainingScore> sysTrainingScores = trainingScoreMapper.selectByExample(sysTrainingScoreExample);
|
|
|
|
|
|
|
|
|
|
if (sysTrainingScores.isEmpty()) {
|
|
|
|
|
return AjaxResult.error(404,"报告不存在");
|
|
|
|
|
}
|
|
|
|
|
SysTrainingScore sysTrainingScore = sysTrainingScores.get(0);
|
|
|
|
|
String filePath = sysTrainingScore.getReportUploadPath();
|
|
|
|
|
String fileName = sysTrainingScore.getReportFilename();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// 下载文件
|
|
|
|
|
fileUtil.download(response, fileName, filePath);
|
|
|
|
|
} catch (IllegalArgumentException e) {
|
|
|
|
|
return AjaxResult.error(400,"下载失败");
|
|
|
|
|
}
|
|
|
|
|
return AjaxResult.success("下载成功");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|