Kaynağa Gözat

班级量化考核调整

dzx 1 yıl önce
ebeveyn
işleme
29571df608

+ 6 - 0
src/main/java/com/xjrsoft/module/student/dto/QuantitativeAssessmentExcelDto.java

@@ -64,4 +64,10 @@ public class QuantitativeAssessmentExcelDto implements Serializable {
      */
     @ApiModelProperty(value = "子表的类型", hidden = true)
     private Long baseStudentAssessmentCategoryId;
+
+    @ApiModelProperty("年份")
+    private Integer year;
+
+    @ApiModelProperty("月份")
+    private Integer month;
 }

+ 42 - 2
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentAssessmentInspectionServiceImpl.java

@@ -64,7 +64,6 @@ import com.xjrsoft.module.system.service.IFileService;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import lombok.AllArgsConstructor;
 import me.zhyd.oauth.log.Log;
-import org.checkerframework.checker.units.qual.A;
 import org.springframework.beans.BeanUtils;
 import org.springframework.http.ResponseEntity;
 import org.springframework.stereotype.Service;
@@ -291,7 +290,6 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                     CalssQuantitativeAssessmentPageDto calssQuantitativeAssessmentPageDto = new CalssQuantitativeAssessmentPageDto();
                     BeanUtils.copyProperties(dto, calssQuantitativeAssessmentPageDto);
 
-
                     //学生个人行为
                     dto.setBaseStudentAssessmentCategoryId(1768178717588197377L);
                     Map<Long , QuantitativeAssessmentSingleScoreVo> individualBehaviorMap = getQuantitativeAssessmentSingleScoreMap(calssQuantitativeAssessmentPageDto);
@@ -313,6 +311,22 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                         awardsAndHonorableMap.put(q.getClassId(), q);
                     }
 
+                    //查询任课教师查询班级的数据
+                    TeaEvaluateClassDto evaluateClassDto = new TeaEvaluateClassDto();
+                    evaluateClassDto.setEvaluateType(EvaluateTypeEnum.TEACHER_EVALUATE_CLASS.getCode());
+                    evaluateClassDto.setYear(dto.getYear());
+                    LocalDate now = LocalDate.now();
+                    if(dto.getYear() == null){
+                        evaluateClassDto.setYear(now.getYear());
+                    }
+                    evaluateClassDto.setMonth(dto.getMonth());
+                    if(dto.getMonth() == null){
+                        evaluateClassDto.setMonth(now.getMonthValue());
+                    }
+                    List<TeaEvaluateClassListVo> teaEvaluateClassList = evaluateResultMapper.getTeaEvaluateClassList(evaluateClassDto);
+                    Map<Long, List<TeaEvaluateClassListVo>> classEvaluateMap = teaEvaluateClassList.stream().collect(Collectors.groupingBy(TeaEvaluateClassListVo::getEvaluatedObjectId));
+                    String jskhFormula = quotaFormulaRuleService.getFormulaByQuota("teacher_assessment");
+
                     //将结果写进对应的班级里
                     for(CalssQuantitativeAssessmentPageVo c: resultList){
                         Long classId = Long.parseLong(c.getClassId());
@@ -344,6 +358,32 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                                 c.setClassStatusCn("毕业");
                             }
                         }
+
+                        if(classEvaluateMap.containsKey(classId)){
+                            Map<Long, List<TeaEvaluateClassListVo>> evaluateCategoryMap = classEvaluateMap.get(classId).stream().collect(Collectors.groupingBy(TeaEvaluateClassListVo::getId));
+                            int evaluateItemSize = evaluateCategoryMap.size();
+
+                            List<Double> evaluateSocreList = new ArrayList<>();//存每个项的平均分
+                            for (Long id : evaluateCategoryMap.keySet()) {
+                                List<TeaEvaluateClassListVo> evaluateList = evaluateCategoryMap.get(id);
+                                int allSorce = evaluateList.stream().mapToInt(TeaEvaluateClassListVo::getScore).sum();
+                                double avgScore = BigDecimal.valueOf(allSorce).divide(BigDecimal.valueOf(resultList.size())).setScale(2, RoundingMode.HALF_UP).doubleValue();
+                                evaluateSocreList.add(avgScore);
+                            }
+
+                            double jskhValue = evaluateSocreList.stream().mapToDouble(Double::doubleValue).sum();
+                            c.setTeacherAssessComprehensiveIndex(jskhValue);
+                            String replacedExpression = jskhFormula.replace("JSKH", Double.toString(jskhValue));
+
+                            ScriptEngineManager manager = new ScriptEngineManager();
+                            ScriptEngine engine = manager.getEngineByName("JavaScript");
+                            try {
+                                double result = ((Number) engine.eval(replacedExpression)).doubleValue();
+                                c.setTeacherAssessScore(result);
+                            } catch (ScriptException e) {
+                                Log.error(e.getMessage(), e);
+                            }
+                        }
                     }
                 }
                 //sheet名