|
|
@@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.xjrsoft.common.enums.ArchivesStatusEnum;
|
|
|
@@ -20,6 +21,7 @@ import com.xjrsoft.module.base.entity.BaseClassCourse;
|
|
|
import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassAdminCourseMapper;
|
|
|
import com.xjrsoft.module.base.mapper.BaseClassCourseMapper;
|
|
|
+import com.xjrsoft.module.base.mapper.BaseSemesterMapper;
|
|
|
import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
import com.xjrsoft.module.base.service.IBaseSemesterService;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudent;
|
|
|
@@ -37,6 +39,7 @@ import com.xjrsoft.module.textbook.entity.WfTextbookClaimItem;
|
|
|
import com.xjrsoft.module.textbook.mapper.TextbookMapper;
|
|
|
import com.xjrsoft.module.textbook.mapper.TextbookStudentClaimMapper;
|
|
|
import com.xjrsoft.module.textbook.mapper.WfTextbookClaimItemMapper;
|
|
|
+import com.xjrsoft.module.textbook.mapper.WfTextbookClaimMapper;
|
|
|
import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService;
|
|
|
import com.xjrsoft.module.textbook.vo.*;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
@@ -46,11 +49,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* @title: 学生教材认领记录
|
|
|
@@ -76,10 +77,14 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
|
|
|
private final WfTextbookClaimItemMapper wfTextbookClaimItemMapper;
|
|
|
|
|
|
+ private final WfTextbookClaimMapper wfTextbookClaimMapper;
|
|
|
+
|
|
|
private final BaseStudentSchoolRollMapper baseStudentSchoolRollMapper;
|
|
|
|
|
|
private final TextbookMapper textbookMapper;
|
|
|
|
|
|
+ private final BaseSemesterMapper baseSemesterMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public HeadTeaLookClassBookVo headTeaLookClassBook(HeadTeaLookClassBookDto dto) {
|
|
|
HeadTeaLookClassBookVo result = new HeadTeaLookClassBookVo();
|
|
|
@@ -102,10 +107,10 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
.eq(WfTextbookClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
.eq(WfTextbookClaim::getClassId, dto.getBaseClassId())
|
|
|
.eq(WfTextbookClaim::getClaimType, ClaimTypeEnum.ClaimClass.getCode())
|
|
|
- ;
|
|
|
+ ;
|
|
|
List<HeadTeaLookClassBookCategoryDetailVo> claimResultList = wfTextbookClaimItemMapper.selectJoinList(HeadTeaLookClassBookCategoryDetailVo.class, wfTextbookClaimItemMPJLambdaWrapper);
|
|
|
|
|
|
- if(ObjectUtils.isEmpty(claimResultList)){
|
|
|
+ if (ObjectUtils.isEmpty(claimResultList)) {
|
|
|
MPJLambdaWrapper<BaseClassCourse> baseClassCourseMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
baseClassCourseMPJLambdaWrapper
|
|
|
.disableSubLogicDel()
|
|
|
@@ -116,8 +121,8 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
.innerJoin(BaseClassAdminCourse.class, BaseClassAdminCourse::getId, BaseClassCourse::getClassId)
|
|
|
.innerJoin(Textbook.class, Textbook::getId, BaseClassCourse::getTextbookId)
|
|
|
.leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
- wrapper -> wrapper
|
|
|
- .selectAs(DictionaryDetail::getName, HeadTeaLookClassBookCategoryDetailVo::getTextbookTypeCn)
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(DictionaryDetail::getName, HeadTeaLookClassBookCategoryDetailVo::getTextbookTypeCn)
|
|
|
)
|
|
|
.eq(BaseClassAdminCourse::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
.eq(BaseClassAdminCourse::getClassId, dto.getBaseClassId())
|
|
|
@@ -125,7 +130,7 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
claimResultList = baseClassCourseMapper.selectJoinList(HeadTeaLookClassBookCategoryDetailVo.class, baseClassCourseMPJLambdaWrapper);
|
|
|
}
|
|
|
|
|
|
- if(ObjectUtils.isNotEmpty(claimResultList)){
|
|
|
+ if (ObjectUtils.isNotEmpty(claimResultList)) {
|
|
|
// 处理数据
|
|
|
// 根据类型分组
|
|
|
Map<String, List<HeadTeaLookClassBookCategoryDetailVo>> detailByCategoryMap = claimResultList.stream()
|
|
|
@@ -136,19 +141,19 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
List<HeadTeaLookClassBookCategoryVo> categoryVos = new ArrayList<>();
|
|
|
BigDecimal categoryTotalPrice;
|
|
|
HeadTeaLookClassBookCategoryVo headTeaLookClassBookCategoryVo;
|
|
|
- for (Map.Entry<String, List<HeadTeaLookClassBookCategoryDetailVo>> entry : detailByCategoryMap.entrySet()){
|
|
|
+ for (Map.Entry<String, List<HeadTeaLookClassBookCategoryDetailVo>> entry : detailByCategoryMap.entrySet()) {
|
|
|
String key = entry.getKey();
|
|
|
List<HeadTeaLookClassBookCategoryDetailVo> value = entry.getValue();
|
|
|
|
|
|
- if(ObjectUtils.isNotEmpty(value)){
|
|
|
+ if (ObjectUtils.isNotEmpty(value)) {
|
|
|
headTeaLookClassBookCategoryVo = new HeadTeaLookClassBookCategoryVo();
|
|
|
headTeaLookClassBookCategoryVo.setTextbookType(key);
|
|
|
headTeaLookClassBookCategoryVo.setTextbookTypeCn(value.get(0).getTextbookTypeCn());
|
|
|
headTeaLookClassBookCategoryVo.setCategoryDetailVos(value);
|
|
|
|
|
|
categoryTotalPrice = BigDecimal.ZERO;
|
|
|
- for (HeadTeaLookClassBookCategoryDetailVo vo : value){
|
|
|
- if(ObjectUtils.isEmpty(vo.getPrice())){
|
|
|
+ for (HeadTeaLookClassBookCategoryDetailVo vo : value) {
|
|
|
+ if (ObjectUtils.isEmpty(vo.getPrice())) {
|
|
|
vo.setPrice(BigDecimal.ZERO);
|
|
|
}
|
|
|
categoryTotalPrice = categoryTotalPrice.add(vo.getPrice().multiply(BigDecimal.valueOf(vo.getClaimNum())));
|
|
|
@@ -181,74 +186,223 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
.leftJoin(BaseSemester.class, BaseSemester::getId, BaseClassAdminCourse::getBaseSemesterId)
|
|
|
.eq(BaseClass::getTeacherId, loginId)
|
|
|
.orderByDesc(BaseSemester::getName)
|
|
|
- ;
|
|
|
+ ;
|
|
|
return baseClassAdminCourseMapper.selectJoinList(HeadTeaLookClassBookSemesterVo.class, baseClassAdminCourseMPJLambdaWrapper);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public TextbookClaimStudentConfirmVo getStudentConfirmList(TextbookClaimStudentConfirmDto dto) {
|
|
|
- //获取当前登录学生的信息
|
|
|
- MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
|
|
|
- queryUser
|
|
|
+ // 获取学期
|
|
|
+ BaseSemester baseSemester = baseSemesterMapper.selectById(dto.getBaseSemesterId());
|
|
|
+
|
|
|
+ // 获取当前学生的信息
|
|
|
+ MPJLambdaWrapper<BaseStudentSchoolRoll> baseStudentSchoolRollMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ baseStudentSchoolRollMPJLambdaWrapper
|
|
|
.selectAs(XjrUser::getName, TextbookClaimStudentConfirmVo::getStudentName)
|
|
|
.selectAs(BaseStudent::getStudentId, TextbookClaimStudentConfirmVo::getStudentId)
|
|
|
.selectAs(BaseClass::getName, TextbookClaimStudentConfirmVo::getClassCN)
|
|
|
- .leftJoin(BaseStudent.class, BaseStudent::getUserId, XjrUser::getId)
|
|
|
- .leftJoin(BaseStudentSchoolRoll.class, BaseStudentSchoolRoll::getUserId, XjrUser::getId)
|
|
|
+ .selectAs(BaseStudentSchoolRoll::getClassId, TextbookClaimStudentConfirmVo::getClassId)
|
|
|
.leftJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId)
|
|
|
- .eq(XjrUser::getId, StpUtil.getLoginIdAsLong())
|
|
|
- .disableSubLogicDel()
|
|
|
- .orderByDesc(AttendanceRecord::getId);
|
|
|
- TextbookClaimStudentConfirmVo textbookClaimStudentConfirmVo = xjrUserMapper.selectJoinOne(TextbookClaimStudentConfirmVo.class, queryUser);
|
|
|
- if (ObjectUtil.isNull(textbookClaimStudentConfirmVo)) {
|
|
|
- throw new MyException("登录信息出错,请重新登录");
|
|
|
+ .leftJoin(XjrUser.class, XjrUser::getId, BaseStudentSchoolRoll::getUserId)
|
|
|
+ .leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentSchoolRoll::getUserId)
|
|
|
+ .last("limit 1")
|
|
|
+ ;
|
|
|
+ TextbookClaimStudentConfirmVo result = baseStudentSchoolRollMapper.selectJoinOne(TextbookClaimStudentConfirmVo.class, baseStudentSchoolRollMPJLambdaWrapper);
|
|
|
+
|
|
|
+ if(ObjectUtils.isEmpty(result)){
|
|
|
+ throw new MyException("用户信息错误,请重新登录");
|
|
|
}
|
|
|
|
|
|
- //根据学期id查出学期名称
|
|
|
- BaseSemester baseSemester = baseSemesterService.getById(dto.getBaseSemesterId());
|
|
|
- textbookClaimStudentConfirmVo.setBaseSemesterCN(baseSemester.getName());
|
|
|
+ if(ObjectUtils.isNotEmpty(baseSemester)){
|
|
|
+ result.setBaseSemesterCN(baseSemester.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 学生查看自己的教材来源于两个方面,一个是班级申领教材,一个是个人申领的教材
|
|
|
+ // 班级申领教材
|
|
|
+ MPJLambdaWrapper<WfTextbookClaimItem> classMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ classMPJLambdaWrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .selectAs(WfTextbookClaimItem::getTextbookId, HeadTeaLookClassBookCategoryDetailVo::getTextbookId)
|
|
|
+ .selectAs(Textbook::getBookName, HeadTeaLookClassBookCategoryDetailVo::getBookName)
|
|
|
+ .selectAs(Textbook::getPrice, HeadTeaLookClassBookCategoryDetailVo::getPrice)
|
|
|
+ .selectAs(Textbook::getTextbookType, HeadTeaLookClassBookCategoryDetailVo::getTextbookType)
|
|
|
+ .selectAs(WfTextbookClaimItem::getCreateDate, HeadTeaLookClassBookCategoryDetailVo::getClaimTime)
|
|
|
+ .select("1 as claim_num")
|
|
|
+ .innerJoin(WfTextbookClaim.class, WfTextbookClaim::getId, WfTextbookClaimItem::getWfTextbookClaimId)
|
|
|
+ .innerJoin(Textbook.class, Textbook::getId, WfTextbookClaimItem::getTextbookId)
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(DictionaryDetail::getName, HeadTeaLookClassBookCategoryDetailVo::getTextbookTypeCn)
|
|
|
+ )
|
|
|
+ .eq(WfTextbookClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(WfTextbookClaim::getClassId, result.getClassId())
|
|
|
+ .eq(WfTextbookClaim::getClaimType, ClaimTypeEnum.ClaimClass.getCode())
|
|
|
+ ;
|
|
|
+ List<HeadTeaLookClassBookCategoryDetailVo> classList = wfTextbookClaimItemMapper.selectJoinList(HeadTeaLookClassBookCategoryDetailVo.class, classMPJLambdaWrapper);
|
|
|
+
|
|
|
+ MPJLambdaWrapper<WfTextbookClaimItem> personalMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ personalMPJLambdaWrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .selectAs(WfTextbookClaimItem::getTextbookId, HeadTeaLookClassBookCategoryDetailVo::getTextbookId)
|
|
|
+ .selectAs(Textbook::getBookName, HeadTeaLookClassBookCategoryDetailVo::getBookName)
|
|
|
+ .selectAs(Textbook::getPrice, HeadTeaLookClassBookCategoryDetailVo::getPrice)
|
|
|
+ .selectAs(Textbook::getTextbookType, HeadTeaLookClassBookCategoryDetailVo::getTextbookType)
|
|
|
+ .selectAs(WfTextbookClaimItem::getCreateDate, HeadTeaLookClassBookCategoryDetailVo::getClaimTime)
|
|
|
+ .select("1 as claim_num")
|
|
|
+ .innerJoin(WfTextbookClaim.class, WfTextbookClaim::getId, WfTextbookClaimItem::getWfTextbookClaimId)
|
|
|
+ .innerJoin(Textbook.class, Textbook::getId, WfTextbookClaimItem::getTextbookId)
|
|
|
+ .leftJoin(DictionaryDetail.class, DictionaryDetail::getCode, Textbook::getTextbookType,
|
|
|
+ wrapper -> wrapper
|
|
|
+ .selectAs(DictionaryDetail::getName, HeadTeaLookClassBookCategoryDetailVo::getTextbookTypeCn)
|
|
|
+ )
|
|
|
+ .eq(WfTextbookClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(WfTextbookClaim::getApplicantUserId, dto.getStudentUserId())
|
|
|
+ .eq(WfTextbookClaim::getClaimType, ClaimTypeEnum.ClaimStudent.getCode())
|
|
|
+ ;
|
|
|
+ List<HeadTeaLookClassBookCategoryDetailVo> personalList = wfTextbookClaimItemMapper.selectJoinList(HeadTeaLookClassBookCategoryDetailVo.class, personalMPJLambdaWrapper);
|
|
|
+
|
|
|
+ // 合并两个列表
|
|
|
+ List<HeadTeaLookClassBookCategoryDetailVo> mergedList = Stream.concat(classList.stream(), personalList.stream())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 根据 textbookId 去重
|
|
|
+ List<HeadTeaLookClassBookCategoryDetailVo> distinctList = new ArrayList<>(mergedList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ HeadTeaLookClassBookCategoryDetailVo::getTextbookId, // 以 textbookId 作为去重依据
|
|
|
+ vo -> vo, // 保留原始对象
|
|
|
+ (existing, replacement) -> existing // 如果重复,保留已存在的对象
|
|
|
+ ))
|
|
|
+ .values());
|
|
|
+
|
|
|
+ // 获取当前学生当前学期所有已经领取的数据
|
|
|
+ LambdaQueryWrapper<TextbookStudentClaim> textbookStudentClaimLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ textbookStudentClaimLambdaQueryWrapper
|
|
|
+ .eq(TextbookStudentClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(TextbookStudentClaim::getStudentUserId, dto.getStudentUserId())
|
|
|
+ .eq(TextbookStudentClaim::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ ;
|
|
|
+ List<TextbookStudentClaim> textbookStudentClaimList = textbookStudentClaimMapper.selectList(textbookStudentClaimLambdaQueryWrapper);
|
|
|
+
|
|
|
+ Map<Long, TextbookStudentClaim> byTextbookId = textbookStudentClaimList.stream()
|
|
|
+ .collect(Collectors.toMap(TextbookStudentClaim::getTextbookId, t -> t, (t1, t2) -> t1));
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(distinctList)) {
|
|
|
+ // 处理数据
|
|
|
+ // 根据类型分组
|
|
|
+ Map<String, List<HeadTeaLookClassBookCategoryDetailVo>> detailByCategoryMap = distinctList.stream()
|
|
|
+ .filter(detail -> StringUtils.isNotEmpty(detail.getTextbookType())) // Exclude entries where textbookType is null
|
|
|
+ .collect(Collectors.groupingBy(HeadTeaLookClassBookCategoryDetailVo::getTextbookType));
|
|
|
+
|
|
|
+ BigDecimal totalPrice = BigDecimal.ZERO;
|
|
|
+ List<HeadTeaLookClassBookCategoryVo> categoryVos = new ArrayList<>();
|
|
|
+ BigDecimal categoryTotalPrice;
|
|
|
+ HeadTeaLookClassBookCategoryVo headTeaLookClassBookCategoryVo;
|
|
|
+ TextbookStudentClaim textbookStudentClaim;
|
|
|
+ for (Map.Entry<String, List<HeadTeaLookClassBookCategoryDetailVo>> entry : detailByCategoryMap.entrySet()) {
|
|
|
+ String key = entry.getKey();
|
|
|
+ List<HeadTeaLookClassBookCategoryDetailVo> value = entry.getValue();
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(value)) {
|
|
|
+ headTeaLookClassBookCategoryVo = new HeadTeaLookClassBookCategoryVo();
|
|
|
+ headTeaLookClassBookCategoryVo.setTextbookType(key);
|
|
|
+ headTeaLookClassBookCategoryVo.setTextbookTypeCn(value.get(0).getTextbookTypeCn());
|
|
|
+ headTeaLookClassBookCategoryVo.setCategoryDetailVos(value);
|
|
|
|
|
|
- dto.setStudentUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ categoryTotalPrice = BigDecimal.ZERO;
|
|
|
+ for (HeadTeaLookClassBookCategoryDetailVo vo : value) {
|
|
|
+ textbookStudentClaim = byTextbookId.get(vo.getTextbookId());
|
|
|
+ if(ObjectUtils.isNotEmpty(textbookStudentClaim)){
|
|
|
+ vo.setIsClaim(textbookStudentClaim.getIsClaim());
|
|
|
+ }else {
|
|
|
+ vo.setIsClaim(0);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isEmpty(vo.getPrice())) {
|
|
|
+ vo.setPrice(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ categoryTotalPrice = categoryTotalPrice.add(vo.getPrice().multiply(BigDecimal.valueOf(vo.getClaimNum())));
|
|
|
+ totalPrice = totalPrice.add(vo.getPrice().multiply(BigDecimal.valueOf(vo.getClaimNum())));
|
|
|
+ }
|
|
|
+ headTeaLookClassBookCategoryVo.setCategoryTotalPrice(categoryTotalPrice);
|
|
|
|
|
|
- List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimMapper.getTextbookClaimList(dto);
|
|
|
+ categoryVos.add(headTeaLookClassBookCategoryVo);
|
|
|
+ }
|
|
|
|
|
|
- textbookClaimStudentConfirmVo.setTextbookClaimVoList(textbookClaimVOList);
|
|
|
- return textbookClaimStudentConfirmVo;
|
|
|
+ result.setTotalPrice(totalPrice);
|
|
|
+ result.setCategoryVos(categoryVos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public List<TextbookStudentSemesterVo> getStudentSemesterList() {
|
|
|
- //获取当前学生领取记录的所有学期
|
|
|
- MPJLambdaWrapper<TextbookStudentClaim> qwerySemester = new MPJLambdaWrapper<>();
|
|
|
- qwerySemester
|
|
|
- .distinct()
|
|
|
- .disableSubLogicDel()
|
|
|
- .selectAs(BaseSemester::getName, TextbookStudentSemesterVo::getBaseSemesterIdCN)
|
|
|
- .select(TextbookStudentClaim.class, x -> VoToColumnUtil.fieldsToColumns(TextbookStudentSemesterVo.class).contains(x.getProperty()))
|
|
|
- .innerJoin(BaseSemester.class, BaseSemester::getId, TextbookStudentClaim::getBaseSemesterId)
|
|
|
- .eq(TextbookStudentClaim::getStudentUserId, StpUtil.getLoginIdAsLong());
|
|
|
- List<TextbookStudentSemesterVo> textbookStudentSemesterVoList = this.selectJoinList(TextbookStudentSemesterVo.class, qwerySemester);
|
|
|
- if (ObjectUtil.isNull(textbookStudentSemesterVoList) && textbookStudentSemesterVoList.isEmpty()) {
|
|
|
- return null;
|
|
|
+ // 获取当前学生的信息
|
|
|
+ BaseStudentSchoolRoll baseStudentSchoolRoll = baseStudentSchoolRollMapper.selectOne(
|
|
|
+ Wrappers.lambdaQuery(BaseStudentSchoolRoll.class)
|
|
|
+ .eq(BaseStudentSchoolRoll::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
+ .eq(BaseStudentSchoolRoll::getUserId, StpUtil.getLoginIdAsLong())
|
|
|
+ );
|
|
|
+
|
|
|
+ if(ObjectUtils.isEmpty(baseStudentSchoolRoll)){
|
|
|
+ throw new MyException("用户信息错误,请重新登录");
|
|
|
}
|
|
|
|
|
|
- //为每个学期添加未领取人数
|
|
|
- for (TextbookStudentSemesterVo textbookStudentSemesterVo : textbookStudentSemesterVoList) {
|
|
|
- LambdaQueryWrapper<TextbookStudentClaim> queryWrapperNotClaimNum = new LambdaQueryWrapper<>();
|
|
|
- queryWrapperNotClaimNum
|
|
|
- .eq(TextbookStudentClaim::getStudentUserId, StpUtil.getLoginIdAsLong())
|
|
|
- .eq(TextbookStudentClaim::getBaseSemesterId, textbookStudentSemesterVo.getBaseSemesterId())
|
|
|
- .eq(TextbookStudentClaim::getIsClaim, 0);
|
|
|
- Long notClaimNum = this.count(queryWrapperNotClaimNum);
|
|
|
- textbookStudentSemesterVo.setNotClaimNum(notClaimNum);
|
|
|
- }
|
|
|
- return textbookStudentSemesterVoList;
|
|
|
+ // 学生查看自己的教材来源于两个方面,一个是班级申领教材,一个是个人申领的教材
|
|
|
+ // 班级申领教材
|
|
|
+ MPJLambdaWrapper<WfTextbookClaim>classMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ classMPJLambdaWrapper
|
|
|
+ .selectAs(WfTextbookClaim::getBaseSemesterId, TextbookStudentSemesterVo::getBaseSemesterId)
|
|
|
+ .selectAs(BaseSemester::getName, TextbookStudentSemesterVo::getBaseSemesterIdCN)
|
|
|
+ .leftJoin(BaseSemester.class, BaseSemester::getId, WfTextbookClaim::getBaseSemesterId)
|
|
|
+ .eq(WfTextbookClaim::getClassId, baseStudentSchoolRoll.getClassId())
|
|
|
+ .eq(WfTextbookClaim::getClaimType, ClaimTypeEnum.ClaimClass.getCode())
|
|
|
+ ;
|
|
|
+ List<TextbookStudentSemesterVo> classList = wfTextbookClaimMapper.selectJoinList(TextbookStudentSemesterVo.class, classMPJLambdaWrapper);
|
|
|
+
|
|
|
+ // 个人申领的教材
|
|
|
+ MPJLambdaWrapper<WfTextbookClaim> personalMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ personalMPJLambdaWrapper
|
|
|
+ .selectAs(WfTextbookClaim::getBaseSemesterId, TextbookStudentSemesterVo::getBaseSemesterId)
|
|
|
+ .selectAs(BaseSemester::getName, TextbookStudentSemesterVo::getBaseSemesterIdCN)
|
|
|
+ .leftJoin(BaseSemester.class, BaseSemester::getId, WfTextbookClaim::getBaseSemesterId)
|
|
|
+ .eq(WfTextbookClaim::getApplicantUserId, baseStudentSchoolRoll.getUserId())
|
|
|
+ .eq(WfTextbookClaim::getClaimType, ClaimTypeEnum.ClaimStudent.getCode())
|
|
|
+ ;
|
|
|
+ List<TextbookStudentSemesterVo> personalList = wfTextbookClaimMapper.selectJoinList(TextbookStudentSemesterVo.class, personalMPJLambdaWrapper);
|
|
|
+
|
|
|
+ // 合并两个列表
|
|
|
+ List<TextbookStudentSemesterVo> mergedList = Stream.concat(classList.stream(), personalList.stream())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 根据 baseSemesterId 去重
|
|
|
+ List<TextbookStudentSemesterVo> distinctList = new ArrayList<>(mergedList.stream()
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ TextbookStudentSemesterVo::getBaseSemesterId, // 以 baseSemesterId 作为去重依据
|
|
|
+ vo -> vo, // 保留原始对象
|
|
|
+ (existing, replacement) -> existing // 如果重复,保留已存在的对象
|
|
|
+ ))
|
|
|
+ .values());
|
|
|
+
|
|
|
+ // 根据 baseSemesterIdCN 排序
|
|
|
+ distinctList.sort(Comparator.comparing(TextbookStudentSemesterVo::getBaseSemesterIdCN));
|
|
|
+
|
|
|
+// //为每个学期添加未领取人数
|
|
|
+// for (TextbookStudentSemesterVo textbookStudentSemesterVo : textbookStudentSemesterVoList) {
|
|
|
+// LambdaQueryWrapper<TextbookStudentClaim> queryWrapperNotClaimNum = new LambdaQueryWrapper<>();
|
|
|
+// queryWrapperNotClaimNum
|
|
|
+// .eq(TextbookStudentClaim::getStudentUserId, StpUtil.getLoginIdAsLong())
|
|
|
+// .eq(TextbookStudentClaim::getBaseSemesterId, textbookStudentSemesterVo.getBaseSemesterId())
|
|
|
+// .eq(TextbookStudentClaim::getIsClaim, 0);
|
|
|
+// Long notClaimNum = this.count(queryWrapperNotClaimNum);
|
|
|
+// textbookStudentSemesterVo.setNotClaimNum(notClaimNum);
|
|
|
+// }
|
|
|
+ return distinctList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public IPage<TeacherCheckByclassVo> getTeacherCheckByclassList(TeacherCheckByclassDto dto) {
|
|
|
// 如果没有传入班级id
|
|
|
- if(ObjectUtils.isEmpty(dto.getClassIdList())){
|
|
|
+ if (ObjectUtils.isEmpty(dto.getClassIdList())) {
|
|
|
//根据当前班主任用户查出所管理的班级Id
|
|
|
LambdaQueryWrapper<BaseClass> queryWrapperClassId = new LambdaQueryWrapper<>();
|
|
|
queryWrapperClassId
|
|
|
@@ -294,33 +448,18 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
|
|
|
@Override
|
|
|
public IPage<TeacherCheckByStuVo> getTeacherCheckByStuList(TeacherCheckByStuDto dto) {
|
|
|
- // 如果没有传入班级id
|
|
|
- if(ObjectUtils.isEmpty(dto.getClassIdList())) {
|
|
|
- //根据当前班主任用户查出所管理的班级Id
|
|
|
- LambdaQueryWrapper<BaseClass> queryWrapperClassId = new LambdaQueryWrapper<>();
|
|
|
- queryWrapperClassId.eq(BaseClass::getTeacherId, StpUtil.getLoginIdAsLong());
|
|
|
- List<BaseClass> baseClassList = baseClassService.list(queryWrapperClassId);
|
|
|
- if (ObjectUtil.isNull(baseClassList) && baseClassList.isEmpty()) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- List<Long> classIdList = new ArrayList<>();
|
|
|
- for (BaseClass baseClass : baseClassList) {
|
|
|
- classIdList.add(baseClass.getId());
|
|
|
- }
|
|
|
- dto.setClassIdList(classIdList);
|
|
|
- }
|
|
|
-
|
|
|
// 获取班级申领的所有教材
|
|
|
MPJLambdaWrapper<WfTextbookClaimItem> wfTextbookClaimItemMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
wfTextbookClaimItemMPJLambdaWrapper
|
|
|
+ .distinct()
|
|
|
.selectAs(WfTextbookClaim::getClassId, TextbookClaimVO::getTextbookStudentClaimId)
|
|
|
.selectAs(WfTextbookClaimItem::getTextbookId, TextbookClaimVO::getTextbookId)
|
|
|
.selectAs(Textbook::getBookName, TextbookClaimVO::getBookName)
|
|
|
.innerJoin(WfTextbookClaim.class, WfTextbookClaim::getId, WfTextbookClaimItem::getWfTextbookClaimId)
|
|
|
.leftJoin(Textbook.class, Textbook::getId, WfTextbookClaimItem::getTextbookId)
|
|
|
- .in(WfTextbookClaim::getClassId, dto.getClassIdList())
|
|
|
+ .eq(WfTextbookClaim::getClassId, dto.getClassId())
|
|
|
.eq(WfTextbookClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(WfTextbookClaim::getClaimType, ClaimTypeEnum.ClaimClass.getCode())
|
|
|
;
|
|
|
List<TextbookClaimVO> textbookClaimVOList = wfTextbookClaimItemMapper.selectJoinList(TextbookClaimVO.class, wfTextbookClaimItemMPJLambdaWrapper);
|
|
|
|
|
|
@@ -331,7 +470,7 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
LambdaQueryWrapper<TextbookStudentClaim> textbookStudentClaimLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
textbookStudentClaimLambdaQueryWrapper
|
|
|
.eq(TextbookStudentClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
- .in(TextbookStudentClaim::getClassId, dto.getClassIdList())
|
|
|
+ .eq(TextbookStudentClaim::getClassId, dto.getClassId())
|
|
|
.eq(TextbookStudentClaim::getDeleteMark, DeleteMark.NODELETE.getCode())
|
|
|
;
|
|
|
List<TextbookStudentClaim> textbookStudentClaimList = textbookStudentClaimMapper.selectList(textbookStudentClaimLambdaQueryWrapper);
|
|
|
@@ -339,19 +478,41 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
Map<String, TextbookStudentClaim> byClassIdAndUserIdAndBook = textbookStudentClaimList.stream()
|
|
|
.collect(Collectors.toMap(t -> "" + t.getStudentUserId() + t.getTextbookId(), t -> t, (t1, t2) -> t1));
|
|
|
|
|
|
-// Map<Long, List<TextbookStudentClaim>> groupByUserId = textbookStudentClaimList.stream()
|
|
|
-// .collect(Collectors.groupingBy(TextbookStudentClaim::get))
|
|
|
-//
|
|
|
-// List<Long> userIds = recordsInPage.stream()
|
|
|
-// .map(TeacherCheckByStuVo::getStudentUserId)
|
|
|
-// .collect(Collectors.toList());
|
|
|
-// if(ObjectUtils.isNotEmpty(dto.getClaimStatus())
|
|
|
-// && dto.getClaimStatus() != 1
|
|
|
-// ){
|
|
|
-// // 获取已经完全领取的学生的id
|
|
|
-// // 获取所有学生已经领取的教材的数量
|
|
|
-// MPJLambdaWrapper<>
|
|
|
-// }
|
|
|
+ Map<Long, List<TextbookStudentClaim>> groupByUserId = textbookStudentClaimList.stream()
|
|
|
+ .collect(Collectors.groupingBy(TextbookStudentClaim::getStudentUserId));
|
|
|
+
|
|
|
+ // 已经全部发完的用户
|
|
|
+ List<Long> allClaimUserIds = new ArrayList<>();
|
|
|
+ List<Long> partClaimUserIds = new ArrayList<>();
|
|
|
+ for (Map.Entry<Long, List<TextbookStudentClaim>> entry : groupByUserId.entrySet()) {
|
|
|
+ Long key = entry.getKey();
|
|
|
+ List<TextbookStudentClaim> value = entry.getValue();
|
|
|
+ if(ObjectUtils.isEmpty(value)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ Set<Long> distinctTextbookIds = value.stream()
|
|
|
+ .filter(t -> t.getIsClaim() == 1)
|
|
|
+ .map(TextbookStudentClaim::getTextbookId) // 提取 textbookId
|
|
|
+ .collect(Collectors.toSet()); // 收集到 Set 中自动去重
|
|
|
+
|
|
|
+ TextbookStudentClaim one = value.get(0);
|
|
|
+ Long classId = one.getClassId();
|
|
|
+ if(ObjectUtils.isEmpty(classId)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<TextbookClaimVO> classTextbook = textbookByClassIdMap.get(classId);
|
|
|
+ if(ObjectUtils.isEmpty(classTextbook)){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if(distinctTextbookIds.size() == classTextbook.size()){
|
|
|
+ allClaimUserIds.add(key);
|
|
|
+ }else {
|
|
|
+ partClaimUserIds.add(key);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
// 获取班上所有在读学生
|
|
|
MPJLambdaWrapper<BaseStudentSchoolRoll> baseStudentSchoolRollMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
@@ -363,23 +524,44 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
.leftJoin(XjrUser.class, XjrUser::getId, BaseStudentSchoolRoll::getUserId)
|
|
|
.leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentSchoolRoll::getUserId)
|
|
|
.eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
|
|
|
- .in(BaseStudentSchoolRoll::getClassId, dto.getClassIdList())
|
|
|
- .eq(ObjectUtils.isNotEmpty(dto.getStudentUserId()), BaseStudentSchoolRoll::getUserId, dto.getStudentUserId())
|
|
|
- ;
|
|
|
+ ;
|
|
|
+ if(ObjectUtils.isNotEmpty(dto.getStudentUserId())){
|
|
|
+ baseStudentSchoolRollMPJLambdaWrapper
|
|
|
+ .eq(BaseStudentSchoolRoll::getUserId, dto.getStudentUserId());
|
|
|
+ } else if(ObjectUtils.isNotEmpty(dto.getClaimStatus()) && dto.getClaimStatus() == 2){
|
|
|
+ if(ObjectUtils.isEmpty(allClaimUserIds)){
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ baseStudentSchoolRollMPJLambdaWrapper
|
|
|
+ .in(BaseStudentSchoolRoll::getUserId, allClaimUserIds);
|
|
|
+ } else if(ObjectUtils.isNotEmpty(dto.getClaimStatus()) && dto.getClaimStatus() == 3){
|
|
|
+ if(ObjectUtils.isEmpty(partClaimUserIds)){
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ baseStudentSchoolRollMPJLambdaWrapper
|
|
|
+ .in(BaseStudentSchoolRoll::getUserId, partClaimUserIds);
|
|
|
+ } else {
|
|
|
+ if(ObjectUtils.isEmpty(dto.getClassId())){
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ baseStudentSchoolRollMPJLambdaWrapper
|
|
|
+ .eq(BaseStudentSchoolRoll::getClassId, dto.getClassId());
|
|
|
+ }
|
|
|
+
|
|
|
IPage<TeacherCheckByStuVo> teacherCheckByStuVoList = baseStudentSchoolRollMapper.selectJoinPage(ConventPage.getPage(dto), TeacherCheckByStuVo.class, baseStudentSchoolRollMPJLambdaWrapper);
|
|
|
|
|
|
TextbookStudentClaim oldTextbookStudentClaim;
|
|
|
- for (TeacherCheckByStuVo vo : teacherCheckByStuVoList.getRecords()){
|
|
|
+ for (TeacherCheckByStuVo vo : teacherCheckByStuVoList.getRecords()) {
|
|
|
List<TextbookClaimVO> stuTextbooks = textbookByClassIdMap.get(vo.getClassId());
|
|
|
- for (TextbookClaimVO textbookClaimVO : stuTextbooks){
|
|
|
+ for (TextbookClaimVO textbookClaimVO : stuTextbooks) {
|
|
|
textbookClaimVO.setTextbookStudentClaimId(null);
|
|
|
textbookClaimVO.setStudentUserId(vo.getStudentUserId());
|
|
|
String key = "" + vo.getStudentUserId() + textbookClaimVO.getTextbookId();
|
|
|
oldTextbookStudentClaim = byClassIdAndUserIdAndBook.get(key);
|
|
|
- if(ObjectUtils.isNotEmpty(oldTextbookStudentClaim)){
|
|
|
+ if (ObjectUtils.isNotEmpty(oldTextbookStudentClaim)) {
|
|
|
textbookClaimVO.setTextbookStudentClaimId(oldTextbookStudentClaim.getId());
|
|
|
textbookClaimVO.setIsClaim(oldTextbookStudentClaim.getIsClaim());
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
textbookClaimVO.setIsClaim(0);
|
|
|
}
|
|
|
}
|
|
|
@@ -414,7 +596,7 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
setModifyDate(new Date());
|
|
|
setIsClaim(1);
|
|
|
- }},Wrappers.<TextbookStudentClaim>query().lambda()
|
|
|
+ }}, Wrappers.<TextbookStudentClaim>query().lambda()
|
|
|
.in(TextbookStudentClaim::getId, textbookStudentClaimIds));
|
|
|
// for (Long textbookStudentClaimId : textbookStudentClaimIds) {
|
|
|
// this.updateById(new TextbookStudentClaim() {{
|
|
|
@@ -431,7 +613,7 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
public List<TeacherCheckStuClaimVo> getTeacherCheckStuClaimList(TeacherCheckStuClaimDto dto) {
|
|
|
// List<TeacherCheckStuClaimVo> teacherCheckStuClaimVos = textbookStudentClaimMapper.getTeacherCheckStuClaimList(dto);
|
|
|
Textbook textbook = textbookMapper.selectById(dto.getTextbookId());
|
|
|
- if(ObjectUtils.isEmpty(textbook)){
|
|
|
+ if (ObjectUtils.isEmpty(textbook)) {
|
|
|
throw new MyException("教材不存在,请刷新重试");
|
|
|
}
|
|
|
|
|
|
@@ -465,26 +647,26 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
.eq(TextbookStudentClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
.eq(TextbookStudentClaim::getTextbookId, dto.getTextbookId())
|
|
|
.eq(TextbookStudentClaim::getClassId, dto.getClassId())
|
|
|
- ;
|
|
|
+ ;
|
|
|
List<TeacherCheckStuClaimVo> isClaimList = textbookStudentClaimMapper.selectJoinList(TeacherCheckStuClaimVo.class, textbookStudentClaimMPJLambdaWrapper);
|
|
|
|
|
|
Map<Long, TeacherCheckStuClaimVo> isClaimByUserIdMap = isClaimList.stream()
|
|
|
.collect(Collectors.toMap(TeacherCheckStuClaimVo::getStudentUserId, t -> t, (t1, t2) -> t1));
|
|
|
|
|
|
- for (TeacherCheckStuClaimVo stu : stuList){
|
|
|
+ for (TeacherCheckStuClaimVo stu : stuList) {
|
|
|
stu.setTextbookId(textbook.getId());
|
|
|
stu.setBookName(textbook.getBookName());
|
|
|
|
|
|
TeacherCheckStuClaimVo isClaim = isClaimByUserIdMap.get(stu.getStudentUserId());
|
|
|
- if(ObjectUtils.isNotEmpty(isClaim)){
|
|
|
+ if (ObjectUtils.isNotEmpty(isClaim)) {
|
|
|
stu.setTextbookStudentClaimId(isClaim.getTextbookStudentClaimId());
|
|
|
stu.setIsClaim(isClaim.getIsClaim());
|
|
|
- if(isClaim.getIsClaim() == 1){
|
|
|
+ if (isClaim.getIsClaim() == 1) {
|
|
|
result.add(stu);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
result.add(0, stu);
|
|
|
}
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
stu.setIsClaim(0);
|
|
|
result.add(0, stu);
|
|
|
}
|
|
|
@@ -497,51 +679,66 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
public List<TextbookClaimVO> getTeacherGetStuNoClaimList(Long studentUserId) {
|
|
|
MPJLambdaWrapper<TextbookStudentClaim> queryTextbookClaimVOList = new MPJLambdaWrapper<>();
|
|
|
queryTextbookClaimVOList.selectAs(TextbookStudentClaim::getId, TextbookClaimVO::getTextbookStudentClaimId).selectAs(Textbook::getBookName, TextbookClaimVO::getBookName).select(TextbookStudentClaim.class, x -> VoToColumnUtil.fieldsToColumns(TextbookClaimVO.class).contains(x.getProperty())).leftJoin(Textbook.class, Textbook::getId, TextbookStudentClaim::getTextbookId).eq(TextbookStudentClaim::getStudentUserId, studentUserId).disableSubLogicDel();
|
|
|
- List<TextbookClaimVO> textbookClaimVOList = this.selectJoinList(TextbookClaimVO.class, queryTextbookClaimVOList);
|
|
|
- return textbookClaimVOList;
|
|
|
+ return this.selectJoinList(TextbookClaimVO.class, queryTextbookClaimVOList);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public Boolean teacherConfirmBatchBytTextbook(List<TeacherConfirmBatchByTextbookDto> dtos) {
|
|
|
+ public Boolean teacherConfirmBatchBytTextbook(TeacherConfirmBatchByTextbookDto dto) {
|
|
|
+ // 根据学期,班级,学生,教材信息获取记录
|
|
|
+ LambdaQueryWrapper<TextbookStudentClaim> textbookStudentClaimLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ textbookStudentClaimLambdaQueryWrapper
|
|
|
+ .eq(TextbookStudentClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(TextbookStudentClaim::getClassId, dto.getClassId())
|
|
|
+ .in(TextbookStudentClaim::getStudentUserId, dto.getUserIds())
|
|
|
+ .in(TextbookStudentClaim::getTextbookId, dto.getTextbookIds())
|
|
|
+ ;
|
|
|
+ List<TextbookStudentClaim> textbookStudentClaimList = textbookStudentClaimMapper.selectList(textbookStudentClaimLambdaQueryWrapper);
|
|
|
+
|
|
|
+ Map<String, TextbookStudentClaim> byUserIdAndTextbookId = textbookStudentClaimList.stream()
|
|
|
+ .collect(Collectors.toMap(t -> "" + t.getStudentUserId() + t.getTextbookId(), t -> t, (t1, t2) -> t1));
|
|
|
+
|
|
|
+
|
|
|
List<TextbookStudentClaim> insertList = new ArrayList<>();
|
|
|
- TextbookStudentClaim textbookStudentClaim;
|
|
|
- for (TeacherConfirmBatchByTextbookDto dto : dtos) {
|
|
|
- // 根据当前教材和当前班级获取到没有领取的学生
|
|
|
- MPJLambdaWrapper<BaseStudentSchoolRoll> baseStudentSchoolRollMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
- baseStudentSchoolRollMPJLambdaWrapper
|
|
|
- .select(BaseStudentSchoolRoll::getId)
|
|
|
- .select(BaseStudentSchoolRoll.class,x -> VoToColumnUtil.fieldsToColumns(BaseStudentSchoolRoll.class).contains(x.getProperty()))
|
|
|
- .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
|
|
|
- .eq(BaseStudentSchoolRoll::getClassId, dto.getClassId())
|
|
|
- .notExists("SELECT 1" +
|
|
|
- " FROM textbook_student_claim t1" +
|
|
|
- " WHERE t1.student_user_id = t.user_id" +
|
|
|
- " AND t1.base_semester_id = {0}" +
|
|
|
- " AND t1.textbook_id = {1}" +
|
|
|
- " AND t1.class_id = {2}", dto.getBaseSemesterId(), dto.getTextbookId(), dto.getClassId())
|
|
|
- ;
|
|
|
- List<BaseStudentSchoolRoll> baseStudentSchoolRolls = baseStudentSchoolRollMapper.selectJoinList(BaseStudentSchoolRoll.class, baseStudentSchoolRollMPJLambdaWrapper);
|
|
|
- if(ObjectUtils.isEmpty(baseStudentSchoolRolls)){
|
|
|
- continue;
|
|
|
+ List<TextbookStudentClaim> updateList = new ArrayList<>();
|
|
|
+ TextbookStudentClaim oldTextbookStudentClaim;
|
|
|
+ TextbookStudentClaim insertTextbookStudentClaim;
|
|
|
+ TextbookStudentClaim updateTextbookStudentClaim;
|
|
|
+ Date nowDate = new Date();
|
|
|
+ Long loginUserId = StpUtil.getLoginIdAsLong();
|
|
|
+ for (Long textbookId : dto.getTextbookIds()){
|
|
|
+ for (Long userId : dto.getUserIds()){
|
|
|
+ oldTextbookStudentClaim = byUserIdAndTextbookId.get("" + userId + textbookId);
|
|
|
+ if(ObjectUtils.isNotEmpty(oldTextbookStudentClaim)){
|
|
|
+ updateTextbookStudentClaim = new TextbookStudentClaim();
|
|
|
+ updateTextbookStudentClaim.setId(oldTextbookStudentClaim.getId());
|
|
|
+ updateTextbookStudentClaim.setIsClaim(oldTextbookStudentClaim.getIsClaim() == 1 ? 0 : 1);
|
|
|
+ updateTextbookStudentClaim.setModifyDate(nowDate);
|
|
|
+ updateTextbookStudentClaim.setModifyUserId(loginUserId);
|
|
|
+ updateList.add(updateTextbookStudentClaim);
|
|
|
+ }else {
|
|
|
+ insertTextbookStudentClaim = new TextbookStudentClaim();
|
|
|
+ insertTextbookStudentClaim.setBaseSemesterId(dto.getBaseSemesterId());
|
|
|
+ insertTextbookStudentClaim.setClassId(dto.getClassId());
|
|
|
+ insertTextbookStudentClaim.setStudentUserId(userId);
|
|
|
+ insertTextbookStudentClaim.setTextbookId(textbookId);
|
|
|
+ insertTextbookStudentClaim.setIsClaim(1);
|
|
|
+ insertTextbookStudentClaim.setCreateDate(nowDate);
|
|
|
+ insertTextbookStudentClaim.setCreateUserId(loginUserId);
|
|
|
+ insertList.add(insertTextbookStudentClaim);
|
|
|
+ }
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- for (BaseStudentSchoolRoll baseStudentSchoolRoll : baseStudentSchoolRolls){
|
|
|
- textbookStudentClaim = new TextbookStudentClaim();
|
|
|
- textbookStudentClaim.setBaseSemesterId(dto.getBaseSemesterId());
|
|
|
- textbookStudentClaim.setTextbookId(dto.getTextbookId());
|
|
|
- textbookStudentClaim.setClassId(dto.getClassId());
|
|
|
- textbookStudentClaim.setStudentUserId(baseStudentSchoolRoll.getUserId());
|
|
|
- textbookStudentClaim.setIsClaim(ObjectUtils.isNotEmpty(dto.getIsClaim()) ? dto.getIsClaim() : 1);
|
|
|
- textbookStudentClaim.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
- textbookStudentClaim.setCreateDate(new Date());
|
|
|
- insertList.add(textbookStudentClaim);
|
|
|
+ if (ObjectUtils.isNotEmpty(insertList)) {
|
|
|
+ for (TextbookStudentClaim insert : insertList) {
|
|
|
+ textbookStudentClaimMapper.insert(insert);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(ObjectUtils.isNotEmpty(insertList)){
|
|
|
- for (TextbookStudentClaim insert : insertList){
|
|
|
- textbookStudentClaimMapper.insert(insert);
|
|
|
+ if (ObjectUtils.isNotEmpty(updateList)) {
|
|
|
+ for (TextbookStudentClaim update : updateList) {
|
|
|
+ textbookStudentClaimMapper.updateById(update);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -551,22 +748,106 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public Boolean teacherConfirm(List<TeacherConfirmDto> dtos) {
|
|
|
- TextbookStudentClaim textbookStudentClaim;
|
|
|
+ List<Long> baseSemesterIds = dtos.stream()
|
|
|
+ .map(TeacherConfirmDto::getBaseSemesterId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Long> classIds = dtos.stream()
|
|
|
+ .map(TeacherConfirmDto::getClassId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Long> textbookIds = dtos.stream()
|
|
|
+ .map(TeacherConfirmDto::getTextbookId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<Long> studentUserIds = dtos.stream()
|
|
|
+ .map(TeacherConfirmDto::getStudentUserId)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 根据学期,班级,学生,教材信息获取记录
|
|
|
+ LambdaQueryWrapper<TextbookStudentClaim> textbookStudentClaimLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ textbookStudentClaimLambdaQueryWrapper
|
|
|
+ .in(TextbookStudentClaim::getBaseSemesterId, baseSemesterIds)
|
|
|
+ .in(TextbookStudentClaim::getClassId, classIds)
|
|
|
+ .in(TextbookStudentClaim::getStudentUserId, studentUserIds)
|
|
|
+ .in(TextbookStudentClaim::getTextbookId, textbookIds)
|
|
|
+ ;
|
|
|
+ List<TextbookStudentClaim> textbookStudentClaimList = textbookStudentClaimMapper.selectList(textbookStudentClaimLambdaQueryWrapper);
|
|
|
+
|
|
|
+ Map<String, TextbookStudentClaim> byUserIdAndTextbookId = textbookStudentClaimList.stream()
|
|
|
+ .collect(Collectors.toMap(t -> "" + t.getBaseSemesterId() + t.getClassId() + t.getStudentUserId() + t.getTextbookId(), t -> t, (t1, t2) -> t1));
|
|
|
+
|
|
|
+
|
|
|
+ List<TextbookStudentClaim> insertList = new ArrayList<>();
|
|
|
+ List<TextbookStudentClaim> updateList = new ArrayList<>();
|
|
|
+ TextbookStudentClaim oldTextbookStudentClaim;
|
|
|
+ TextbookStudentClaim insertTextbookStudentClaim;
|
|
|
+ TextbookStudentClaim updateTextbookStudentClaim;
|
|
|
+ Date nowDate = new Date();
|
|
|
+ Long loginUserId = StpUtil.getLoginIdAsLong();
|
|
|
for (TeacherConfirmDto dto : dtos){
|
|
|
- if(ObjectUtils.isNotEmpty(dto.getTextbookStudentClaimId()) && dto.getTextbookStudentClaimId() != 0){
|
|
|
- textbookStudentClaim = new TextbookStudentClaim();
|
|
|
- textbookStudentClaim.setId(dto.getTextbookStudentClaimId());
|
|
|
- textbookStudentClaim.setIsClaim(dto.getIsClaim());
|
|
|
- textbookStudentClaim.setModifyUserId(StpUtil.getLoginIdAsLong());
|
|
|
- textbookStudentClaim.setModifyDate(new Date());
|
|
|
- textbookStudentClaimMapper.updateById(textbookStudentClaim);
|
|
|
- }else {
|
|
|
- textbookStudentClaim = BeanUtil.toBean(dto, TextbookStudentClaim.class);
|
|
|
- textbookStudentClaim.setCreateUserId(StpUtil.getLoginIdAsLong());
|
|
|
- textbookStudentClaim.setCreateDate(new Date());
|
|
|
- textbookStudentClaimMapper.insert(textbookStudentClaim);
|
|
|
+ if (ObjectUtils.isNotEmpty(dto.getTextbookStudentClaimId())) {
|
|
|
+ updateTextbookStudentClaim = new TextbookStudentClaim();
|
|
|
+ updateTextbookStudentClaim.setId(dto.getTextbookStudentClaimId());
|
|
|
+ updateTextbookStudentClaim.setIsClaim(dto.getIsClaim());
|
|
|
+ updateTextbookStudentClaim.setModifyUserId(loginUserId);
|
|
|
+ updateTextbookStudentClaim.setModifyDate(nowDate);
|
|
|
+ updateList.add(updateTextbookStudentClaim);
|
|
|
+ } else {
|
|
|
+ oldTextbookStudentClaim = byUserIdAndTextbookId.get("" + dto.getBaseSemesterId() + dto.getClassId() + dto.getStudentUserId() + dto.getTextbookId());
|
|
|
+ if(ObjectUtils.isNotEmpty(oldTextbookStudentClaim)){
|
|
|
+ updateTextbookStudentClaim = new TextbookStudentClaim();
|
|
|
+ updateTextbookStudentClaim.setId(oldTextbookStudentClaim.getId());
|
|
|
+ updateTextbookStudentClaim.setIsClaim(oldTextbookStudentClaim.getIsClaim() == 1 ? 0 : 1);
|
|
|
+ updateTextbookStudentClaim.setModifyDate(nowDate);
|
|
|
+ updateTextbookStudentClaim.setModifyUserId(loginUserId);
|
|
|
+ updateList.add(updateTextbookStudentClaim);
|
|
|
+ }else {
|
|
|
+ insertTextbookStudentClaim = new TextbookStudentClaim();
|
|
|
+ insertTextbookStudentClaim.setBaseSemesterId(dto.getBaseSemesterId());
|
|
|
+ insertTextbookStudentClaim.setClassId(dto.getClassId());
|
|
|
+ insertTextbookStudentClaim.setStudentUserId(dto.getStudentUserId());
|
|
|
+ insertTextbookStudentClaim.setTextbookId(dto.getTextbookId());
|
|
|
+ insertTextbookStudentClaim.setIsClaim(1);
|
|
|
+ insertTextbookStudentClaim.setCreateDate(nowDate);
|
|
|
+ insertTextbookStudentClaim.setCreateUserId(loginUserId);
|
|
|
+ insertList.add(insertTextbookStudentClaim);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(insertList)) {
|
|
|
+ for (TextbookStudentClaim insert : insertList) {
|
|
|
+ textbookStudentClaimMapper.insert(insert);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotEmpty(updateList)) {
|
|
|
+ for (TextbookStudentClaim update : updateList) {
|
|
|
+ textbookStudentClaimMapper.updateById(update);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TeacherConfirmBatchTextbookListVo> teacherConfirmBatchTextbookList(TeacherConfirmBatchTextbookListDto dto) {
|
|
|
+ MPJLambdaWrapper<WfTextbookClaimItem> wfTextbookClaimItemMPJLambdaWrapper = new MPJLambdaWrapper<>();
|
|
|
+ wfTextbookClaimItemMPJLambdaWrapper
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .distinct()
|
|
|
+ .selectAs(WfTextbookClaimItem::getTextbookId, TeacherConfirmBatchTextbookListVo::getTextbookId)
|
|
|
+ .selectAs(Textbook::getBookName, TeacherConfirmBatchTextbookListVo::getBookName)
|
|
|
+ .innerJoin(WfTextbookClaim.class, WfTextbookClaim::getId, WfTextbookClaimItem::getWfTextbookClaimId)
|
|
|
+ .leftJoin(Textbook.class, Textbook::getId, WfTextbookClaimItem::getTextbookId)
|
|
|
+ .eq(WfTextbookClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
+ .eq(WfTextbookClaim::getClassId, dto.getClassId())
|
|
|
+ ;
|
|
|
+ return wfTextbookClaimItemMapper.selectJoinList(TeacherConfirmBatchTextbookListVo.class, wfTextbookClaimItemMPJLambdaWrapper);
|
|
|
+ }
|
|
|
}
|