Browse Source

梳理教材整个流程

phoenix 1 year ago
parent
commit
8e5bfa72a0
17 changed files with 193 additions and 286 deletions
  1. 8 6
      src/main/java/com/xjrsoft/module/textbook/controller/TextbookStudentClaimController.java
  2. 1 1
      src/main/java/com/xjrsoft/module/textbook/controller/WfTextbookClaimController.java
  3. 6 3
      src/main/java/com/xjrsoft/module/textbook/dto/TeacherCheckByStuDto.java
  4. 8 3
      src/main/java/com/xjrsoft/module/textbook/dto/TeacherCheckByclassDto.java
  5. 2 2
      src/main/java/com/xjrsoft/module/textbook/dto/TeacherCheckStuClaimDto.java
  6. 4 1
      src/main/java/com/xjrsoft/module/textbook/dto/TextbookClaimStudentConfirmDto.java
  7. 6 1
      src/main/java/com/xjrsoft/module/textbook/dto/WfTextbookClaimPageDto.java
  8. 9 6
      src/main/java/com/xjrsoft/module/textbook/mapper/TextbookStudentClaimMapper.java
  9. 3 2
      src/main/java/com/xjrsoft/module/textbook/service/ITextbookStudentClaimService.java
  10. 63 169
      src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookStudentClaimServiceImpl.java
  11. 37 48
      src/main/java/com/xjrsoft/module/textbook/service/impl/WfTextbookClaimServiceImpl.java
  12. 5 0
      src/main/java/com/xjrsoft/module/textbook/vo/TeacherCheckByclassVo.java
  13. 1 1
      src/main/java/com/xjrsoft/module/textbook/vo/TextbookStudentSemesterVo.java
  14. 2 2
      src/main/java/com/xjrsoft/module/textbook/vo/WfTextbookClaimPageVo.java
  15. 29 32
      src/main/resources/mapper/textbook/TextbookStudentClaimMapper.xml
  16. 9 8
      src/main/resources/mapper/textbook/WfTextbookClaimMapper.xml
  17. 0 1
      src/test/java/com/xjrsoft/xjrsoftboot/FreeMarkerGeneratorTest.java

+ 8 - 6
src/main/java/com/xjrsoft/module/textbook/controller/TextbookStudentClaimController.java

