Forráskód Böngészése

Merge remote-tracking branch 'origin/dev' into dev

dzx 9 hónapja
szülő
commit
cc595b7d8b

+ 26 - 40
src/main/java/com/xjrsoft/module/textbook/controller/TextbookStudentClaimController.java

@@ -59,7 +59,7 @@ public class TextbookStudentClaimController {
     }
 
     @GetMapping(value = "/page")
-    @ApiOperation(value="学生教材领记录列表(分页)")
+    @ApiOperation(value="学生确认教材领记录列表(分页)")
     @SaCheckPermission("textbookstudentclaim:detail")
     public RT<PageOutput<TextbookStudentClaimPageVo>> page(@Valid TextbookStudentClaimPageDto dto){
         LambdaQueryWrapper<TextbookStudentClaim> queryWrapper = new LambdaQueryWrapper<>();
@@ -75,7 +75,7 @@ public class TextbookStudentClaimController {
     }
 
     @GetMapping(value = "/student-confirm-list")
-    @ApiOperation(value="学生教材领取确定页面")
+    @ApiOperation(value="学生确定教材领取页面")
     @SaCheckPermission("textbookstudentclaim:detail")
     public RT<TextbookClaimStudentConfirmVo> studentConfirmList(@Valid TextbookClaimStudentConfirmDto dto){
         TextbookClaimStudentConfirmVo textbookClaimStudentConfirmVo = textbookStudentClaimService.getStudentConfirmList(dto);
@@ -83,7 +83,7 @@ public class TextbookStudentClaimController {
     }
 
     @GetMapping(value = "/student-semester-list")
-    @ApiOperation(value="学生教材领取学期页面")
+    @ApiOperation(value="学生确定教材领取学期页面")
     @SaCheckPermission("textbookstudentclaim:detail")
     public RT<List<TextbookStudentSemesterVo>> studentSemesterList(){
         List<TextbookStudentSemesterVo> textbookStudentSemesterVoList = textbookStudentClaimService.getStudentSemesterList();
@@ -91,7 +91,7 @@ public class TextbookStudentClaimController {
     }
 
     @GetMapping(value = "/teacher-check-byClass-list")
-    @ApiOperation(value="教师教材领取按班级查看页面")
+    @ApiOperation(value="班主任确认教材领取按班级查看页面")
     @SaCheckPermission("textbookstudentclaim:detail")
     public RT<PageOutput<TeacherCheckByclassVo>> teacherCheckByClassList(@Valid TeacherCheckByclassDto dto){
         IPage<TeacherCheckByclassVo> page = textbookStudentClaimService.getTeacherCheckByclassList(dto);
@@ -99,17 +99,8 @@ public class TextbookStudentClaimController {
         return RT.ok(pageOutput);
     }
 
-//    @GetMapping(value = "/teacher-check-byClass-list")
-//    @ApiOperation(value="班主任为学生教材领取按班级查看页面")
-//    @SaCheckPermission("textbookstudentclaim:detail")
-//    public RT<PageOutput<TeacherCheckByclassVo>> teacherCheckByClassList(@Valid TeacherCheckByclassDto dto){
-//        IPage<TeacherCheckByclassVo> page = textbookStudentClaimService.getTeacherCheckByclassList(dto);
-//        PageOutput<TeacherCheckByclassVo> pageOutput = ConventPage.getPageOutput(page, TeacherCheckByclassVo.class);
-//        return RT.ok(pageOutput);
-//    }
-
     @GetMapping(value = "/teacher-check-byStu-list")
-    @ApiOperation(value="教师教材领取按学生查看页面")
+    @ApiOperation(value="班主任确认教材领取按学生查看页面")
     @SaCheckPermission("textbookstudentclaim:detail")
     public RT<PageOutput<TeacherCheckByStuVo>> teacherCheckByStuList(@Valid TeacherCheckByStuDto dto){
         IPage<TeacherCheckByStuVo> page = textbookStudentClaimService.getTeacherCheckByStuList(dto);
@@ -133,6 +124,27 @@ public class TextbookStudentClaimController {
         return RT.ok(textbookClaimVOList);
     }
 
+    @PutMapping("/confirm")
+    @ApiOperation(value = "学生自己确认已经领取")
+    @SaCheckPermission("textbookstudentclaim:edit")
+    public RT<Boolean> confirm(@Valid @RequestBody List<Long> textbookStudentClaimIds){
+        return RT.ok(textbookStudentClaimService.updateByIds(textbookStudentClaimIds));
+    }
+
+    @PutMapping("/teacher-confirm")
+    @ApiOperation(value = "教师帮助学生确认已经领取")
+    @SaCheckPermission("textbookstudentclaim:edit")
+    public RT<Boolean> teacherConfirm(@Valid @RequestBody List<TeacherConfirmDto> teacherConfirmDtoList){
+        return RT.ok( textbookStudentClaimService.teacherConfirm(teacherConfirmDtoList));
+    }
+
+    @PutMapping("/teacher-confirm-batch-by-textbook")
+    @ApiOperation(value = "教师根据教材帮助学生批量确认已经领取")
+    @SaCheckPermission("textbookstudentclaim:edit")
+    public RT<Boolean> teacherConfirmBatchBytTextbook(@Valid @RequestBody List<TeacherConfirmBatchByTextbookDto> dtos){
+        return RT.ok(textbookStudentClaimService.teacherConfirmBatchBytTextbook(dtos));
+    }
+
     @GetMapping(value = "/info")
     @ApiOperation(value="根据id查询学生教材认领记录信息")
     @SaCheckPermission("textbookstudentclaim:detail")
@@ -144,7 +156,6 @@ public class TextbookStudentClaimController {
         return RT.ok(BeanUtil.toBean(textbookStudentClaim, TextbookStudentClaimVo.class));
     }
 
-
     @PostMapping
     @ApiOperation(value = "新增学生教材认领记录")
     @SaCheckPermission("textbookstudentclaim:add")
@@ -164,35 +175,10 @@ public class TextbookStudentClaimController {
 
     }
 
-    @PutMapping("/confirm")
-    @ApiOperation(value = "学生自己确认已经领取")
-    @SaCheckPermission("textbookstudentclaim:edit")
-    public RT<Boolean> confirm(@Valid @RequestBody List<Long> textbookStudentClaimIds){
-        return RT.ok(textbookStudentClaimService.updateByIds(textbookStudentClaimIds));
-    }
-
-    @PutMapping("/teacher-confirm")
-    @ApiOperation(value = "教师帮助学生确认已经领取")
-    @SaCheckPermission("textbookstudentclaim:edit")
-    public RT<Boolean> teacherConfirm(@Valid @RequestBody List<TeacherConfirmDto> teacherConfirmDtoList){
-        for (TeacherConfirmDto dto : teacherConfirmDtoList) {
-            TextbookStudentClaim textbookStudentClaim = BeanUtil.toBean(dto, TextbookStudentClaim.class);
-            textbookStudentClaim.setId(dto.getTextbookStudentClaimId());
-            textbookStudentClaim.setIsClaim(1);
-            textbookStudentClaim.setRemark(dto.getRemark());
-            textbookStudentClaim.setModifyUserId(StpUtil.getLoginIdAsLong());
-            textbookStudentClaim.setModifyDate(new Date());
-            textbookStudentClaimService.updateById(textbookStudentClaim);
-        }
-        return RT.ok(true);
-    }
-
     @DeleteMapping
     @ApiOperation(value = "删除学生教材认领记录")
     @SaCheckPermission("textbookstudentclaim:delete")
     public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
         return RT.ok(textbookStudentClaimService.removeBatchByIds(ids));
-
     }
-
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/textbook/dto/TeacherCheckByStuDto.java

@@ -15,6 +15,9 @@ import java.util.List;
 */
 @Data
 public class TeacherCheckByStuDto extends PageInput {
+
+    @ApiModelProperty("学期主键编号")
+    private String baseSemesterId;
     /**
      * 学生用户编号
      */

+ 18 - 0
src/main/java/com/xjrsoft/module/textbook/dto/TeacherCheckByTextbookListDto.java

@@ -0,0 +1,18 @@
+package com.xjrsoft.module.textbook.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class TeacherCheckByTextbookListDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("学期主键编号")
+    private String baseSemesterId;
+
+    @ApiModelProperty("班级主键编号")
+    private String baseClassId;
+}

+ 4 - 0
src/main/java/com/xjrsoft/module/textbook/dto/TeacherCheckByclassDto.java

@@ -17,6 +17,10 @@ import java.util.List;
 @Data
 @EqualsAndHashCode(callSuper = false)
 public class TeacherCheckByclassDto extends PageInput {
+
+    @ApiModelProperty("学期主键编号")
+    private String baseSemesterId;
+
     /**
      * 班级编号
      */

+ 2 - 0
src/main/java/com/xjrsoft/module/textbook/dto/TeacherCheckStuClaimDto.java

@@ -12,6 +12,8 @@ import lombok.Data;
 */
 @Data
 public class TeacherCheckStuClaimDto {
+    @ApiModelProperty(value = "教材主键编号",required = true)
+    private Long baseSemesterId;
     /**
      * 教材主键编号
      */

+ 24 - 0
src/main/java/com/xjrsoft/module/textbook/dto/TeacherConfirmBatchByTextbookDto.java

@@ -0,0 +1,24 @@
+package com.xjrsoft.module.textbook.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class TeacherConfirmBatchByTextbookDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty("学期主键编号")
+    private Long baseSemesterId;;
+
+    @ApiModelProperty("教材主键编号")
+    private Long textbookId;
+
+    @ApiModelProperty("班级主键编号")
+    private Long classId;
+
+    @ApiModelProperty("是否领取(1:已领取 0:未领取)")
+    private Integer isClaim;
+}

+ 9 - 0
src/main/java/com/xjrsoft/module/textbook/dto/TeacherConfirmDto.java

@@ -17,6 +17,12 @@ public class TeacherConfirmDto {
      */
     @ApiModelProperty("学生教材认领主键编号")
     private Long textbookStudentClaimId;
+
+    @ApiModelProperty(value = "学期主键编号")
+    private Long baseSemesterId;
+
+    @ApiModelProperty(value = "班级主键编号")
+    private Long classId;
     /**
      * 教材主键编号
      */
@@ -32,4 +38,7 @@ public class TeacherConfirmDto {
      */
     @ApiModelProperty("备注")
     private String remark;
+
+    @ApiModelProperty("是否领取(1:已领取 0:未领取)")
+    private Integer isClaim;
 }

+ 3 - 0
src/main/java/com/xjrsoft/module/textbook/service/ITextbookStudentClaimService.java

@@ -78,4 +78,7 @@ public interface ITextbookStudentClaimService extends MPJBaseService<TextbookStu
      */
     List<TextbookClaimVO> getTeacherGetStuNoClaimList(Long studentUserId);
 
+    Boolean teacherConfirmBatchBytTextbook(List<TeacherConfirmBatchByTextbookDto> dtos);
+
+    Boolean teacherConfirm(List<TeacherConfirmDto> dtos);
 }

+ 268 - 36
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookStudentClaimServiceImpl.java

@@ -1,13 +1,16 @@
 package com.xjrsoft.module.textbook.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.bean.BeanUtil;
 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.github.yulichang.base.MPJBaseServiceImpl;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.enums.ArchivesStatusEnum;
 import com.xjrsoft.common.enums.ClaimTypeEnum;
+import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.common.page.ConventPage;
 import com.xjrsoft.common.utils.VoToColumnUtil;
@@ -21,12 +24,17 @@ 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.student.mapper.BaseStudentSchoolRollMapper;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
 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.*;
-import com.xjrsoft.module.textbook.entity.*;
+import com.xjrsoft.module.textbook.entity.Textbook;
+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.TextbookMapper;
 import com.xjrsoft.module.textbook.mapper.TextbookStudentClaimMapper;
 import com.xjrsoft.module.textbook.mapper.WfTextbookClaimItemMapper;
 import com.xjrsoft.module.textbook.service.ITextbookStudentClaimService;
@@ -68,6 +76,10 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
 
     private final WfTextbookClaimItemMapper wfTextbookClaimItemMapper;
 
+    private final BaseStudentSchoolRollMapper baseStudentSchoolRollMapper;
+
+    private final TextbookMapper textbookMapper;
+
     @Override
     public HeadTeaLookClassBookVo headTeaLookClassBook(HeadTeaLookClassBookDto dto) {
         HeadTeaLookClassBookVo result = new HeadTeaLookClassBookVo();
@@ -177,7 +189,16 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
     public TextbookClaimStudentConfirmVo getStudentConfirmList(TextbookClaimStudentConfirmDto dto) {
         //获取当前登录学生的信息
         MPJLambdaWrapper<XjrUser> queryUser = new MPJLambdaWrapper<>();
-        queryUser.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).leftJoin(BaseClass.class, BaseClass::getId, BaseStudentSchoolRoll::getClassId).eq(XjrUser::getId, StpUtil.getLoginIdAsLong()).disableSubLogicDel().orderByDesc(AttendanceRecord::getId);
+        queryUser
+                .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)
+                .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("登录信息出错,请重新登录");
@@ -226,21 +247,26 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
 
     @Override
     public IPage<TeacherCheckByclassVo> getTeacherCheckByclassList(TeacherCheckByclassDto dto) {
-        //根据当前班主任用户查出所管理的班级Id
-        LambdaQueryWrapper<BaseClass> queryWrapperClassId = new LambdaQueryWrapper<>();
-        queryWrapperClassId.eq(BaseClass::getTeacherId, StpUtil.getLoginIdAsLong());
-        List<BaseClass> baseClassList = baseClassService.list(queryWrapperClassId);
-        if (ObjectUtil.isNull(baseClassList) && baseClassList.size() == 0) {
-            return null;
-        }
+        // 如果没有传入班级id
+        if(ObjectUtils.isEmpty(dto.getClassIdList())){
+            //根据当前班主任用户查出所管理的班级Id
+            LambdaQueryWrapper<BaseClass> queryWrapperClassId = new LambdaQueryWrapper<>();
+            queryWrapperClassId
+                    .eq(BaseClass::getTeacherId, StpUtil.getLoginIdAsLong())
+                    .eq(BaseClass::getDeleteMark, DeleteMark.NODELETE.getCode())
+            ;
+            List<BaseClass> baseClassList = baseClassService.list(queryWrapperClassId);
+            if (ObjectUtils.isEmpty(baseClassList)) {
+                return null;
+            }
 
-        List<Long> classIdList = new ArrayList<>();
-        for (BaseClass baseClass : baseClassList) {
-            classIdList.add(baseClass.getId());
-        }
-        dto.setClassIdList(classIdList);
+            List<Long> classIdList = new ArrayList<>();
+            for (BaseClass baseClass : baseClassList) {
+                classIdList.add(baseClass.getId());
+            }
 
-        IPage<TeacherCheckByclassVo> teacherCheckByclassVoList = textbookStudentClaimMapper.getTeacherCheckByclassList(ConventPage.getPage(dto), dto);
+            dto.setClassIdList(classIdList);
+        }
 
         //为每本书添加数据
 //        for (TeacherCheckByclassVo t : teacherCheckByclassVoList.getRecords()) {
@@ -263,27 +289,105 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
 //            Long actualClaimNum = this.count(queryActualClaimNum);
 //            t.setActualClaimNum(actualClaimNum);
 //        }
-        return teacherCheckByclassVoList;
+        return textbookStudentClaimMapper.getTeacherCheckByclassList(ConventPage.getPage(dto), dto);
     }
 
     @Override
     public IPage<TeacherCheckByStuVo> getTeacherCheckByStuList(TeacherCheckByStuDto dto) {
-        //根据当前班主任用户查出所管理的班级Id
-        LambdaQueryWrapper<BaseClass> queryWrapperClassId = new LambdaQueryWrapper<>();
-        queryWrapperClassId.eq(BaseClass::getTeacherId, StpUtil.getLoginIdAsLong());
-        List<BaseClass> baseClassList = baseClassService.list(queryWrapperClassId);
-        if (ObjectUtil.isNull(baseClassList) && baseClassList.size() == 0) {
-            return null;
+        // 如果没有传入班级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);
         }
 
-        List<Long> classIdList = new ArrayList<>();
-        for (BaseClass baseClass : baseClassList) {
-            classIdList.add(baseClass.getId());
+        // 获取班级申领的所有教材
+        MPJLambdaWrapper<WfTextbookClaimItem> wfTextbookClaimItemMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        wfTextbookClaimItemMPJLambdaWrapper
+                .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::getBaseSemesterId, dto.getBaseSemesterId())
+        ;
+        List<TextbookClaimVO> textbookClaimVOList = wfTextbookClaimItemMapper.selectJoinList(TextbookClaimVO.class, wfTextbookClaimItemMPJLambdaWrapper);
+
+        Map<Long, List<TextbookClaimVO>> textbookByClassIdMap = textbookClaimVOList.stream()
+                .collect(Collectors.groupingBy(TextbookClaimVO::getTextbookStudentClaimId));
+
+        // 查询已有领取记录
+        LambdaQueryWrapper<TextbookStudentClaim> textbookStudentClaimLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        textbookStudentClaimLambdaQueryWrapper
+                .eq(TextbookStudentClaim::getBaseSemesterId, dto.getBaseSemesterId())
+                .in(TextbookStudentClaim::getClassId, dto.getClassIdList())
+                .eq(TextbookStudentClaim::getDeleteMark, DeleteMark.NODELETE.getCode())
+        ;
+        List<TextbookStudentClaim> textbookStudentClaimList = textbookStudentClaimMapper.selectList(textbookStudentClaimLambdaQueryWrapper);
+
+        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<>
+//        }
+
+        // 获取班上所有在读学生
+        MPJLambdaWrapper<BaseStudentSchoolRoll> baseStudentSchoolRollMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        baseStudentSchoolRollMPJLambdaWrapper
+                .selectAs(BaseStudentSchoolRoll::getClassId, TeacherCheckByStuVo::getClassId)
+                .selectAs(BaseStudentSchoolRoll::getUserId, TeacherCheckByStuVo::getStudentUserId)
+                .selectAs(XjrUser::getName, TeacherCheckByStuVo::getStudentUserIdCN)
+                .selectAs(BaseStudent::getStudentId, TeacherCheckByStuVo::getStudentId)
+                .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())
+                ;
+        IPage<TeacherCheckByStuVo> teacherCheckByStuVoList = baseStudentSchoolRollMapper.selectJoinPage(ConventPage.getPage(dto), TeacherCheckByStuVo.class, baseStudentSchoolRollMPJLambdaWrapper);
+
+        TextbookStudentClaim oldTextbookStudentClaim;
+        for (TeacherCheckByStuVo vo : teacherCheckByStuVoList.getRecords()){
+            List<TextbookClaimVO> stuTextbooks = textbookByClassIdMap.get(vo.getClassId());
+            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)){
+                    textbookClaimVO.setTextbookStudentClaimId(oldTextbookStudentClaim.getId());
+                    textbookClaimVO.setIsClaim(oldTextbookStudentClaim.getIsClaim());
+                }else {
+                    textbookClaimVO.setIsClaim(0);
+                }
+            }
+            vo.setTextbookClaimVOList(stuTextbooks);
         }
-        dto.setClassIdList(classIdList);
 
-        //将班上所有学生进行分组,查询出list集合
-        IPage<TeacherCheckByStuVo> teacherCheckByStuVoList = textbookStudentClaimMapper.getTeacherCheckByStuList(ConventPage.getPage(dto), dto);
+//        //将班上所有学生进行分组,查询出list集合
+//        IPage<TeacherCheckByStuVo> teacherCheckByStuVoList = textbookStudentClaimMapper.getTeacherCheckByStuList(ConventPage.getPage(dto), dto);
 
         //为每个学生添加教材领取记录集合
         //学生id集合
@@ -295,15 +399,14 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
 //        if(stuIdList.size() > 0){
 //            List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimMapper.getTextbookClaimVOList(stuIdList);
 //        }
-
-        for (TeacherCheckByStuVo t : teacherCheckByStuVoList.getRecords()) {
-            List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimMapper.getTextbookClaimVOList(t.getStudentUserId());
-            t.setTextbookClaimVOList(textbookClaimVOList);
-        }
+//
+//        for (TeacherCheckByStuVo t : teacherCheckByStuVoList.getRecords()) {
+//            List<TextbookClaimVO> textbookClaimVOList = textbookStudentClaimMapper.getTextbookClaimVOList(t.getStudentUserId());
+//            t.setTextbookClaimVOList(textbookClaimVOList);
+//        }
         return teacherCheckByStuVoList;
     }
 
-
     @Override
     @Transactional
     public Boolean updateByIds(List<Long> textbookStudentClaimIds) {
@@ -326,8 +429,68 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
 
     @Override
     public List<TeacherCheckStuClaimVo> getTeacherCheckStuClaimList(TeacherCheckStuClaimDto dto) {
-        List<TeacherCheckStuClaimVo> teacherCheckStuClaimVos = textbookStudentClaimMapper.getTeacherCheckStuClaimList(dto);
-        return teacherCheckStuClaimVos;
+//        List<TeacherCheckStuClaimVo> teacherCheckStuClaimVos = textbookStudentClaimMapper.getTeacherCheckStuClaimList(dto);
+        Textbook textbook = textbookMapper.selectById(dto.getTextbookId());
+        if(ObjectUtils.isEmpty(textbook)){
+            throw new MyException("教材不存在,请刷新重试");
+        }
+
+        List<TeacherCheckStuClaimVo> result = new ArrayList<>();
+        // 获取一个班级的学生
+        MPJLambdaWrapper<BaseStudentSchoolRoll> baseStudentSchoolRollMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        baseStudentSchoolRollMPJLambdaWrapper
+                .disableSubLogicDel()
+                .selectAs(BaseStudentSchoolRoll::getUserId, TeacherCheckStuClaimVo::getStudentUserId)
+                .selectAs(XjrUser::getName, TeacherCheckStuClaimVo::getStudentName)
+                .selectAs(BaseStudent::getStudentId, TeacherCheckStuClaimVo::getStudentId)
+                .select("0 as is_claim")
+                .leftJoin(XjrUser.class, XjrUser::getId, BaseStudentSchoolRoll::getUserId)
+                .leftJoin(BaseStudent.class, BaseStudent::getUserId, BaseStudentSchoolRoll::getUserId)
+                .eq(BaseStudentSchoolRoll::getArchivesStatus, ArchivesStatusEnum.FB2901.getCode())
+                .eq(BaseStudentSchoolRoll::getClassId, dto.getClassId())
+                .orderByAsc(BaseStudent::getStudentId)
+        ;
+        List<TeacherCheckStuClaimVo> stuList = baseStudentSchoolRollMapper.selectJoinList(TeacherCheckStuClaimVo.class, baseStudentSchoolRollMPJLambdaWrapper);
+
+        // 获取当前班级已经领取的记录
+        MPJLambdaWrapper<TextbookStudentClaim> textbookStudentClaimMPJLambdaWrapper = new MPJLambdaWrapper<>();
+        textbookStudentClaimMPJLambdaWrapper
+                .disableSubLogicDel()
+                .selectAs(TextbookStudentClaim::getId, TeacherCheckStuClaimVo::getTextbookStudentClaimId)
+                .selectAs(TextbookStudentClaim::getTextbookId, TeacherCheckStuClaimVo::getTextbookId)
+                .selectAs(Textbook::getBookName, TeacherCheckStuClaimVo::getBookName)
+                .selectAs(TextbookStudentClaim::getStudentUserId, TeacherCheckStuClaimVo::getStudentUserId)
+                .selectAs(TextbookStudentClaim::getIsClaim, TeacherCheckStuClaimVo::getIsClaim)
+                .leftJoin(Textbook.class, Textbook::getId, TextbookStudentClaim::getTextbookId)
+                .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){
+            stu.setTextbookId(textbook.getId());
+            stu.setBookName(textbook.getBookName());
+
+            TeacherCheckStuClaimVo isClaim = isClaimByUserIdMap.get(stu.getStudentUserId());
+            if(ObjectUtils.isNotEmpty(isClaim)){
+                stu.setTextbookStudentClaimId(isClaim.getTextbookStudentClaimId());
+                stu.setIsClaim(isClaim.getIsClaim());
+                if(isClaim.getIsClaim() == 1){
+                    result.add(stu);
+                }else {
+                    result.add(0, stu);
+                }
+            }else {
+                stu.setIsClaim(0);
+                result.add(0, stu);
+            }
+        }
+
+        return result;
     }
 
     @Override
@@ -337,4 +500,73 @@ public class TextbookStudentClaimServiceImpl extends MPJBaseServiceImpl<Textbook
         List<TextbookClaimVO> textbookClaimVOList = this.selectJoinList(TextbookClaimVO.class, queryTextbookClaimVOList);
         return textbookClaimVOList;
     }
