|
|
@@ -26,6 +26,7 @@ import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
+import org.omg.CORBA.INTERNAL;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
import org.springframework.validation.BindingResult;
|
|
|
@@ -37,6 +38,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -278,6 +280,22 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
return CommonResult.fail("选择的用户身份非学生,无法添加成绩");
|
|
|
}
|
|
|
|
|
|
+ SmartSubject subject = smartSubjectService.getSmartById(isr.getSubjectId());
|
|
|
+ if (subject == null) {
|
|
|
+ return CommonResult.fail(subject.getName() + "的科目数据为空,新增成绩失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartExamtype examtype = smartExamtypeService.getSmartById(isr.getExamType());
|
|
|
+ if (examtype == null) {
|
|
|
+ return CommonResult.fail(examtype.getName() + "的考试类型数据为空,新增成绩失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //成绩去重判断 一个学生同一个学期同一个考试类型同一个科目只能加一次
|
|
|
+ int existCount = smartScoreService.getExistScore(isr.getUserId(), isr.getSemesterId(), isr.getExamType(), isr.getSubjectId());
|
|
|
+ if (existCount > 0) {
|
|
|
+ return CommonResult.ok(user.getName() + "的" + isr.getSemester() + "的" + examtype.getName() + "的" + subject.getName() + "的成绩在系统中已存在");
|
|
|
+ }
|
|
|
+
|
|
|
SmartScore ss = new SmartScore();
|
|
|
ss.setSemester(isr.getSemester());
|
|
|
ss.setSemesterId(isr.getSemesterId());
|
|
|
@@ -293,8 +311,58 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
ss.setScore(isr.getScore());
|
|
|
|
|
|
int result = smartScoreService.insertSmartScore(ss);
|
|
|
+ if (result <= 0) {
|
|
|
+ return CommonResult.fail("添加失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartExamtype examType = smartExamtypeService.getSmartById(isr.getExamType());
|
|
|
+ if (examType == null) {
|
|
|
+ return CommonResult.fail("考试类型数据为空,添加失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //学生综合评价中是否存在历史数据
|
|
|
+ //更新综合素质评价
|
|
|
+ SmartEvaluateStudent evaStudent = smartEvaluateStudentService.getEvaluateStudent(isr.getUserId(), isr.getSemesterId(), isr.getExamType());
|
|
|
+ if (evaStudent != null) {
|
|
|
+ BigDecimal scoreNum = new BigDecimal(evaStudent.getScoreNum()).add(new BigDecimal(isr.getScore()));
|
|
|
+ evaStudent.setScoreNum(scoreNum.doubleValue());
|
|
|
+ int updateEva = smartEvaluateStudentService.updateSmartEvaluateStudent(evaStudent);
|
|
|
+ if (updateEva <= 0) {
|
|
|
+ return CommonResult.fail("添加失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //region 添加到学生综合素质评价表中
|
|
|
+ SmartEvaluateStudent ses = new SmartEvaluateStudent();
|
|
|
+ ses.setTermId(isr.getSemesterId());
|
|
|
+ ses.setTerm(isr.getSemester());
|
|
|
+ ses.setGradeName(isr.getGrade());
|
|
|
+ ses.setGradeId(isr.getGradeId());
|
|
|
+ ses.setExamType(examType == null ? "" : examType.getName());
|
|
|
+ ses.setExamTypeId(isr.getExamType());
|
|
|
+ ses.setClassId(isr.getSchoolClassId());
|
|
|
+ ses.setClassName(isr.getSchoolClass());
|
|
|
+ ses.setCardNo(isr.getCardNo());
|
|
|
+ ses.setName(user.getName());
|
|
|
+ ses.setUserId(isr.getUserId());
|
|
|
+
|
|
|
+ BigDecimal totalScore = new BigDecimal(0.0);
|
|
|
+ List<SmartScore> userScores = smartScoreService.getScores(isr.getUserId(), isr.getSemesterId(), isr.getExamType());
|
|
|
+ for (SmartScore userScore : userScores) {
|
|
|
+ totalScore.add(new BigDecimal(userScore.getScore()));
|
|
|
+ }
|
|
|
+
|
|
|
+ totalScore = totalScore.add(new BigDecimal(isr.getScore()));
|
|
|
+ ses.setScoreNum(totalScore.doubleValue());//分数要计算 已经加进去的成绩的
|
|
|
|
|
|
- return result > 0 ? CommonResult.ok("添加成功") : CommonResult.fail("添加失败");
|
|
|
+ Integer insertStudent = smartEvaluateStudentService.insertSmartEvaluateStudent(ses);
|
|
|
+
|
|
|
+ if (insertStudent <= 0) {
|
|
|
+ return CommonResult.fail("添加失败");
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ return CommonResult.ok("添加成功");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -310,6 +378,60 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
return CommonResult.fail("成绩数据无效,无法编辑");
|
|
|
}
|
|
|
|
|
|
+ //更新综合素质评价
|
|
|
+ SmartEvaluateStudent evaStudent = smartEvaluateStudentService.getEvaluateStudent(usr.getUserId(), usr.getSemesterId(), usr.getExamType());
|
|
|
+ if (evaStudent != null) {
|
|
|
+ BigDecimal scoreNum = new BigDecimal(evaStudent.getScoreNum());
|
|
|
+ scoreNum = scoreNum.subtract(scoreNum);
|
|
|
+ scoreNum = scoreNum.add(new BigDecimal(usr.getScore()));
|
|
|
+
|
|
|
+ evaStudent.setScoreNum(scoreNum.doubleValue());
|
|
|
+
|
|
|
+ int updateStudent = smartEvaluateStudentService.updateSmartEvaluateStudent(evaStudent);
|
|
|
+ if (updateStudent <= 0) {
|
|
|
+ return CommonResult.fail("编辑失败");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //判断学生是否有效
|
|
|
+ SmartUser user = smartUserService.getSmartById(usr.getUserId());
|
|
|
+ if (user == null) {
|
|
|
+ return CommonResult.fail("学生信息无效,无法编辑学生成绩");
|
|
|
+ }
|
|
|
+
|
|
|
+ SmartExamtype examType = smartExamtypeService.getSmartById(usr.getExamType());
|
|
|
+ if (examType == null) {
|
|
|
+ return CommonResult.fail("考试类型数据为空,编辑失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ //region 添加到学生综合素质评价表中
|
|
|
+ SmartEvaluateStudent ses = new SmartEvaluateStudent();
|
|
|
+ ses.setTermId(usr.getSemesterId());
|
|
|
+ ses.setTerm(usr.getSemester());
|
|
|
+ ses.setGradeName(usr.getGrade());
|
|
|
+ ses.setGradeId(usr.getGradeId());
|
|
|
+ ses.setExamType(examType == null ? "" : examType.getName());
|
|
|
+ ses.setExamTypeId(usr.getExamType());
|
|
|
+ ses.setClassId(usr.getSchoolClassId());
|
|
|
+ ses.setClassName(usr.getSchoolClass());
|
|
|
+ ses.setCardNo(usr.getCardNo());
|
|
|
+ ses.setName(user.getName());
|
|
|
+ ses.setUserId(usr.getUserId());
|
|
|
+
|
|
|
+ BigDecimal totalScore = new BigDecimal(0.0);
|
|
|
+ List<SmartScore> userScores = smartScoreService.getScores(usr.getUserId(), usr.getSemesterId(), usr.getExamType());
|
|
|
+ for (SmartScore userScore : userScores) {
|
|
|
+ totalScore.add(new BigDecimal(userScore.getScore()));
|
|
|
+ }
|
|
|
+ ses.setScoreNum(totalScore.doubleValue());//分数要计算 已经加进去的成绩的
|
|
|
+
|
|
|
+ Integer insertStudent = smartEvaluateStudentService.insertSmartEvaluateStudent(ses);
|
|
|
+
|
|
|
+ if (insertStudent <= 0) {
|
|
|
+ return CommonResult.fail("添加失败");
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+
|
|
|
//判断学生是否有效
|
|
|
SmartUser user = smartUserService.getSmartById(usr.getUserId());
|
|
|
if (user == null) {
|
|
|
@@ -333,9 +455,9 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
score.setExamType(usr.getExamType());
|
|
|
score.setScore(usr.getScore());
|
|
|
|
|
|
-
|
|
|
int result = smartScoreService.updateSmartScore(score);
|
|
|
|
|
|
+
|
|
|
return result > 0 ? CommonResult.ok("编辑成功") : CommonResult.fail("编辑失败");
|
|
|
}
|
|
|
|
|
|
@@ -360,6 +482,49 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
@Override
|
|
|
@DESRespondSecret(validated = true)
|
|
|
public CommonResult deleteSmartScoresByIds(deleteSmartScoreRequest dssr, BindingResult bindingResult) {
|
|
|
+ List<SmartScore> scores = smartScoreService.querySmartScoreByIds(dssr.getIds());
|
|
|
+ if (scores != null && scores.size() > 0) {
|
|
|
+ //用户 学期 考试类型
|
|
|
+ List<Integer> userIds = scores.stream().map(SmartScore::getUserId).collect(Collectors.toList());
|
|
|
+ List<Integer> semesterIds = scores.stream().map(SmartScore::getSemesterId).collect(Collectors.toList());
|
|
|
+ List<Integer> examTypes = scores.stream().map(SmartScore::getExamType).collect(Collectors.toList());
|
|
|
+ List<SmartEvaluateStudent> students = smartEvaluateStudentService.getEvaluateStudents(userIds, semesterIds, examTypes);
|
|
|
+
|
|
|
+ List<Integer> deleteStudents = new ArrayList<>();
|
|
|
+ for (SmartEvaluateStudent student : students) {
|
|
|
+ Optional<SmartScore> scoreData = scores.stream().filter(e -> e.getUserId().equals(student.getUserId()) && e.getSemesterId().equals(student.getTermId())
|
|
|
+ && e.getExamType().equals(student.getExamTypeId())).findFirst();
|
|
|
+ if (scoreData != null && scoreData.isPresent()) {
|
|
|
+ BigDecimal restScore = new BigDecimal(0.0);
|
|
|
+ restScore = new BigDecimal(student.getScoreNum()).subtract(new BigDecimal(scoreData.get().getScore()));
|
|
|
+
|
|
|
+ if (restScore.doubleValue() > 0) {
|
|
|
+ student.setScoreNum(restScore.doubleValue());
|
|
|
+ } else {
|
|
|
+ // 删除成绩的时候如果减掉的分数小于等于零
|
|
|
+ // 则把综合评价里的学生的成绩总分数数据删掉
|
|
|
+ deleteStudents.add(student.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除和更新已有的综合评价数据
|
|
|
+ if (students != null && students.size() > 0) {
|
|
|
+ boolean updateStudents = smartEvaluateStudentService.updateBatchById(students);
|
|
|
+ if (!updateStudents) {
|
|
|
+ return CommonResult.fail("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (deleteStudents != null && deleteStudents.size() > 0) {
|
|
|
+ int deleteStudentDatas = smartEvaluateStudentService.deleteEvaluateStudents(deleteStudents);
|
|
|
+ if (deleteStudentDatas <= 0) {
|
|
|
+ return CommonResult.fail("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
int result = smartScoreService.deleteSmartScoreByIds(dssr.getIds());
|
|
|
|
|
|
return result > 0 ? CommonResult.ok("删除成功") : CommonResult.fail("删除失败");
|
|
|
@@ -469,7 +634,7 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
//b表示要冻结的行数;
|
|
|
//c表示右边区域[可见]的首列序号;
|
|
|
//d表示下边区域[可见]的首行序号;
|
|
|
- sheet.createFreezePane(6,3,0,0);
|
|
|
+ sheet.createFreezePane(6, 3, 0, 0);
|
|
|
|
|
|
Row headerRow = sheet.createRow(0);
|
|
|
for (int i = 0; i < (subjects.size() + 6); i++) {
|
|
|
@@ -625,6 +790,66 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
return CommonResult.fail("耗材数据导入只支持Xls、Xlsx");
|
|
|
}
|
|
|
|
|
|
+ //region 循环成绩加进综合评价学生里
|
|
|
+ List<SmartEvaluateStudent> addSess = new ArrayList<>();
|
|
|
+ List<SmartEvaluateStudent> sess = new ArrayList<>();
|
|
|
+ List<SmartScore> allUserScores = new ArrayList<>();
|
|
|
+ List<SmartExamtype> examtypes = new ArrayList<>();
|
|
|
+ if (result != null && result.size() > 0) {
|
|
|
+ List<Integer> userIds = result.stream().map(SmartScore::getUserId).collect(Collectors.toList());
|
|
|
+ List<Integer> semesterIds = result.stream().map(SmartScore::getSemesterId).collect(Collectors.toList());
|
|
|
+ List<Integer> examTypes = result.stream().map(SmartScore::getExamType).collect(Collectors.toList());
|
|
|
+ allUserScores = smartScoreService.getScores(userIds, semesterIds, examTypes);
|
|
|
+ sess = smartEvaluateStudentService.getEvaluateStudents(userIds, semesterIds, examTypes);
|
|
|
+ examtypes = smartExamtypeService.getSmartByIdes(examTypes);
|
|
|
+ }
|
|
|
+ for (SmartScore score : result) {
|
|
|
+ List<SmartScore> userScores = allUserScores == null ? new ArrayList<>() : allUserScores.stream().filter(e -> e.getUserId().equals(score.getUserId())
|
|
|
+ && e.getSemesterId().equals(score.getSemesterId()) && e.getExamType().equals(score.getExamType())).collect(Collectors.toList());
|
|
|
+ Optional<SmartEvaluateStudent> userSes = sess.stream().filter(e -> e.getUserId().equals(score.getUserId())
|
|
|
+ && e.getTermId().equals(score.getSemesterId()) && e.getExamTypeId().equals(score.getExamType())).findFirst();
|
|
|
+ //region 添加到学生综合素质评价表中
|
|
|
+ SmartEvaluateStudent ses = new SmartEvaluateStudent();
|
|
|
+ if (userSes != null && userSes.isPresent()) {
|
|
|
+ ses = userSes.get();
|
|
|
+ BigDecimal totalScore = new BigDecimal(ses.getScoreNum()).add(new BigDecimal(score.getScore()));
|
|
|
+ ses.setScoreNum(totalScore.doubleValue());//分数要计算 已经加进去的成绩的
|
|
|
+ } else {
|
|
|
+ Optional<SmartExamtype> examType = examtypes.stream().filter(e -> e.getId().equals(score.getExamType())).findFirst();
|
|
|
+ ses.setTermId(score.getSemesterId());
|
|
|
+ ses.setTerm(score.getSemester());
|
|
|
+ ses.setGradeName(score.getGrade());
|
|
|
+ ses.setGradeId(score.getGradeId());
|
|
|
+ ses.setExamType(examType != null && examType.isPresent() ? examType.get().getName() : "");
|
|
|
+ ses.setExamTypeId(score.getExamType());
|
|
|
+ ses.setClassId(score.getSchoolClassId());
|
|
|
+ ses.setClassName(score.getSchoolClass());
|
|
|
+ ses.setCardNo(score.getCardNo());
|
|
|
+ ses.setName(score.getName());
|
|
|
+ ses.setUserId(score.getUserId());
|
|
|
+
|
|
|
+ BigDecimal totalScore = new BigDecimal(0.0);
|
|
|
+
|
|
|
+ for (SmartScore userScore : userScores) {
|
|
|
+ totalScore.add(new BigDecimal(userScore.getScore()));
|
|
|
+ }
|
|
|
+
|
|
|
+ totalScore = totalScore.add(new BigDecimal(score.getScore()));
|
|
|
+ ses.setScoreNum(totalScore.doubleValue());//分数要计算 已经加进去的成绩的
|
|
|
+ }
|
|
|
+
|
|
|
+ addSess.add(ses);
|
|
|
+ //endregion
|
|
|
+ }
|
|
|
+
|
|
|
+ if(addSess != null && addSess.size() > 0){
|
|
|
+ boolean insertEvaluate = smartEvaluateStudentService.saveBatch(addSess);
|
|
|
+ if (!insertEvaluate) {
|
|
|
+ return CommonResult.fail("导入失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //endregion
|
|
|
+
|
|
|
boolean resultBool = smartScoreService.saveBatch(result);
|
|
|
|
|
|
return resultBool ? CommonResult.ok("导入成功") : CommonResult.fail("导入失败");
|
|
|
@@ -651,11 +876,11 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
for (SmartSubject smartSubject : list) {
|
|
|
AverageScoreVo averageScoreVo = new AverageScoreVo();
|
|
|
Integer smartSemesterId = smartSemester.getId();
|
|
|
- Double score =smartScoreService.getAverageScore(userId,semesterId,smartSemesterId);
|
|
|
+ Double score = smartScoreService.getAverageScore(userId, semesterId, smartSemesterId);
|
|
|
averageScoreVo.setSubjectName(smartSubject.getName());
|
|
|
if (ObjectUtils.isNotEmpty(score)) {
|
|
|
averageScoreVo.setScore(score);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
averageScoreVo.setScore(0.0);
|
|
|
}
|
|
|
|
|
|
@@ -673,13 +898,13 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
return CommonResult.ok("当前时间不属于任何学期");
|
|
|
}
|
|
|
String name = smartSemester.getName();
|
|
|
- SmartEvaluateStudent smartEvaluateStudent =smartEvaluateStudentService.getTeacherMessage(cardNo,name);
|
|
|
+ SmartEvaluateStudent smartEvaluateStudent = smartEvaluateStudentService.getTeacherMessage(cardNo, name);
|
|
|
HashMap<String, String> map = new HashMap<>();
|
|
|
if (ObjectUtils.isNotEmpty(smartEvaluateStudent)) {
|
|
|
String scoreComment = smartEvaluateStudent.getScoreComment();
|
|
|
- map.put("teacherMessage",scoreComment);
|
|
|
- }else {
|
|
|
- map.put("teacherMessage","暂无");
|
|
|
+ map.put("teacherMessage", scoreComment);
|
|
|
+ } else {
|
|
|
+ map.put("teacherMessage", "暂无");
|
|
|
}
|
|
|
return CommonResult.ok(map);
|
|
|
}
|
|
|
@@ -687,14 +912,14 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
@Override
|
|
|
@DESRespondSecret(validated = true)
|
|
|
public CommonResult studentExamName(int userId) {
|
|
|
- List<StudentExamNameVo> vos =smartScoreService.getstudentExamName(userId);
|
|
|
- return CommonResult.ok(vos);
|
|
|
+ List<StudentExamNameVo> vos = smartScoreService.getstudentExamName(userId);
|
|
|
+ return CommonResult.ok(vos);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@DESRespondSecret(validated = true)
|
|
|
public CommonResult historicalExam(int userId, int semesterId, int examTypeId) {
|
|
|
- List<HistoricalExamVo> list = smartScoreService.getHistoricalExam(userId,semesterId,examTypeId);
|
|
|
+ List<HistoricalExamVo> list = smartScoreService.getHistoricalExam(userId, semesterId, examTypeId);
|
|
|
return CommonResult.ok(list);
|
|
|
}
|
|
|
|
|
|
@@ -703,7 +928,7 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
public CommonResult teachingResultsExamName(int userId) {
|
|
|
SmartUser smartUser = smartUserService.getSmartById(userId);
|
|
|
Integer schoolClassId = smartUser.getSchoolClass();
|
|
|
- List<StudentExamNameVo> vos= smartScoreService.getTeachingResultsExamName(schoolClassId);
|
|
|
+ List<StudentExamNameVo> vos = smartScoreService.getTeachingResultsExamName(schoolClassId);
|
|
|
return CommonResult.ok(vos);
|
|
|
}
|
|
|
|
|
|
@@ -796,7 +1021,7 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
|
|
|
String name = dataFormatter.formatCellValue(row.getCell(0));//姓名
|
|
|
|
|
|
- if(name.equals("")){
|
|
|
+ if (name.equals("")) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
@@ -965,7 +1190,7 @@ public class SmartScoreController implements SmartScoreControllerAPI {
|
|
|
|
|
|
String name = dataFormatter.formatCellValue(row.getCell(0));//姓名
|
|
|
|
|
|
- if(name.equals("")){
|
|
|
+ if (name.equals("")) {
|
|
|
continue;
|
|
|
}
|
|
|
String cardNo = dataFormatter.formatCellValue(row.getCell(1));//学号
|