@@ -67,17 +67,19 @@ public class TextbookStudentClaimController {
     @GetMapping(value = "/teacher-check-byClass-list")
     @ApiOperation(value="教师教材领取按班级查看页面")
     @SaCheckPermission("textbookstudentclaim:detail")
-    public RT<List<TeacherCheckByclassVo>> teacherCheckByClassList(@Valid TeacherCheckByclassDto dto){
-        List<TeacherCheckByclassVo> teacherCheckByclassList = textbookStudentClaimService.getTeacherCheckByclassList(dto);
-        return RT.ok(teacherCheckByclassList);
+    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="教师教材领取按学生查看页面")
     @SaCheckPermission("textbookstudentclaim:detail")
-    public RT<List<TeacherCheckByStuVo>> teacherCheckByStuList(@Valid TeacherCheckByStuDto dto){
-        List<TeacherCheckByStuVo> teacherCheckByStuList = textbookStudentClaimService.getTeacherCheckByStuList(dto);
-        return RT.ok(teacherCheckByStuList);
+    public RT<PageOutput<TeacherCheckByStuVo>> teacherCheckByStuList(@Valid TeacherCheckByStuDto dto){
+        IPage<TeacherCheckByStuVo> page = textbookStudentClaimService.getTeacherCheckByStuList(dto);
+        PageOutput<TeacherCheckByStuVo> pageOutput = ConventPage.getPageOutput(page, TeacherCheckByStuVo.class);
+        return RT.ok(pageOutput);
     }
 
     @GetMapping(value = "/teacher-check-stu-claim-list")

+ 1 - 1
src/main/java/com/xjrsoft/module/textbook/controller/WfTextbookClaimController.java

@@ -69,7 +69,7 @@ public class WfTextbookClaimController {
     public RT<WfTextbookClaimVo> infoDistribute(@RequestParam Long id){
         WfTextbookClaimVo wfTextbookClaimVo = wfTextbookClaimService.infoDistribute(id);
         if (wfTextbookClaimVo == null) {
-            return RT.error("找不到此数据!");
+            return RT.error("没有发放数据!");
         }
         return RT.ok(BeanUtil.toBean(wfTextbookClaimVo, WfTextbookClaimVo.class));
     }

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

@@ -1,8 +1,11 @@
 package com.xjrsoft.module.textbook.dto;
 
+import com.xjrsoft.common.page.PageInput;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
+import java.util.List;
+
 
 /**
 * @title: 教师教材领取按学生查看页面入参
@@ -11,7 +14,7 @@ import lombok.Data;
 * @Version 1.0
 */
 @Data
-public class TeacherCheckByStuDto {
+public class TeacherCheckByStuDto extends PageInput {
     /**
      * 学生用户编号
      */
@@ -20,8 +23,8 @@ public class TeacherCheckByStuDto {
     /**
      * 班级编号
      */
-    @ApiModelProperty(value = "班级编号",hidden = true)
-    private Long classId;
+    @ApiModelProperty(value = "班级编号")
+    private List<Long> classIdList;
     /**
      * 领取情况(1=全部数据,2=该教材全部领取,3=该教材部分未领取)
      */

+ 8 - 3
src/main/java/com/xjrsoft/module/textbook/dto/TeacherCheckByclassDto.java

@@ -1,7 +1,11 @@
 package com.xjrsoft.module.textbook.dto;
 
+import com.xjrsoft.common.page.PageInput;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.util.List;
 
 
 /**
@@ -11,12 +15,13 @@ import lombok.Data;
 * @Version 1.0
 */
 @Data
-public class TeacherCheckByclassDto{
+@EqualsAndHashCode(callSuper = false)
+public class TeacherCheckByclassDto extends PageInput {
     /**
      * 班级编号
      */
-    @ApiModelProperty(value = "班级编号",hidden = true)
-    private Long classId;
+    @ApiModelProperty(value = "班级编号")
+    private List<Long> classIdList;
     /**
      * 领取情况(1=全部数据,2=该教材全部领取,3=该教材部分未领取)
      */

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

@@ -15,11 +15,11 @@ public class TeacherCheckStuClaimDto {
     /**
      * 教材主键编号
      */
-    @ApiModelProperty(value = "教材主键编号")
+    @ApiModelProperty(value = "教材主键编号",required = true)
     private Long textbookId;
     /**
      * 班级编号
      */
-    @ApiModelProperty(value = "班级编号",hidden = true)
+    @ApiModelProperty(value = "班级编号",required = true)
     private Long classId;
 }

+ 4 - 1
src/main/java/com/xjrsoft/module/textbook/dto/TextbookClaimStudentConfirmDto.java

@@ -1,7 +1,9 @@
 package com.xjrsoft.module.textbook.dto;
 
+import com.xjrsoft.common.page.PageInput;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
 
 
 /**
@@ -11,7 +13,8 @@ import lombok.Data;
 * @Version 1.0
 */
 @Data
-public class TextbookClaimStudentConfirmDto {
+@EqualsAndHashCode(callSuper = false)
+public class TextbookClaimStudentConfirmDto extends PageInput {
 
     /**
      * 学期ID(base_semester)

+ 6 - 1
src/main/java/com/xjrsoft/module/textbook/dto/WfTextbookClaimPageDto.java

@@ -1,6 +1,7 @@
 package com.xjrsoft.module.textbook.dto;
 
 import com.xjrsoft.common.page.PageInput;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -15,5 +16,9 @@ import lombok.EqualsAndHashCode;
 @EqualsAndHashCode(callSuper = false)
 public class WfTextbookClaimPageDto extends PageInput {
 
-
+    /**
+     * 当前用户的id
+     */
+    @ApiModelProperty(value = "当前用户的id",hidden = true)
+    private Long userId;
 }

+ 9 - 6
src/main/java/com/xjrsoft/module/textbook/mapper/TextbookStudentClaimMapper.java

@@ -1,11 +1,16 @@
 package com.xjrsoft.module.textbook.mapper;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.base.MPJBaseMapper;
 import com.xjrsoft.module.textbook.dto.TeacherCheckByStuDto;
+import com.xjrsoft.module.textbook.dto.TeacherCheckByclassDto;
 import com.xjrsoft.module.textbook.dto.TeacherCheckStuClaimDto;
 import com.xjrsoft.module.textbook.dto.TextbookClaimStudentConfirmDto;
 import com.xjrsoft.module.textbook.entity.TextbookStudentClaim;
-import com.xjrsoft.module.textbook.vo.*;
+import com.xjrsoft.module.textbook.vo.TeacherCheckByStuVo;
+import com.xjrsoft.module.textbook.vo.TeacherCheckByclassVo;
+import com.xjrsoft.module.textbook.vo.TeacherCheckStuClaimVo;
+import com.xjrsoft.module.textbook.vo.TextbookClaimVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -22,13 +27,11 @@ public interface TextbookStudentClaimMapper extends MPJBaseMapper<TextbookStuden
 
     List<TextbookClaimVO> getTextbookClaimList(@Param("dto")TextbookClaimStudentConfirmDto dto);
 
-    List<TeacherCheckByclassVo> getTeacherCheckByclassList(Long classId);
-
-    List<TextbookStudentSemesterVo> getStudentSemesterList(Long studentUserId);
+    IPage<TeacherCheckByclassVo> getTeacherCheckByclassList(IPage<TeacherCheckByclassDto> page, @Param("dto")TeacherCheckByclassDto dto);
 
     List<TeacherCheckStuClaimVo> getTeacherCheckStuClaimList(@Param("dto")TeacherCheckStuClaimDto dto);
 
-    List<TeacherCheckByStuVo> getTeacherCheckByStuList(@Param("dto")TeacherCheckByStuDto dto);
+    IPage<TeacherCheckByStuVo> getTeacherCheckByStuList(IPage<TeacherCheckByStuDto> page, @Param("dto")TeacherCheckByStuDto dto);
 
-    List<TextbookClaimVO> getTextbookClaimVOList(Long classId, Long studentUserId);
+    List<TextbookClaimVO> getTextbookClaimVOList(Long studentUserId);
 }

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

@@ -1,5 +1,6 @@
 package com.xjrsoft.module.textbook.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.textbook.dto.*;
 import com.xjrsoft.module.textbook.entity.TextbookStudentClaim;
@@ -34,14 +35,14 @@ public interface ITextbookStudentClaimService extends MPJBaseService<TextbookStu
      * @param dto
      * @return
      */
-    List<TeacherCheckByclassVo> getTeacherCheckByclassList(TeacherCheckByclassDto dto);
+    IPage<TeacherCheckByclassVo> getTeacherCheckByclassList(TeacherCheckByclassDto dto);
 
     /**
      * 教师教材领取按班级查看页面
      * @param dto
      * @return
      */
-    List<TeacherCheckByStuVo> getTeacherCheckByStuList(TeacherCheckByStuDto dto);
+    IPage<TeacherCheckByStuVo> getTeacherCheckByStuList(TeacherCheckByStuDto dto);
 
     /**
      * 学生自己确认已经领取

+ 63 - 169
src/main/java/com/xjrsoft/module/textbook/service/impl/TextbookStudentClaimServiceImpl.java

@@ -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;
     }

+ 37 - 48
src/main/java/com/xjrsoft/module/textbook/service/impl/WfTextbookClaimServiceImpl.java

@@ -10,6 +10,7 @@ import com.xjrsoft.common.enums.ClaimTypeEnum;
 import com.xjrsoft.common.enums.IssueModeEnum;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.common.page.ConventPage;
+import com.xjrsoft.module.organization.mapper.RoleMapper;
 import com.xjrsoft.module.teacher.entity.XjrUser;
 import com.xjrsoft.module.teacher.mapper.XjrUserMapper;
 import com.xjrsoft.module.textbook.dto.ConfirmDistributeDto;
@@ -49,6 +50,8 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
 
     private final XjrUserMapper xjrUserMapper;
 
+    private final RoleMapper roleMapper;
+
     private final ITextbookService textbookService;
 
     private final ITextbookStudentClaimService textbookStudentClaimService;
@@ -57,7 +60,6 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
 
     private final TextbookClaimUserMapper textbookClaimUserMapper;
 
-
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Boolean add(WfTextbookClaim wfTextbookClaim) {
@@ -117,10 +119,12 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
 
     @Override
     public IPage<WfTextbookClaimPageVo> getPage(WfTextbookClaimPageDto dto) {
-        IPage<WfTextbookClaimPageVo> page = wfTextbookClaimWfTextbookClaimMapper.getPage(ConventPage.getPage(dto), dto);
+
+        dto.setUserId(StpUtil.getLoginIdAsLong());
+        IPage<WfTextbookClaimPageVo> page = wfTextbookClaimWfTextbookClaimMapper.getPage(ConventPage.getPage(dto),dto);
 
         for (WfTextbookClaimPageVo wfTextbookClaimPageVo : page.getRecords()) {
-            //拆分代领人
+            //拆分代领
             String receiveUserIdStr = wfTextbookClaimPageVo.getReceiveUserId();
             if (ObjectUtil.isNotNull(receiveUserIdStr) && !receiveUserIdStr.equals("")) {
                 String[] receiveUserIdStrs = receiveUserIdStr.split(",");
@@ -130,7 +134,7 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
                 }
                 LambdaQueryWrapper<XjrUser> queryWrapper = new LambdaQueryWrapper<>();
                 queryWrapper
-                        .in(XjrUser::getId, receiveUserIdStr);
+                        .in(XjrUser::getId, receiveUserIdList);
                 List<XjrUser> xjrUserList = xjrUserMapper.selectList(queryWrapper);
                 if (ObjectUtil.isNotNull(xjrUserList) && xjrUserList.size() > 0) {
                     StringBuilder sb = new StringBuilder();
@@ -189,7 +193,7 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
     public Boolean confirmDistribute(ConfirmDistributeDto dto) {
         WfTextbookClaim wfTextbookClaim = this.getById(dto.getTextbookClaimId());
 
-        if (ObjectUtil.isNull(wfTextbookClaim) || ObjectUtil.isNull(dto.getTextbookClaimItemList()) || dto.getTextbookClaimItemList().size() <= 0) {
+        if (ObjectUtil.isNull(wfTextbookClaim) || ObjectUtil.isNull(dto.getTextbookClaimItemList()) || dto.getTextbookClaimItemList().size() == 0) {
             throw new MyException("未找到申领数据");
         }
 
@@ -216,7 +220,7 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
                 throw new MyException(textbook.getBookName() + "发放总数量超出申领数量");
             }
 
-            //判断总发放数量是否超出该申请的申请数量
+            //判断总发放数量是否超出该申请的申请数量
             Integer stock = ObjectUtil.isNull(textbook.getStock()) ? 0 : textbook.getStock();
             if (stock < confirmNumber) {
                 throw new MyException(textbook.getBookName() + "库存不足");
@@ -254,10 +258,10 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
 
             //当申领类型为学生的时候,为班级每个学生生成领取(确认信息)认领记录
             //查出班上的所有学生id
-            if(ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())){
+            if (ObjectUtil.isNotNull(wfTextbookClaim.getClaimType()) && wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())) {
                 List<Long> userIdList = xjrUserMapper.getUserIdByClassId(wfTextbookClaim.getClassId());
 
-                if (ObjectUtil.isNull(userIdList) && userIdList.size() <= 0) {
+                if (ObjectUtil.isNull(userIdList) && userIdList.size() == 0) {
                     throw new MyException("申领班级有误,请核实");
                 }
 
@@ -278,53 +282,38 @@ public class WfTextbookClaimServiceImpl extends MPJBaseServiceImpl<WfTextbookCla
     @Transactional
     public Boolean dataHandleAddClaimUserNode(Long id) {
         WfTextbookClaim wfTextbookClaim = this.getById(id);
-        if(ObjectUtil.isNotNull(wfTextbookClaim)
-                && ObjectUtil.isNotNull(wfTextbookClaim.getClaimType())){
-            //申领类型是学生申领,申请人,学生代表可领取
-            if(wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())){
-                //所有需要添加的可领取人ID
-                List<TextbookClaimUser> textbookClaimUserList = new ArrayList<>();
-                textbookClaimUserList.add(new TextbookClaimUser(){{
-                    setWfTextbookClaimId(wfTextbookClaim.getId());
-                    setUserId(wfTextbookClaim.getApplicantUserId());
-                    setUserType(2);
-                }});
-                textbookClaimUserList.add(new TextbookClaimUser(){{
+        if (ObjectUtil.isNotNull(wfTextbookClaim)
+                && ObjectUtil.isNotNull(wfTextbookClaim.getClaimType())) {
+            //所有需要添加的可领取人ID
+            List<TextbookClaimUser> textbookClaimUserList = new ArrayList<>();
+            textbookClaimUserList.add(new TextbookClaimUser() {{
+                setWfTextbookClaimId(wfTextbookClaim.getId());
+                setUserId(wfTextbookClaim.getApplicantUserId());
+                setUserType(2);
+            }});
+            //申领类型是学生申领,学生代表可领取
+            if (wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimStudent.getCode())) {
+                textbookClaimUserList.add(new TextbookClaimUser() {{
                     setWfTextbookClaimId(wfTextbookClaim.getId());
                     setUserId(wfTextbookClaim.getStudentUserId());
                     setUserType(1);
                 }});
-                for (TextbookClaimUser textbookClaimUser : textbookClaimUserList) {
-                    textbookClaimUserMapper.insert(textbookClaimUser);
-                }
             }
-
-            //申领类型是教师申领,申请人,领取人可领取
-            if(wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimTeacher.getCode())){
-                //拆分代领取人
-                String receiveUserIdStr = wfTextbookClaim.getReceiveUserId();
-                if (ObjectUtil.isNotNull(receiveUserIdStr) && !receiveUserIdStr.equals("")) {
-                    String[] receiveUserIdStrs = receiveUserIdStr.split(",");
-                    List<TextbookClaimUser> textbookClaimUserList = new ArrayList<>();
-                    for (String str : receiveUserIdStrs) {
-                        textbookClaimUserList.add(new TextbookClaimUser(){{
-                            setWfTextbookClaimId(wfTextbookClaim.getId());
-                            setUserId(Long.parseLong(str));
-                            setUserType(2);
-                        }});
-                    }
-                    textbookClaimUserList.add(new TextbookClaimUser(){{
-                        setWfTextbookClaimId(wfTextbookClaim.getId());
-                        setUserId(wfTextbookClaim.getApplicantUserId());
-                        setUserType(2);
-                    }});
-                    LambdaQueryWrapper<XjrUser> queryWrapper = new LambdaQueryWrapper<>();
-                    for (TextbookClaimUser textbookClaimUser : textbookClaimUserList) {
-                        textbookClaimUserMapper.insert(textbookClaimUser);
-                    }
-                }
+            //申领类型是教师申领,领取人可领取
+            if (wfTextbookClaim.getClaimType().equals(ClaimTypeEnum.ClaimTeacher.getCode())
+                    && ObjectUtil.isNotNull(wfTextbookClaim.getApplicantUserId())
+                    && ObjectUtil.isNotNull(wfTextbookClaim.getClaimUserId())
+                    && wfTextbookClaim.getApplicantUserId().equals(wfTextbookClaim.getClaimUserId())) {
+                textbookClaimUserList.add(new TextbookClaimUser() {{
+                    setWfTextbookClaimId(wfTextbookClaim.getId());
+                    setUserId(wfTextbookClaim.getClaimUserId());
+                    setUserType(2);
+                }});
             }
 
+            for (TextbookClaimUser textbookClaimUser : textbookClaimUserList) {
+                textbookClaimUserMapper.insert(textbookClaimUser);
+            }
         }
         return true;
     }

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

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

+ 1 - 1
src/main/java/com/xjrsoft/module/textbook/vo/TextbookStudentSemesterVo.java

@@ -26,6 +26,6 @@ public class TextbookStudentSemesterVo {
      * 该学生该学期未领取数量
      */
     @ApiModelProperty("该学生该学期未领取数量")
-    private Integer notClaimNum;
+    private Long notClaimNum;
 
 }

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

@@ -15,8 +15,8 @@ import java.util.List;
 public class WfTextbookClaimPageVo {
 
     /**
-    * 主键编号
-    */
+     * 主键编号
+     */
     @ApiModelProperty("主键编号")
     private String id;
     /**

+ 29 - 32
src/main/resources/mapper/textbook/TextbookStudentClaimMapper.xml

@@ -23,36 +23,27 @@
         ORDER BY t.id DESC
     </select>
 
-    <select id="getStudentSemesterList" parameterType="java.lang.Long"
-            resultType="com.xjrsoft.module.textbook.vo.TextbookStudentSemesterVo">
-        SELECT t.base_semester_id,
-               t1.name as baseSemesterIdCN,
-               count(*) as notClaimNum
-        FROM textbook_student_claim t
-                 LEFT JOIN base_semester t1 ON (t1.id = t.base_semester_id)
-                 LEFT JOIN (select base_semester_id
-                            from textbook_student_claim
-                            where student_user_id = #{studentUserId}
-                            GROUP BY base_semester_id) t2 ON (t2.base_semester_id = t.base_semester_id)
-        WHERE t.delete_mark = 0 and t.is_claim = 0
-          AND (t.student_user_id = #{studentUserId})
-        GROUP BY base_semester_id
-    </select>
-
-    <select id="getTeacherCheckByclassList" parameterType="java.lang.Long"
+    <select id="getTeacherCheckByclassList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByclassDto"
             resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByclassVo">
-        SELECT t.id               AS textbookId,
-               t.book_name        AS bookName,
-               t.base_semester_id AS baseSemesterId,
-               t3.name            AS baseSemesterIdCN,
-               t4.total_student   AS classStudentNum
-        FROM textbook t
-                 LEFT JOIN base_semester t3 ON (t3.id = t.base_semester_id)
-                 LEFT JOIN base_class_major_set t4 ON (t4.class_id = #{classId})
-        WHERE t.delete_mark = 0 and t.id in (SELECT textbook_id
-                                             FROM textbook_student_claim
-                                             WHERE delete_mark = 0 AND class_id = #{classId}
-                                             GROUP BY textbook_id)
+        SELECT a.class_id,
+        b.id            as textbookId,
+        b.book_name,
+        c.name,
+        d.total_student as classStudentNum
+        from textbook b
+        right join (SELECT class_id, textbook_id
+        from textbook_student_claim
+        GROUP BY class_id, textbook_id) a on a.textbook_id = b.id
+        left join base_class c on a.class_id = c.id
+        left join base_class_major_set d on c.id = d.class_id
+        where a.class_id != 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>
     </select>
 
     <select id="getTeacherCheckStuClaimList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckStuClaimDto"
@@ -77,7 +68,7 @@
     <select id="getTeacherCheckByStuList" parameterType="com.xjrsoft.module.textbook.dto.TeacherCheckByStuDto"
             resultType="com.xjrsoft.module.textbook.vo.TeacherCheckByStuVo">
         SELECT
-        t.id,
+        t.id as studentUserId,
         t.name as studentUserIdCN,
         t1.student_id as studentId
         FROM xjr_user t
@@ -85,7 +76,13 @@
         where t.id in (SELECT student_user_id
         FROM textbook_student_claim
         WHERE delete_mark = 0
-        AND class_id = #{dto.classId}
+        <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 student_user_id)
         <if test="dto.studentUserId != null and dto.studentUserId != 0 and dto.studentUserId != ''">
             t.id = #{dto.studentUserId}
@@ -101,7 +98,7 @@
             t.is_claim
         FROM textbook_student_claim t
                  LEFT JOIN textbook t1 ON (t1.id = t.textbook_id)
-        where t.class_id = #{classId} and t.student_user_id = #{studentUserId}
+        where t.student_user_id = #{studentUserId}
         ORDER BY t.is_claim
     </select>
 </mapper>

+ 9 - 8
src/main/resources/mapper/textbook/WfTextbookClaimMapper.xml

@@ -12,16 +12,17 @@
             t3.name as baseSemesterIdCN,
             t4.name as studentUserIdCN,
             t5.name as claimTypeCN,
+            t6.user_id,
             t7.name as claimUserIdCN
         FROM wf_textbook_claim t
-             LEFT JOIN xjr_user t1 ON (t1.id = t.applicant_user_id)
-             LEFT JOIN base_class t2 ON (t2.id = t.class_id)
-             LEFT JOIN base_semester t3 ON (t3.id = t.base_semester_id)
-             LEFT JOIN xjr_user t4 ON (t4.id = t.student_user_id)
-             LEFT JOIN xjr_dictionary_detail t5 ON (t5.code = t.claim_type)
-             LEFT JOIN textbook_claim_user t6 ON (t6.id = t.claim_user_id)
-             LEFT JOIN xjr_user t7 ON (t7.id = t6.user_id)
-        WHERE t.delete_mark = 0
+                 LEFT JOIN xjr_user t1 ON (t1.id = t.applicant_user_id)
+                 LEFT JOIN base_class t2 ON (t2.id = t.class_id)
+                 LEFT JOIN base_semester t3 ON (t3.id = t.base_semester_id)
+                 LEFT JOIN xjr_user t4 ON (t4.id = t.student_user_id)
+                 LEFT JOIN xjr_dictionary_detail t5 ON (t5.code = t.claim_type)
+                 LEFT JOIN textbook_claim_user t6 ON (t6.wf_textbook_claim_id = t.id)
+                 LEFT JOIN xjr_user t7 ON (t7.id = t6.user_id)
+        WHERE t.delete_mark = 0 and t6.user_id = #{dto.userId}
         order by t.id;
     </select>
 

+ 0 - 1
src/test/java/com/xjrsoft/xjrsoftboot/FreeMarkerGeneratorTest.java

@@ -1615,5 +1615,4 @@ public class FreeMarkerGeneratorTest {
 
         apiGeneratorService.generateCodes(params);
     }
-
 }