|
@@ -3,10 +3,11 @@ 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.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
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.common.page.ConventPage;
|
|
|
import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
import com.xjrsoft.module.base.entity.BaseSemester;
|
|
@@ -60,11 +61,6 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
|
|
|
@Override
|
|
|
public TextbookClaimStudentConfirmVo getStudentConfirmList(TextbookClaimStudentConfirmDto dto) {
|
|
|
- //判断输入的合法性
|
|
|
- if(ObjectUtil.isNull(dto.getBaseSemesterId()) || dto.getBaseSemesterId() <= 0){
|
|
|
- throw new MyException("请选择学期");
|
|
|
- }
|
|
|
-
|
|
|
//获取当前登录学生的信息
|
|
|
MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
|
|
|
queryUser
|
|
@@ -79,32 +75,13 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
.orderByDesc(AttendanceRecord::getId);
|
|
|
TextbookClaimStudentConfirmVo textbookClaimStudentConfirmVo = xjrUserMapper.selectJoinOne(TextbookClaimStudentConfirmVo.class, queryUser);
|
|
|
if(ObjectUtil.isNull(textbookClaimStudentConfirmVo)){
|
|
|
- throw new MyException("未找到该学生的相关信息");
|
|
|
+ throw new MyException("登录信息出错,请重新登录");
|
|
|
}
|
|
|
|
|
|
//根据学期id查出学期名称
|
|
|
BaseSemester baseSemester = baseSemesterService.getById(dto.getBaseSemesterId());
|
|
|
- if(ObjectUtil.isNull(baseSemester)){
|
|
|
- throw new MyException("学期不存在");
|
|
|
- }
|
|
|
textbookClaimStudentConfirmVo.setBaseSemesterCN(baseSemester.getName());
|
|
|
|
|
|
- //查出整个学生教材认领记录集合
|
|
|
- /*MPJLambdaWrapper<TextbookStudentClaim> queryTextbookClaimList = new MPJLambdaWrapper<>();
|
|
|
- queryTextbookClaimList
|
|
|
- .selectAs(TextbookStudentClaim::getId, TextbookClaimVO::getTextbookStudentClaimId)
|
|
|
- .selectFunc(() ->"t1.price * t1.discount", TextbookClaimVO::getDiscountPrice)
|
|
|
- .selectFunc("(%f * %f", arg -> arg.accept(Textbook::getPrice, Textbook::getDiscount), TextbookClaimVO::getDiscountPrice)
|
|
|
- .select(TextbookStudentClaim.class, x -> VoToColumnUtil.fieldsToColumns(TextbookClaimVO.class).contains(x.getProperty()))
|
|
|
- .select(Textbook.class, x -> VoToColumnUtil.fieldsToColumns(TextbookClaimVO.class).contains(x.getProperty()))
|
|
|
- .leftJoin(Textbook.class, Textbook::getId, TextbookStudentClaim::getTextbookId)
|
|
|
- .eq(TextbookStudentClaim::getStudentUserId, StpUtil.getLoginIdAsLong())
|
|
|
- .eq(TextbookStudentClaim::getBaseSemesterId, dto.getBaseSemesterId())
|
|
|
- .disableSubLogicDel()
|
|
|
- .orderByDesc(AttendanceRecord::getId);
|
|
|
- List<TextbookClaimVO> textbookClaimVOList = this.selectJoinList(TextbookClaimVO.class, queryTextbookClaimList);
|
|
|
- textbookClaimStudentConfirmVo.setTextbookClaimVoList(textbookClaimVOList);*/
|
|
|
-
|
|
|
dto.setStudentUserId(StpUtil.getLoginIdAsLong());
|
|
|
|
|
|
List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimMapper.getTextbookClaimList(dto);
|
|
@@ -115,169 +92,98 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
|
|
|
@Override
|
|
|
public List<TextbookStudentSemesterVo> getStudentSemesterList() {
|
|
|
- return textbookStudentClaimMapper.getStudentSemesterList(StpUtil.getLoginIdAsLong());
|
|
|
+ //获取当前学生领取记录的所有学期
|
|
|
+ MPJLambdaWrapper<TextbookStudentClaim> qwerySemester = new MPJLambdaWrapper<>();
|
|
|
+ qwerySemester
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .selectAs(BaseSemester::getName,TextbookStudentSemesterVo::getBaseSemesterIdCN)
|
|
|
+ .leftJoin(BaseSemester.class,BaseSemester::getId,TextbookStudentClaim::getBaseSemesterId)
|
|
|
+ .eq(TextbookStudentClaim::getStudentUserId,StpUtil.getLoginIdAsLong());
|
|
|
+ List<TextbookStudentSemesterVo> textbookStudentSemesterVoList = this.selectJoinList(TextbookStudentSemesterVo.class,qwerySemester);
|
|
|
+ if(ObjectUtil.isNull(textbookStudentSemesterVoList) && textbookStudentSemesterVoList.size() == 0){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //为每个学期添加未领取人数
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<TeacherCheckByclassVo> getTeacherCheckByclassList(TeacherCheckByclassDto dto) {
|
|
|
+ public IPage<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("班级信息获取失败");
|
|
|
+ List<BaseClass> baseClassList = baseClassService.list(queryWrapperClassId);
|
|
|
+ if(ObjectUtil.isNull(baseClassList) && baseClassList.size() == 0){
|
|
|
+ return null;
|
|
|
}
|
|
|
- Long classId = baseClass.getId();
|
|
|
-
|
|
|
- dto.setClassId(classId);
|
|
|
|
|
|
- //将班上所有发放的教材进行分组,查询出list集合
|
|
|
- List<TeacherCheckByclassVo> teacherCheckByclassVoList = textbookStudentClaimMapper.getTeacherCheckByclassList(classId);
|
|
|
-
|
|
|
- if(ObjectUtil.isNull(teacherCheckByclassVoList) || teacherCheckByclassVoList.size() == 0){
|
|
|
- throw new MyException("未找到教材领取数据");
|
|
|
- }
|
|
|
-
|
|
|
- //为每种教材添加统计值
|
|
|
- //实际领取教材数量
|
|
|
- //根据班主任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());
|
|
|
+ List<Long> classIdList = new ArrayList<>();
|
|
|
+ for (BaseClass baseClass : baseClassList) {
|
|
|
+ classIdList.add(baseClass.getId());
|
|
|
}
|
|
|
+ dto.setClassIdList(classIdList);
|
|
|
|
|
|
- //根据申领记录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);
|
|
|
- }
|
|
|
-
|
|
|
- Integer claimStatus = 1;
|
|
|
- //根据领取情况入参返回不同状态的数据
|
|
|
- if(ObjectUtil.isNotNull(dto.getClaimStatus())){
|
|
|
- claimStatus = dto.getClaimStatus();
|
|
|
- }
|
|
|
+ IPage<TeacherCheckByclassVo> teacherCheckByclassVoList = textbookStudentClaimMapper.getTeacherCheckByclassList(ConventPage.getPage(dto),dto);
|
|
|
|
|
|
- List<TeacherCheckByclassVo> result = new ArrayList<>();
|
|
|
+ //为每本书添加数据
|
|
|
+ for (TeacherCheckByclassVo t: teacherCheckByclassVoList.getRecords()) {
|
|
|
+ MPJLambdaWrapper<WfTextbookClaim> qweryActualReceivedNum = new MPJLambdaWrapper<>();
|
|
|
+ qweryActualReceivedNum
|
|
|
+ .disableSubLogicDel()
|
|
|
+ .selectSum(WfTextbookClaimItem::getIssueNumber,TeacherCheckByclassVo::getActualReceivedNum)
|
|
|
+ .leftJoin(WfTextbookClaimItem.class,WfTextbookClaimItem::getWfTextbookClaimId,WfTextbookClaim::getId)
|
|
|
+ .eq(WfTextbookClaim::getClassId,t.getClassId())
|
|
|
+ .eq(WfTextbookClaimItem::getTextbookId,t.getTextbookId());
|
|
|
+ TeacherCheckByclassVo teacherCheckByclassVo = wfTextbookClaimMapper.selectJoinOne(TeacherCheckByclassVo.class,qweryActualReceivedNum);
|
|
|
|
|
|
- if (claimStatus == 2){
|
|
|
- for (TeacherCheckByclassVo t : teacherCheckByclassVoList) {
|
|
|
- if (t.getClassStudentNum().compareTo(t.getActualReceivedNum()) == 0 && Long.valueOf(t.getClassStudentNum()).compareTo(t.getActualClaimNum()) == 0){
|
|
|
- result.add(t);
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
+ t.setActualReceivedNum(teacherCheckByclassVo.getActualReceivedNum());
|
|
|
|
|
|
- if (claimStatus == 3){
|
|
|
- for (TeacherCheckByclassVo t : teacherCheckByclassVoList) {
|
|
|
- if (t.getClassStudentNum().compareTo(t.getActualReceivedNum()) > 0 || Long.valueOf(t.getClassStudentNum()).compareTo(t.getActualClaimNum()) > 0){
|
|
|
- result.add(t);
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
+ LambdaQueryWrapper<TextbookStudentClaim> queryActualClaimNum = new LambdaQueryWrapper<>();
|
|
|
+ queryActualClaimNum
|
|
|
+ .eq(TextbookStudentClaim::getClassId, t.getClassId())
|
|
|
+ .eq(TextbookStudentClaim::getTextbookId, t.getTextbookId());
|
|
|
+ Long actualClaimNum = this.count(queryActualClaimNum);
|
|
|
+ t.setActualClaimNum(actualClaimNum);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
return teacherCheckByclassVoList;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<TeacherCheckByStuVo> getTeacherCheckByStuList(TeacherCheckByStuDto dto) {
|
|
|
+ public IPage<TeacherCheckByStuVo> getTeacherCheckByStuList(TeacherCheckByStuDto 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("班级信息获取失败");
|
|
|
+ List<BaseClass> baseClassList = baseClassService.list(queryWrapperClassId);
|
|
|
+ if(ObjectUtil.isNull(baseClassList) && baseClassList.size() == 0){
|
|
|
+ return null;
|
|
|
}
|
|
|
- Long classId = baseClass.getId();
|
|
|
|
|
|
- dto.setClassId(classId);
|
|
|
+ List<Long> classIdList = new ArrayList<>();
|
|
|
+ for (BaseClass baseClass : baseClassList) {
|
|
|
+ classIdList.add(baseClass.getId());
|
|
|
+ }
|
|
|
+ dto.setClassIdList(classIdList);
|
|
|
|
|
|
//将班上所有学生进行分组,查询出list集合
|
|
|
- List<TeacherCheckByStuVo> teacherCheckByStuVoList = textbookStudentClaimMapper.getTeacherCheckByStuList(dto);
|
|
|
-
|
|
|
- if(ObjectUtil.isNull(teacherCheckByStuVoList) || teacherCheckByStuVoList.size() == 0){
|
|
|
- throw new MyException("未找到学生数据");
|
|
|
- }
|
|
|
+ IPage<TeacherCheckByStuVo> teacherCheckByStuVoList = textbookStudentClaimMapper.getTeacherCheckByStuList(ConventPage.getPage(dto),dto);
|
|
|
|
|
|
//为每个学生添加教材领取记录集合
|
|
|
- for (TeacherCheckByStuVo t: teacherCheckByStuVoList) {
|
|
|
- List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimMapper.getTextbookClaimVOList(classId,t.getStudentUserId());
|
|
|
+ for (TeacherCheckByStuVo t: teacherCheckByStuVoList.getRecords()) {
|
|
|
+ List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimMapper.getTextbookClaimVOList(t.getStudentUserId());
|
|
|
t.setTextbookClaimVOList(textbookClaimVOList);
|
|
|
}
|
|
|
|
|
|
- Integer claimStatus = 1;
|
|
|
- //根据领取情况入参返回不同状态的数据
|
|
|
- if(ObjectUtil.isNotNull(dto.getClaimStatus())){
|
|
|
- claimStatus = dto.getClaimStatus();
|
|
|
- }
|
|
|
-
|
|
|
- List<TeacherCheckByStuVo> result = new ArrayList<>();
|
|
|
-
|
|
|
- if (claimStatus == 2){
|
|
|
- for (TeacherCheckByStuVo t : teacherCheckByStuVoList) {
|
|
|
- int claimNum = 0;
|
|
|
- for (TextbookClaimVO textbookClaimVO : t.getTextbookClaimVOList()) {
|
|
|
- if (textbookClaimVO.getIsClaim() == 1){
|
|
|
- claimNum++;
|
|
|
- }
|
|
|
- }
|
|
|
- if(claimNum == t.getTextbookClaimVOList().size()){//全部领取
|
|
|
- result.add(t);
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- if (claimStatus == 3){
|
|
|
- for (TeacherCheckByStuVo t : teacherCheckByStuVoList) {
|
|
|
- int claimNum = 0;
|
|
|
- for (TextbookClaimVO textbookClaimVO : t.getTextbookClaimVOList()) {
|
|
|
- if (textbookClaimVO.getIsClaim() == 1){
|
|
|
- claimNum++;
|
|
|
- }
|
|
|
- }
|
|
|
- if(claimNum < t.getTextbookClaimVOList().size()){//部分未领取
|
|
|
- result.add(t);
|
|
|
- }
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
return teacherCheckByStuVoList;
|
|
|
}
|
|
|
|
|
@@ -296,18 +202,6 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
|
|
|
|
|
|
@Override
|
|
|
public List<TeacherCheckStuClaimVo> getTeacherCheckStuClaimList(TeacherCheckStuClaimDto 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<TeacherCheckStuClaimVo> teacherCheckStuClaimVos = textbookStudentClaimMapper.getTeacherCheckStuClaimList(dto);
|
|
|
return teacherCheckStuClaimVos;
|
|
|
}
|