|
@@ -101,11 +101,13 @@ public class MarkSiteServiceImpl extends ServiceImpl<MarkSiteDao, MarkSiteEntity
|
|
|
lw.eq(MarkSiteEntity::getExamId, examId);
|
|
|
List<MarkSiteEntity> list = this.list(wrapper);
|
|
|
List<SubjectConfigVo> result = new ArrayList<>();
|
|
|
- Map<String, List<MarkSiteEntity>> map = list.stream().collect(Collectors.groupingBy(MarkSiteEntity::getSubjectCode));
|
|
|
- for (String subjectCode: map.keySet()) {
|
|
|
+ Map<String, List<MarkSiteEntity>> map = list.stream()
|
|
|
+ .collect(Collectors.groupingBy(MarkSiteEntity::getSubjectCode));
|
|
|
+ for (String subjectCode : map.keySet()) {
|
|
|
SubjectConfigVo vo = new SubjectConfigVo();
|
|
|
vo.setCode(subjectCode);
|
|
|
- vo.setPaperTypeBarcodeContent(map.get(subjectCode).stream().map(MarkSiteEntity::getPaperType).collect(Collectors.toList()));
|
|
|
+ vo.setPaperTypeBarcodeContent(
|
|
|
+ map.get(subjectCode).stream().map(MarkSiteEntity::getPaperType).collect(Collectors.toList()));
|
|
|
result.add(vo);
|
|
|
}
|
|
|
return result;
|
|
@@ -115,13 +117,18 @@ public class MarkSiteServiceImpl extends ServiceImpl<MarkSiteDao, MarkSiteEntity
|
|
|
@Transactional
|
|
|
public void saveByExamIdAndSubjectCode(Long examId, List<SubjectConfigVo> paperTypeBarcodeContent) {
|
|
|
List<MarkSiteEntity> saveList = new ArrayList<>();
|
|
|
- for (SubjectConfigVo vo: paperTypeBarcodeContent) {
|
|
|
- List<MarkSiteEntity> oldList = this.findByExamAndSubject(examId,vo.getCode());
|
|
|
- List<MarkSiteEntity> deleteList = oldList.stream().filter(e->!vo.getPaperTypeBarcodeContent().contains(e.getPaperType())).collect(Collectors.toList());
|
|
|
- this.removeByIds(deleteList);
|
|
|
- List<String> existPaperTypeList = oldList.stream().filter(e->vo.getPaperTypeBarcodeContent().contains(e.getPaperType())).map(MarkSiteEntity::getPaperType).collect(Collectors.toList());
|
|
|
- for (String paperType: vo.getPaperTypeBarcodeContent()) {
|
|
|
- if(existPaperTypeList.contains(paperType)){
|
|
|
+ for (SubjectConfigVo vo : paperTypeBarcodeContent) {
|
|
|
+ List<MarkSiteEntity> oldList = this.findByExamAndSubject(examId, vo.getCode());
|
|
|
+ List<Long> deleteIds = oldList.stream()
|
|
|
+ .filter(e -> !vo.getPaperTypeBarcodeContent().contains(e.getPaperType())).map(e -> e.getId())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ this.removeByIds(deleteIds);
|
|
|
+ List<String> existPaperTypeList = oldList.stream()
|
|
|
+ .filter(e -> vo.getPaperTypeBarcodeContent().contains(e.getPaperType()))
|
|
|
+ .map(MarkSiteEntity::getPaperType).collect(Collectors.toList());
|
|
|
+ for (String paperType : vo.getPaperTypeBarcodeContent()) {
|
|
|
+ if (existPaperTypeList.contains(paperType)) {
|
|
|
continue;
|
|
|
}
|
|
|
MarkSiteEntity e = new MarkSiteEntity();
|
|
@@ -136,7 +143,7 @@ public class MarkSiteServiceImpl extends ServiceImpl<MarkSiteDao, MarkSiteEntity
|
|
|
|
|
|
@Override
|
|
|
public List<String> findPaperTypeBarcodeContentByExamAndSubjectCode(Long examId, String subejctCode) {
|
|
|
- List<MarkSiteEntity> list =this.findByExamAndSubject(examId,subejctCode);
|
|
|
+ List<MarkSiteEntity> list = this.findByExamAndSubject(examId, subejctCode);
|
|
|
return list.stream().map(MarkSiteEntity::getPaperType).collect(Collectors.toList());
|
|
|
}
|
|
|
}
|