فهرست منبع

Merge remote-tracking branch 'origin/dev' into dev

大数据与最优化研究所 9 ماه پیش
والد
کامیت
7fec8d438e

+ 53 - 16
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentAssessmentInspectionServiceImpl.java

@@ -99,7 +99,6 @@ import java.math.RoundingMode;
 import java.text.SimpleDateFormat;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.time.ZoneId;
 import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
 import java.util.Date;
@@ -992,8 +991,9 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                     new QueryWrapper<BaseClass>().lambda()
                             .in(BaseClass::getName, classNames)
             );
-            Map<String, Long> classMap = classList.stream().collect(Collectors.toMap(BaseClass::getName, BaseClass::getId));
-            Set<String> checkClassNames = new HashSet<>(classNames);
+            Map<String, BaseClass> classMap = classList.stream().collect(Collectors.toMap(BaseClass::getName, x -> x));
+
+            Set<String> checkClassNames = new HashSet<>(classMap.values().stream().map(BaseClass::getName).collect(Collectors.toSet()));
             checkClassNames.removeAll(classMap.keySet());
             if(!checkClassNames.isEmpty()){
                 throw new MyException("导入表格中的班级:" + checkClassNames.toString() + " 在系统中不存在");
@@ -1047,26 +1047,23 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
             Set<String> checkItems = new HashSet<>();
 
             List<BaseStudentAssessmentInspection> insertList = new ArrayList<>();
+            List<BaseStudentAssessmentStudentRelation> childInsertList = new ArrayList<>();
+            List<BaseStudentAssessmentClassRelation> child2InsertList = new ArrayList<>();
             SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
+            int sortCode = 1;
             for (ImportBaseStudentAssessmentInspectionDto dto : savedDataList) {
-
+                long id = IdUtil.getSnowflakeNextId();
                 BaseStudentAssessmentInspection data = new BaseStudentAssessmentInspection();
 
+                data.setId(id);
+
                 data.setEnabledMark(EnabledMark.ENABLED.getCode());
                 data.setDeleteMark(DeleteMark.NODELETE.getCode());
                 data.setCreateDate(new Date());
                 data.setCreateUserId(StpUtil.getLoginIdAsLong());
-                if("班级".equals(dto.getAssessmentType())){
-                    data.setAssessmentType("class");
-                }else if("个人".equals(dto.getAssessmentType())){
-                    data.setAssessmentType("personal");
-                    if(!studentMap.containsKey(dto.getCredentialNumber())){
-                        checkStudents.add(dto.getStudentName());
-                        continue;
-                    }
-                    data.setPersonalStudentUserIds(studentMap.get(dto.getCredentialNumber()));
-                }
-                data.setClassIds(classMap.get(dto.getClassName()).toString());
+                BaseClass baseClass = classMap.get(dto.getClassName());
+                data.setClassIds(baseClass.getId().toString());
+                data.setGradeId(baseClass.getGradeId());
                 data.setBaseStudentAssessmentCategoryId(categoryMap.get(dto.getAssessmentCategory()));
 
 
@@ -1084,7 +1081,8 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                 }
                 BaseStudentAssessmentProject project = projectGroup.get(dto.getAssessmentProject());
                 data.setBaseStudentAssessmentProjectId(project.getId());
-
+                data.setScore(project.getBasicPoints());
+                data.setTotalScore(project.getBasicPoints());
                 if(project.getBasicPoints() > 0){
                     data.setScoreType("score_add");
                 }else{
@@ -1095,7 +1093,36 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
                 data.setAssessmentUserId(StpUtil.getLoginIdAsLong());
                 data.setAssessmentDate(sdf.parse(dto.getAssessmentDate()));
 
+                if("班级".equals(dto.getAssessmentType())){
+                    data.setAssessmentType("class");
+
+                    BaseStudentAssessmentClassRelation children = new BaseStudentAssessmentClassRelation();
+                    children.setBaseStudentAssessmentInspectionId(id);
+                    children.setClassId(baseClass.getId());
+                    children.setSortCode(sortCode);
+                    child2InsertList.add(children);
+                    sortCode ++;
+                }else if("个人".equals(dto.getAssessmentType())){
+                    data.setAssessmentType("personal");
+                    if(!studentMap.containsKey(dto.getCredentialNumber())){
+                        checkStudents.add(dto.getStudentName());
+                        continue;
+                    }
+                    data.setPersonalStudentUserIds(studentMap.get(dto.getCredentialNumber()));
+
+                    BaseStudentAssessmentStudentRelation children = new BaseStudentAssessmentStudentRelation();
+                    children.setBaseStudentAssessmentInspectionId(id);
+                    children.setScore(project.getBasicPoints());
+                    children.setUserId(Long.parseLong(studentMap.get(dto.getCredentialNumber())));
+                    children.setClassId(baseClass.getId());
+                    children.setEnabledMark(EnabledMark.ENABLED.getCode());
+                    children.setDeleteMark(DeleteMark.NODELETE.getCode());
+                    childInsertList.add(children);
+                }
+
                 insertList.add(data);
+
+
             }
             if(!checkStudents.isEmpty()){
                 throw new MyException("导入表格中的学生:" + checkStudents.toString() + " 在系统中不存在");
@@ -1109,6 +1136,16 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
             if(!insertList.isEmpty()){
                this.saveBatch(insertList);
             }
+            if(!childInsertList.isEmpty()){
+                for (BaseStudentAssessmentStudentRelation baseStudentAssessmentStudentRelation : childInsertList) {
+                    assessmentStudentRelationMapper.insert(baseStudentAssessmentStudentRelation);
+                }
+            }
+            if(!child2InsertList.isEmpty()){
+                for (BaseStudentAssessmentClassRelation baseStudentAssessmentStudentRelation : child2InsertList) {
+                    assessmentClassRelationMapper.insert(baseStudentAssessmentStudentRelation);
+                }
+            }
         }catch (Exception e){
             Log.error(e.getMessage(), e);
             if(e.getClass().equals(MyException.class)){