|
@@ -2,26 +2,38 @@ package com.xjrsoft.module.textbook.service.impl;
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.enums.ClaimTypeEnum;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
+import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
import com.xjrsoft.module.base.service.IBaseSemesterService;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudent;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
|
import com.xjrsoft.module.teacher.entity.AttendanceRecord;
|
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
import com.xjrsoft.module.teacher.mapper.XjrUserMapper;
|
|
|
+import com.xjrsoft.module.textbook.dto.TeacherCheckByclassDto;
|
|
|
import com.xjrsoft.module.textbook.dto.TextbookClaimStudentConfirmDto;
|
|
|
import com.xjrsoft.module.textbook.entity.TextbookStudentClaim;
|
|
|
+import com.xjrsoft.module.textbook.entity.WfTextbookClaim;
|
|
|
+import com.xjrsoft.module.textbook.entity.WfTextbookClaimItem;
|
|
|
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.TeacherCheckByclassVo;
|
|
|
import com.xjrsoft.module.textbook.vo.TextbookClaimStudentConfirmVo;
|
|
|
import com.xjrsoft.module.textbook.vo.TextbookClaimVO;
|
|
|
+import com.xjrsoft.module.textbook.vo.TextbookStudentSemesterVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -39,6 +51,12 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
private final TextbookStudentClaimMapper textbookStudentClaimMapper;
|
|
|
private final IBaseSemesterService baseSemesterService;
|
|
|
|
|
|
+ private final IBaseClassService baseClassService;
|
|
|
+
|
|
|
+ private final WfTextbookClaimMapper wfTextbookClaimMapper;
|
|
|
+
|
|
|
+ private final WfTextbookClaimItemMapper wfTextbookClaimItemMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public TextbookClaimStudentConfirmVo getStudentConfirmList(TextbookClaimStudentConfirmDto dto) {
|
|
|
//判断输入的合法性
|
|
@@ -85,8 +103,91 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
.orderByDesc(AttendanceRecord::getId);
|
|
|
List<TextbookClaimVO> textbookClaimVOList = this.selectJoinList(TextbookClaimVO.class, queryTextbookClaimList);
|
|
|
textbookClaimStudentConfirmVo.setTextbookClaimVoList(textbookClaimVOList);*/
|
|
|
- List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimMapper.queryTextbookClaimList(dto.getBaseSemesterId(),StpUtil.getLoginIdAsLong());
|
|
|
+
|
|
|
+ dto.setStudentUserId(StpUtil.getLoginIdAsLong());
|
|
|
+
|
|
|
+ List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimMapper.getTextbookClaimList(dto);
|
|
|
+
|
|
|
textbookClaimStudentConfirmVo.setTextbookClaimVoList(textbookClaimVOList);
|
|
|
return textbookClaimStudentConfirmVo;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TextbookStudentSemesterVo> getStudentSemesterList() {
|
|
|
+ return textbookStudentClaimMapper.getStudentSemesterList(StpUtil.getLoginIdAsLong());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<TeacherCheckByclassVo> getTeacherCheckByclassList(TeacherCheckByclassDto dto) {
|
|
|
+ //根据当前班主任用户查出所管理的班级Id
|
|
|
+ LambdaQueryWrapper<BaseClass> queryWrapperClassId = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapperClassId
|
|
|
+ .eq(BaseClass::getTeacherId,StpUtil.getLoginIdAsLong());
|
|
|
+ BaseClass baseClass = baseClassService.getOne(queryWrapperClassId);
|
|
|
+ if(ObjectUtil.isNull(baseClass)){
|
|
|
+ throw new MyException("班级信息获取失败");
|
|
|
+ }
|
|
|
+ Long classId = baseClass.getId();
|
|
|
+
|
|
|
+ dto.setClassId(classId);
|
|
|
+
|
|
|
+ //将班上所有发放的教材进行分组,查询出list集合
|
|
|
+ List<TeacherCheckByclassVo> teacherCheckByclassVoList = textbookStudentClaimMapper.getTeacherCheckByclassList(classId);
|
|
|
+
|
|
|
+ //实际领取教材数量
|
|
|
+ //根据班主任ID和班级ID找到所有班主任为该班申请的教材的所有申领记录,申领类型应该为学生
|
|
|
+ LambdaQueryWrapper<WfTextbookClaim> queryWrapperWfTextbookClaim = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapperWfTextbookClaim
|
|
|
+ .eq(WfTextbookClaim::getApplicantUserId,StpUtil.getLoginIdAsLong())
|
|
|
+ .eq(WfTextbookClaim::getClaimType, ClaimTypeEnum.ClaimStudent.getCode())
|
|
|
+ .eq(WfTextbookClaim::getClassId,classId);
|
|
|
+ List<WfTextbookClaim> wfTextbookClaimList = wfTextbookClaimMapper.selectList(queryWrapperWfTextbookClaim);
|
|
|
+ if(ObjectUtil.isNull(wfTextbookClaimList) || wfTextbookClaimList.size() == 0){
|
|
|
+ throw new MyException("未找到教材申请数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Long> wfTextbookClaimIdList = new ArrayList<>();
|
|
|
+ for (WfTextbookClaim w : wfTextbookClaimList) {
|
|
|
+ wfTextbookClaimIdList.add(w.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据申领记录ID找到其关联的所有申领项中当前教材的已经发放数量数据
|
|
|
+ for (TeacherCheckByclassVo t: teacherCheckByclassVoList) {
|
|
|
+ LambdaQueryWrapper<WfTextbookClaimItem> queryWrapperWfTextbookClaimItem = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapperWfTextbookClaimItem
|
|
|
+ .in(WfTextbookClaimItem::getWfTextbookClaimId,wfTextbookClaimIdList)
|
|
|
+ .eq(WfTextbookClaimItem::getTextbookId, t.getTextbookId());
|
|
|
+ List<WfTextbookClaimItem> wfTextbookClaimItemList = wfTextbookClaimItemMapper.selectList(queryWrapperWfTextbookClaimItem);
|
|
|
+ Integer issueNumber = 0;
|
|
|
+ for (WfTextbookClaimItem w : wfTextbookClaimItemList) {
|
|
|
+ issueNumber += w.getIssueNumber();
|
|
|
+ }
|
|
|
+ t.setActualReceivedNum(issueNumber);
|
|
|
+ }
|
|
|
+
|
|
|
+ //已经确认领取人数
|
|
|
+ for (TeacherCheckByclassVo t: teacherCheckByclassVoList) {
|
|
|
+ LambdaQueryWrapper<TextbookStudentClaim> queryWrapperTextbookStudentClaimCount = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapperTextbookStudentClaimCount
|
|
|
+ .in(TextbookStudentClaim::getClassId,classId)
|
|
|
+ .eq(TextbookStudentClaim::getTextbookId, t.getTextbookId())
|
|
|
+ .eq(TextbookStudentClaim::getIsClaim, 1);
|
|
|
+ Long count = this.count(queryWrapperTextbookStudentClaimCount);
|
|
|
+ t.setActualClaimNum(count);
|
|
|
+ }
|
|
|
+
|
|
|
+ return teacherCheckByclassVoList;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public Boolean updateByIds(List<Long> textbookStudentClaimIds) {
|
|
|
+ for (Long textbookStudentClaimId : textbookStudentClaimIds) {
|
|
|
+ this.updateById(new TextbookStudentClaim(){{
|
|
|
+ setId(textbookStudentClaimId);
|
|
|
+ setIsClaim(1);
|
|
|
+ }});
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|