|
|
@@ -1010,6 +1010,83 @@ public class TextbookServiceImpl extends MPJBaseServiceImpl<TextbookMapper, Text
|
|
|
return textbookSubscriptionListVoIPage;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<TextbookSubscriptionListVo> getSubscriptionListByClass(TextbookSubscriptionListDto dto) {
|
|
|
+ List<String> classIdList = new ArrayList<>();
|
|
|
+ if(dto.getClassIds() != null && !"".equals(dto.getClassIds())){
|
|
|
+ String[] classIdArr = dto.getClassIds().split(",");
|
|
|
+ classIdList = Arrays.asList(classIdArr);
|
|
|
+ }
|
|
|
+ dto.setClassIdList(classIdList);
|
|
|
+
|
|
|
+ // 找到可以使用多个学期且已经征订的教材
|
|
|
+ MPJLambdaWrapper<BaseClassCourse> subscribedTextbook = new MPJLambdaWrapper<>();
|
|
|
+ subscribedTextbook
|
|
|
+ .distinct()
|
|
|
+ .select(BaseClassCourse::getId)
|
|
|
+ .innerJoin(TextbookSubscriptionClass.class, TextbookSubscriptionClass::getBaseClassId, BaseClassCourse::getClassId)
|
|
|
+ .innerJoin(TextbookSubscriptionItem.class, wrapper -> wrapper
|
|
|
+ .eq(TextbookSubscriptionItem::getTextbookSubscriptionId, TextbookSubscriptionClass::getTextbookSubscriptionId)
|
|
|
+ .eq(TextbookSubscriptionItem::getTextbookId, BaseClassCourse::getTextbookId)
|
|
|
+ )
|
|
|
+
|
|
|
+ .innerJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
|
|
|
+ .gt(Textbook::getUseType, 1)
|
|
|
+ .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .in(BaseClassCourse::getClassId, dto.getClassIdList())
|
|
|
+ ;
|
|
|
+ List<BaseClassCourse> baseClassCourses = baseClassCourseMapper.selectJoinList(BaseClassCourse.class, subscribedTextbook);
|
|
|
+
|
|
|
+ List<Long> baseClassCourseIds = baseClassCourses.stream()
|
|
|
+ .map(BaseClassCourse::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ MPJLambdaWrapper<BaseClassCourse> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ baseClassCourseMPJLambdaWrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .distinct()
|
|
|
+ .selectAs(BaseClassCourse::getCourseId, TextbookSubscriptionListVo::getCourseSubjectId)
|
|
|
+ .selectAs(BaseClassCourse::getTextbookId, TextbookSubscriptionListVo::getTextbookId)
|
|
|
+ .selectAs(BaseCourseSubject::getName, TextbookSubscriptionListVo::getCourseName)
|
|
|
+ .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(TextbookSubscriptionListVo.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
|
|
|
+ .leftJoin(BaseCourseSubject.class, BaseCourseSubject::getId, BaseClassCourse::getCourseId)
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(DictionaryDetail::getName, TextbookSubscriptionListVo::getTextbookTypeCn)
|
|
|
+ )
|
|
|
+ .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .in(BaseClassCourse::getClassId, dto.getClassIdList())
|
|
|
+ .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
|
|
|
+ .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(Textbook::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ ;
|
|
|
+ List<TextbookSubscriptionListVo> textbookSubscriptionListVoList = baseClassCourseMapper.selectJoinList(TextbookSubscriptionListVo.class, baseClassCourseMPJLambdaWrapper);
|
|
|
+// IPage<TextbookSubscriptionListVo> page = this.baseMapper.getSubscriptionPageByClass(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
+
|
|
|
+ // 处理每本教材使用的人数
|
|
|
+ if(!classIdList.isEmpty()) {
|
|
|
+ for(TextbookSubscriptionListVo t : textbookSubscriptionListVoList){
|
|
|
+ MPJLambdaWrapper<BaseClassCourse> countNum = new MPJLambdaWrapper<>();
|
|
|
+ countNum
|
|
|
+ .innerJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getClassId, BaseClassCourse::getClassId)
|
|
|
+ .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
|
|
|
+ .eq(BaseClassCourse::getTextbookId, t.getTextbookId())
|
|
|
+ .eq(BaseClassCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .in(BaseClassCourse::getClassId, dto.getClassIdList())
|
|
|
+ .notIn(!baseClassCourseIds.isEmpty(), BaseClassCourse::getId, baseClassCourseIds)
|
|
|
+ .eq(BaseClassCourse::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ ;
|
|
|
+ Long num = baseClassCourseMapper.selectCount(countNum);
|
|
|
+ t.setStudentSubscriptionNumber(num.intValue());
|
|
|
+
|
|
|
+ t.setClassIds(dto.getClassIds());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return textbookSubscriptionListVoList;
|
|
|
+ }
|
|
|
+
|
|
|
// private void saveData(List<TextbookImportDto> dataList) {
|
|
|
// //查询所有需要的数据
|
|
|
// //学科组
|