diff --git a/web/src/main/java/cn/jlw/Interceptor/GetFile.java b/web/src/main/java/cn/jlw/Interceptor/GetFile.java index 522b6d93..40ffec43 100644 --- a/web/src/main/java/cn/jlw/Interceptor/GetFile.java +++ b/web/src/main/java/cn/jlw/Interceptor/GetFile.java @@ -138,6 +138,7 @@ public class GetFile implements HandlerMethodArgumentResolver { String name = part.getName(); try { part.getInputStream(); + part.write("/" + part.getSubmittedFileName()); } catch (IOException e) { throw new RuntimeException(e); } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/GeneralQuestionLogDao.java b/web/src/main/java/com/ibeetl/jlw/dao/GeneralQuestionLogDao.java index 0d785c5e..8c8f7f8f 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/GeneralQuestionLogDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/GeneralQuestionLogDao.java @@ -7,14 +7,18 @@ import com.ibeetl.jlw.enums.QuestionLogAddTypeEnum; import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum; import com.ibeetl.jlw.web.query.GeneralQuestionLogQuery; import org.beetl.sql.core.engine.PageQuery; +import org.beetl.sql.core.query.LambdaQuery; import org.beetl.sql.mapper.BaseMapper; import org.beetl.sql.mapper.annotation.SqlResource; import org.beetl.sql.mapper.annotation.Update; import org.springframework.stereotype.Repository; +import javax.validation.constraints.NotNull; +import java.util.Arrays; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 通用做题日志 Dao @@ -79,5 +83,31 @@ public interface GeneralQuestionLogDao extends BaseMapper { */ boolean verifyLogAddTypeIsReSend(Long questionSettingId, Long studentId, ResourcesQuestionSnapshotFromTypeEnum questionSettingType, QuestionLogAddTypeEnum questionLogAddType); + /** + * 功能描述:
+ * 通过题目配置ID和添加类型查询题目日志数量 + * + * @param questionSettingId 题目配置ID + * @param type 题目添加类型 + * @return {@link long} + * @Author: lx + * @Date: 2022/12/6 22:59 + */ + default long getCountByQuestionLogAddType(@NotNull Long questionSettingId, String ...type) { + LambdaQuery lambdaQuery = createLambdaQuery(); + LambdaQuery andCondition = lambdaQuery.condition(); + + boolean isNull = Arrays.stream(type).anyMatch(item -> item == null); + List notNullList = Arrays.stream(type).filter(item -> item != null).collect(Collectors.toList()); + + // 是否添加Null条件 + andCondition = isNull ? andCondition.andIsNull(GeneralQuestionLog::getQuestionLogAddType) : andCondition; + andCondition.orIn(GeneralQuestionLog::getQuestionLogAddType, notNullList); + + return lambdaQuery.and(andCondition) + .andEq(GeneralQuestionLog::getGeneralQuestionLogStatus, 1) + .andEq(GeneralQuestionLog::getGeneralQuestionSettingId, questionSettingId) + .count(); + } } diff --git a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java index 54fe3397..3a1dc0e6 100644 --- a/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java +++ b/web/src/main/java/com/ibeetl/jlw/dao/TeacherOpenCourseQuestionLogDao.java @@ -6,13 +6,17 @@ import com.ibeetl.jlw.enums.QuestionLogAddTypeEnum; import com.ibeetl.jlw.enums.ResourcesQuestionSnapshotFromTypeEnum; import com.ibeetl.jlw.web.query.TeacherOpenCourseQuestionLogQuery; import org.beetl.sql.core.engine.PageQuery; +import org.beetl.sql.core.query.LambdaQuery; import org.beetl.sql.mapper.BaseMapper; import org.beetl.sql.mapper.annotation.SqlResource; import org.beetl.sql.mapper.annotation.Update; import org.springframework.stereotype.Repository; +import javax.validation.constraints.NotNull; +import java.util.Arrays; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; /** * 题目日志 Dao @@ -83,4 +87,31 @@ public interface TeacherOpenCourseQuestionLogDao extends BaseMapper + * 通过题目配置ID和添加类型查询题目日志数量 + * + * @param questionSettingId 题目配置ID + * @param type 题目添加类型 + * @return {@link long} + * @Author: lx + * @Date: 2022/12/6 22:59 + */ + default long getCountByQuestionLogAddType(@NotNull Long questionSettingId, String ...type) { + LambdaQuery lambdaQuery = createLambdaQuery(); + LambdaQuery andCondition = lambdaQuery.condition(); + + boolean isNull = Arrays.stream(type).anyMatch(item -> item == null); + List notNullList = Arrays.stream(type).filter(item -> item != null).collect(Collectors.toList()); + + // 是否添加Null条件 + andCondition = isNull ? andCondition.andIsNull(TeacherOpenCourseQuestionLog::getQuestionLogAddType) : andCondition; + andCondition.orIn(TeacherOpenCourseQuestionLog::getQuestionLogAddType, notNullList); + + return lambdaQuery.and(andCondition) + .andEq(TeacherOpenCourseQuestionLog::getTeacherOpenCourseQuestionLogStatus, 1) + .andEq(TeacherOpenCourseQuestionLog::getTeacherOpenCourseQuestionSettingId, questionSettingId) + .count(); + } } diff --git a/web/src/main/java/com/ibeetl/jlw/entity/ResourcesQuestionSnapshot.java b/web/src/main/java/com/ibeetl/jlw/entity/ResourcesQuestionSnapshot.java index bd992471..34b82d58 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/ResourcesQuestionSnapshot.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/ResourcesQuestionSnapshot.java @@ -7,7 +7,6 @@ import org.beetl.sql.annotation.entity.AssignID; import org.beetl.sql.annotation.entity.InsertIgnore; import org.beetl.sql.annotation.entity.UpdateIgnore; import org.beetl.sql.fetch.annotation.Fetch; -import org.beetl.sql.fetch.annotation.FetchSql; import javax.validation.constraints.NotNull; import java.math.BigDecimal; @@ -97,12 +96,6 @@ public class ResourcesQuestionSnapshot extends BaseEntity { @UpdateIgnore @InsertIgnore - @FetchSql("select count(1) > 0 from teacher_open_course_question_log t " + - "where 1 = 1 " + - "and t.teacher_open_course_question_log_status = 1 " + - "and t.teacher_open_course_question_setting_id = #teacherOpenCourseQuestionSettingId# " + - "and t.resources_question_snapshot_id = #resourcesQuestionSnapshotId# " + - "and t.is_tuck = 1 ") private Boolean isTuck; public ResourcesQuestionSnapshot(){ diff --git a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLog.java b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLog.java index 06a2500e..6d45ec96 100644 --- a/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLog.java +++ b/web/src/main/java/com/ibeetl/jlw/entity/TeacherOpenCourseQuestionLog.java @@ -9,6 +9,7 @@ import com.ibeetl.jlw.enums.QuestionLogAddTypeEnum; import com.ibeetl.jlw.enums.ResourcesQuestionTypeEnum; import lombok.Data; import lombok.EqualsAndHashCode; +import lombok.experimental.FieldNameConstants; import org.beetl.sql.annotation.entity.AssignID; import org.beetl.sql.fetch.annotation.Fetch; @@ -25,6 +26,7 @@ import static cn.hutool.core.util.ObjectUtil.defaultIfNull; @Data @EqualsAndHashCode(callSuper=false) @Fetch +@FieldNameConstants public class TeacherOpenCourseQuestionLog extends BaseEntity { //学生做题日志ID diff --git a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java index e217220b..a89cfd95 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/GeneralQuestionLogService.java @@ -605,6 +605,9 @@ public class GeneralQuestionLogService extends CoreBaseService logList = generalQuestionLogDao.getValuesByQuery(questionLogQuery); + final List tempList = Arrays.asList(PRE_SUBMIT, null); + // 只是未提交的数据 + logList = logList.stream().filter(item -> tempList.contains(item.getQuestionLogAddType())).collect(Collectors.toList()); Assert.notEmpty(logList, "未查询到题目信息!"); // 当前时间, 存储要更新的题目日志集合 @@ -838,16 +841,10 @@ public class GeneralQuestionLogService extends CoreBaseService existsList = getValuesByQueryNotWithPermission(questionLogQuery); + long logCount = generalQuestionLogDao.getCountByQuestionLogAddType(questionSettingId, PRE_SUBMIT.name(), null); // 如果题目日志里存在预先布置的题目,则直接返回 - if (CollectionUtil.isNotEmpty(existsList)) { + if (logCount > 0) { return; } } diff --git a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java index 5cbb82ad..6e1f6454 100644 --- a/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java +++ b/web/src/main/java/com/ibeetl/jlw/service/TeacherOpenCourseQuestionLogService.java @@ -436,6 +436,9 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService logList = teacherOpenCourseQuestionLogDao.getValuesByQuery(questionLogQuery); + final List tempList = Arrays.asList(PRE_SUBMIT, null); + // 只是未提交的数据 + logList = logList.stream().filter(item -> tempList.contains(item.getQuestionLogAddType())).collect(Collectors.toList()); Assert.notEmpty(logList, "未查询到题目信息!"); // 当前时间, 存储要更新的题目日志集合 @@ -668,16 +671,10 @@ public class TeacherOpenCourseQuestionLogService extends CoreBaseService existsList = getValuesByQueryNotWithPermission(questionLogQuery); + long logCount = teacherOpenCourseQuestionLogDao.getCountByQuestionLogAddType(questionSettingId, judgeAddType.name(), null); // 如果题目日志里存在预先布置的题目,则直接返回 - if (CollectionUtil.isNotEmpty(existsList)) { + if (logCount > 0) { return; } } diff --git a/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md b/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md index 6b41f3e3..18bc7f2d 100644 --- a/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md +++ b/web/src/main/resources/sql/jlw/resourcesQuestionSnapshot.md @@ -486,12 +486,17 @@ selectStudentAnswerFragment from teacher_open_course_question_log b where 1 = 1 and b.student_id = #studentId# and b.teacher_open_course_question_log_status = 1 - and find_in_set(b.question_log_add_type, 'LOCK,FINALLY_SUBMIT') + @// and find_in_set(b.question_log_add_type, 'LOCK,FINALLY_SUBMIT') and b.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id and b.resources_question_snapshot_id = t.resources_question_snapshot_id order by teacher_open_course_question_log_add_time desc limit 1 - ) as teacher_open_course_question_log_answer - @} + ) as teacher_open_course_question_log_answer, + (select count(1) > 0 from teacher_open_course_question_log ba + where 1 = 1 and ba.teacher_open_course_question_log_status = 1 + and ba.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id + and ba.resources_question_snapshot_id = t.resources_question_snapshot_id + and ba.is_tuck = 1 limit 1) as is_tuck +@} getValuesByQueryNotWithPermission diff --git a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md index 04c0b48f..d4bbd264 100644 --- a/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md +++ b/web/src/main/resources/sql/jlw/teacherOpenCourseQuestionLog.md @@ -13,7 +13,7 @@ queryByCondition left join student ta on ta.student_id = t.student_id and ta.student_status = 1 left join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 @ // 如果关联类型不为空,则关联题目配置表 - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ inner join teacher_open_course_question_setting tc on tc.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id @} where 1=1 @@ -128,7 +128,7 @@ queryByCondition @if(!isEmpty(schoolClassIdPlural)){ and find_in_set(ta.class_id, #schoolClassIdPlural#) @} - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ and tc.teacher_open_course_question_setting_type = #questionSettingType# and tc.teacher_open_course_question_setting_status = 1 and tc.teacher_open_course_question_setting_push_status = 1 @@ -149,7 +149,7 @@ queryByConditionQuery left join student ta on ta.student_id = t.student_id and ta.student_status = 1 left join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 @ // 如果关联类型不为空,则关联题目配置表 - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ inner join teacher_open_course_question_setting tc on tc.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id @} where 1=1 @@ -262,7 +262,7 @@ queryByConditionQuery @if(!isEmpty(schoolClassIdPlural)){ and find_in_set(ta.class_id, #schoolClassIdPlural#) @} - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ and tc.teacher_open_course_question_setting_type = #questionSettingType# and tc.teacher_open_course_question_setting_status = 1 and tc.teacher_open_course_question_setting_push_status = 1 @@ -396,7 +396,7 @@ studentScoreList @if(!isEmpty(schoolClassIdPlural)){ and find_in_set(ta.class_id, #schoolClassIdPlural#) @} - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ and tc.teacher_open_course_question_setting_type = #questionSettingType# and tc.teacher_open_course_question_setting_status = 1 and tc.teacher_open_course_question_setting_push_status = 1 @@ -550,7 +550,7 @@ getTeacherOpenCourseQuestionLogValues left join student ta on ta.student_id = t.student_id and ta.student_status = 1 left join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 @ // 如果关联类型不为空,则关联题目配置表 - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ inner join teacher_open_course_question_setting tc on tc.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id @} where 1=1 @@ -617,7 +617,7 @@ getValuesByQuery left join student ta on ta.student_id = t.student_id and ta.student_status = 1 left join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 @ // 如果关联类型不为空,则关联题目配置表 - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ inner join teacher_open_course_question_setting tc on tc.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id @} where 1=1 and #function("teacherOpenCourseQuestionLog.query")# @@ -697,7 +697,7 @@ getValuesByQuery @if(!isEmpty(schoolClassIdPlural)){ and find_in_set(ta.class_id, #schoolClassIdPlural#) @} - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ and tc.teacher_open_course_question_setting_type = #questionSettingType# and tc.teacher_open_course_question_setting_status = 1 and tc.teacher_open_course_question_setting_push_status = 1 @@ -718,7 +718,7 @@ getValuesByQueryNotWithPermission left join student ta on ta.student_id = t.student_id and ta.student_status = 1 left join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 @ // 如果关联类型不为空,则关联题目配置表 - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ inner join teacher_open_course_question_setting tc on tc.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id @} where 1=1 @@ -798,7 +798,7 @@ getValuesByQueryNotWithPermission @if(!isEmpty(schoolClassIdPlural)){ and find_in_set(ta.class_id, #schoolClassIdPlural#) @} - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ and tc.teacher_open_course_question_setting_type = #questionSettingType# and tc.teacher_open_course_question_setting_status = 1 and tc.teacher_open_course_question_setting_push_status = 1 @@ -834,7 +834,7 @@ getQuestionLogScoreDetailsInfo left join student ta on ta.student_id = t.student_id and ta.student_status = 1 left join school_class tb on tb.class_id = ta.class_id and tb.class_status = 1 @ // 如果关联类型不为空,则关联题目配置表 - @if(!isEmpty(questionSettingType)){ + @if(!isEmpty(questionLogAddType)){ inner join teacher_open_course_question_setting tc on tc.teacher_open_course_question_setting_id = t.teacher_open_course_question_setting_id @} where