|
@@ -5,21 +5,27 @@ import com.keao.edu.common.exception.BizException;
|
|
import com.keao.edu.common.page.PageInfo;
|
|
import com.keao.edu.common.page.PageInfo;
|
|
import com.keao.edu.common.page.QueryInfo;
|
|
import com.keao.edu.common.page.QueryInfo;
|
|
import com.keao.edu.common.service.impl.BaseServiceImpl;
|
|
import com.keao.edu.common.service.impl.BaseServiceImpl;
|
|
|
|
+import com.keao.edu.user.dao.ExamSubjectDao;
|
|
import com.keao.edu.user.dao.ExamSubjectSongDao;
|
|
import com.keao.edu.user.dao.ExamSubjectSongDao;
|
|
|
|
+import com.keao.edu.user.entity.ExamSubject;
|
|
import com.keao.edu.user.entity.ExamSubjectSong;
|
|
import com.keao.edu.user.entity.ExamSubjectSong;
|
|
import com.keao.edu.user.service.ExamSubjectSongService;
|
|
import com.keao.edu.user.service.ExamSubjectSongService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
+import org.springframework.transaction.annotation.Isolation;
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjectSong> implements ExamSubjectSongService {
|
|
public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjectSong> implements ExamSubjectSongService {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ExamSubjectSongDao examSubjectSongDao;
|
|
private ExamSubjectSongDao examSubjectSongDao;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ExamSubjectDao examSubjectDao;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public BaseDAO<Long, ExamSubjectSong> getDAO() {
|
|
public BaseDAO<Long, ExamSubjectSong> getDAO() {
|
|
@@ -27,10 +33,17 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional(rollbackFor = Exception.class, isolation = Isolation.READ_COMMITTED)
|
|
public void addExamSubjects(List<ExamSubjectSong> examSubjectSongs) {
|
|
public void addExamSubjects(List<ExamSubjectSong> examSubjectSongs) {
|
|
if(CollectionUtils.isEmpty(examSubjectSongs)){
|
|
if(CollectionUtils.isEmpty(examSubjectSongs)){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ List<ExamSubject> examSubjects = examSubjectDao.getWithTenant(examSubjectSongs.get(0).getExaminationBasicId());
|
|
|
|
+ Set<Integer> existSubjectIds = new HashSet<>();
|
|
|
|
+ if(!CollectionUtils.isEmpty(examSubjects)){
|
|
|
|
+ existSubjectIds=examSubjects.stream().map(ExamSubject::getSubjectId).collect(Collectors.toSet());
|
|
|
|
+ }
|
|
|
|
+ List<ExamSubject> newExamSubjects = new ArrayList<>();
|
|
for (ExamSubjectSong examSubjectSong : examSubjectSongs) {
|
|
for (ExamSubjectSong examSubjectSong : examSubjectSongs) {
|
|
if(Objects.isNull(examSubjectSong.getExaminationBasicId())){
|
|
if(Objects.isNull(examSubjectSong.getExaminationBasicId())){
|
|
throw new BizException("请指定考级项目");
|
|
throw new BizException("请指定考级项目");
|
|
@@ -44,7 +57,17 @@ public class ExamSubjectSongServiceImpl extends BaseServiceImpl<Long, ExamSubjec
|
|
if(Objects.isNull(examSubjectSong.getRegistrationFee())){
|
|
if(Objects.isNull(examSubjectSong.getRegistrationFee())){
|
|
throw new BizException("请指定报名费用");
|
|
throw new BizException("请指定报名费用");
|
|
}
|
|
}
|
|
|
|
+ if(existSubjectIds.contains(examSubjectSong.getExamSubjectId())){
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ ExamSubject newExamSubject=new ExamSubject();
|
|
|
|
+ newExamSubject.setExaminationBasicId(examSubjectSong.getExaminationBasicId());
|
|
|
|
+ newExamSubject.setTenantId(examSubjectSong.getTenantId());
|
|
|
|
+ newExamSubject.setSubjectId(examSubjectSong.getExamSubjectId().intValue());
|
|
|
|
+ newExamSubjects.add(newExamSubject);
|
|
|
|
+ existSubjectIds.add(newExamSubject.getSubjectId());
|
|
}
|
|
}
|
|
examSubjectSongDao.batchInsert(examSubjectSongs);
|
|
examSubjectSongDao.batchInsert(examSubjectSongs);
|
|
|
|
+ examSubjectDao.batchInsert(newExamSubjects);
|
|
}
|
|
}
|
|
}
|
|
}
|