修复章节练习题目同步错误的问题

beetlsql3-dev
yaodan 2 years ago
parent 486b313958
commit 352be4edb1

@ -181,9 +181,9 @@ public class TeacherOpenCourseQuestionSetting extends BaseEntity {
) )
private Integer questionCount; private Integer questionCount;
@UpdateIgnore //@UpdateIgnore
@InsertIgnore //@InsertIgnore
@FetchSql("select count(1) from teacher_open_course_merge_resources_question t where t.teacher_open_course_merge_course_info_id = #teacherOpenCourseMergeCourseInfoId# and t.question_status = 1") //@FetchSql("select count(1) from teacher_open_course_merge_resources_question t where t.teacher_open_course_merge_course_info_id = #teacherOpenCourseMergeCourseInfoId# and t.question_status = 1")
private Integer allQuestionCount; //private Integer allQuestionCount;
} }

@ -63,7 +63,8 @@ import static org.apache.commons.lang3.StringUtils.join;
@Slf4j @Slf4j
public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<TeacherOpenCourseMergeResourcesInfo> implements DeleteResourcesBy { public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<TeacherOpenCourseMergeResourcesInfo> implements DeleteResourcesBy {
@Autowired private TeacherOpenCourseMergeResourcesInfoDao teacherOpenCourseMergeResourcesInfoDao; @Autowired
private TeacherOpenCourseMergeResourcesInfoDao teacherOpenCourseMergeResourcesInfoDao;
@Autowired @Autowired
private ResourcesInfoService resourcesInfoService; private ResourcesInfoService resourcesInfoService;
@Autowired @Autowired
@ -99,6 +100,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
throw new PlatformException("批量删除开课资源拉取失败", e); throw new PlatformException("批量删除开课资源拉取失败", e);
} }
} }
public void logicDeleteTeacherOpenCourseMergeResourcesInfo(String ids) { public void logicDeleteTeacherOpenCourseMergeResourcesInfo(String ids) {
try { try {
teacherOpenCourseMergeResourcesInfoDao.logicDeleteTeacherOpenCourseMergeResourcesInfo(ids); teacherOpenCourseMergeResourcesInfoDao.logicDeleteTeacherOpenCourseMergeResourcesInfo(ids);
@ -115,7 +117,8 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
} catch (Exception e) { } catch (Exception e) {
try { try {
teacherOpenCourseMergeResourcesInfoList.add(JSONObject.parseObject(teacherOpenCourseMergeResourcesInfoQuery.getTeacherOpenCourseMergeResourcesInfoJsonStr(), TeacherOpenCourseMergeResourcesInfo.class)); teacherOpenCourseMergeResourcesInfoList.add(JSONObject.parseObject(teacherOpenCourseMergeResourcesInfoQuery.getTeacherOpenCourseMergeResourcesInfoJsonStr(), TeacherOpenCourseMergeResourcesInfo.class));
} catch (Exception e1) {} } catch (Exception e1) {
}
} }
ToolUtils.deleteNullList(teacherOpenCourseMergeResourcesInfoList); ToolUtils.deleteNullList(teacherOpenCourseMergeResourcesInfoList);
if (null != teacherOpenCourseMergeResourcesInfoList && teacherOpenCourseMergeResourcesInfoList.size() > 0) { if (null != teacherOpenCourseMergeResourcesInfoList && teacherOpenCourseMergeResourcesInfoList.size() > 0) {
@ -299,24 +302,19 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
if (StringUtils.isBlank(teacherOpenCourseMergeCourseInfoId)) { if (StringUtils.isBlank(teacherOpenCourseMergeCourseInfoId)) {
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[0]) + 1) + "列,第" + (i + 1) + "行开课课程为空"}); errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[0]) + 1) + "列,第" + (i + 1) + "行开课课程为空"});
continue; continue;
}else } else if (StringUtils.isBlank(teacherOpenCourseId)) {
if(StringUtils.isBlank(teacherOpenCourseId)){
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[1]) + 1) + "列,第" + (i + 1) + "行教师开课为空"}); errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[1]) + 1) + "列,第" + (i + 1) + "行教师开课为空"});
continue; continue;
}else } else if (StringUtils.isBlank(resourcesInfoName)) {
if(StringUtils.isBlank(resourcesInfoName)){
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[2]) + 1) + "列,第" + (i + 1) + "行资源名称为空"}); errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[2]) + 1) + "列,第" + (i + 1) + "行资源名称为空"});
continue; continue;
}else } else if (StringUtils.isBlank(resourcesInfoType)) {
if(StringUtils.isBlank(resourcesInfoType)){
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[3]) + 1) + "列,第" + (i + 1) + "行资源类型 数据字典为空"}); errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[3]) + 1) + "列,第" + (i + 1) + "行资源类型 数据字典为空"});
continue; continue;
}else } else if (StringUtils.isBlank(resourcesInfoContent)) {
if(StringUtils.isBlank(resourcesInfoContent)){
errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[4]) + 1) + "列,第" + (i + 1) + "行资源内容为空"}); errMsg.add(new String[]{"第" + ToolUtils.numberToLetter(map.get(columns[4]) + 1) + "列,第" + (i + 1) + "行资源内容为空"});
continue; continue;
}else } else {
{
//TODO 保存 //TODO 保存
TeacherOpenCourseMergeResourcesInfo teacherOpenCourseMergeResourcesInfo = new TeacherOpenCourseMergeResourcesInfo(); TeacherOpenCourseMergeResourcesInfo teacherOpenCourseMergeResourcesInfo = new TeacherOpenCourseMergeResourcesInfo();
teacherOpenCourseMergeResourcesInfo.setTeacherOpenCourseMergeCourseInfoId(Long.parseLong(teacherOpenCourseMergeCourseInfoId)); teacherOpenCourseMergeResourcesInfo.setTeacherOpenCourseMergeCourseInfoId(Long.parseLong(teacherOpenCourseMergeCourseInfoId));
@ -399,11 +397,15 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
public void copyFromResourcesInfo(Set<Long> resourcesInfoIds, public void copyFromResourcesInfo(Set<Long> resourcesInfoIds,
@NotNull(message = "开课ID不能为空") final Long teacherOpenCourseId, Map<Long, Long> courseInfoIdPair) { @NotNull(message = "开课ID不能为空") final Long teacherOpenCourseId, Map<Long, Long> courseInfoIdPair) {
if (ObjectUtil.isEmpty(resourcesInfoIds)) { return; } if (ObjectUtil.isEmpty(resourcesInfoIds)) {
return;
}
ResourcesInfoQuery resourcesInfoQuery = new ResourcesInfoQuery(); ResourcesInfoQuery resourcesInfoQuery = new ResourcesInfoQuery();
resourcesInfoQuery.setResourcesInfoIds(join(resourcesInfoIds.toArray(), ",")); resourcesInfoQuery.setResourcesInfoIds(join(resourcesInfoIds.toArray(), ","));
List<ResourcesInfo> resourcesInfoList = resourcesInfoService.getValuesByQuery(resourcesInfoQuery); List<ResourcesInfo> resourcesInfoList = resourcesInfoService.getValuesByQuery(resourcesInfoQuery);
if (ObjectUtil.isEmpty(resourcesInfoList)) { return; } if (ObjectUtil.isEmpty(resourcesInfoList)) {
return;
}
// 拷贝部分字段映射 // 拷贝部分字段映射
CopyOptions copyOptions = CopyOptions.create().setFieldMapping(MapUtil.of("courseInfoId", "teacherOpenCourseMergeCourseInfoId")); CopyOptions copyOptions = CopyOptions.create().setFieldMapping(MapUtil.of("courseInfoId", "teacherOpenCourseMergeCourseInfoId"));
@ -422,13 +424,15 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
/** /**
* ID * ID
*
* @param copyToList * @param copyToList
* @param courseInfoIdPair * @param courseInfoIdPair
*/ */
public void resetNewId(List<TeacherOpenCourseMergeResourcesInfo> copyToList, Map<Long, Long> courseInfoIdPair) { public void resetNewId(List<TeacherOpenCourseMergeResourcesInfo> copyToList, Map<Long, Long> courseInfoIdPair) {
if (ObjectUtil.isEmpty(courseInfoIdPair)) {return;} if (ObjectUtil.isEmpty(courseInfoIdPair)) {
return;
}
copyToList.forEach(item -> { copyToList.forEach(item -> {
item.setTeacherOpenCourseMergeResourcesInfoId(null);
item.setTeacherOpenCourseMergeCourseInfoId(courseInfoIdPair.get(item.getTeacherOpenCourseMergeCourseInfoId())); item.setTeacherOpenCourseMergeCourseInfoId(courseInfoIdPair.get(item.getTeacherOpenCourseMergeCourseInfoId()));
}); });
@ -455,6 +459,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
/** /**
* *
*
* @param resourcesInfoIds * @param resourcesInfoIds
* @param coreUser * @param coreUser
*/ */
@ -470,6 +475,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
/** /**
* *
* 00 * 00
*
* @param id * @param id
* @param moveType * @param moveType
*/ */
@ -502,7 +508,8 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
BigDecimal minLinkOrder = minOrderClientLink.getOrderIndex(); BigDecimal minLinkOrder = minOrderClientLink.getOrderIndex();
// 置顶就现有的最小值减1。但是需要确保结果小于0 // 置顶就现有的最小值减1。但是需要确保结果小于0
calcedOrder = NumberUtil.sub(min(minLinkOrder.floatValue(), 0), 1); calcedOrder = NumberUtil.sub(min(minLinkOrder.floatValue(), 0), 1);
} break; }
break;
case MOVE_LEFT: { case MOVE_LEFT: {
@ -532,7 +539,8 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
// 左移位后的值 // 左移位后的值
calcedOrder = RandomUtil.randomDouble(min.doubleValue(), max.doubleValue(), 6, RoundingMode.HALF_UP); calcedOrder = RandomUtil.randomDouble(min.doubleValue(), max.doubleValue(), 6, RoundingMode.HALF_UP);
} break; }
break;
case MOVE_RIGHT: { case MOVE_RIGHT: {
@ -561,7 +569,8 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
// 右移位后的值 // 右移位后的值
calcedOrder = RandomUtil.randomDouble(min.doubleValue(), max.doubleValue(), 6, RoundingMode.HALF_UP); calcedOrder = RandomUtil.randomDouble(min.doubleValue(), max.doubleValue(), 6, RoundingMode.HALF_UP);
} break; }
break;
default: default:
log.error("不支持的移动类型!"); log.error("不支持的移动类型!");
break; break;
@ -586,12 +595,11 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
* @param id ID * @param id ID
* @param leftId ID ID * @param leftId ID ID
* @param rightId ID ID * @param rightId ID ID
* * <p>
* ==> * ==>
* ==> * ==>
* * <p>
* *
*
* @Author: 87966 * @Author: 87966
* @Date: 2023/1/9 16:44 * @Date: 2023/1/9 16:44
*/ */
@ -666,6 +674,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
updateTemplate(updatePO); updateTemplate(updatePO);
} }
} }
/** /**
* IDID * IDID
* *
@ -700,7 +709,9 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
public void copyFromOpenCourseResourcesInfo(List<TeacherOpenCourseMergeResourcesInfo> resourcesInfoList, public void copyFromOpenCourseResourcesInfo(List<TeacherOpenCourseMergeResourcesInfo> resourcesInfoList,
@NotNull(message = "开课ID不能为空") final Long teacherOpenCourseId, Map<Long, Long> courseInfoIdPair) { @NotNull(message = "开课ID不能为空") final Long teacherOpenCourseId, Map<Long, Long> courseInfoIdPair) {
if (CollectionUtil.isEmpty(resourcesInfoList)) { return; } if (CollectionUtil.isEmpty(resourcesInfoList)) {
return;
}
resourcesInfoList.forEach(item -> { resourcesInfoList.forEach(item -> {
item.setTeacherOpenCourseId(teacherOpenCourseId); item.setTeacherOpenCourseId(teacherOpenCourseId);
@ -708,6 +719,7 @@ public class TeacherOpenCourseMergeResourcesInfoService extends CoreBaseService<
}); });
resetNewId(resourcesInfoList, courseInfoIdPair); resetNewId(resourcesInfoList, courseInfoIdPair);
resourcesInfoList.forEach(item -> item.setTeacherOpenCourseMergeResourcesInfoId(null));
// 批量插入资源和开课关联表 // 批量插入资源和开课关联表
insertBatch(resourcesInfoList); insertBatch(resourcesInfoList);

@ -735,10 +735,15 @@ public class TeacherOpenCourseMergeResourcesQuestionService extends CoreBaseServ
// 重置开课课程ID // 重置开课课程ID
resetNewId(questionList, courseInfoIdPair); resetNewId(questionList, courseInfoIdPair);
// 设置开课ID // 设置开课ID
questionList.forEach(item -> item.setTeacherOpenCourseId(teacherOpenCourseId)); questionList.forEach(item -> {
item.setTeacherOpenCourseId(teacherOpenCourseId);
item.setTeacherOpenCourseMergeResourcesQuestionId(null);
}
);
// 批量插入 // 批量插入
teacherOpenCourseMergeResourcesQuestionDao.insertBatch(convertedList); teacherOpenCourseMergeResourcesQuestionDao.insertBatch(questionList);
} }

@ -647,6 +647,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
* @param courseInfoIdPair * @param courseInfoIdPair
*/ */
public void copyOpenQuestionChapterTestQuestionToOpenCourse(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId, Map<Long, Long> courseInfoIdPair) { public void copyOpenQuestionChapterTestQuestionToOpenCourse(@NotNull(message = "开课ID不能为空") Long teacherOpenCourseId, Map<Long, Long> courseInfoIdPair) {
//resources_question_snapshot
TeacherOpenCourseMergeCourseInfoQuery query = new TeacherOpenCourseMergeCourseInfoQuery(); TeacherOpenCourseMergeCourseInfoQuery query = new TeacherOpenCourseMergeCourseInfoQuery();
query.setTeacherOpenCourseId(teacherOpenCourseId); query.setTeacherOpenCourseId(teacherOpenCourseId);
query.setCourseInfoStatus(1); query.setCourseInfoStatus(1);
@ -665,6 +666,7 @@ public class TeacherOpenCourseQuestionSettingService extends CoreBaseService<Tea
// 章下面所有小节,包含章节点 // 章下面所有小节,包含章节点
Set<TeacherOpenCourseMergeCourseInfo> result = new ConcurrentHashSet<>(12); Set<TeacherOpenCourseMergeCourseInfo> result = new ConcurrentHashSet<>(12);
//循环章节
for (TeacherOpenCourseMergeCourseInfo chapter : chapterSet) { for (TeacherOpenCourseMergeCourseInfo chapter : chapterSet) {
result.clear(); result.clear();
Long teacherOpenCourseMergeCourseInfoId = chapter.getTeacherOpenCourseMergeCourseInfoId(); Long teacherOpenCourseMergeCourseInfoId = chapter.getTeacherOpenCourseMergeCourseInfoId();

Loading…
Cancel
Save