+
+    @Override
+    @Transactional
+    public Boolean teacherConfirmBatchBytTextbook(List<TeacherConfirmBatchByTextbookDto> dtos) {
+        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;
+            }
+
+            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);
+            }
+        }
+
+        return true;
+    }
+
+    @Override
+    @Transactional
+    public Boolean teacherConfirm(List<TeacherConfirmDto> dtos) {
+        TextbookStudentClaim textbookStudentClaim;
+        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);
+            }
+        }
+        return true;
+    }
 }

+ 2 - 0
src/main/java/com/xjrsoft/module/textbook/vo/TeacherCheckByStuVo.java

@@ -14,6 +14,8 @@ import java.util.List;
 @Data
 public class TeacherCheckByStuVo {
 
+    @ApiModelProperty("班级主键编号")
+    private Long classId;
     /**
      * 学生用户编号
      */

+ 49 - 0
src/main/java/com/xjrsoft/module/textbook/vo/TeacherCheckByTextbookListVo.java

@@ -0,0 +1,49 @@
+package com.xjrsoft.module.textbook.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+public class TeacherCheckByTextbookListVo {
+
+    /**
+    * 教材主键编号
+    */
+    @ApiModelProperty("教材主键编号")
+    private Long textbookId;
+    /**
+     * 教材名称
+     */
+    @ApiModelProperty("教材名称")
+    private String bookName;
+    /**
+     * 学期id
+     */
+    @ApiModelProperty("学期id")
+    private Long baseSemesterId;
+    /**
+     * 学期id
+     */
+    @ApiModelProperty("学期id")
+    private String baseSemesterIdCN;
+    /**
+     * 班级id
+     */
+    @ApiModelProperty("班级id")
+    private Long classId;
+    /**
+    * 班级人数
+    */
+    @ApiModelProperty("班级人数")
+    private Integer classStudentNum;
+    /**
+     * 实际领取教材数量
+     */
+    @ApiModelProperty("实际领取教材数量")
+    private Integer actualReceivedNum;
+    /**
+     * 已经确认领取人数
+     */
+    @ApiModelProperty("已经确认领取人数")
+    private Long actualClaimNum;
+}

+ 5 - 0
src/main/java/com/xjrsoft/module/textbook/vo/TeacherCheckByclassVo.java

@@ -37,6 +37,11 @@ public class TeacherCheckByclassVo {
      */
     @ApiModelProperty("班级id")
     private Long classId;
+    /**
+     * 班级id
+     */
+    @ApiModelProperty("班级id")
+    private String classIdCn;
     /**
     * 班级人数
     */

+ 96 - 61
src/main/resources/mapper/textbook/TextbookStudentClaimMapper.xml

@@ -5,7 +5,7 @@
 <mapper namespace="com.xjrsoft.module.textbook.mapper.TextbookStudentClaimMapper">
     <select id="getTextbookClaimList" parameterType="com.xjrsoft.module.textbook.dto.TextbookClaimStudentConfirmDto"
             resultType="com.xjrsoft.module.textbook.vo.TextbookClaimVO">
-        SELECT t.id                   AS textbookStudentClaimId,
+        SELECT t.id AS textbookStudentClaimId,
         t1.price * t1.discount/10 AS discountPrice,
         t.sort_code as sortCode,
         t.textbook_id as textbookId,
@@ -23,69 +23,102 @@
         ORDER BY t.id DESC
     </select>
 
-<select id="getTeacherCheckByclassList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByclassDto"
-        resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByclassVo">
-    WITH textbook_claim_counts AS (
-    SELECT t.class_id, t1.textbook_id, count(t1.issue_number) AS received_num
-    FROM wf_textbook_claim t
-    LEFT JOIN wf_textbook_claim_item t1 ON t1.wf_textbook_claim_id = t.id
-    GROUP BY t.class_id, t1.textbook_id
-    ),
-    actual_claim_counts AS (
-    SELECT class_id, textbook_id, count(is_claim) AS claim_num
-    FROM textbook_student_claim
-    WHERE is_claim = 1
-    GROUP BY class_id, textbook_id
-    )
-    SELECT a.class_id,
-    b.id AS textbookId,
-    b.book_name,
-    c.name,
-    d.total_student AS classStudentNum,
-    tcc.received_num AS actualReceivedNum,
-    acc.claim_num AS actualClaimNum
-    FROM textbook b
-    INNER JOIN (
-    SELECT class_id, textbook_id
-    FROM textbook_student_claim
-    GROUP BY class_id, textbook_id
-    ) a ON a.textbook_id = b.id
-    INNER JOIN base_class c ON a.class_id = c.id
-    INNER JOIN base_class_major_set d ON c.id = d.class_id
-    LEFT JOIN textbook_claim_counts tcc ON tcc.class_id = a.class_id AND tcc.textbook_id = a.textbook_id
-    LEFT JOIN actual_claim_counts acc ON acc.class_id = a.class_id AND acc.textbook_id = a.textbook_id
-    WHERE a.class_id &lt;&gt; 0
-    <if test="dto.classIdList != null and dto.classIdList.size() > 0">
-        AND a.class_id IN
-        <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
-                 separator=",">
-            #{classId}
-        </foreach>
-    </if>
-    <if test="dto.claimStatus != null and dto.claimStatus == 2">
-        AND tcc.received_num = acc.claim_num
-    </if>
-    <if test="dto.claimStatus != null and dto.claimStatus == 3">
-        AND tcc.received_num > acc.claim_num
-    </if>
-</select>
+    <select id="getTeacherCheckByclassList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByclassDto"
+            resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByclassVo">
+        WITH textbook_claim_counts AS
+        (SELECT t.base_semester_id, t.class_id, t1.textbook_id, sum(t1.issue_number) AS received_num
+        FROM wf_textbook_claim t
+        inner JOIN wf_textbook_claim_item t1 ON t1.wf_textbook_claim_id = t.id
+        where t.delete_mark = 0
+        and t1.delete_mark = 0
+        <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
+            AND t.base_semester_id = #{dto.baseSemesterId}
+        </if>
+        <if test="dto.classIdList != null and dto.classIdList.size() > 0">
+            AND t.class_id IN
+            <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
+                     separator=",">
+                #{classId}
+            </foreach>
+        </if>
+        GROUP BY t.base_semester_id, t.class_id, t1.textbook_id),
+        actual_claim_counts AS
+        (SELECT base_semester_id, class_id, textbook_id, count(is_claim) AS claim_num
+        FROM textbook_student_claim
+        WHERE is_claim = 1
+        and delete_mark = 0
+        <if test="dto.baseSemesterId != null and dto.baseSemesterId > 0">
+            AND base_semester_id = #{dto.baseSemesterId}
+        </if>
+        <if test="dto.classIdList != null and dto.classIdList.size() > 0">
+            AND class_id IN
+            <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
+                     separator=",">
+                #{classId}
+            </foreach>
+        </if>
+        GROUP BY base_semester_id, class_id, textbook_id),
+        class_stu_num AS
+        (SELECT class_id, count(t.id) AS total_student
+        FROM base_student_school_roll t
+        WHERE t.delete_mark = 0
+        and t.archives_status = 'FB2901'
+        <if test="dto.classIdList != null and dto.classIdList.size() > 0">
+            AND t.class_id IN
+            <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
+                     separator=",">
+                #{classId}
+            </foreach>
+        </if>
+        GROUP BY class_id)
+        SELECT t.base_semester_id,
+        t.class_id,
+        t.textbook_id,
+        t1.book_name,
+        t2.name as classIdCn,
+        t5.name as baseSemesterIdCN,
+        ifnull(t.received_num, 0) AS actualReceivedNum,
+        ifnull(t4.total_student, 0) AS classStudentNum,
+        ifnull(t3.claim_num, 0) AS actualClaimNum
+        FROM textbook_claim_counts t
+        inner join textbook t1 on t1.id = t.textbook_id
+        LEFT JOIN base_class t2 ON t2.id = t.class_id
+        LEFT JOIN base_semester t5 ON t5.id = t.base_semester_id
+        LEFT JOIN actual_claim_counts t3 ON t3.base_semester_id = t.base_semester_id AND t3.class_id = t.class_id AND
+        t3.textbook_id = t.textbook_id
+        LEFT JOIN class_stu_num t4 ON t4.class_id = t.class_id
+        where t.class_id &lt;&gt; 0
+        <if test="dto.classIdList != null and dto.classIdList.size() > 0">
+            AND t.class_id IN
+            <foreach item="classId" index="index" collection="dto.classIdList" open="(" close=")"
+                     separator=",">
+                #{classId}
+            </foreach>
+        </if>
+        <if test="dto.claimStatus != null and dto.claimStatus == 2">
+            AND t.received_num &lt;= t3.claim_num
+        </if>
+        <if test="dto.claimStatus != null and dto.claimStatus == 3">
+            AND t.received_num &gt; t3.claim_num
+        </if>
+    </select>
 
     <select id="getTeacherCheckStuClaimList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckStuClaimDto"
             resultType="com.xjrsoft.module.textbook.vo.TeacherCheckStuClaimVo">
-        SELECT
-            t.id as textbookStudentClaimId,
-            t.textbook_id,
-               t1.book_name as bookName,
+        SELECT t.id          as textbookStudentClaimId,
+               t.textbook_id,
+               t1.book_name  as bookName,
                t.student_user_id,
                t2.student_id as studentId,
-               t3.name as studentName,
+               t3.name       as studentName,
                t.is_claim
         FROM textbook_student_claim t
                  LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
                  LEFT JOIN base_student t2 ON (t2.user_id = t.student_user_id)
                  LEFT JOIN xjr_user t3 ON (t3.id = t.student_user_id)
         WHERE t.delete_mark = 0
-            and t.class_id = #{dto.classId} and  t.textbook_id = #{dto.textbookId}
+          and t.class_id = #{dto.classId}
+          and t.textbook_id = #{dto.textbookId}
         ORDER BY t.is_claim
     </select>
 
@@ -101,10 +134,12 @@
         FROM textbook_student_claim t
         WHERE delete_mark = 0
         <if test="dto.claimStatus != null and dto.claimStatus == 3">
-            and (select count(*) from textbook_student_claim where is_claim = 1 and student_user_id = t.student_user_id) != (select count(*) from textbook_student_claim where student_user_id = t.student_user_id)
+            and (select count(*) from textbook_student_claim where is_claim = 1 and student_user_id = t.student_user_id)
+            != (select count(*) from textbook_student_claim where student_user_id = t.student_user_id)
         </if>
         <if test="dto.claimStatus != null and dto.claimStatus == 2">
-            and (select count(*) from textbook_student_claim where is_claim = 1 and student_user_id = t.student_user_id) = (select count(*) from textbook_student_claim where student_user_id = t.student_user_id)
+            and (select count(*) from textbook_student_claim where is_claim = 1 and student_user_id = t.student_user_id)
+            = (select count(*) from textbook_student_claim where student_user_id = t.student_user_id)
         </if>
         <if test="dto.classIdList != null and dto.classIdList.size() > 0">
             and class_id in
@@ -112,7 +147,8 @@
                      separator=",">
                 #{classId}
             </foreach>
-        </if>)
+        </if>
+        )
         <if test="dto.studentUserId != null and dto.studentUserId != 0 and dto.studentUserId != ''">
             and t.id = #{dto.studentUserId}
         </if>
@@ -120,11 +156,10 @@
 
     <select id="getTextbookClaimVOList"
             resultType="com.xjrsoft.module.textbook.vo.TextbookClaimVO">
-        SELECT
-            t.id as textbookStudentClaimId,
-            t.textbook_id,
-            t1.book_name as bookName,
-            t.is_claim
+        SELECT t.id         as textbookStudentClaimId,
+               t.textbook_id,
+               t1.book_name as bookName,
+               t.is_claim
         FROM textbook_student_claim t
                  LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
         where t.student_user_id = #{studentUserId}