|
|
|
|
@ -108,12 +108,14 @@ public class TrainingTaskServiceImpl implements TrainingTaskService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public TrainingTask update(String id, TrainingTask task) {
|
|
|
|
|
ensureTrainingTaskTable();
|
|
|
|
|
TrainingTask existing = trainingTaskMapper.selectByPrimaryKey(id);
|
|
|
|
|
if (existing == null) {
|
|
|
|
|
throw new IllegalArgumentException("实训任务不存在");
|
|
|
|
|
}
|
|
|
|
|
String previousSteps = existing.getSteps();
|
|
|
|
|
normalizeTask(task);
|
|
|
|
|
TrainingTask builtInTask = requireBuiltInTask(existing.getTaskKey());
|
|
|
|
|
task.setId(id);
|
|
|
|
|
@ -124,6 +126,7 @@ public class TrainingTaskServiceImpl implements TrainingTaskService {
|
|
|
|
|
task.setSteps(normalizeSteps(task.getSteps(), builtInTask));
|
|
|
|
|
task.setUpdateTime(new Date());
|
|
|
|
|
trainingTaskMapper.updateByPrimaryKeySelective(task);
|
|
|
|
|
synchronizeClassTaskSteps(existing.getTaskKey(), previousSteps, task.getSteps());
|
|
|
|
|
return trainingTaskMapper.selectByPrimaryKey(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -492,6 +495,34 @@ public class TrainingTaskServiceImpl implements TrainingTaskService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void synchronizeClassTaskSteps(String taskKey, String previousSteps, String updatedSteps) {
|
|
|
|
|
if (schoolClassMapper == null || trainingTaskClassConfigMapper == null
|
|
|
|
|
|| StringUtils.equals(previousSteps, updatedSteps)) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SchoolClassExample example = new SchoolClassExample();
|
|
|
|
|
example.createCriteria().andClassTypeEqualTo("TEACHING");
|
|
|
|
|
List<SchoolClass> teachingClasses = schoolClassMapper.selectByExample(example);
|
|
|
|
|
if (teachingClasses == null || teachingClasses.isEmpty()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
for (SchoolClass teachingClass : teachingClasses) {
|
|
|
|
|
if (teachingClass == null || StringUtils.isBlank(teachingClass.getSchoolClassId())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
TrainingTaskClassConfig classTask = trainingTaskClassConfigMapper.selectByTeachingClassAndTaskKey(
|
|
|
|
|
teachingClass.getSchoolClassId(), taskKey);
|
|
|
|
|
if (classTask == null || !StringUtils.equals(previousSteps, classTask.getSteps())) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
TrainingTaskClassConfig update = new TrainingTaskClassConfig();
|
|
|
|
|
update.setId(classTask.getId());
|
|
|
|
|
update.setSteps(updatedSteps);
|
|
|
|
|
update.setUpdateTime(new Date());
|
|
|
|
|
trainingTaskClassConfigMapper.updateByPrimaryKeySelective(update);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String resolveClassTaskCreator(String teachingClassId, String operatorId) {
|
|
|
|
|
if (StringUtils.isNotBlank(operatorId)) {
|
|
|
|
|
return operatorId;
|
|
|
|
|
|